Skip to content

Commit 6a36323

Browse files
committed
fix(web): fold interim turn responses
1 parent e09b88b commit 6a36323

2 files changed

Lines changed: 8 additions & 17 deletions

File tree

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

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ describe("deriveMessagesTimelineRows", () => {
452452
expect(assistantRow?.assistantTurnDiffSummary).toBe(assistantTurnDiffSummary);
453453
});
454454

455-
it("keeps the first and terminal assistant messages visible around settled work", () => {
455+
it("folds the first assistant message and settled work before the terminal response", () => {
456456
const timelineEntries = [
457457
{
458458
id: "user-entry",
@@ -528,7 +528,6 @@ describe("deriveMessagesTimelineRows", () => {
528528
expect(foldRow?.label).toBe("Worked for 22s");
529529
expect(collapsedRows.map((row) => row.id)).toEqual([
530530
"user-entry",
531-
"assistant-first-entry",
532531
"turn-fold:turn-1",
533532
"assistant-final-entry",
534533
]);
@@ -544,8 +543,8 @@ describe("deriveMessagesTimelineRows", () => {
544543

545544
expect(expandedRows.map((row) => row.id)).toEqual([
546545
"user-entry",
547-
"assistant-first-entry",
548546
"turn-fold:turn-1",
547+
"assistant-first-entry",
549548
"work-toggle:work-entry-1",
550549
"assistant-final-entry",
551550
]);
@@ -554,7 +553,7 @@ describe("deriveMessagesTimelineRows", () => {
554553
).toBeDefined();
555554
});
556555

557-
it("folds assistant messages between the first and terminal messages", () => {
556+
it("folds all assistant messages before the terminal message", () => {
558557
const timelineEntries = [
559558
{
560559
id: "assistant-first-entry",
@@ -608,11 +607,7 @@ describe("deriveMessagesTimelineRows", () => {
608607
revertTurnCountByUserMessageId: new Map(),
609608
});
610609

611-
expect(rows.map((row) => row.id)).toEqual([
612-
"assistant-first-entry",
613-
"turn-fold:turn-1",
614-
"assistant-final-entry",
615-
]);
610+
expect(rows.map((row) => row.id)).toEqual(["turn-fold:turn-1", "assistant-final-entry"]);
616611
});
617612

618613
it("derives a sane duration for a steer-superseded turn with one instant commentary message", () => {

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -521,10 +521,9 @@ function timelineEntryTurnId(entry: TimelineEntry): TurnId | null {
521521
}
522522

523523
/**
524-
* Settled turns keep their first and terminal assistant messages visible.
525-
* Everything between them folds behind a "Worked for ..." row anchored at
526-
* the first hidden entry. Keeping both ends prevents a short follow-up from
527-
* hiding a substantive opening response while still bounding noisy turns.
524+
* Settled turns keep only their terminal assistant message visible.
525+
* Everything before it folds behind a "Worked for ..." row anchored at the
526+
* first hidden entry, so the duration leads directly into the final response.
528527
*/
529528
function deriveTurnFolds(input: {
530529
timelineEntries: ReadonlyArray<TimelineEntry>;
@@ -594,12 +593,9 @@ function deriveTurnFolds(input: {
594593
if (group.hasStreamingMessage) {
595594
continue;
596595
}
597-
const firstAssistantEntry = group.entries.find(
598-
(entry): entry is Extract<TimelineEntry, { kind: "message" }> => entry.kind === "message",
599-
);
600596
const hiddenEntryIds = new Set<string>();
601597
for (const entry of group.entries) {
602-
if (entry.id === firstAssistantEntry?.id || entry.id === group.terminalEntry?.id) {
598+
if (entry.id === group.terminalEntry?.id) {
603599
continue;
604600
}
605601
// Agent-spawn CTA rows never fold: workflows outlive their launching

0 commit comments

Comments
 (0)