TypeScript
fix(web): fold interim turn responses (#8828)
maria17c48f7fc1af
diff --git a/apps/web/src/components/chat/MessagesTimeline.logic.test.ts b/apps/web/src/components/chat/MessagesTimeline.logic.test.tsindex e9dd9bad053..3186c8873c5 100644--- a/apps/web/src/components/chat/MessagesTimeline.logic.test.ts+++ b/apps/web/src/components/chat/MessagesTimeline.logic.test.ts@@ -469,7 +469,7 @@ describe("deriveMessagesTimelineRows", () => {expect(assistantRow?.assistantTurnDiffSummary).toBe(assistantTurnDiffSummary);});- it("keeps the first and terminal assistant messages visible around settled work", () => {+ it("folds the first assistant message and settled work before the terminal response", () => {const timelineEntries = [{id: "user-entry",@@ -545,7 +545,6 @@ describe("deriveMessagesTimelineRows", () => {expect(foldRow?.label).toBe("Worked for 22s");expect(collapsedRows.map((row) => row.id)).toEqual(["user-entry",- "assistant-first-entry","turn-fold:turn-1","assistant-final-entry",]);@@ -561,8 +560,8 @@ describe("deriveMessagesTimelineRows", () => {expect(expandedRows.map((row) => row.id)).toEqual(["user-entry",- "assistant-first-entry","turn-fold:turn-1",+ "assistant-first-entry","work-toggle:work-entry-1","assistant-final-entry",]);@@ -571,7 +570,7 @@ describe("deriveMessagesTimelineRows", () => {).toBeDefined();});- it("folds assistant messages between the first and terminal messages", () => {+ it("folds all assistant messages before the terminal message", () => {const timelineEntries = [{id: "assistant-first-entry",@@ -625,11 +624,7 @@ describe("deriveMessagesTimelineRows", () => {revertTurnCountByUserMessageId: new Map(),});- expect(rows.map((row) => row.id)).toEqual([- "assistant-first-entry",- "turn-fold:turn-1",- "assistant-final-entry",- ]);+ expect(rows.map((row) => row.id)).toEqual(["turn-fold:turn-1", "assistant-final-entry"]);});it("derives a sane duration for a steer-superseded turn with one instant commentary message", () => {diff --git a/apps/web/src/components/chat/MessagesTimeline.logic.ts b/apps/web/src/components/chat/MessagesTimeline.logic.tsindex d2b7b6a82eb..1ca449ca172 100644--- a/apps/web/src/components/chat/MessagesTimeline.logic.ts+++ b/apps/web/src/components/chat/MessagesTimeline.logic.ts@@ -523,10 +523,9 @@ function timelineEntryTurnId(entry: TimelineEntry): TurnId | null {}/**- * Settled turns keep their first and terminal assistant messages visible.- * Everything between them folds behind a "Worked for ..." row anchored at- * the first hidden entry. Keeping both ends prevents a short follow-up from- * hiding a substantive opening response while still bounding noisy turns.+ * Settled turns keep only their terminal assistant message visible.+ * Everything before it folds behind a "Worked for ..." row anchored at the+ * first hidden entry, so the duration leads directly into the final response.*/function deriveTurnFolds(input: {timelineEntries: ReadonlyArray<TimelineEntry>;@@ -596,12 +595,9 @@ function deriveTurnFolds(input: {if (group.hasStreamingMessage) {continue;}- const firstAssistantEntry = group.entries.find(- (entry): entry is Extract<TimelineEntry, { kind: "message" }> => entry.kind === "message",- );const hiddenEntryIds = new Set<string>();for (const entry of group.entries) {- if (entry.id === firstAssistantEntry?.id || entry.id === group.terminalEntry?.id) {+ if (entry.id === group.terminalEntry?.id) {continue;}// Agent-spawn CTA rows never fold: workflows outlive their launching