TypeScript
fix(web): show a supervisor waiting on its worker as running in Lineage (#18603)
Scott Norteman321b86b05d9c
diff --git a/apps/web/src/components/chat/ThreadRelationshipsControl.agents.browser.test.tsx b/apps/web/src/components/chat/ThreadRelationshipsControl.agents.browser.test.tsxindex 2beeb669b5b..efe5ab0f742 100644--- a/apps/web/src/components/chat/ThreadRelationshipsControl.agents.browser.test.tsx+++ b/apps/web/src/components/chat/ThreadRelationshipsControl.agents.browser.test.tsx@@ -92,7 +92,7 @@ vi.mock(import("../ui/tooltip"), async () => {TooltipTrigger: (({ render, children }: { render: ReactElement; children: ReactNode }) =>cloneElement(render, {}, children)) as never,TooltipPopup: (({ children }: { children: ReactNode }) =>- state.showTooltips ? children : null) as never,+ state.showTooltips ? <div role="tooltip">{children}</div> : null) as never,};});@@ -739,6 +739,78 @@ it("shows the matching child agent details and refreshes them when the agent setexpect(text()).toContain("Lineage · 1 running");});+it("keeps active supervisor status, progress, and task timing after its child turn ends", async () => {+ using _now = vi.spyOn(Date, "now").mockReturnValue(Date.parse("2026-09-16T12:05:15Z"));+ state.showTooltips = true;+ // The child request follows task creation by milliseconds, but finishing that+ // turn does not settle a supervisor still waiting on its worker.+ state.shells = [+ {+ environmentId: "test",+ source: {+ id: "child-1",+ title: "Supervisor",+ status: "completed",+ activityRunStatus: null,+ latestRunId: "run-child-1",+ latestRunRequestedAt: DateTime.makeUnsafe("2026-09-16T12:00:00.003Z"),+ latestRunStartedAt: DateTime.makeUnsafe("2026-09-16T12:00:01Z"),+ latestRunCompletedAt: DateTime.makeUnsafe("2026-09-16T12:02:09Z"),+ lineage: { parentThreadId: "parent", relationshipToParent: "subagent" },+ },+ },+ ];+ const projection = {+ thread: {+ id: "parent",+ lineage: { relationshipToParent: null },+ activeProviderThreadId: null,+ },+ runs: [],+ providerThreads: [],+ providerSessions: [],+ contextTransfers: [],+ subagents: [+ {+ id: "agent-1",+ origin: "app_owned",+ driver: "claudeAgent",+ providerInstanceId: "claudeAgent",+ childThreadId: "child-1",+ title: "Supervisor",+ prompt: "Coordinate the worker",+ model: "claude-opus-5-5",+ status: "running",+ progress: "Waiting for the worker to finish",+ result: null,+ startedAt: DateTime.makeUnsafe("2026-09-16T12:00:00Z"),+ completedAt: null,+ updatedAt: DateTime.makeUnsafe("2026-09-16T12:00:00Z"),+ },+ ],+ };+ for (const status of ["pending", "running", "waiting"]) {+ state.projection = {+ ...projection,+ subagents: [{ ...projection.subagents[0], status }],+ };+ await render(+ <ThreadRelationshipsPanel+ environmentId={EnvironmentId.make("test")}+ threadId={ThreadId.make("parent")}+ />,+ );++ expect(heading()).toBe(status === "running" ? "Lineage · 1 running" : "Lineage");+ expect(textNodes(" ")).not.toContain("Previous agents");+ expect(buttons().some((button) => button.textContent?.includes("Supervisor"))).toBe(true);+ const tooltip = container.querySelector('[role="tooltip"]')?.textContent;+ expect.soft(tooltip).toContain(status);+ expect.soft(tooltip).toContain("Waiting for the worker to finish");+ expect.soft(tooltip).toContain("5m 15s");+ }+});+it("shows readable models and only differing workspace details in agent tooltips", async () => {state.showTooltips = true;const parent = {diff --git a/apps/web/src/components/chat/ThreadRelationshipsControl.tsx b/apps/web/src/components/chat/ThreadRelationshipsControl.tsxindex d9755bf523d..67d7f2ad4d4 100644--- a/apps/web/src/components/chat/ThreadRelationshipsControl.tsx+++ b/apps/web/src/components/chat/ThreadRelationshipsControl.tsx@@ -28,6 +28,7 @@ import {resolveLatestMergeBackRun,} from "@t3tools/client-runtime/state/thread-workflows";import {+ isOrchestrationV2WorkActive,isProviderNativeSubagentThread,NodeId,type EnvironmentId,@@ -179,9 +180,9 @@ function currentSubagent<Agent extends RuntimeSubagent>(agent: Agent | undefined,childThread: OrchestrationV2ThreadShell | null | undefined,): Agent | undefined {+ if (!agent || !childThread || isOrchestrationV2WorkActive(agent.status)) return agent;const liveStatus =- childThread?.activityRunStatus ?? (childThread?.status === "queued" ? "queued" : null);- if (!agent || !childThread) return agent;+ childThread.activityRunStatus ?? (childThread.status === "queued" ? "queued" : null);const newerRun =childThread.latestRunRequestedAt &&DateTime.toEpochMillis(childThread.latestRunRequestedAt) >diff --git a/packages/client-runtime/src/state/threadRelationships.ts b/packages/client-runtime/src/state/threadRelationships.tsindex d218de9d183..e8a636efdb4 100644--- a/packages/client-runtime/src/state/threadRelationships.ts+++ b/packages/client-runtime/src/state/threadRelationships.ts@@ -1,7 +1,8 @@-import type {- OrchestrationV2ThreadProjection,- OrchestrationV2ThreadShell,- ThreadId,+import {+ isOrchestrationV2WorkActive,+ type OrchestrationV2ThreadProjection,+ type OrchestrationV2ThreadShell,+ type ThreadId,} from "@t3tools/contracts";import * as DateTime from "effect/DateTime";@@ -103,7 +104,10 @@ export function deriveThreadRelationshipGraph(input: {targetThreadId: subagent.childThreadId,kind: "subagent",status:- child?.activityRunStatus ?? (child?.latestRunId != null ? child.status : subagent.status),+ child?.activityRunStatus ??+ (child?.latestRunId != null && !isOrchestrationV2WorkActive(subagent.status)+ ? child.status+ : subagent.status),});}for (const transfer of input.projection.contextTransfers) {