The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import { type EnvironmentContextRecord, resolveEnvironmentMachineKind } from "@t3tools/contracts"; |
| 2 | |
| 3 | import { useGT } from "gt-react"; |
| 4 | |
| 5 | import { useEnvironment } from "~/state/environments"; |
| 6 | import { ContextChip, ContextChipLabel } from "./ContextChip"; |
| 7 | import { EnvironmentMachineIcon } from "./EnvironmentMachineIcon"; |
| 8 | import { Tooltip, TooltipPopup, TooltipTrigger } from "./ui/tooltip"; |
| 9 | |
| 10 | /** |
| 11 | * Inline chip for a mentioned machine, in the composer and in sent messages. Prefers the |
| 12 | * name this client knows the machine by, and draws it with its machine icon. |
| 13 | */ |
| 14 | export function EnvironmentContextChip(props: { |
| 15 | record: Pick<EnvironmentContextRecord, "environmentId" | "label">; |
| 16 | copyMarkdown?: string; |
| 17 | }) { |
| 18 | const gt = useGT(); |
| 19 | const environment = useEnvironment(props.record.environmentId); |
| 20 | const label = environment?.label.trim() || props.record.label; |
| 21 | return ( |
| 22 | <Tooltip> |
| 23 | <TooltipTrigger |
| 24 | render={ |
| 25 | <ContextChip |
| 26 | kind="environment" |
| 27 | tabIndex={0} |
| 28 | aria-label={gt("Machine, {label}", { label })} |
| 29 | data-markdown-copy={props.copyMarkdown} |
| 30 | > |
| 31 | <EnvironmentMachineIcon |
| 32 | kind={resolveEnvironmentMachineKind(environment?.serverConfig ?? null)} |
| 33 | /> |
| 34 | <ContextChipLabel>{label}</ContextChipLabel> |
| 35 | </ContextChip> |
| 36 | } |
| 37 | /> |
| 38 | <TooltipPopup side="top"> |
| 39 | {environment ? gt("T3 Code environment") : gt("Machine not in this app")} |
| 40 | </TooltipPopup> |
| 41 | </Tooltip> |
| 42 | ); |
| 43 | } |