Repository navigation
fix(chat): check the sender before a chat message's prompt is written - #1792
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Summary
Merge Risk: ⚪ Minimal · up to
|
|
Merge pass: this touches observe permissions, so this comment records the review. A gate reviewer on a different model than the author's found no blockers within this PR's scope. What was checked:
Follow-up: an older race outside this PR. The input line's typed fallback ( The reviewer found no matching hole in the other excluded paths. Queued and held delivery ( All required checks are green and no review thread is open. |
… are written (#1796) ## Summary - `server/core/composer.ts`: the typing that ends `submitText` now writes the text and its Enter with the sender's live `authorize` as herdr's write guard. #1791 and #1792 already do this for both `agentPrompt` calls. herdr asks the guard once connected, right before each write. - If the sender was revoked, or switched to watching, while the text was on its way, nothing is written. - If it happened while the Enter was on its way, the text stays typed and no Enter is pressed. This matches what the existing `authorize()` check before the Enter already does. - Either way the submit fails with the sender's own refusal (`read_only` or `device_revoked`), not herdr's `cancelled`. - This typing carries the terminal input line's short lines and multi-line messages, chat messages to a pane without an agent (or where `agent.prompt` answers `agent_not_found`, `agent_not_ready`, or `agent_blocked` only by a Codex queue), and mirrored panes. - `server/core/typed-send-guard.test.ts`: - both writes get a guard; - a lapse while the text is on its way writes nothing and reports `read_only`; - a lapse while the Enter is on its way writes the text only and reports `read_only`. - `server/submit.contract.test.ts`, next to the observe cases of #1791 and #1792: `types nothing of an input line for a sender that switched to observe while herdr was being reached`. A shell recorder pane is used, and `paneSendText` is held before it reaches the isolated test herdr. The sender switches to observe, then the real RPC runs. The test expects `read_only`, and that the recorder receives only another client's later line. - Eight assertions that pinned the two-argument `paneSendText` and `paneSendKeys` calls now expect the guard as well (`input-line-send`, `chat-prompt-guard` and `outcome-delivery` tests). - `changelog.d/typed-send-sender-guard.md`. ## Verification - On main, the three new unit cases fail, and the new contract test fails: the recorder receives the held line, then the other client's line. - With this change: `server/core` unit tests 91/91, `server/submit.contract.test.ts` 87/87 (including the existing `still sends the Enter after the sender is gone`), `src/lib/compose.test.ts` 51/51. - `bun run check fast`. Queued and held messages (`dispatchPendingText`) already pass a guard to their paste, Enter and Escape writes. Claude's draft-clear keys and OpenCode's skill typing pass one as well. A refusal there writes nothing but is reported as `cancelled`; this PR does not change those two paths.
Summary
server/core/composer.ts: the chat composer'sagentPromptcall now passes the sender's liveauthorizeas herdr's write guard, as the input line's long-line path does since fix(terminal-input): send a long input-line line to the pane's agent as its prompt #1791. herdr asks it once connected, right before the prompt is written. A sender that was revoked or switched to watching meanwhile gets that refusal (read_onlyordevice_revoked), nothing is written, and nothing runs after it: no typing fallback, no Codex queue check. The guard and the refusal it records are declared once insubmitTextand shared by bothagentPromptcalls.server/core/chat-prompt-guard.test.ts: a chat message goes out with a guard; a sender that starts watching once herdr is reached getsread_onlywith nothing written or typed; a pane herdr finds no agent in is still typed into.server/submit.contract.test.ts, next to fix(terminal-input): send a long input-line line to the pane's agent as its prompt #1791's observe case:writes no chat message for a sender that switched to observe while herdr was being reached. With Claude's input box read as empty,agentPromptis held before it reaches the isolated test herdr, the sender switches to observe, then the real RPC runs. The test expectsread_only, and that the recorder receives only another client's later line.agentPrompt's two-argument call (six inserver/submit.contract.test.ts, three inserver/core/outcome-delivery.test.ts) now expect the guard as well.changelog.d/chat-prompt-sender-guard.md.Verification
ok: true: the message was written after the sender switched to observe. All pass with this change.server/coreunit tests 88/88,server/submit.contract.test.ts86/86,src/lib/compose.test.ts51/51.bun run check fast.Not changed here: queued and held messages go through
dispatchPendingText, not this call. The input line's typed fallback (paneSendTextaftermirrorInput), Claude's draft-clear keys and OpenCode's skill typing still check the sender without recording a refusal.