The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 24, 02:45 UTC
fix(web): keep subagent rows visible under folded turns (#11474)
maria committed
Sep 12, 2026 at 19:54 UTC
af2baccd100604f9885d6af97a5fa99622dd1c4f
3 files changed
+14
-50
apps/web/src/components/chat/MessagesTimeline.logic.test.ts
+5
-12
@@ -1122,7 +1122,7 @@ describe("deriveMessagesTimelineRows", () => {
1122
]);
1123
});
1124
1125
- it("folds a settled subagent spawn row and keeps a live one outside the fold", () => {
1125
+ it("keeps subagent spawn rows outside turn folds even after they settle", () => {
1126
const firstMessage: ChatMessage = {
1127
id: MessageId.make("assistant-first-entry"),
1128
role: "assistant",
@@ -1161,7 +1161,6 @@ describe("deriveMessagesTimelineRows", () => {
1161
const derive = (
1162
timelineEntries: typeof direct,
1163
liveAgentTaskIds: ReadonlySet<string> | undefined,
1164
- expandedSpawnEntryIds?: ReadonlySet<string>,
1164
expandedTurnIds?: ReadonlySet<TurnId>,
1165
) =>
1166
deriveMessagesTimelineRows({
@@ -1171,10 +1170,8 @@ describe("deriveMessagesTimelineRows", () => {
1170
turnDiffSummaries: [],
1171
supportsConversationRollback: false,
1172
liveAgentTaskIds,
1174
- expandedSpawnEntryIds,
1173
...(expandedTurnIds ? { expandedTurnIds } : {}),
1174
}).map((row) => row.id);
1177
- const folded = ["turn-fold:turn-1", "assistant-final-entry"];
1175
const unfolded = ["turn-fold:turn-1", "spawn-entry", "assistant-final-entry"];
1176
1177
const activeRows = (
@@ -1237,19 +1234,15 @@ describe("deriveMessagesTimelineRows", () => {
1234
}
1235
}
1236
1240
- expect(derive(direct, new Set())).toEqual(folded);
1237
+ expect(derive(direct, new Set())).toEqual(unfolded);
1238
expect(derive(direct, new Set(["agent-b"]))).toEqual(unfolded);
1239
// A workflow coordinator between phases keeps its batch out of the fold.
1240
expect(derive(workflow, new Set(["wf-1"]))).toEqual(unfolded);
1244
- expect(derive(workflow, new Set())).toEqual(folded);
1241
+ expect(derive(workflow, new Set())).toEqual(unfolded);
1242
// No live set is known.
1243
expect(derive(direct, undefined)).toEqual(unfolded);
1247
- // The user has it open: it stays visible under the collapsed fold and
1248
- // keeps its place when the fold is expanded.
1249
- expect(derive(direct, new Set(), new Set(["spawn-entry"]))).toEqual(unfolded);
1250
- expect(
1251
- derive(direct, new Set(), new Set(["spawn-entry"]), new Set(["turn-1" as TurnId])),
1252
- ).toEqual([
1244
+ // Expanding the turn reveals the other work without duplicating the batch.
1245
+ expect(derive(direct, new Set(), new Set(["turn-1" as TurnId]))).toEqual([
1246
"turn-fold:turn-1",
1247
"assistant-first-entry",
1248
"spawn-entry",
apps/web/src/components/chat/MessagesTimeline.logic.ts
+6
-30
@@ -577,7 +577,6 @@ function deriveTurnFolds(input: {
577
terminalAssistantMessageIds: ReadonlySet<string>;
578
latestTurn: TimelineLatestTurn | null;
579
unfoldedTurnIds: ReadonlySet<TurnId>;
580
- liveAgentTaskIds: ReadonlySet<string> | undefined;
580
}): ReadonlyMap<string, TurnFold> {
581
interface TurnGroup {
582
entries: Array<TimelineEntry>;
@@ -658,27 +657,13 @@ function deriveTurnFolds(input: {
657
if (!isCompaction && index > terminalEntryIndex && !isSingleTrailingActivity) {
658
continue;
659
}
661
- // User input stays visible after the surrounding work settles.
662
- if (entry.kind === "work" && entry.entry.questionAnswer !== undefined) {
660
+ // User input and subagent batches stay visible after their turn settles.
661
+ if (
662
+ entry.kind === "work" &&
663
+ (entry.entry.questionAnswer !== undefined || entry.entry.agentSpawn !== undefined)
664
+ ) {
665
continue;
666
}
665
- // Workflows outlive their launching turn (dynamic spawns, background
666
- // execution), so a spawn row with a live member or coordinator stays
667
- // outside the fold instead of hiding a still-running fleet. Settled
668
- // spawns fold with the rest of the turn. Without a live set (no agent
669
- // panel model, as in the held paint during a thread switch) every
670
- // spawn row stays out.
671
- if (entry.kind === "work" && entry.entry.agentSpawn !== undefined) {
672
- const live = input.liveAgentTaskIds;
673
- const { workflowId, agentTaskIds } = entry.entry.agentSpawn;
674
- if (
675
- live === undefined ||
676
- (workflowId !== null && live.has(workflowId)) ||
677
- agentTaskIds.some((taskId) => live.has(taskId))
678
- ) {
679
- continue;
680
- }
681
- }
667
hiddenEntryIds.add(entry.id);
668
}
669
if (hiddenEntryIds.size === 0) {
@@ -870,13 +855,8 @@ export function deriveMessagesTimelineRows(input: {
855
activeTurnStartedAt: string | null;
856
turnDiffSummaries: ReadonlyArray<TurnDiffSummary>;
857
supportsConversationRollback: boolean;
873
- /**
874
- * Task ids of subagents still working; their spawn row stays outside turn
875
- * folds. Undefined means unknown, which keeps every spawn row out.
876
- */
858
+ /** Task ids of subagents still working, used by the active tool indicator. */
859
liveAgentTaskIds?: ReadonlySet<string> | undefined;
878
- /** Spawn rows the user opened stay visible while their turn fold is collapsed. */
879
- expandedSpawnEntryIds?: ReadonlySet<string> | undefined;
860
}): MessagesTimelineRow[] {
861
const turnDiffSummaryByAssistantMessageId = new Map<MessageId, TurnDiffSummary>();
862
for (const summary of input.turnDiffSummaries) {
@@ -911,15 +891,11 @@ export function deriveMessagesTimelineRows(input: {
891
terminalAssistantMessageIds,
892
latestTurn: input.latestTurn ?? null,
893
unfoldedTurnIds: activeVisualResponseTurnIds,
914
- liveAgentTaskIds: input.liveAgentTaskIds,
894
});
895
const collapsedEntryIds = new Set<string>();
896
for (const fold of foldsByAnchorEntryId.values()) {
897
if (!input.expandedTurnIds?.has(fold.turnId)) {
898
for (const entryId of fold.hiddenEntryIds) {
920
- // An opened spawn row keeps its fold membership but is not pulled
921
- // away mid-read when its last member settles.
922
- if (input.expandedSpawnEntryIds?.has(entryId)) continue;
899
collapsedEntryIds.add(entryId);
900
}
901
}
apps/web/src/components/chat/MessagesTimeline.tsx
+3
-8
@@ -465,8 +465,7 @@ export const MessagesTimeline = memo(function MessagesTimeline({
465
}: MessagesTimelineProps) {
466
const [expandedTurnIds, setExpandedTurnIds] = useState<ReadonlySet<TurnId>>(new Set());
467
const [expandedWorkGroupIds, setExpandedWorkGroupIds] = useState<ReadonlySet<string>>(new Set());
468
- // Expanded spawn rows outlive virtualization and stay visible while their
469
- // turn fold is collapsed, so a settling fleet is not pulled away mid-read.
468
+ // Preserve member disclosure state across virtualization.
469
const [expandedSpawnEntryIds, setExpandedSpawnEntryIds] = useState<ReadonlySet<string>>(
470
new Set(),
471
);
@@ -628,10 +627,8 @@ export const MessagesTimeline = memo(function MessagesTimeline({
627
workspaceRoot: string | undefined;
628
projection: MessagesTimelineRowsProjection;
629
} | null>(null);
631
- // Subagents still working keep their spawn row outside the turn fold. Same
632
- // liveness rule as the row header (deriveAgentSpawnSummary): members while
633
- // active, workflow coordinators until terminal. Keyed by content so the
634
- // projection input keeps its identity across unrelated panel updates.
630
+ // Match the row header's liveness, retaining projection input identity
631
+ // across unrelated panel updates.
632
const liveAgentTaskKey = useMemo(() => {
633
if (agentPanelModel === undefined) return undefined;
634
const ids: string[] = [];
@@ -667,7 +664,6 @@ export const MessagesTimeline = memo(function MessagesTimeline({
664
turnDiffSummaries,
665
supportsConversationRollback,
666
liveAgentTaskIds,
670
- expandedSpawnEntryIds: paintedExpandedSpawnEntryIds,
667
},
668
previous?.threadKey === listIdentityKey && previous.workspaceRoot === workspaceRoot
669
? previous.projection
@@ -689,7 +685,6 @@ export const MessagesTimeline = memo(function MessagesTimeline({
685
turnDiffSummaries,
686
supportsConversationRollback,
687
liveAgentTaskIds,
692
- paintedExpandedSpawnEntryIds,
688
]);
689
const rows = useStableRows(rawRows, listIdentityKey);
690
const minimapItems = useMemo(() => deriveTimelineMinimapItems(rows), [rows]);