Skip to content

Commit 8662082

Browse files
Merge branch 'main' into fix/v2-cleanup-terminal-statuses
2 parents cfa4450 + 5e35272 commit 8662082

76 files changed

Lines changed: 3829 additions & 642 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎apps/mobile/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
"react-native": "0.88.0-rc.3",
115115
"react-native-gesture-handler": "~3.2.1",
116116
"react-native-image-viewing": "^0.2.2",
117-
"react-native-keyboard-controller": "1.22.4",
117+
"react-native-keyboard-controller": "1.22.6",
118118
"react-native-nitro-markdown": "^0.5.0",
119119
"react-native-nitro-modules": "0.35.9",
120120
"react-native-reanimated": "4.7.0",
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
import { scopeProjectRef, scopeThreadRef } from "@t3tools/client-runtime/environment";
2+
import { resolveSubagentMetadata } from "@t3tools/client-runtime/state/subagent-display";
3+
import type { EnvironmentId, OrchestrationV2Subagent } from "@t3tools/contracts";
4+
import type { ReactNode } from "react";
5+
import { View } from "react-native";
6+
7+
import { AppText as Text } from "../../components/AppText";
8+
import { SymbolView } from "../../components/AppSymbol";
9+
import { ProviderIcon } from "../../components/ProviderIcon";
10+
import { cn } from "../../lib/cn";
11+
import { useEnvironmentServerConfig, useProject, useThreadShell } from "../../state/entities";
12+
import { subagentCardDetail } from "./subagent-card-presentation";
13+
import { SUBAGENT_TONE_TEXT_CLASS, SubagentStatusDot } from "./SubagentStatusDot";
14+
import { resolveSubagentRowPresentation } from "./threadAgentsPresentation";
15+
16+
type SubagentRowSubagent = Pick<
17+
OrchestrationV2Subagent,
18+
| "threadId"
19+
| "childThreadId"
20+
| "model"
21+
| "driver"
22+
| "providerInstanceId"
23+
| "title"
24+
| "prompt"
25+
| "status"
26+
| "progress"
27+
| "result"
28+
>;
29+
30+
/**
31+
* One agent as shown in the Agents sheet and transcript cards: status, model,
32+
* workspace changes, and recent progress or result. Callers own the press
33+
* target and pass their own elapsed timer so ticking stays isolated.
34+
*/
35+
export function SubagentRow(props: {
36+
readonly environmentId: EnvironmentId;
37+
readonly subagent: SubagentRowSubagent;
38+
readonly elapsed: ReactNode;
39+
}) {
40+
const presentation = resolveSubagentRowPresentation(props.subagent);
41+
const detail = subagentCardDetail(presentation.detail);
42+
return (
43+
<View className="flex-row gap-3">
44+
<View className="h-5 justify-center">
45+
<SubagentStatusDot tone={presentation.tone} placement="sheet" />
46+
</View>
47+
<View className="min-w-0 flex-1 gap-1">
48+
<View className="min-h-5 flex-row items-center gap-2">
49+
<View className="min-w-0 flex-1 flex-row items-baseline gap-1.5">
50+
<Text
51+
numberOfLines={1}
52+
className="min-w-0 shrink font-t3-medium text-sm text-foreground"
53+
>
54+
{presentation.title}
55+
</Text>
56+
<Text
57+
accessibilityElementsHidden
58+
importantForAccessibility="no"
59+
className="shrink-0 text-xs text-foreground-muted"
60+
>
61+
·
62+
</Text>
63+
<Text
64+
className={cn(
65+
"shrink-0 text-xs font-t3-medium",
66+
SUBAGENT_TONE_TEXT_CLASS[presentation.tone],
67+
)}
68+
>
69+
{presentation.statusLabel}
70+
</Text>
71+
</View>
72+
{props.elapsed}
73+
{presentation.canOpenThread ? (
74+
<SymbolView name="chevron.right" size={12} tintColorClassName="accent-icon-subtle" />
75+
) : null}
76+
</View>
77+
<SubagentMetadata environmentId={props.environmentId} subagent={props.subagent} />
78+
{detail ? (
79+
<Text
80+
numberOfLines={3}
81+
className={cn(
82+
"text-xs text-foreground-muted",
83+
presentation.tone === "failed" && SUBAGENT_TONE_TEXT_CLASS.failed,
84+
)}
85+
>
86+
{detail}
87+
</Text>
88+
) : null}
89+
</View>
90+
</View>
91+
);
92+
}
93+
94+
/** Uses shell data already held by the client, without loading child transcripts. */
95+
function SubagentMetadata(props: {
96+
readonly environmentId: EnvironmentId;
97+
readonly subagent: SubagentRowSubagent;
98+
}) {
99+
const { environmentId, subagent } = props;
100+
const config = useEnvironmentServerConfig(environmentId);
101+
const provider = config?.providers.find(
102+
(candidate) => candidate.instanceId === subagent.providerInstanceId,
103+
);
104+
const parent = useThreadShell(scopeThreadRef(environmentId, subagent.threadId))?.source;
105+
const child = useThreadShell(
106+
subagent.childThreadId === null ? null : scopeThreadRef(environmentId, subagent.childThreadId),
107+
)?.source;
108+
const parentProject = useProject(
109+
parent ? scopeProjectRef(environmentId, parent.projectId) : null,
110+
);
111+
const childProject = useProject(child ? scopeProjectRef(environmentId, child.projectId) : null);
112+
const { modelLabel, workspace } = resolveSubagentMetadata({
113+
model: subagent.model,
114+
provider,
115+
parentThread: parent,
116+
childThread: child,
117+
parentProject,
118+
childProject,
119+
});
120+
return (
121+
<View className="min-w-0 flex-row items-center gap-1.5">
122+
<ProviderIcon
123+
provider={provider?.driver ?? subagent.driver}
124+
iconUrl={provider?.iconUrl}
125+
size={12}
126+
/>
127+
<Text className="min-w-0 shrink text-xs text-foreground-muted" numberOfLines={1}>
128+
{provider?.displayName ? `${provider.displayName} · ` : ""}
129+
{modelLabel}
130+
</Text>
131+
{workspace.map(({ label, value }) => (
132+
// The row reads this label in place of the icon. collapsable keeps the
133+
// view (and label) from being flattened away without making it a
134+
// separate accessibility stop.
135+
<View
136+
key={label}
137+
collapsable={false}
138+
accessibilityLabel={`${label}: ${value}`}
139+
className="min-w-0 shrink flex-row items-center gap-1.5"
140+
>
141+
<Text className="text-xs text-foreground-muted">·</Text>
142+
<SymbolView
143+
name={label === "Branch" ? "arrow.triangle.branch" : "folder"}
144+
size={11}
145+
tintColorClassName="accent-icon-muted"
146+
/>
147+
<Text className="min-w-0 shrink text-xs text-foreground-muted" numberOfLines={1}>
148+
{value}
149+
</Text>
150+
</View>
151+
))}
152+
</View>
153+
);
154+
}

‎apps/mobile/src/features/threads/SubagentStatusDot.tsx‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,25 @@ const TONE_CLASS = {
1010
stopped: "bg-foreground-muted",
1111
} as const satisfies Record<SubagentRowTone, string>;
1212

13+
export const SUBAGENT_TONE_TEXT_CLASS = {
14+
working: "text-adaptive-sky-600-400",
15+
completed: "text-adaptive-emerald-600-400",
16+
failed: "text-adaptive-rose-600-400",
17+
stopped: "text-foreground-muted",
18+
} as const satisfies Record<SubagentRowTone, string>;
19+
1320
export function SubagentStatusDot({
1421
tone,
1522
placement = "inline",
1623
}: {
1724
readonly tone: SubagentRowTone;
18-
readonly placement?: "inline" | "provider" | "sheet";
25+
readonly placement?: "inline" | "sheet";
1926
}) {
2027
return (
2128
<View
2229
className={cn(
2330
"shrink-0 rounded-full",
2431
placement === "sheet" ? "h-2 w-2" : "h-1.5 w-1.5",
25-
placement === "provider" && "absolute bottom-0.5 right-0.5",
2632
TONE_CLASS[tone],
2733
)}
2834
/>

‎apps/mobile/src/features/threads/ThreadAgentsSheet.tsx‎

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,10 @@ import { useSafeAreaInsets } from "react-native-safe-area-context";
1717

1818
import { AndroidSheetHeader } from "../../components/AndroidScreenHeader";
1919
import { AppText as Text } from "../../components/AppText";
20-
import { SymbolView } from "../../components/AppSymbol";
2120
import { useUniwindTheme } from "../../lib/useUniwindTheme";
2221
import { environmentThreadDetails } from "../../state/threads";
2322
import { nativeHeaderScrollEdgeEffects } from "../../native/StackHeader";
24-
import { resolveSubagentRowPresentation } from "./threadAgentsPresentation";
25-
26-
import { SubagentStatusDot } from "./SubagentStatusDot";
23+
import { SubagentRow } from "./SubagentRow";
2724

2825
const HEADER_SCROLL_EDGE_EFFECTS = nativeHeaderScrollEdgeEffects(Platform.OS, Platform.Version);
2926

@@ -72,6 +69,7 @@ export function ThreadAgentsSheet({ route }: StaticScreenProps<AgentsTarget>) {
7269
<AgentRow
7370
key={subagent.id}
7471
subagent={subagent}
72+
environmentId={target.environmentId}
7573
tickSeconds={hasLiveAgent}
7674
onOpen={openChildThread}
7775
/>
@@ -121,40 +119,28 @@ export function ThreadAgentsSheet({ route }: StaticScreenProps<AgentsTarget>) {
121119
}
122120

123121
function AgentRow(props: {
122+
readonly environmentId: EnvironmentId;
124123
readonly subagent: OrchestrationV2Subagent;
125124
readonly tickSeconds: boolean;
126125
readonly onOpen: (childThreadId: ThreadId) => void;
127126
}) {
128127
const { subagent } = props;
129-
const presentation = resolveSubagentRowPresentation(subagent);
130128
const childThreadId = subagent.childThreadId;
131-
const elapsed = useSubagentElapsed(subagent, props.tickSeconds);
132129

133130
const row = (
134-
<View className="min-h-14 flex-row items-center gap-3 border-b border-border py-3">
135-
<SubagentStatusDot tone={presentation.tone} placement="sheet" />
136-
<View className="min-w-0 flex-1 gap-0.5">
137-
<Text className="font-t3-medium text-sm text-foreground" numberOfLines={1}>
138-
{presentation.title}
139-
</Text>
140-
<Text className="text-xs text-foreground-muted" numberOfLines={1}>
141-
{presentation.detail ?? presentation.statusLabel}
142-
</Text>
143-
</View>
144-
{elapsed === null ? null : (
145-
<Text className="shrink-0 text-2xs tabular-nums text-foreground-muted">{elapsed}</Text>
146-
)}
147-
{presentation.canOpenThread ? (
148-
<SymbolView name="chevron.right" size={12} tintColorClassName="accent-icon-subtle" />
149-
) : null}
131+
<View className="border-b border-border py-3.5">
132+
<SubagentRow
133+
environmentId={props.environmentId}
134+
subagent={subagent}
135+
elapsed={<AgentElapsed subagent={subagent} tickSeconds={props.tickSeconds} />}
136+
/>
150137
</View>
151138
);
152139

153140
if (childThreadId === null) {
154141
return (
155142
<View
156143
accessible
157-
accessibilityLabel={`${presentation.title}, ${presentation.statusLabel}`}
158144
accessibilityHint="Provider-managed agent. Its work appears in the transcript."
159145
>
160146
{row}
@@ -165,7 +151,6 @@ function AgentRow(props: {
165151
return (
166152
<Pressable
167153
accessibilityRole="link"
168-
accessibilityLabel={`${presentation.title}, ${presentation.statusLabel}`}
169154
accessibilityHint="Opens this agent's thread"
170155
onPress={() => props.onOpen(childThreadId)}
171156
className="active:opacity-70"
@@ -175,9 +160,19 @@ function AgentRow(props: {
175160
);
176161
}
177162

163+
function AgentElapsed(props: {
164+
readonly subagent: OrchestrationV2Subagent;
165+
readonly tickSeconds: boolean;
166+
}) {
167+
const elapsed = useSubagentElapsed(props.subagent, props.tickSeconds);
168+
return elapsed === null ? null : (
169+
<Text className="shrink-0 text-xs tabular-nums text-foreground-muted">{elapsed}</Text>
170+
);
171+
}
172+
178173
/**
179-
* Elapsed time for one agent. Only a roster with live work subscribes to the
180-
* shared second tick, so a settled sheet never repaints.
174+
* Elapsed time for one agent. Only live work ticks, inside AgentElapsed,
175+
* so the timer never repaints the metadata or a settled sheet.
181176
*/
182177
function useSubagentElapsed(
183178
subagent: Pick<OrchestrationV2Subagent, "status" | "startedAt" | "completedAt">,

‎apps/mobile/src/features/threads/ThreadDetailScreen.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,11 +474,12 @@ export const ThreadDetailScreen = memo(function ThreadDetailScreen(props: Thread
474474
}
475475
if (pendingBackgroundWork !== null && contentPresentationKind === "ready") {
476476
return {
477-
kind: "waiting",
477+
kind: "background",
478478
label: pendingBackgroundWork.title,
479479
accessibilityLabel: `${pendingBackgroundWork.title}: ${pendingBackgroundWork.items
480480
.map((item) => item.label)
481481
.join(", ")}`,
482+
waiting: pendingBackgroundWork.waiting,
482483
};
483484
}
484485
return null;

‎apps/mobile/src/features/threads/floating-working-control.tsx‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -385,16 +385,18 @@ function FloatingStatusLabel(props: {
385385
</StatusLabelRow>
386386
);
387387
}
388-
if (props.status.kind === "waiting") {
388+
if (props.status.kind === "background") {
389389
return (
390390
<StatusLabelRow
391-
key="waiting"
391+
key="background"
392392
accessibilityLabel={props.status.accessibilityLabel}
393393
className="gap-2"
394394
onLayout={props.onLayout}
395395
>
396+
{/* A dev server can run for hours after the agent is done, so only work
397+
that will wake the agent gets the bolt. */}
396398
<SymbolView
397-
name={{ ios: "bolt", android: "bolt" }}
399+
name={props.status.waiting ? { ios: "bolt", android: "bolt" } : "terminal"}
398400
size={13}
399401
tintColorClassName="foreground"
400402
type="monochrome"

‎apps/mobile/src/features/threads/floating-working-status.ts‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,14 @@ export type FloatingWorkingStatus =
99
| { readonly kind: "working"; readonly startedAt: string }
1010
| { readonly kind: "syncing"; readonly label: string }
1111
| { readonly kind: "compacting" }
12-
// The turn settled while background work it started still runs.
13-
| { readonly kind: "waiting"; readonly label: string; readonly accessibilityLabel: string }
12+
// The turn settled while background work it started still runs. `waiting`
13+
// is false when only commands remain, such as a dev server: the agent is done.
14+
| {
15+
readonly kind: "background";
16+
readonly label: string;
17+
readonly accessibilityLabel: string;
18+
readonly waiting: boolean;
19+
}
1420
// A task whose thread the server has not created yet: the worktree may
1521
// still be checking out, so there is no turn to time.
1622
| { readonly kind: "preparing"; readonly label: string }

0 commit comments

Comments
 (0)