Open History to see the last commit
1import {
2 formatProviderSubagentStatus,
3 type ProviderSubagentStatus,
4} from "@t3tools/client-runtime/state/thread-execution";
5import { isOrchestrationV2WorkActive, type EnvironmentId, type ThreadId } from "@t3tools/contracts";
6import { T, useGT, useMessages, Var } from "gt-react-native";
7import { useState } from "react";
8import { View } from "react-native";
9
10import { AppText as Text } from "../../components/ui/AppText";
11import { ProviderIcon } from "../../components/ProviderIcon";
12import { Button } from "../../components/ui/Button";
13import { NativeChildWorkSheet } from "./NativeChildWorkSheet";
14import { ReadOnlyComposerBar } from "./ReadOnlyComposerBar";
15import { useVisibleSecondClock } from "./use-visible-second-clock";
16
17export function ProviderSubagentBar(props: {
18 readonly provider: { readonly driver: string; readonly iconUrl?: string | undefined } | null;
19 readonly modelLabel: string;
20 readonly effortLabel: string | null;
21 readonly status: ProviderSubagentStatus | null;
22 readonly onOpenParent: (() => void) | null;
23 /** Set for providers whose children T3 reads on demand instead of streaming. */
24 readonly inspect: { readonly environmentId: EnvironmentId; readonly threadId: ThreadId } | null;
25}) {
26 const gt = useGT();
27 const messages = useMessages();
28 const [inspecting, setInspecting] = useState(false);
29 const live = props.status !== null && isOrchestrationV2WorkActive(props.status.status);
30 const nowMs = useVisibleSecondClock(live);
31 const statusLabel = formatProviderSubagentStatus(props.status, nowMs, messages);
32 const modelDescription =
33 props.effortLabel === null ? props.modelLabel : `${props.modelLabel}, ${props.effortLabel}`;
34
35 return (
36 <ReadOnlyComposerBar>
37 <View
38 accessible
39 accessibilityLabel={gt`${{ modelDescription }} subagent, ${{ statusLabel }}. It runs on its own and cannot take messages.`}
40 className="min-w-0 flex-1 gap-0.5"
41 >
42 <View className="min-w-0 flex-row items-center gap-1.5">
43 {props.provider ? (
44 <ProviderIcon
45 iconUrl={props.provider.iconUrl}
46 provider={props.provider.driver}
47 size={16}
48 />
49 ) : null}
50 <Text numberOfLines={1} className="min-w-0 shrink font-t3-bold text-sm text-foreground">
51 {props.modelLabel}
52 </Text>
53 {props.effortLabel === null ? null : (
54 <Text
55 numberOfLines={1}
56 className="shrink-0 font-sans text-sm text-foreground-secondary"
57 >
58 {props.effortLabel}
59 </Text>
60 )}
61 </View>
62 <Text
63 numberOfLines={1}
64 className="font-sans text-xs text-foreground-secondary"
65 style={{ fontVariant: ["tabular-nums"] }}
66 >
67 <T>
68 <Var>{statusLabel}</Var> · Runs on its own
69 </T>
70 </Text>
71 </View>
72 {props.inspect ? (
73 <Button
74 label={gt({ context: "noun, opens the subagent's work log" })`Work`}
75 tone="secondary"
76 onPress={() => setInspecting(true)}
77 />
78 ) : null}
79 {props.onOpenParent ? (
80 <Button label={gt`Open parent`} tone="secondary" onPress={props.onOpenParent} />
81 ) : null}
82 {props.inspect && inspecting ? (
83 <NativeChildWorkSheet {...props.inspect} onClose={() => setInspecting(false)} />
84 ) : null}
85 </ReadOnlyComposerBar>
86 );
87}