Stop repeating streamed Claude text when assistant blocks arrive split

Claude Code emits one assistant event per content block, so a text block that
streamed at index 1 after a redacted (empty) thinking block arrives alone at
index 0 of its event. The translator aligned completed blocks by that local
index and cleared stream state after every event, found no streamed text, and
re-emitted the whole paragraph as a new text part. Claim the streamed block of
the same kind whose text prefixes the completed one, and keep stream state for
the whole message (reset on message_start or a new message id).
This commit is contained in:
2026-10-31 20:37:48 +00:00
parent 62b56e66d0
commit d7ad468b78
4 changed files with 180 additions and 14 deletions
+1 -3
View File
@@ -352,9 +352,7 @@ func (s *session) processExit(p *process, err error) {
turn := s.turnID
s.running = false
s.turnID = ""
s.streamBlocks = map[int]blockState{}
s.streamText = map[int]string{}
s.streamOrdinals = map[string]int{}
s.resetStreamLocked()
s.mu.Unlock()
if !running {
return