Skip to content
TypeScript

fix(web): show native coordinator status in member lineage (#18149)

ash6eff4a9647f0
diff --git a/apps/web/src/components/chat/ThreadRelationshipsControl.agents.browser.test.tsx b/apps/web/src/components/chat/ThreadRelationshipsControl.agents.browser.test.tsx
index ae09b4f639a..4efcb87b7b2 100644
--- a/apps/web/src/components/chat/ThreadRelationshipsControl.agents.browser.test.tsx
+++ b/apps/web/src/components/chat/ThreadRelationshipsControl.agents.browser.test.tsx
@@ -1,9 +1,11 @@
import { act, cloneElement, type ReactElement, type ReactNode } from "react";
import { createRoot, type Root } from "react-dom/client";
+import { scopedThreadKey } from "@t3tools/client-runtime/environment";
import {
EnvironmentId,
ThreadId,
type ModelSelection,
+ type ScopedThreadRef,
type ProviderOptionDescriptor,
type OrchestrationV2ContextTransfer,
} from "@t3tools/contracts";
@@ -15,6 +17,7 @@ import "~/index.css";
const state = vi.hoisted(() => ({
stopWorkflowLabel: "environment-data:orchestration:stop-workflow",
projection: null as unknown,
+ projections: null as Map<string, unknown> | null,
navigate: vi.fn(),
shells: [] as unknown[],
projects: [] as unknown[],
@@ -31,7 +34,14 @@ vi.mock(import("@tanstack/react-router"), async (original) => ({
}));
vi.mock(import("../../state/entities"), async (original) => ({
...(await original()),
- useThreadProjection: (() => ({ projection: state.projection })) as never,
+ useThreadProjection: ((ref: ScopedThreadRef | null) =>
+ ref === null
+ ? undefined
+ : {
+ projection: state.projections
+ ? state.projections.get(scopedThreadKey(ref))
+ : state.projection,
+ }) as never,
useThreadRelationshipShells: ((ref: { readonly environmentId: string }) =>
(state.shells as ReadonlyArray<{ readonly environmentId: string; readonly source: unknown }>)
.filter((shell) => shell.environmentId === ref.environmentId)
@@ -153,6 +163,7 @@ afterEach(async () => {
state.workflowCommand.mockReset().mockResolvedValue({ _tag: "Success" });
state.toast.mockClear();
state.projection = null;
+ state.projections = null;
});
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",
expect(visibleText()).not.toContain("Running");
});
+it("shows the native coordinator status from its member and gives follow-up activity precedence", async () => {
+ const environmentId = EnvironmentId.make("remote");
+ const coordinator = {
+ id: "coordinator",
+ title: "Workflow coordinator",
+ status: "idle",
+ creationSource: "provider",
+ activeProviderThreadId: null,
+ lineage: { parentThreadId: "parent", relationshipToParent: "subagent" },
+ };
+ const member = {
+ ...coordinator,
+ id: "member",
+ title: "Reviewer",
+ lineage: { parentThreadId: "coordinator", relationshipToParent: "subagent" },
+ };
+ const emptyProjection = {
+ runs: [],
+ nodes: [],
+ providerThreads: [],
+ providerSessions: [],
+ contextTransfers: [],
+ subagents: [],
+ };
+ const rootTurn = {
+ kind: "root_turn",
+ runId: null,
+ status: "failed",
+ startedAt: DateTime.makeUnsafe("2026-09-16T12:00:00Z"),
+ completedAt: DateTime.makeUnsafe("2026-09-16T12:00:10Z"),
+ };
+ state.projections = new Map([
+ ["remote:member", { ...emptyProjection, thread: member, nodes: [rootTurn] }],
+ ["local:coordinator", { ...emptyProjection, thread: coordinator, nodes: [rootTurn] }],
+ ]);
+ state.shells = [coordinator, member].map((source) => ({ environmentId, source }));
+ await render(
+ <ThreadRelationshipsPanel environmentId={environmentId} threadId={ThreadId.make("member")} />,
+ );
+ const coordinatorText = () =>
+ buttons().find((button) => button.textContent?.includes("Workflow coordinator"))?.textContent;
+ expect(coordinatorText()).toMatch(/Workflow coordinator\s*Idle$/);
+
+ for (const [status, label] of [
+ ["running", "Running"],
+ ["completed", "Done"],
+ ]) {
+ state.projections.set("remote:coordinator", {
+ ...emptyProjection,
+ thread: coordinator,
+ nodes: [
+ { ...rootTurn, status, completedAt: status === "running" ? null : rootTurn.completedAt },
+ ],
+ });
+ await update();
+ expect(coordinatorText()).toMatch(new RegExp(`Workflow coordinator\\s*${label}$`));
+ }
+
+ state.shells = [
+ { environmentId, source: { ...coordinator, activityRunStatus: "running" } },
+ { environmentId, source: member },
+ ];
+ await update();
+ expect(coordinatorText()).toMatch(/Workflow coordinator\s*Running$/);
+});
+
it.each(["source", "target"])(
"shows transfer lifecycle states when viewing the %s thread",
async (currentThreadId) => {
diff --git a/apps/web/src/components/chat/ThreadRelationshipsControl.tsx b/apps/web/src/components/chat/ThreadRelationshipsControl.tsx
index b4688c45f57..d9755bf523d 100644
--- a/apps/web/src/components/chat/ThreadRelationshipsControl.tsx
+++ b/apps/web/src/components/chat/ThreadRelationshipsControl.tsx
@@ -12,6 +12,7 @@ import {
type RuntimeSubagent,
} from "@t3tools/client-runtime/state/subagentRuntime";
import { formatSubagentDisplayTitle } from "@t3tools/client-runtime/state/subagent-display";
+import { deriveProviderSubagentStatus } from "@t3tools/client-runtime/state/thread-execution";
import {
deriveThreadRelationshipGraph,
immediateThreadRelationships,
@@ -27,6 +28,7 @@ import {
resolveLatestMergeBackRun,
} from "@t3tools/client-runtime/state/thread-workflows";
import {
+ isProviderNativeSubagentThread,
NodeId,
type EnvironmentId,
type OrchestrationV2Subagent,
@@ -214,6 +216,26 @@ export function ThreadRelationshipsPanel(props: {
const relationshipShells = useThreadRelationshipShells(ref);
const allProjects = useProjects();
const archived = useArchivedThreadSnapshots([props.environmentId]);
+ const archivedShells = archived.snapshots.find(
+ (entry) => entry.environmentId === props.environmentId,
+ )?.snapshot.threads;
+ const currentThread =
+ projection?.thread ??
+ relationshipShells.find((thread) => thread.id === props.threadId) ??
+ archivedShells?.find((thread) => thread.id === props.threadId);
+ const parentThreadId =
+ currentThread?.forkedFrom?.type === "run"
+ ? currentThread.forkedFrom.threadId
+ : currentThread?.lineage.parentThreadId;
+ const parentShell = parentThreadId
+ ? (relationshipShells.find((thread) => thread.id === parentThreadId) ??
+ archivedShells?.find((thread) => thread.id === parentThreadId))
+ : undefined;
+ const parentRef =
+ parentShell && isProviderNativeSubagentThread(parentShell)
+ ? scopeThreadRef(props.environmentId, parentShell.id)
+ : null;
+ const parentProjection = useThreadProjection(parentRef)?.projection;
const navigate = useNavigate();
const mergeBack = useAtomCommand(threadEnvironment.mergeBack);
const stopSession = useAtomCommand(threadEnvironment.stopSession);
@@ -228,9 +250,9 @@ export function ThreadRelationshipsPanel(props: {
// the panel's hooks where the compiler can cache them.
const providers = providersByEnvironment.get(props.environmentId);
const projects = allProjects.filter((project) => project.environmentId === props.environmentId);
- const archivedShells = archived.snapshots.find(
- (entry) => entry.environmentId === props.environmentId,
- )?.snapshot.threads;
+ const parentNativeStatus = parentProjection
+ ? deriveProviderSubagentStatus(parentProjection)?.status
+ : undefined;
const projected = projection?.subagents ?? [];
const runtimeSubagents = projectedSubagentsToRuntime(projected);
const byId = new Map(runtimeSubagents.map((agent) => [agent.id, agent]));
@@ -261,7 +283,6 @@ export function ThreadRelationshipsPanel(props: {
...(archivedShells ?? []),
];
const graph = deriveThreadRelationshipGraph({ threads: shells, projection });
- const currentThread = projection?.thread ?? graph.nodes.get(props.threadId)?.thread;
const currentProject = projects.find((project) => project.id === currentThread?.projectId);
const latestMergeBackRun = projection === null ? null : resolveLatestMergeBackRun(projection);
const mergeTargetThreadId = resolveMergeBackTargetThreadId(projection);
@@ -418,7 +439,10 @@ export function ThreadRelationshipsPanel(props: {
const isSubagent = edge.kind === "subagent";
const isMergeTarget = threadId === mergeTargetThreadId;
const isParent = isParentThreadRelationship(edge, props.threadId);
- const rowStatus = threadRelationshipRowStatus(graph, { threadId, edge });
+ const rowStatus =
+ (isParent && threadId === parentRef?.threadId
+ ? (node?.thread?.activityRunStatus ?? parentNativeStatus)
+ : undefined) ?? threadRelationshipRowStatus(graph, { threadId, edge });
const RelationshipIcon = isParent
? CornerLeftUpIcon
: isSubagent