Keep observing chats with an in-flight turn after the last client leaves
Chat attention notifications (questions, approvals, finished replies) come from a session's event stream, which the hub only read while a room existed; detach destroyed the room when the last client left, so a turn that finished or asked with the app closed notified nobody. A room whose last client leaves now stays observing, unattended, while its turn is in flight or it holds an unanswered question/approval, and is torn down when the turn ends (or after 6h for a stuck turn); at most 16 such rooms. At server start, recently used open sessions whose harness reports a running turn (OpenCode /api/session/active, Codex thread/turns/list) are observed again so their reply still notifies. Settings, dedupe and app_notifications recording are unchanged.
This commit is contained in:
@@ -100,6 +100,14 @@ func TestCompactionTransportLossAndInterruptClearDoNotReleaseTurn(t *testing.T)
|
||||
room.cancel()
|
||||
h.drainStream(room, result)
|
||||
}
|
||||
if mode == "detach" {
|
||||
// The last client leaving a running turn keeps the room observing
|
||||
// unattended: the turn, and its live compaction, are still current.
|
||||
if h.rooms[room.sessionID] != room || !room.watching || !room.running {
|
||||
t.Fatal("detach released the room of a live turn")
|
||||
}
|
||||
return
|
||||
}
|
||||
if h.turns[room.sessionID].compaction != nil || !room.running {
|
||||
t.Fatal("cleanup stuck label or released live turn")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user