The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 04:45 UTC
| 1 | import type { PullRequestContextMetadata } from "@t3tools/contracts"; |
| 2 | import { sourceControlClients } from "@t3tools/client-runtime/source-control-clients"; |
| 3 | import { useGT, useMessages } from "gt-react"; |
| 4 | import { ArrowRightIcon } from "lucide-react"; |
| 5 | |
| 6 | import { cn } from "~/lib/utils"; |
| 7 | |
| 8 | import { changeRequestTermKind } from "./pullRequest/changeRequestTerm"; |
| 9 | import { resolvePullRequestState } from "./pullRequest/pullRequestPresentation"; |
| 10 | |
| 11 | export function PullRequestContextDetails({ metadata }: { metadata: PullRequestContextMetadata }) { |
| 12 | const gt = useGT(); |
| 13 | const messages = useMessages(); |
| 14 | const state = resolvePullRequestState(metadata, messages); |
| 15 | // A context chip carries the change request's URL alone, so the URL names its host. |
| 16 | const term = changeRequestTermKind( |
| 17 | ( |
| 18 | sourceControlClients.findByChangeRequestUrl(metadata.url) ?? |
| 19 | sourceControlClients.get(undefined) |
| 20 | ).changeRequest, |
| 21 | ); |
| 22 | return ( |
| 23 | <div className="max-w-80 space-y-1 overflow-hidden py-0.5 text-left"> |
| 24 | <div className="flex items-center gap-1.5 text-xs font-medium"> |
| 25 | <state.Icon className={cn("size-3.5 shrink-0", state.toneClassName)} /> |
| 26 | <span className="text-foreground"> |
| 27 | {gt( |
| 28 | "{term, select, mr {Merge request} cr {Change request} other {Pull request}} #{number}", |
| 29 | { term, number: metadata.number }, |
| 30 | )} |
| 31 | </span> |
| 32 | <span className={state.toneClassName}>{state.label}</span> |
| 33 | </div> |
| 34 | <div className="wrap-break-word text-foreground">{metadata.title}</div> |
| 35 | <div className="flex min-w-0 items-center gap-1 text-secondary-label text-3xs"> |
| 36 | <code className="truncate">{metadata.headBranch}</code> |
| 37 | <ArrowRightIcon className="size-3 shrink-0" aria-hidden="true" /> |
| 38 | <code className="truncate">{metadata.baseBranch}</code> |
| 39 | </div> |
| 40 | </div> |
| 41 | ); |
| 42 | } |