Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions apps/web/src/components/chat/MessagesTimeline.logic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ describe("deriveMessagesTimelineRows", () => {
).toBeDefined();
});

it("keeps a tool group after the terminal response visible when the turn is folded", () => {
it("keeps a trailing tool group visible but folds a single activity", () => {
const turnId = TurnId.make("turn-1");
const timelineEntries = [
{
Expand Down Expand Up @@ -829,19 +829,19 @@ 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",
},
isWorking: false,
activeTurnStartedAt: null,
turnDiffSummaryByAssistantMessageId: new Map(),
revertTurnCountByUserMessageId: new Map(),
});
};
const rows = deriveMessagesTimelineRows({ ...input, timelineEntries });

expect(rows.map((row) => row.id)).toEqual([
"turn-fold:turn-1",
Expand All @@ -864,6 +864,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", () => {
Expand Down
10 changes: 7 additions & 3 deletions apps/web/src/components/chat/MessagesTimeline.logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -540,8 +540,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>;
Expand Down Expand Up @@ -621,7 +621,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
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/chat/MessagesTimeline.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1097,7 +1097,7 @@ describe("MessagesTimeline", () => {
expect(markup).toContain("tool call failed");
});

it("renders trailing tool calls as part of the terminal assistant block", () => {
it("renders a failed trailing tool call as part of the terminal assistant block", () => {
const turnId = TurnId.make("turn-trailing-tools");
const assistantMessageId = MessageId.make("assistant-trailing-tools");
const markup = renderToStaticMarkup(
Expand Down Expand Up @@ -1135,7 +1135,7 @@ describe("MessagesTimeline", () => {
label: "Ran command",
tone: "tool",
itemType: "command_execution",
toolLifecycleStatus: "completed",
toolLifecycleStatus: "failed",
},
},
]}
Expand Down
Loading