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:
@@ -523,6 +523,11 @@ type ChatQuery struct {
|
||||
// Cursor is the opaque continuation returned by OpenCode's descending
|
||||
// message listing. It is deliberately not interpreted by the broker.
|
||||
Cursor string `json:"cursor,omitempty"`
|
||||
// History, on chat_subscribe, asks the reply to also carry the newest
|
||||
// history page (Limit messages), as a chat_messages reply would, read once
|
||||
// the subscription is attached. It saves the client a second round trip;
|
||||
// a server that ignores it simply leaves the page out.
|
||||
History bool `json:"history,omitempty"`
|
||||
}
|
||||
|
||||
// ChatHistoryPage describes the bounded slice returned by chat_messages. The
|
||||
|
||||
Reference in New Issue
Block a user