load chat transcripts as a tail window and lazy-load older on scroll-up

extremely long transcripts made bottom-anchoring the virtualized list unreliable
(thousands of unmeasured variable-height items = a huge estimate the scroll never
lands on). now GET /chat/sessions/:id takes limit+before and returns a windowed
slice plus total+offset. the chat opens on the last 20 messages, anchors to the
bottom instantly, and scrolling near the top pages in the next older window,
prepending it and pinning the previously-top message so the view stays put.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-30 03:49:13 +00:00
co-authored by Claude Opus 4.8
parent 3682269936
commit b27dd7512b
7 changed files with 173 additions and 18 deletions
@@ -28,7 +28,14 @@ export type ClaudeSessionMessage =
isError?: boolean;
};
export type ClaudeSessionDetail = { id: string; model: string; cwd: string; messages: ClaudeSessionMessage[] };
export type ClaudeSessionDetail = {
id: string;
model: string;
cwd: string;
messages: ClaudeSessionMessage[];
total: number; // full transcript length (the loaded messages may be a tail window)
offset: number; // absolute index of messages[0]; older messages remain above when > 0
};
export type ClaudePwd = { cwd: string; sessionCount: number; updatedAt: string; isDefault: boolean };