Claude chat: a history read mid-reply carries the streaming block's beginning

Claude Code writes a content block to its session file only once the block
is complete. A client that read history while a block streamed (opening the
chat mid-reply, a reconnect, a resync) got only the deltas after its read,
and nothing re-sent the block's beginning, so the reply showed with its first
part cut off. Deltas are now numbered (seq) and their text retained for the
newest assistant messages; the newest history page adds every retained part
the transcript lacks and reports the last included seq (live_seq) and the
overlaid parts (live_parts).

History now numbers empty text/thinking blocks as the live stream does, so a
thinking block after an empty display-omitted one keeps one part id live and
in history. Text a content_block_start carries is published, not dropped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-30 15:41:57 +00:00
parent 1772100af2
commit ea25cf504f
6 changed files with 408 additions and 29 deletions
+7
View File
@@ -390,6 +390,13 @@ type session struct {
streamClaimed map[int]bool
toolMessages map[string]string
// liveSeq numbers the text and reasoning deltas this session publishes;
// live holds the text they carried for the newest assistant messages, so
// a history read can include a block the transcript does not hold yet
// (see live.go).
liveSeq int64
live []*liveMessage
// injectedSeen holds the identities of agent reports and notices already
// published live, so a delivery the stream repeats is shown once.
injectedSeen map[string]bool