Skip to content

Commit cd35b71

Browse files
nullStack65claude
andcommitted
fix(web): open a slow show_file that finishes behind a newer row
The watermark was the newest timeline start time, so a show_file that started before a later row never opened when it completed earlier than that row's start. The watermark is now the newest completion. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
1 parent 13c1b15 commit cd35b71

3 files changed

Lines changed: 34 additions & 5 deletions

File tree

‎apps/web/src/components/chat/MessagesTimeline.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
import { parseScopedThreadKey } from "@t3tools/client-runtime/environment";
2323
import { useRightPanelStore } from "../../rightPanelStore";
2424
import {
25-
latestTimelineCreatedAt,
25+
latestShownFileCreatedAt,
2626
shownFileKey,
2727
shownFileTargets,
2828
shownFilesToOpen,
@@ -496,7 +496,7 @@ const ConversationTimeline = memo(function ConversationTimeline({
496496
return {
497497
files,
498498
signature: shownFileKey(files),
499-
latestCreatedAt: latestTimelineCreatedAt(timelineEntries),
499+
latestCreatedAt: latestShownFileCreatedAt(files),
500500
entryCount: timelineEntries.length,
501501
};
502502
}, [timelineEntries]);

‎apps/web/src/components/chat/shownFileOpen.test.ts‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,34 @@ describe("shownFilesToOpen", () => {
166166
).toEqual([completed]);
167167
});
168168

169+
it("opens a file that finishes after one which completed earlier, even though a row started later", () => {
170+
const first = files[0]!;
171+
const previous = shownFilesToOpen({
172+
threadKey: "env/thread",
173+
previous: null,
174+
nextKey: shownFileKey([first]),
175+
files: [first],
176+
entryCount: 2,
177+
latestCreatedAt: first.createdAt,
178+
}).baseline;
179+
const slow: ShownFileTarget = {
180+
id: "show-slow",
181+
path: "/tmp/slow.md",
182+
createdAt: "2026-01-02T00:00:00.500Z",
183+
};
184+
expect(slow.createdAt > first.createdAt).toBe(true);
185+
expect(
186+
shownFilesToOpen({
187+
threadKey: "env/thread",
188+
previous,
189+
nextKey: shownFileKey([first, slow]),
190+
files: [first, slow],
191+
entryCount: 3,
192+
latestCreatedAt: slow.createdAt,
193+
}).open,
194+
).toEqual([slow]);
195+
});
196+
169197
it("opens only a file that completed after the newest item already on screen", () => {
170198
const first = files.slice(0, 1);
171199
const previous = shownFilesToOpen({

‎apps/web/src/components/chat/shownFileOpen.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ export function shownFileTargets(
3333
return targets;
3434
}
3535

36-
export function latestTimelineCreatedAt(entries: ReadonlyArray<{ createdAt: string }>): string {
36+
/** Newest completion, so a slow tool is not hidden behind a row that started later. */
37+
export function latestShownFileCreatedAt(files: ReadonlyArray<{ createdAt: string }>): string {
3738
let latest = "";
38-
for (const entry of entries) {
39-
if (entry.createdAt > latest) latest = entry.createdAt;
39+
for (const file of files) {
40+
if (file.createdAt > latest) latest = file.createdAt;
4041
}
4142
return latest;
4243
}

0 commit comments

Comments
 (0)