Chat and runs: tell a slow client to resync instead of dropping it silently; join queued deltas

A chat subscriber whose queue fills is detached and its writer ends the
stream with a resync frame (the app re-attaches and re-reads history); a run
subscriber gets a final runs_resync and the app subscribes again and
re-reads the Runs list and open detail. Consecutive text/reasoning deltas of
one part are joined in a chat subscriber's queue; joined numbered frames carry
seq_from and delta_lens so the app trims exactly the prefix a history page
already holds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-03 00:39:38 +00:00
parent e649eced10
commit c316bc9bc8
20 changed files with 603 additions and 80 deletions
+5 -2
View File
@@ -294,8 +294,11 @@ func (h *chatHub) endObservedTurnLocked(room *chatRoom) {
h.finishTurnLocked(room)
resync := protocol.ChatEventFrame{SessionID: room.sessionID, Kind: protocol.ChatEventResync}
for _, sub := range room.subs {
enqueueChatLocked(sub, protocol.Message{Type: protocol.ChatEvent, ChatEvent: &resync})
enqueueChatLocked(sub, protocol.Message{Type: protocol.ChatEvent, ChatEvent: &end})
if !enqueueChatLocked(sub, protocol.Message{Type: protocol.ChatEvent, ChatEvent: &resync}) ||
!enqueueChatLocked(sub, protocol.Message{Type: protocol.ChatEvent, ChatEvent: &end}) {
// overflow detaches under h.mu: never from inside the fold lock.
go sub.overflow()
}
}
}