The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 23, 01:45 UTC
fix(web): show native coordinator status in member lineage (#18149)
Co-authored-by: ashx-j <281260375+ashx-j@users.noreply.github.com> Co-authored-by: Julius Marminge <julius0216@outlook.com>
ash committed
Oct 19, 2026 at 22:30 UTC
6eff4a9647f0f08d9e97f89e0546be3320cb056a
2 files changed
+107
-6
apps/web/src/components/chat/ThreadRelationshipsControl.agents.browser.test.tsx
+78
-1
@@ -1,9 +1,11 @@
1
import { act, cloneElement, type ReactElement, type ReactNode } from "react";
2
import { createRoot, type Root } from "react-dom/client";
3
+import { scopedThreadKey } from "@t3tools/client-runtime/environment";
4
import {
5
EnvironmentId,
6
ThreadId,
7
type ModelSelection,
8
+ type ScopedThreadRef,
9
type ProviderOptionDescriptor,
10
type OrchestrationV2ContextTransfer,
11
} from "@t3tools/contracts";
@@ -15,6 +17,7 @@ import "~/index.css";
17
const state = vi.hoisted(() => ({
18
stopWorkflowLabel: "environment-data:orchestration:stop-workflow",
19
projection: null as unknown,
20
+ projections: null as Map<string, unknown> | null,
21
navigate: vi.fn(),
22
shells: [] as unknown[],
23
projects: [] as unknown[],
@@ -31,7 +34,14 @@ vi.mock(import("@tanstack/react-router"), async (original) => ({
34
}));
35
vi.mock(import("../../state/entities"), async (original) => ({
36
...(await original()),
34
- useThreadProjection: (() => ({ projection: state.projection })) as never,
37
+ useThreadProjection: ((ref: ScopedThreadRef | null) =>
38
+ ref === null
39
+ ? undefined
40
+ : {
41
+ projection: state.projections
42
+ ? state.projections.get(scopedThreadKey(ref))
43
+ : state.projection,
44
+ }) as never,
45
useThreadRelationshipShells: ((ref: { readonly environmentId: string }) =>
46
(state.shells as ReadonlyArray<{ readonly environmentId: string; readonly source: unknown }>)
47
.filter((shell) => shell.environmentId === ref.environmentId)
@@ -153,6 +163,7 @@ afterEach(async () => {
163
state.workflowCommand.mockReset().mockResolvedValue({ _tag: "Success" });
164
state.toast.mockClear();
165
state.projection = null;
166
+ state.projections = null;
167
});
168
169
it("stops the entire native workflow through its parent without changing state before acknowledgement", async () => {
@@ -1188,6 +1199,72 @@ it("shows the parent's own visible status as parent and child activity change",
1199
expect(visibleText()).not.toContain("Running");
1200
});
1201
1202
+it("shows the native coordinator status from its member and gives follow-up activity precedence", async () => {
1203
+ const environmentId = EnvironmentId.make("remote");
1204
+ const coordinator = {
1205
+ id: "coordinator",
1206
+ title: "Workflow coordinator",
1207
+ status: "idle",
1208
+ creationSource: "provider",
1209
+ activeProviderThreadId: null,
1210
+ lineage: { parentThreadId: "parent", relationshipToParent: "subagent" },
1211
+ };
1212
+ const member = {
1213
+ ...coordinator,
1214
+ id: "member",
1215
+ title: "Reviewer",
1216
+ lineage: { parentThreadId: "coordinator", relationshipToParent: "subagent" },
1217
+ };
1218
+ const emptyProjection = {
1219
+ runs: [],
1220
+ nodes: [],
1221
+ providerThreads: [],
1222
+ providerSessions: [],
1223
+ contextTransfers: [],
1224
+ subagents: [],
1225
+ };
1226
+ const rootTurn = {
1227
+ kind: "root_turn",
1228
+ runId: null,
1229
+ status: "failed",
1230
+ startedAt: DateTime.makeUnsafe("2026-09-16T12:00:00Z"),
1231
+ completedAt: DateTime.makeUnsafe("2026-09-16T12:00:10Z"),
1232
+ };
1233
+ state.projections = new Map([
1234
+ ["remote:member", { ...emptyProjection, thread: member, nodes: [rootTurn] }],
1235
+ ["local:coordinator", { ...emptyProjection, thread: coordinator, nodes: [rootTurn] }],
1236
+ ]);
1237
+ state.shells = [coordinator, member].map((source) => ({ environmentId, source }));
1238
+ await render(
1239
+ <ThreadRelationshipsPanel environmentId={environmentId} threadId={ThreadId.make("member")} />,
1240
+ );
1241
+ const coordinatorText = () =>
1242
+ buttons().find((button) => button.textContent?.includes("Workflow coordinator"))?.textContent;
1243
+ expect(coordinatorText()).toMatch(/Workflow coordinator\s*Idle$/);
1244
+
1245
+ for (const [status, label] of [
1246
+ ["running", "Running"],
1247
+ ["completed", "Done"],
1248
+ ]) {
1249
+ state.projections.set("remote:coordinator", {
1250
+ ...emptyProjection,
1251
+ thread: coordinator,
1252
+ nodes: [
1253
+ { ...rootTurn, status, completedAt: status === "running" ? null : rootTurn.completedAt },
1254
+ ],
1255
+ });
1256
+ await update();
1257
+ expect(coordinatorText()).toMatch(new RegExp(`Workflow coordinator\\s*${label}$`));
1258
+ }
1259
+
1260
+ state.shells = [
1261
+ { environmentId, source: { ...coordinator, activityRunStatus: "running" } },
1262
+ { environmentId, source: member },
1263
+ ];
1264
+ await update();
1265
+ expect(coordinatorText()).toMatch(/Workflow coordinator\s*Running$/);
1266
+});
1267
+
1268
it.each(["source", "target"])(
1269
"shows transfer lifecycle states when viewing the %s thread",
1270
async (currentThreadId) => {
apps/web/src/components/chat/ThreadRelationshipsControl.tsx
+29
-5
@@ -12,6 +12,7 @@ import {
12
type RuntimeSubagent,
13
} from "@t3tools/client-runtime/state/subagentRuntime";
14
import { formatSubagentDisplayTitle } from "@t3tools/client-runtime/state/subagent-display";
15
+import { deriveProviderSubagentStatus } from "@t3tools/client-runtime/state/thread-execution";
16
import {
17
deriveThreadRelationshipGraph,
18
immediateThreadRelationships,
@@ -27,6 +28,7 @@ import {
28
resolveLatestMergeBackRun,
29
} from "@t3tools/client-runtime/state/thread-workflows";
30
import {
31
+ isProviderNativeSubagentThread,
32
NodeId,
33
type EnvironmentId,
34
type OrchestrationV2Subagent,
@@ -214,6 +216,26 @@ export function ThreadRelationshipsPanel(props: {
216
const relationshipShells = useThreadRelationshipShells(ref);
217
const allProjects = useProjects();
218
const archived = useArchivedThreadSnapshots([props.environmentId]);
219
+ const archivedShells = archived.snapshots.find(
220
+ (entry) => entry.environmentId === props.environmentId,
221
+ )?.snapshot.threads;
222
+ const currentThread =
223
+ projection?.thread ??
224
+ relationshipShells.find((thread) => thread.id === props.threadId) ??
225
+ archivedShells?.find((thread) => thread.id === props.threadId);
226
+ const parentThreadId =
227
+ currentThread?.forkedFrom?.type === "run"
228
+ ? currentThread.forkedFrom.threadId
229
+ : currentThread?.lineage.parentThreadId;
230
+ const parentShell = parentThreadId
231
+ ? (relationshipShells.find((thread) => thread.id === parentThreadId) ??
232
+ archivedShells?.find((thread) => thread.id === parentThreadId))
233
+ : undefined;
234
+ const parentRef =
235
+ parentShell && isProviderNativeSubagentThread(parentShell)
236
+ ? scopeThreadRef(props.environmentId, parentShell.id)
237
+ : null;
238
+ const parentProjection = useThreadProjection(parentRef)?.projection;
239
const navigate = useNavigate();
240
const mergeBack = useAtomCommand(threadEnvironment.mergeBack);
241
const stopSession = useAtomCommand(threadEnvironment.stopSession);
@@ -228,9 +250,9 @@ export function ThreadRelationshipsPanel(props: {
250
// the panel's hooks where the compiler can cache them.
251
const providers = providersByEnvironment.get(props.environmentId);
252
const projects = allProjects.filter((project) => project.environmentId === props.environmentId);
231
- const archivedShells = archived.snapshots.find(
232
- (entry) => entry.environmentId === props.environmentId,
233
- )?.snapshot.threads;
253
+ const parentNativeStatus = parentProjection
254
+ ? deriveProviderSubagentStatus(parentProjection)?.status
255
+ : undefined;
256
const projected = projection?.subagents ?? [];
257
const runtimeSubagents = projectedSubagentsToRuntime(projected);
258
const byId = new Map(runtimeSubagents.map((agent) => [agent.id, agent]));
@@ -261,7 +283,6 @@ export function ThreadRelationshipsPanel(props: {
283
...(archivedShells ?? []),
284
];
285
const graph = deriveThreadRelationshipGraph({ threads: shells, projection });
264
- const currentThread = projection?.thread ?? graph.nodes.get(props.threadId)?.thread;
286
const currentProject = projects.find((project) => project.id === currentThread?.projectId);
287
const latestMergeBackRun = projection === null ? null : resolveLatestMergeBackRun(projection);
288
const mergeTargetThreadId = resolveMergeBackTargetThreadId(projection);
@@ -418,7 +439,10 @@ export function ThreadRelationshipsPanel(props: {
439
const isSubagent = edge.kind === "subagent";
440
const isMergeTarget = threadId === mergeTargetThreadId;
441
const isParent = isParentThreadRelationship(edge, props.threadId);
421
- const rowStatus = threadRelationshipRowStatus(graph, { threadId, edge });
442
+ const rowStatus =
443
+ (isParent && threadId === parentRef?.threadId
444
+ ? (node?.thread?.activityRunStatus ?? parentNativeStatus)
445
+ : undefined) ?? threadRelationshipRowStatus(graph, { threadId, edge });
446
const RelationshipIcon = isParent
447
? CornerLeftUpIcon
448
: isSubagent