Skip to content

Commit 010687e

Browse files
committed
feat(web): subagent spawns render as an expandable work row
The spawn CTA was a bordered card between plain work rows, exempt from turn folds, and clicking it only opened the Agents panel. It now uses the same icon, type, and chevron as sibling tool rows, expands in place to list each member with status, role, duration, tokens, and the first line of its result, and folds with its turn once every member settles. A batch with a live member stays outside the fold, decided from the agent panel model.
1 parent 15c6167 commit 010687e

3 files changed

Lines changed: 301 additions & 40 deletions

File tree

‎apps/web/src/components/chat/MessagesTimeline.logic.test.ts‎

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,6 +1121,68 @@ describe("deriveMessagesTimelineRows", () => {
11211121
]);
11221122
});
11231123

1124+
it("folds a settled subagent spawn row and keeps a live one outside the fold", () => {
1125+
const timelineEntries = [
1126+
{
1127+
id: "assistant-first-entry",
1128+
kind: "message" as const,
1129+
createdAt: "2026-01-01T00:00:01Z",
1130+
message: {
1131+
id: "assistant-first" as never,
1132+
role: "assistant" as const,
1133+
text: "Fanning out.",
1134+
turnId: "turn-1" as never,
1135+
createdAt: "2026-01-01T00:00:01Z",
1136+
updatedAt: "2026-01-01T00:00:02Z",
1137+
streaming: false,
1138+
},
1139+
},
1140+
{
1141+
id: "spawn-entry",
1142+
kind: "work" as const,
1143+
createdAt: "2026-01-01T00:00:03Z",
1144+
entry: {
1145+
id: "spawn-1",
1146+
createdAt: "2026-01-01T00:00:03Z",
1147+
turnId: "turn-1" as never,
1148+
label: "Ran 2 subagents",
1149+
tone: "tool" as const,
1150+
agentSpawn: { workflowId: null, agentTaskIds: ["agent-a", "agent-b"] },
1151+
},
1152+
},
1153+
{
1154+
id: "assistant-final-entry",
1155+
kind: "message" as const,
1156+
createdAt: "2026-01-01T00:00:05Z",
1157+
message: {
1158+
id: "assistant-final" as never,
1159+
role: "assistant" as const,
1160+
text: "Done.",
1161+
turnId: "turn-1" as never,
1162+
createdAt: "2026-01-01T00:00:05Z",
1163+
updatedAt: "2026-01-01T00:00:06Z",
1164+
streaming: false,
1165+
},
1166+
},
1167+
];
1168+
const derive = (liveAgentTaskIds: ReadonlySet<string>) =>
1169+
deriveMessagesTimelineRows({
1170+
timelineEntries,
1171+
isWorking: false,
1172+
activeTurnStartedAt: null,
1173+
turnDiffSummaries: [],
1174+
supportsConversationRollback: false,
1175+
liveAgentTaskIds,
1176+
}).map((row) => row.id);
1177+
1178+
expect(derive(new Set())).toEqual(["turn-fold:turn-1", "assistant-final-entry"]);
1179+
expect(derive(new Set(["agent-b"]))).toEqual([
1180+
"turn-fold:turn-1",
1181+
"spawn-entry",
1182+
"assistant-final-entry",
1183+
]);
1184+
});
1185+
11241186
it("only enables assistant copy for the terminal assistant message in a turn", () => {
11251187
const rows = deriveMessagesTimelineRows({
11261188
timelineEntries: [

‎apps/web/src/components/chat/MessagesTimeline.logic.ts‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,7 @@ function deriveTurnFolds(input: {
577577
terminalAssistantMessageIds: ReadonlySet<string>;
578578
latestTurn: TimelineLatestTurn | null;
579579
unfoldedTurnIds: ReadonlySet<TurnId>;
580+
liveAgentTaskIds: ReadonlySet<string> | undefined;
580581
}): ReadonlyMap<string, TurnFold> {
581582
interface TurnGroup {
582583
entries: Array<TimelineEntry>;
@@ -657,10 +658,15 @@ function deriveTurnFolds(input: {
657658
if (!isCompaction && index > terminalEntryIndex && !isSingleTrailingActivity) {
658659
continue;
659660
}
660-
// Agent-spawn CTA rows never fold: workflows outlive their launching
661-
// turn (dynamic spawns, background execution), and folding the CTA
662-
// when the turn settles makes a still-running fleet invisible.
663-
if (entry.kind === "work" && entry.entry.agentSpawn !== undefined) {
661+
// Workflows outlive their launching turn (dynamic spawns, background
662+
// execution), so a spawn row with a live member stays outside the fold
663+
// instead of hiding a still-running fleet. Settled spawns fold with
664+
// the rest of the turn.
665+
if (
666+
entry.kind === "work" &&
667+
entry.entry.agentSpawn !== undefined &&
668+
entry.entry.agentSpawn.agentTaskIds.some((taskId) => input.liveAgentTaskIds?.has(taskId))
669+
) {
664670
continue;
665671
}
666672
hiddenEntryIds.add(entry.id);
@@ -854,6 +860,8 @@ export function deriveMessagesTimelineRows(input: {
854860
activeTurnStartedAt: string | null;
855861
turnDiffSummaries: ReadonlyArray<TurnDiffSummary>;
856862
supportsConversationRollback: boolean;
863+
/** Task ids of subagents still working; their spawn row stays outside turn folds. */
864+
liveAgentTaskIds?: ReadonlySet<string>;
857865
}): MessagesTimelineRow[] {
858866
const turnDiffSummaryByAssistantMessageId = new Map<MessageId, TurnDiffSummary>();
859867
for (const summary of input.turnDiffSummaries) {
@@ -888,6 +896,7 @@ export function deriveMessagesTimelineRows(input: {
888896
terminalAssistantMessageIds,
889897
latestTurn: input.latestTurn ?? null,
890898
unfoldedTurnIds: activeVisualResponseTurnIds,
899+
liveAgentTaskIds: input.liveAgentTaskIds,
891900
});
892901
const collapsedEntryIds = new Set<string>();
893902
for (const fold of foldsByAnchorEntryId.values()) {

0 commit comments

Comments
 (0)