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
+14
View File
@@ -834,6 +834,20 @@ func (m *chatManager) TurnRunning(sessionID string) bool {
return ok && reporter.TurnRunning(sessionID)
}
// TracksTurnState reports whether the routed harness reports its own turn
// state through TurnRunning (Claude Code does; OpenCode and Codex are probed).
func (m *chatManager) TracksTurnState(sessionID string) bool {
m.mu.Lock()
backend := m.cache[sessionID]
m.mu.Unlock()
adapter := m.opencode
if backend != "" && backend != "opencode" {
adapter = m.attached(backend)
}
_, ok := adapter.(chatTurnReporter)
return ok
}
// ProbeTurn asks the session's own harness whether a turn is in flight. It is
// the server-start probe (chat_unattended.go): a harness that can be asked
// (OpenCode, Codex) is asked; otherwise its in-memory state is used, which for