Repository navigation
Message a Claude Code session when input reaches a page it left unwatched - #765
Merged
Merged
Conversation
…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]>
leaf-agent
approved these changes
Sep 17, 2026
This was referenced Sep 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 waitdelivers, 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 asmessaged_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
crossSessionInboundtoaccept, 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.mdcarries the mechanism, the gate, and the limits;references/host-claude-code.mdtells the agent what the message means; the README notes the approval dialog for bypass-mode users. Removes theTODO.mditem 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 theleaf-delivery-v1batch 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.