From 730be8b96d85d1c9d5669dc1701d6149cb27566b Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Thu, 12 Nov 2026 09:03:27 +0000 Subject: [PATCH 1/4] test(web): a turn waiting on a foreground subagent does not read as Thinking Fails on main: the open turn appends the generic Thinking row while its only work is a running foreground subagent (#17767). AI-assisted; verified with the tests and tools listed above. --- .../chat/MessagesTimeline.logic.test.ts | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/apps/web/src/components/chat/MessagesTimeline.logic.test.ts b/apps/web/src/components/chat/MessagesTimeline.logic.test.ts index 09cbfe4e7775a..a7f3f3a30fa5f 100644 --- a/apps/web/src/components/chat/MessagesTimeline.logic.test.ts +++ b/apps/web/src/components/chat/MessagesTimeline.logic.test.ts @@ -4668,6 +4668,42 @@ describe("live subagents after their parent turn settles", () => { }); expect(rows.map((row) => row.id)).toEqual([`attempt-fold:${attempt.id}`, "child"]); }); + + it("does not show Thinking while the open turn only waits on a running foreground child", () => { + const rows = deriveMessagesTimelineRows({ + timelineEntries: deriveTimelineEntriesFromVisibleTurnItems({ + visibleTurnItems: ( + [ + { + ...base("user", 0), + status: "completed", + type: "user_message", + messageId: MessageId.make("user"), + createdBy: "user", + creationSource: "web", + inputIntent: "turn_start", + text: "Run three foreground subagents", + attachments: [], + }, + child("child", 3, "running", "provider_native"), + ] satisfies OrchestrationV2TurnItem[] + ).map(projected), + optimisticMessages: [], + }), + latestRun: { + runId, + status: "running", + startedAt: DateTime.formatIso(at(0)), + completedAt: null, + }, + isWorking: true, + activeTurnStartedAt: DateTime.formatIso(at(0)), + turnDiffSummaries: [], + supportsConversationRollback: false, + }); + expect(rows.find((row) => row.id === "child")).toBeDefined(); + expect(rows.filter((row) => row.kind === "thinking")).toEqual([]); + }); }); describe("subagent continued by a later turn", () => { From 6972e5ffb1b1fbd7adec382173a6d7524e4defa4 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Thu, 12 Nov 2026 09:11:30 +0000 Subject: [PATCH 2/4] fix(web): a turn waiting on a foreground subagent no longer reads as Thinking A running subagent card from the open run did not count as live activity, so the timeline appended the generic Thinking row under it for as long as foreground subagents ran (#17767). Treat a live subagent from the unsettled run as the turn's activity row, like an in-progress tool. AI-assisted; verified with the tests and tools listed above. --- apps/web/src/components/chat/MessagesTimeline.logic.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/apps/web/src/components/chat/MessagesTimeline.logic.ts b/apps/web/src/components/chat/MessagesTimeline.logic.ts index c422656647863..beebb6c66b3e0 100644 --- a/apps/web/src/components/chat/MessagesTimeline.logic.ts +++ b/apps/web/src/components/chat/MessagesTimeline.logic.ts @@ -2139,6 +2139,15 @@ export function deriveMessagesTimelineRows(input: { } if (timelineEntry.kind === "event") { + const eventItem = timelineEntry.projectedItem.item; + if ( + input.isWorking && + isLiveSubagentTurnItem(eventItem) && + eventItem.runId != null && + eventItem.runId === unsettledRunId + ) { + hasActivityRow = true; + } const previous = nextRows.at(-1); if ( timelineEntry.projectedItem.item.type === "subagent" && From 430189cc6ef1dbccf77ae324079ef38028da64b1 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Thu, 12 Nov 2026 09:23:49 +0000 Subject: [PATCH 3/4] fix(web): only a trailing running subagent stands in for Thinking A running child from the open run hid the Thinking row even after a steer or more parent output followed it. Count live subagents as the turn's activity only when their group is the newest entry in the timeline. AI-assisted; verified with the tests and tools listed above. --- .../chat/MessagesTimeline.logic.test.ts | 41 ++++++++++++++++++- .../components/chat/MessagesTimeline.logic.ts | 22 ++++++---- 2 files changed, 52 insertions(+), 11 deletions(-) diff --git a/apps/web/src/components/chat/MessagesTimeline.logic.test.ts b/apps/web/src/components/chat/MessagesTimeline.logic.test.ts index a7f3f3a30fa5f..76d12b1131bc4 100644 --- a/apps/web/src/components/chat/MessagesTimeline.logic.test.ts +++ b/apps/web/src/components/chat/MessagesTimeline.logic.test.ts @@ -4669,8 +4669,8 @@ describe("live subagents after their parent turn settles", () => { expect(rows.map((row) => row.id)).toEqual([`attempt-fold:${attempt.id}`, "child"]); }); - it("does not show Thinking while the open turn only waits on a running foreground child", () => { - const rows = deriveMessagesTimelineRows({ + const openTurnRows = (after: ReadonlyArray) => + deriveMessagesTimelineRows({ timelineEntries: deriveTimelineEntriesFromVisibleTurnItems({ visibleTurnItems: ( [ @@ -4686,6 +4686,7 @@ describe("live subagents after their parent turn settles", () => { attachments: [], }, child("child", 3, "running", "provider_native"), + ...after, ] satisfies OrchestrationV2TurnItem[] ).map(projected), optimisticMessages: [], @@ -4701,9 +4702,45 @@ describe("live subagents after their parent turn settles", () => { turnDiffSummaries: [], supportsConversationRollback: false, }); + + it("does not show Thinking while the open turn only waits on a running foreground child", () => { + const rows = openTurnRows([]); expect(rows.find((row) => row.id === "child")).toBeDefined(); expect(rows.filter((row) => row.kind === "thinking")).toEqual([]); }); + + it.each([ + { + name: "a steer", + item: { + ...base("steer", 4), + status: "completed", + type: "user_message", + messageId: MessageId.make("steer"), + createdBy: "user", + creationSource: "web", + inputIntent: "steer", + text: "Also check the docs", + attachments: [], + }, + }, + { + name: "more parent output", + item: { + ...base("assistant", 4), + status: "completed", + type: "assistant_message", + messageId: MessageId.make("assistant"), + text: "Children started; continuing.", + streaming: false, + }, + }, + ] satisfies ReadonlyArray<{ name: string; item: OrchestrationV2TurnItem }>)( + "still shows Thinking when $name follows the running child", + ({ item }) => { + expect(openTurnRows([item]).at(-1)?.kind).toBe("thinking"); + }, + ); }); describe("subagent continued by a later turn", () => { diff --git a/apps/web/src/components/chat/MessagesTimeline.logic.ts b/apps/web/src/components/chat/MessagesTimeline.logic.ts index beebb6c66b3e0..71521a255361b 100644 --- a/apps/web/src/components/chat/MessagesTimeline.logic.ts +++ b/apps/web/src/components/chat/MessagesTimeline.logic.ts @@ -2139,15 +2139,6 @@ export function deriveMessagesTimelineRows(input: { } if (timelineEntry.kind === "event") { - const eventItem = timelineEntry.projectedItem.item; - if ( - input.isWorking && - isLiveSubagentTurnItem(eventItem) && - eventItem.runId != null && - eventItem.runId === unsettledRunId - ) { - hasActivityRow = true; - } const previous = nextRows.at(-1); if ( timelineEntry.projectedItem.item.type === "subagent" && @@ -2276,6 +2267,19 @@ export function deriveMessagesTimelineRows(input: { } } + // The open run is only waiting when its subagent group is the newest work in the timeline. + for (let index = timelineEntries.length - 1; input.isWorking && index >= 0; index -= 1) { + const entry = timelineEntries[index]!; + if ( + entry.kind !== "event" || + entry.projectedItem.item.type !== "subagent" || + entry.projectedItem.item.runId == null || + entry.projectedItem.item.runId !== unsettledRunId + ) { + break; + } + hasActivityRow ||= isLiveSubagentTurnItem(entry.projectedItem.item); + } const hasWorkingRow = nextRows.some((row) => row.kind === "working"); if (input.isWorking && !hasWorkingRow && activeTurnHeaderIndex === timelineEntries.length) { appendWorkingRow(); From f33697872f759c27ab53f0a70978aae0cde405c9 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Thu, 12 Nov 2026 10:41:31 +0000 Subject: [PATCH 4/4] fix(web): an open turn waiting on foreground subagents says so instead of Thinking The live row now reads 'Waiting on N subagents' when the open run's newest work is its running subagent group, including when the parent has already finished the message announcing them. AI-assisted; verified with the tests and tools listed above. --- .../chat/MessagesTimeline.logic.test.ts | 34 +++++++++++-------- .../components/chat/MessagesTimeline.logic.ts | 16 +++++++-- .../components/chat/TimelineWorkGroupRows.tsx | 9 +++-- 3 files changed, 40 insertions(+), 19 deletions(-) diff --git a/apps/web/src/components/chat/MessagesTimeline.logic.test.ts b/apps/web/src/components/chat/MessagesTimeline.logic.test.ts index 76d12b1131bc4..d7ade5b63fd4f 100644 --- a/apps/web/src/components/chat/MessagesTimeline.logic.test.ts +++ b/apps/web/src/components/chat/MessagesTimeline.logic.test.ts @@ -4703,10 +4703,22 @@ describe("live subagents after their parent turn settles", () => { supportsConversationRollback: false, }); - it("does not show Thinking while the open turn only waits on a running foreground child", () => { - const rows = openTurnRows([]); + const assistant = (streaming: boolean): OrchestrationV2TurnItem => ({ + ...base("assistant", 4), + status: streaming ? "running" : "completed", + type: "assistant_message", + messageId: MessageId.make("assistant"), + text: "Started three subagents; waiting for their results.", + streaming, + }); + + it.each([ + { name: "nothing", after: [] }, + { name: "the parent's finished launch message", after: [assistant(false)] }, + ])("shows a waiting row when $name follows the running child", ({ after }) => { + const rows = openTurnRows(after); expect(rows.find((row) => row.id === "child")).toBeDefined(); - expect(rows.filter((row) => row.kind === "thinking")).toEqual([]); + expect(rows.at(-1)).toMatchObject({ kind: "thinking", waitingOnSubagents: 1 }); }); it.each([ @@ -4724,21 +4736,13 @@ describe("live subagents after their parent turn settles", () => { attachments: [], }, }, - { - name: "more parent output", - item: { - ...base("assistant", 4), - status: "completed", - type: "assistant_message", - messageId: MessageId.make("assistant"), - text: "Children started; continuing.", - streaming: false, - }, - }, + { name: "a streaming parent reply", item: assistant(true) }, ] satisfies ReadonlyArray<{ name: string; item: OrchestrationV2TurnItem }>)( "still shows Thinking when $name follows the running child", ({ item }) => { - expect(openTurnRows([item]).at(-1)?.kind).toBe("thinking"); + const last = openTurnRows([item]).at(-1); + expect(last?.kind).toBe("thinking"); + expect(last).not.toHaveProperty("waitingOnSubagents"); }, ); }); diff --git a/apps/web/src/components/chat/MessagesTimeline.logic.ts b/apps/web/src/components/chat/MessagesTimeline.logic.ts index 71521a255361b..040c47dd60168 100644 --- a/apps/web/src/components/chat/MessagesTimeline.logic.ts +++ b/apps/web/src/components/chat/MessagesTimeline.logic.ts @@ -531,6 +531,7 @@ type MessagesTimelineRowContent = createdAt: string | null; groupId?: string; expanded?: boolean; + waitingOnSubagents?: number; } | { kind: "work-toggle"; @@ -2267,9 +2268,19 @@ export function deriveMessagesTimelineRows(input: { } } - // The open run is only waiting when its subagent group is the newest work in the timeline. + // The open run is only waiting when its subagent group is its newest work; finished text the + // parent wrote after launching them does not count as work. + let waitingOnSubagents = 0; for (let index = timelineEntries.length - 1; input.isWorking && index >= 0; index -= 1) { const entry = timelineEntries[index]!; + if ( + entry.kind === "message" && + entry.message.role === "assistant" && + !entry.message.streaming && + entry.message.runId === unsettledRunId + ) { + continue; + } if ( entry.kind !== "event" || entry.projectedItem.item.type !== "subagent" || @@ -2278,7 +2289,7 @@ export function deriveMessagesTimelineRows(input: { ) { break; } - hasActivityRow ||= isLiveSubagentTurnItem(entry.projectedItem.item); + if (isLiveSubagentTurnItem(entry.projectedItem.item)) waitingOnSubagents += 1; } const hasWorkingRow = nextRows.some((row) => row.kind === "working"); if (input.isWorking && !hasWorkingRow && activeTurnHeaderIndex === timelineEntries.length) { @@ -2313,6 +2324,7 @@ export function deriveMessagesTimelineRows(input: { kind: "thinking", id: LIVE_ACTIVITY_ROW_ID, createdAt: input.activeTurnStartedAt ?? null, + ...(waitingOnSubagents > 0 ? { waitingOnSubagents } : {}), }); } } diff --git a/apps/web/src/components/chat/TimelineWorkGroupRows.tsx b/apps/web/src/components/chat/TimelineWorkGroupRows.tsx index 2a17b5363cc50..f964e52cda4ea 100644 --- a/apps/web/src/components/chat/TimelineWorkGroupRows.tsx +++ b/apps/web/src/components/chat/TimelineWorkGroupRows.tsx @@ -377,10 +377,15 @@ export function ThinkingTimelineRow({ row }: { row: Extract; // A failed group keeps this disclosure while an approval waits, but nothing is thinking then. const live = ctx.pendingApprovals.size === 0; + const waiting = row.waitingOnSubagents; const activity = (