Skip to content

Commit e1144c1

Browse files
authored
fix: keep running turns expanded (#29)
1 parent ced365a commit e1144c1

2 files changed

Lines changed: 14 additions & 21 deletions

File tree

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

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ describe("deriveMessagesTimelineRows", () => {
679679
expect(finalRow?.kind === "message" && finalRow.showAssistantMeta).toBe(true);
680680
});
681681

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

738+
expect(rows.some((row) => row.kind === "turn-fold")).toBe(false);
738739
expect(rows.map((row) => row.id)).toEqual([
739-
"turn-fold:turn-1",
740+
"assistant-thought-entry",
741+
"work-entry-1",
740742
"assistant-latest-entry",
741743
"working-indicator-row",
742744
]);
743-
expect(rows.find((row) => row.kind === "turn-fold")).toEqual(
744-
expect.objectContaining({
745-
kind: "turn-fold",
746-
turnId: "turn-1",
747-
label: "Working",
748-
expanded: false,
749-
}),
750-
);
751745
});
752746

753747
it("only shows assistant metadata on the terminal assistant message", () => {

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

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,9 @@ function deriveTurnFolds(input: {
236236

237237
const foldsByAnchorEntryId = new Map<string, TurnFold>();
238238
for (const [turnId, group] of groupsByTurnId) {
239+
if (turnId === input.unsettledTurnId) {
240+
continue;
241+
}
239242
if (group.hasStreamingMessage) {
240243
continue;
241244
}
@@ -257,8 +260,6 @@ function deriveTurnFolds(input: {
257260

258261
const isLatestInterruptedTurn =
259262
input.latestTurn?.turnId === turnId && input.latestTurn.state === "interrupted";
260-
const isLatestRunningTurn =
261-
input.latestTurn?.turnId === turnId && input.latestTurn.state === "running";
262263
// A turn cut short by a steer leaves trailing work entries behind its
263264
// terminal message — take whichever ended last.
264265
const lastEntryEnd =
@@ -276,15 +277,13 @@ function deriveTurnFolds(input: {
276277
lastEntryEnd,
277278
);
278279
const duration = elapsedMs !== null ? formatDuration(elapsedMs) : null;
279-
const label = isLatestRunningTurn
280-
? "Working"
281-
: isLatestInterruptedTurn
282-
? duration
283-
? `You stopped after ${duration}`
284-
: "You stopped this response"
285-
: duration
286-
? `Worked for ${duration}`
287-
: "Worked";
280+
const label = isLatestInterruptedTurn
281+
? duration
282+
? `You stopped after ${duration}`
283+
: "You stopped this response"
284+
: duration
285+
? `Worked for ${duration}`
286+
: "Worked";
288287

289288
foldsByAnchorEntryId.set(firstEntry.id, {
290289
turnId,

0 commit comments

Comments
 (0)