Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

TriageDraftHero.tsx

79 lines2.6 KB

1import { msg, T, Var } from "gt-react";
2import { useCopyToClipboard } from "~/hooks/useCopyToClipboard";
3import { TRIAGE_CLI_COMMAND } from "~/hooks/useStartTriage";
4​
5import { InlineButton } from "../ui/button";
6import { SharedTooltipTrigger } from "../ui/shared-tooltip";
7​
8/**
9 * The empty-draft hero for a triage session, in place of "What should we work on?".
10 * Keeps the regular hero's heading-plus-one-line rhythm above the composer.
11 */
12export function TriageDraftHero(props: {
13 readonly machineLabel: string | null;
14 readonly serverVersion: string | null;
15}) {
16 const { copyToClipboard, isCopied } = useCopyToClipboard({
17 timeout: 1500,
18 target: {
19 target: "command",
20 unavailableMessage: msg("Clipboard API is unavailable while copying command."),
21 failureMessage: msg("Failed to copy command to the clipboard."),
22 },
23 });
24 return (
25 <div className="mx-auto flex w-full max-w-5xl flex-col items-center">
26 <h1 className="w-full text-center font-normal text-2xl text-foreground tracking-tight sm:text-3xl">
27 <T>What went wrong?</T>
28 </h1>
29 <p className="mt-2 flex h-6 w-full items-center justify-center gap-1.5 text-sm">
30 <SharedTooltipTrigger
31 render={<span tabIndex={0} className="min-w-0 truncate font-medium text-foreground" />}
32 label={
33 <>
34 <T>
35 The agent reads T3 Code's logs and source here, and asks before it applies a fix or
36 posts anything.
37 </T>
38 </>
39 }
40 side="bottom"
41 >
42 {props.machineLabel ?? <T>This machine</T>}
43 {props.serverVersion === null ? null : (
44 <span className="ml-1.5 font-normal text-muted-foreground">v{props.serverVersion}</span>
45 )}
46 </SharedTooltipTrigger>
47 <span aria-hidden className="text-muted-foreground">
48 ·
49 </span>
50 <SharedTooltipTrigger
51 render={
52 <InlineButton
53 tone="muted"
54 className="pointer-events-auto"
55 onClick={() => copyToClipboard(TRIAGE_CLI_COMMAND, undefined)}
56 />
57 }
58 label={
59 <>
60 <T>Copy command, for a terminal</T>
61 </>
62 }
63 side="bottom"
64 >
65 {isCopied ? (
66 <T>Copied</T>
67 ) : (
68 <T>
69 or run
70 <code className="ml-1 font-mono text-xs">
71 <Var>{TRIAGE_CLI_COMMAND}</Var>
72 </code>
73 </T>
74 )}
75 </SharedTooltipTrigger>
76 </p>
77 </div>
78 );