Open History to see the last commit
1import {
2 formatProviderSubagentStatus,
3 type ProviderSubagentStatus,
4} from "@t3tools/client-runtime/state/thread-execution";
5import { isOrchestrationV2WorkActive } from "@t3tools/contracts";
6import { T, useGT, useMessages } from "gt-react";
7import { ArrowUpLeftIcon } from "lucide-react";
8import type { ReactNode } from "react";
9
10import { tickTextContent } from "~/lib/tickTextContent";
11import type { ProviderInstanceEntry } from "../../providerInstances";
12import { Button } from "../ui/button";
13import { ProviderInstanceIcon } from "./ProviderInstanceIcon";
14
15export function ProviderSubagentBar(props: {
16 readonly provider: ProviderInstanceEntry | null;
17 readonly showInstanceBadge: boolean;
18 readonly modelLabel: string;
19 readonly effortLabel: string | null;
20 readonly status: ProviderSubagentStatus | null;
21 readonly onOpenParent: (() => void) | null;
22 readonly actions?: ReactNode;
23}) {
24 const { status } = props;
25 const gt = useGT();
26 const messages = useMessages();
27 const live = status !== null && isOrchestrationV2WorkActive(status.status);
28 const modelDescription =
29 props.effortLabel === null ? props.modelLabel : `${props.modelLabel}, ${props.effortLabel}`;
30 const announcement = formatProviderSubagentStatus(
31 status === null ? null : { ...status, startedAt: null },
32 0,
33 messages,
34 );
35
36 // Sized by the composer, not the viewport: a docked side panel narrows the
37 // chat column on a wide window, and one row there squeezes out the model
38 // and status, so the status drops to its own line instead.
39 return (
40 <div className="flex min-h-12 items-center gap-3 rounded-2xl py-2 ps-5 pe-2 text-sm">
41 <div className="flex min-w-0 flex-1 items-center gap-3 @max-[560px]/composer-surface:flex-col @max-[560px]/composer-surface:items-start @max-[560px]/composer-surface:gap-0.5">
42 <span className="flex min-w-0 max-w-full items-center gap-2">
43 {props.provider ? (
44 <ProviderInstanceIcon
45 driverKind={props.provider.driverKind}
46 displayName={props.provider.displayName}
47 accentColor={props.provider.accentColor}
48 acpRegistryAgentId={props.provider.acpRegistryAgentId}
49 acpRegistryIconUrl={props.provider.acpRegistryIconUrl}
50 showBadge={props.showInstanceBadge}
51 className="size-4 shrink-0"
52 iconClassName="size-4"
53 badgeClassName="right-[-0.125rem] bottom-[-0.125rem] h-3 min-w-3 px-0.5 text-5xs"
54 />
55 ) : null}
56 <span className="min-w-0 truncate font-medium text-foreground">{props.modelLabel}</span>
57 {props.effortLabel === null ? null : (
58 <span className="shrink-0 text-muted-foreground">{props.effortLabel}</span>
59 )}
60 </span>
61 <span
62 ref={tickTextContent(
63 (nowMs) => formatProviderSubagentStatus(status, nowMs, messages),
64 live,
65 )}
66 aria-hidden
67 className="min-w-0 max-w-full truncate text-muted-foreground tabular-nums @max-[560px]/composer-surface:text-xs"
68 />
69 </div>
70 <span role="status" className="sr-only">
71 {gt("{model} subagent: {status}", { model: modelDescription, status: announcement })}
72 </span>
73 <span className="shrink-0 text-muted-foreground @max-[640px]/composer-surface:sr-only">
74 <T>Runs on its own</T>
75 </span>
76 {props.actions}
77 {props.onOpenParent ? (
78 <Button size="sm" variant="ghost" onClick={props.onOpenParent}>
79 <ArrowUpLeftIcon />
80 <span className="@max-[320px]/composer-surface:sr-only">
81 <T>Open parent</T>
82 </span>
83 </Button>
84 ) : null}
85 </div>
86 );
87}