The best way to control Claude Code, Codex and more from any computer or phone

main
tsx 90 lines 3.43 KB
Raw
1 import {
2 formatProviderSubagentStatus,
3 type ProviderSubagentStatus,
4 } from "@t3tools/client-runtime/state/thread-execution";
5 import { isOrchestrationV2WorkActive, type EnvironmentId, type ThreadId } from "@t3tools/contracts";
6 import { T, useGT, useMessages, Var } from "gt-react-native";
7 import { useState } from "react";
8 import { View } from "react-native";
9
10 import { AppText as Text } from "../../components/ui/AppText";
11 import { ProviderIcon } from "../../components/ProviderIcon";
12 import { Button } from "../../components/ui/Button";
13 import { NativeChildWorkSheet } from "./NativeChildWorkSheet";
14 import { ReadOnlyComposerBar } from "./ReadOnlyComposerBar";
15 import { useVisibleSecondClock } from "./use-visible-second-clock";
16
17 export 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(
40 "{modelDescription} subagent, {statusLabel}. It runs on its own and cannot take messages.",
41 { modelDescription, statusLabel },
42 )}
43 className="min-w-0 flex-1 gap-0.5"
44 >
45 <View className="min-w-0 flex-row items-center gap-1.5">
46 {props.provider ? (
47 <ProviderIcon
48 iconUrl={props.provider.iconUrl}
49 provider={props.provider.driver}
50 size={16}
51 />
52 ) : null}
53 <Text numberOfLines={1} className="min-w-0 shrink font-t3-bold text-sm text-foreground">
54 {props.modelLabel}
55 </Text>
56 {props.effortLabel === null ? null : (
57 <Text
58 numberOfLines={1}
59 className="shrink-0 font-sans text-sm text-foreground-secondary"
60 >
61 {props.effortLabel}
62 </Text>
63 )}
64 </View>
65 <Text
66 numberOfLines={1}
67 className="font-sans text-xs text-foreground-secondary"
68 style={{ fontVariant: ["tabular-nums"] }}
69 >
70 <T>
71 <Var>{statusLabel}</Var> · Runs on its own
72 </T>
73 </Text>
74 </View>
75 {props.inspect ? (
76 <Button
77 label={gt("Work", { $context: "noun, opens the subagent's work log" })}
78 tone="secondary"
79 onPress={() => setInspecting(true)}
80 />
81 ) : null}
82 {props.onOpenParent ? (
83 <Button label={gt("Open parent")} tone="secondary" onPress={props.onOpenParent} />
84 ) : null}
85 {props.inspect && inspecting ? (
86 <NativeChildWorkSheet {...props.inspect} onClose={() => setInspecting(false)} />
87 ) : null}
88 </ReadOnlyComposerBar>
89 );
90 }