Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
14 changes: 4 additions & 10 deletions apps/web/src/components/chat/MessagesTimeline.logic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ describe("deriveMessagesTimelineRows", () => {
expect(finalRow?.kind === "message" && finalRow.showAssistantMeta).toBe(true);
});

it("folds prior active-turn work while keeping the latest assistant message visible", () => {
it("does not fold the active in-progress turn", () => {
const rows = deriveMessagesTimelineRows({
timelineEntries: [
{
Expand Down Expand Up @@ -735,19 +735,13 @@ describe("deriveMessagesTimelineRows", () => {
revertTurnCountByUserMessageId: new Map(),
});

expect(rows.some((row) => row.kind === "turn-fold")).toBe(false);
expect(rows.map((row) => row.id)).toEqual([
"turn-fold:turn-1",
"assistant-thought-entry",
"work-entry-1",
"assistant-latest-entry",
"working-indicator-row",
]);
expect(rows.find((row) => row.kind === "turn-fold")).toEqual(
expect.objectContaining({
kind: "turn-fold",
turnId: "turn-1",
label: "Working",
expanded: false,
}),
);
});

it("only shows assistant metadata on the terminal assistant message", () => {
Expand Down
21 changes: 10 additions & 11 deletions apps/web/src/components/chat/MessagesTimeline.logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,9 @@ function deriveTurnFolds(input: {

const foldsByAnchorEntryId = new Map<string, TurnFold>();
for (const [turnId, group] of groupsByTurnId) {
if (turnId === input.unsettledTurnId) {
continue;
}
if (group.hasStreamingMessage) {
continue;
}
Expand All @@ -257,8 +260,6 @@ function deriveTurnFolds(input: {

const isLatestInterruptedTurn =
input.latestTurn?.turnId === turnId && input.latestTurn.state === "interrupted";
const isLatestRunningTurn =
input.latestTurn?.turnId === turnId && input.latestTurn.state === "running";
// A turn cut short by a steer leaves trailing work entries behind its
// terminal message — take whichever ended last.
const lastEntryEnd =
Expand All @@ -276,15 +277,13 @@ function deriveTurnFolds(input: {
lastEntryEnd,
);
const duration = elapsedMs !== null ? formatDuration(elapsedMs) : null;
const label = isLatestRunningTurn
? "Working"
: isLatestInterruptedTurn
? duration
? `You stopped after ${duration}`
: "You stopped this response"
: duration
? `Worked for ${duration}`
: "Worked";
const label = isLatestInterruptedTurn
? duration
? `You stopped after ${duration}`
: "You stopped this response"
: duration
? `Worked for ${duration}`
: "Worked";

foldsByAnchorEntryId.set(firstEntry.id, {
turnId,
Expand Down
Loading