Skip to content

Commit c079848

Browse files
committed
fix(web): spawn row keeps its header as the only button and pins open rows
Nested member rows and the Agents panel link no longer bubble Enter and Space into the batch toggle, member expansion suspends end-scroll maintenance like other rows, and a row the user opened stays outside the turn fold until collapsed. Live detection follows the header's rule for workflow coordinators and keeps every spawn row out when no agent panel model is provided.
1 parent 26a1bea commit c079848

4 files changed

Lines changed: 129 additions & 64 deletions

File tree

‎apps/web/src/components/AgentsPanel.tsx‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/**
2-
* Agents right-panel surface: the fleet view over the native subagent fold,
3-
* and the ONLY place the roster renders (the chat carries one CTA row per
4-
* spawn batch).
2+
* Agents right-panel surface: the fleet view over the native subagent fold.
3+
* The chat carries one expandable row per spawn batch and links here.
54
*
65
* Visualization rules (from live-test feedback):
76
* - Spawn order is stable. Activity and completion update rows in place.

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

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,7 +1122,7 @@ describe("deriveMessagesTimelineRows", () => {
11221122
});
11231123

11241124
it("folds a settled subagent spawn row and keeps a live one outside the fold", () => {
1125-
const timelineEntries = [
1125+
const entriesWith = (agentSpawn: { workflowId: string | null; agentTaskIds: string[] }) => [
11261126
{
11271127
id: "assistant-first-entry",
11281128
kind: "message" as const,
@@ -1147,7 +1147,7 @@ describe("deriveMessagesTimelineRows", () => {
11471147
turnId: "turn-1" as never,
11481148
label: "Ran 2 subagents",
11491149
tone: "tool" as const,
1150-
agentSpawn: { workflowId: null, agentTaskIds: ["agent-a", "agent-b"] },
1150+
agentSpawn,
11511151
},
11521152
},
11531153
{
@@ -1165,22 +1165,33 @@ describe("deriveMessagesTimelineRows", () => {
11651165
},
11661166
},
11671167
];
1168-
const derive = (liveAgentTaskIds: ReadonlySet<string>) =>
1168+
const direct = entriesWith({ workflowId: null, agentTaskIds: ["agent-a", "agent-b"] });
1169+
const workflow = entriesWith({ workflowId: "wf-1", agentTaskIds: ["wf-1", "agent-a"] });
1170+
const derive = (
1171+
timelineEntries: typeof direct,
1172+
liveAgentTaskIds: ReadonlySet<string> | undefined,
1173+
expandedSpawnEntryIds?: ReadonlySet<string>,
1174+
) =>
11691175
deriveMessagesTimelineRows({
11701176
timelineEntries,
11711177
isWorking: false,
11721178
activeTurnStartedAt: null,
11731179
turnDiffSummaries: [],
11741180
supportsConversationRollback: false,
11751181
liveAgentTaskIds,
1182+
expandedSpawnEntryIds,
11761183
}).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+
const folded = ["turn-fold:turn-1", "assistant-final-entry"];
1185+
const unfolded = ["turn-fold:turn-1", "spawn-entry", "assistant-final-entry"];
1186+
1187+
expect(derive(direct, new Set())).toEqual(folded);
1188+
expect(derive(direct, new Set(["agent-b"]))).toEqual(unfolded);
1189+
// A workflow coordinator between phases keeps its batch out of the fold.
1190+
expect(derive(workflow, new Set(["wf-1"]))).toEqual(unfolded);
1191+
expect(derive(workflow, new Set())).toEqual(folded);
1192+
// The user has it open, or no live set is known.
1193+
expect(derive(direct, new Set(), new Set(["spawn-entry"]))).toEqual(unfolded);
1194+
expect(derive(direct, undefined)).toEqual(unfolded);
11841195
});
11851196

11861197
it("only enables assistant copy for the terminal assistant message in a turn", () => {

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

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,7 @@ function deriveTurnFolds(input: {
578578
latestTurn: TimelineLatestTurn | null;
579579
unfoldedTurnIds: ReadonlySet<TurnId>;
580580
liveAgentTaskIds: ReadonlySet<string> | undefined;
581+
expandedSpawnEntryIds: ReadonlySet<string> | undefined;
581582
}): ReadonlyMap<string, TurnFold> {
582583
interface TurnGroup {
583584
entries: Array<TimelineEntry>;
@@ -660,14 +661,18 @@ function deriveTurnFolds(input: {
660661
}
661662
// Workflows outlive their launching turn (dynamic spawns, background
662663
// 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-
) {
670-
continue;
664+
// instead of hiding a still-running fleet, as does one the user has
665+
// open. Settled spawns fold with the rest of the turn. Without a live
666+
// set (no agent panel model) every spawn row stays out.
667+
if (entry.kind === "work" && entry.entry.agentSpawn !== undefined) {
668+
const live = input.liveAgentTaskIds;
669+
if (
670+
live === undefined ||
671+
entry.entry.agentSpawn.agentTaskIds.some((taskId) => live.has(taskId)) ||
672+
input.expandedSpawnEntryIds?.has(entry.id)
673+
) {
674+
continue;
675+
}
671676
}
672677
hiddenEntryIds.add(entry.id);
673678
}
@@ -860,8 +865,13 @@ export function deriveMessagesTimelineRows(input: {
860865
activeTurnStartedAt: string | null;
861866
turnDiffSummaries: ReadonlyArray<TurnDiffSummary>;
862867
supportsConversationRollback: boolean;
863-
/** Task ids of subagents still working; their spawn row stays outside turn folds. */
864-
liveAgentTaskIds?: ReadonlySet<string>;
868+
/**
869+
* Task ids of subagents still working; their spawn row stays outside turn
870+
* folds. Undefined means unknown, which keeps every spawn row out.
871+
*/
872+
liveAgentTaskIds?: ReadonlySet<string> | undefined;
873+
/** Spawn rows the user expanded; they stay outside turn folds too. */
874+
expandedSpawnEntryIds?: ReadonlySet<string> | undefined;
865875
}): MessagesTimelineRow[] {
866876
const turnDiffSummaryByAssistantMessageId = new Map<MessageId, TurnDiffSummary>();
867877
for (const summary of input.turnDiffSummaries) {
@@ -897,6 +907,7 @@ export function deriveMessagesTimelineRows(input: {
897907
latestTurn: input.latestTurn ?? null,
898908
unfoldedTurnIds: activeVisualResponseTurnIds,
899909
liveAgentTaskIds: input.liveAgentTaskIds,
910+
expandedSpawnEntryIds: input.expandedSpawnEntryIds,
900911
});
901912
const collapsedEntryIds = new Set<string>();
902913
for (const fold of foldsByAnchorEntryId.values()) {

0 commit comments

Comments
 (0)