Report a busy chat on subscribe after a reload

The room that records a server-run turn is torn down when its last client
leaves, so a page reload re-subscribed to a new room that no longer knew the
turn was running and never replayed the step-started marker. Claude Code does
not re-announce a running turn to a new stream either, so the activity row and
Stop control vanished until the next streamed delta.

chat_subscribe now also replays the marker when the room's stream announced a
turn (CLI-originated or re-announced on attach) or when the broker reports its
own turn in flight through the optional chatTurnReporter (Claude Code reads its
in-process running flag; the chat manager routes it without I/O).
This commit is contained in:
2026-10-31 22:09:11 +00:00
parent 063c1144a1
commit 429e175b95
7 changed files with 288 additions and 5 deletions
+15
View File
@@ -666,3 +666,18 @@ func (m *chatManager) ReleaseShells(sessionID string) {
releaser.ReleaseShells(sessionID)
}
}
// TurnRunning reports the routed harness's own in-flight state. It reads only
// the backend cache (filled once the session is observed) and an already
// attached client: no registry read and no harness probe.
func (m *chatManager) TurnRunning(sessionID string) bool {
m.mu.Lock()
backend := m.cache[sessionID]
m.mu.Unlock()
adapter := m.opencode
if backend != "" && backend != "opencode" {
adapter = m.attached(backend)
}
reporter, ok := adapter.(chatTurnReporter)
return ok && reporter.TurnRunning(sessionID)
}