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:
2026-11-02 16:07:42 +00:00
parent 467f3eafa7
commit 80022ea41a
13 changed files with 820 additions and 25 deletions
+17 -3
View File
@@ -21,9 +21,23 @@ The same settings decide what is sent on both paths.
Each event notifies once. Opening or dismissing it on one device clears it on
the others.
Chat events are seen while some client has the chat open or the server still
holds queued messages for it. A turn that finishes with no client attached and
nothing queued does not produce a "replied" notification.
Chat events do not need the chat to be open. When the last app or browser
leaves a chat whose turn is still running, or which has an unanswered question
or approval, the server keeps watching it until the turn ends and nothing is
left to answer, so "Chat needs you" and "Chat replied" still arrive with the
app closed. A client that reopens the chat meanwhile joins the same watch, so
nothing is announced twice. Idle chats are not watched.
Limits:
- At most 16 chats are watched with no client attached; a further one is not
(queued messages are always delivered regardless).
- A turn that never reports its end stops being watched after 6 hours.
- After a server restart, the 32 most recently used open chats (used in the last
24 hours) are asked whether a turn is still running, and those that are are
watched again. This works for OpenCode and Codex, which keep running across a
Pipelines restart. A Claude Code turn runs inside the server process and ends
with it, so there is nothing to resume.
## Settings