Server: serve a Claude chat's history page from a per-file line index

Reading a history page parsed the whole session file (tens of MB) on every
chat_messages. A per-file index now records which lines build each shown
message; a page re-reads and replays only its own messages' lines, and the
index follows appends by reading only the new bytes. Results match the
whole-file read (compared page by page on synthetic transcripts); shapes the
index cannot replay exactly fall back to the whole-file read.

chat_subscribe may ask (history: true) for the newest page in its reply,
read once the subscription is attached, saving the client a round trip.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-03 14:58:57 +00:00
parent 17baa9e24c
commit 686690f7b4
8 changed files with 1303 additions and 251 deletions
+1 -1
View File
@@ -184,7 +184,7 @@ func handleChat(ctx context.Context, request protocol.Message, broker chatBroker
handleChatPrompt(ctx, request, broker, hub, registry, clientID, write)
return true
case protocol.ChatSubscribe:
handleChatSubscribe(request, broker, hub, clientID, write)
handleChatSubscribe(ctx, request, broker, hub, clientID, write)
return true
case protocol.ChatUnqueue:
handleChatUnqueue(ctx, request, hub, write)