fix(web): fold single trailing activity (#9739)

Co-authored-by: maria-rcks <[email protected]>
This commit is contained in:
mariaandmaria-rcks authored and GitHub committed 2026-09-04 14:26:31 -04:00
1 parent c8f77e0d44
commit cfc9bf3415
3 files changed
+17 -8

No files matched your search

@@ -1170,11 +1170,10 @@ describe("deriveMessagesTimelineRows", () => {
})),
];
const rows = deriveMessagesTimelineRows({
timelineEntries,
const input = {
latestTurn: {
turnId,
state: "error",
state: "error" as const,
startedAt: "2026-01-01T00:00:00Z",
completedAt: "2026-01-01T00:00:10Z",
},
@@ -1182,7 +1181,8 @@ describe("deriveMessagesTimelineRows", () => {
activeTurnStartedAt: null,
turnDiffSummaryByAssistantMessageId: new Map(),
revertTurnCountByUserMessageId: new Map(),
});
};
const rows = deriveMessagesTimelineRows({ ...input, timelineEntries });
expect(rows.map((row) => row.id)).toEqual([
"turn-fold:turn-1",
@@ -1205,6 +1205,11 @@ describe("deriveMessagesTimelineRows", () => {
showAssistantMeta: false,
showAssistantCopyButton: false,
});
expect(
deriveMessagesTimelineRows({ ...input, timelineEntries: timelineEntries.slice(0, 3) }).map(
(row) => row.id,
),
).toEqual(["turn-fold:turn-1", "assistant-final-entry"]);
});
it("folds all assistant messages before the terminal message", () => {
@@ -542,8 +542,8 @@ function workEntryIsActiveTurnActivity(entry: WorkLogEntry): boolean {
/**
* Settled turns fold activity before their terminal assistant message behind
* a "Worked for ..." row. Work that lands after that message stays visible so
* failed or interrupted turns do not hide their trailing tool-call summary.
* a "Worked for ..." row. A single ordinary activity after that message joins
* the fold, while larger groups and failures stay visible as a trailing summary.
*/
function deriveTurnFolds(input: {
timelineEntries: ReadonlyArray<TimelineEntry>;
@@ -623,7 +623,11 @@ function deriveTurnFolds(input: {
}
const isCompaction =
entry.kind === "work" && entry.entry.sourceActivityKind === "context-compaction";
if (!isCompaction && index > terminalEntryIndex) {
const isSingleTrailingActivity =
group.entries.length === terminalEntryIndex + 2 &&
entry.kind === "work" &&
!workEntryDisplayIndicatesToolFailure(entry.entry);
if (!isCompaction && index > terminalEntryIndex && !isSingleTrailingActivity) {
continue;
}
// Agent-spawn CTA rows never fold: workflows outlive their launching
@@ -1135,7 +1135,7 @@ describe("MessagesTimeline", () => {
label: "Ran command",
tone: "tool",
itemType: "command_execution",
toolLifecycleStatus: "completed",
toolLifecycleStatus: "failed",
},
},
]}