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

ProviderSubagentBar.tsx

75 lines3.3 KB

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