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

ProviderSubagentBar.tsx

67 lines2.5 KB

1import {
2 formatProviderSubagentStatus,
3 type ProviderSubagentStatus,
4} from "@t3tools/client-runtime/state/thread-execution";
5import { isOrchestrationV2WorkActive } from "@t3tools/contracts";
6import { View } from "react-native";
7​
8import { AppText as Text } from "../../components/ui/AppText";
9import { ProviderIcon } from "../../components/ProviderIcon";
10import { Button } from "../../components/ui/Button";
11import { useVisibleSecondClock } from "./use-visible-second-clock";
12​
13export function ProviderSubagentBar(props: {
14 readonly provider: { readonly driver: string; readonly iconUrl?: string | undefined } | null;
15 readonly modelLabel: string;
16 readonly effortLabel: string | null;
17 readonly status: ProviderSubagentStatus | null;
18 readonly onOpenParent: (() => void) | null;
19}) {
20 const live = props.status !== null && isOrchestrationV2WorkActive(props.status.status);
21 const nowMs = useVisibleSecondClock(live);
22 const statusLabel = formatProviderSubagentStatus(props.status, nowMs);
23 const modelDescription =
24 props.effortLabel === null ? props.modelLabel : `${props.modelLabel}, ${props.effortLabel}`;
25​
26 return (
27 <View className="flex-row items-center gap-3 rounded-[20px] border border-border-subtle bg-card-alt py-2 pe-2 ps-4">
28 {}
29 <View
30 accessible
31 accessibilityLabel={`${modelDescription} subagent, ${statusLabel}. It runs on its own and cannot take messages.`}
32 className="min-w-0 flex-1 gap-0.5"
33 >
34 <View className="min-w-0 flex-row items-center gap-1.5">
35 {props.provider ? (
36 <ProviderIcon
37 iconUrl={props.provider.iconUrl}
38 provider={props.provider.driver}
39 size={16}
40 />
41 ) : null}
42 <Text numberOfLines={1} className="min-w-0 shrink font-t3-bold text-sm text-foreground">
43 {props.modelLabel}
44 </Text>
45 {props.effortLabel === null ? null : (
46 <Text
47 numberOfLines={1}
48 className="shrink-0 font-sans text-sm text-foreground-secondary"
49 >
50 {props.effortLabel}
51 </Text>
52 )}
53 </View>
54 <Text
55 numberOfLines={1}
56 className="font-sans text-xs text-foreground-secondary"
57 style={{ fontVariant: ["tabular-nums"] }}
58 >
59 {statusLabel} · Runs on its own
60 </Text>
61 </View>
62 {props.onOpenParent ? (
63 <Button label="Open parent" tone="secondary" onPress={props.onOpenParent} />
64 ) : null}
65 </View>
66 );