Chat: never drop a Claude turn's lifecycle frames; end a runner turn whose end was lost

emit now waits (bounded) for a full watcher to accept step and resync
frames instead of dropping them. The turn runner also ends its turn once a
harness that tracks its turn state has reported idle for the settle period
and its probe confirms, asking clients to resync.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-03 00:21:44 +00:00
parent accb9970b6
commit 3e267d4863
6 changed files with 295 additions and 3 deletions
+16
View File
@@ -190,6 +190,22 @@ func errChatQueueFull(sessionID string) error {
return errors.New("session " + sessionID + " already has the maximum number of prompts queued")
}
// chatTurnTracker is implemented by a broker that routes to several harnesses
// and knows whether the one serving a session reports its own turn state.
type chatTurnTracker interface {
TracksTurnState(sessionID string) bool
}
// brokerTracksTurns reports whether brokerTurnRunning's answer for sessionID
// comes from a harness that tracks its turn, rather than a constant false.
func brokerTracksTurns(broker chatBroker, sessionID string) bool {
if tracker, ok := broker.(chatTurnTracker); ok {
return tracker.TracksTurnState(sessionID)
}
_, ok := broker.(chatTurnReporter)
return ok
}
// brokerTurnRunning asks a harness that knows its own turn state without I/O.
func brokerTurnRunning(broker chatBroker, sessionID string) bool {
reporter, ok := broker.(chatTurnReporter)