Skip to content

Message a Claude Code session when input reaches a page it left unwatched - #765

Merged
max-sixty merged 3 commits into
mainfrom
harness-nudge
Sep 17, 2026
Merged

max-sixty merged 3 commits into
mainfrom
harness-nudge

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

A page whose watcher never came back is invisible from the browser: the reader comments and nothing carries it. The Stop hook polices a turn that is still running and a live leaf wait delivers, so what is left is a claim whose turn has closed with no wait lease held — a watcher stopped after the turn ended, or a Stop that failed open.

Browser-event admission now messages that session over the Unix socket Claude Code binds per session, found by session id in Claude Code's own session registry, telling the agent to start an unnamed leaf wait — which remains the one delivery path. Each page messages once per closed turn, recorded on the claim as messaged_turn, so a reader ticking three boxes queues one turn rather than three; a send no socket took leaves that mark unwritten, and the next input tries again. Codex keeps its own route, since its adapter queues turns itself.

Behavior keys on the harness already recorded on every page claim (host), the way the Stop hook's remedies and the Codex adapter do, rather than on a new flag that could contradict the environment it is derived from.

Delivery is the recipient's decision and nothing reports it back. Measured on Claude Code 2.1.274: a session in a prompting permission mode takes the message, wakes, and fires UserPromptSubmit with the text as its prompt, so the prompt hook reopens the turn and lists the unpicked input; a session that bypasses permissions holds it behind a deliver-or-deny dialog unless its user sets crossSessionInbound to accept, because the gate accepts only a sender inside the recipient's own process tree and a page server is spawned into a session of its own.

session-lifetime.md carries the mechanism, the gate, and the limits; references/host-claude-code.md tells the agent what the message means; the README notes the approval dialog for bypass-mode users. Removes the TODO.md item this implements.

Verified end to end against a real throwaway Claude Code session: the served page's message woke it, it ran leaf wait, received the leaf-delivery-v1 batch carrying the comment, and answered. The new test drives a real page server, a fake session registry, and a bound Unix listener over the gate conditions, the per-turn rule, retry after a refused send, and selection by session id; eight planted faults across the gate and the sender each turn it red.

This was written by Claude Code on behalf of max-sixty

max-sixty and others added 2 commits September 17, 2026 10:41
…ched

A page whose watcher never came back is invisible from the browser: the reader
comments and nothing carries it. The Stop hook polices a running turn, and a
live `leaf wait` delivers, so the gap is a claim whose turn has closed with no
wait lease held.

Browser-event admission now messages that session over the Unix socket Claude
Code binds per session, found by session id in its session registry, telling the
agent to start an unnamed `leaf wait` — which remains the one delivery path. Each
page messages once per closed turn, recorded on the claim as `messaged_turn`, so
a reader ticking three boxes queues one turn rather than three; a send no socket
took leaves the mark unwritten and the next input tries again.

Delivery is the recipient's: a prompting-mode session takes it and fires
UserPromptSubmit, while a bypass-permission session holds it for approval unless
its user sets `crossSessionInbound` to `accept`.

Codex keeps its own route, since its adapter queues turns itself.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants