Repository navigation
fix(codex): no chat message is typed into one of Codex's own screens - #3612
Conversation
herdr reports Codex at rest while one of its own screens has the input (a list such as /model or /permissions, /rename's field, the /statusline and /keymap editors, the agents view, the /diff pager, Find, the search through earlier prompts), so agent.prompt pasted a chat message into it and the Enter that follows took the row under the cursor. Seen on Codex 0.167 in an isolated herdr session: the Enter changed the permission mode, answered the folder question and opened a model's levels. - codexOwnScreenOpen (server/dialogs/codex.ts) knows such a screen by the footer that ends it: a row below the last › or » that begins with a key and what it does and names, as a whole item, the key that leaves (esc back, esc cancel, esc exit, esc save/close, q close), with nothing but rows of keys under it. The composer's last rows are its status line, which begins with the model, and its shortcut hint. - Every chat send to a Codex pane checks it in the last screen read before herdr is written to: the immediate path right before agent.prompt, the queued path in the read it already made for a masked prompt, with the process check still after that read. Refused as agent_blocked; the terminal's own input line is not read. - Codex at Ultra reasoning effort marks its composer »: the start-screen reader (which also lacked the ultra level), the input-row recognizer and the transcript readers (the first exchange, the footed turn, the screen's parts) knew only ›. Screens recorded from Codex 0.167.0 are in src/lib/fixtures-input-rows/codex-0.167.0. The bug was reported, with a first fix, in #3103 by @nocstah; this is a separate implementation. Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
No actionable comments were generated in the recent review. Summary
Merge Risk:
|
Merge passMerged head
Merge pass note (head 21f40c5). Both reviewers CLEAR (Codex with no findings). This is the maintainer's rebuild of the bug reported in #3103; the earlier PID-reuse finding is closed by keeping the process check after the last screen read. Going to a follow-up PR now (queued input a user can hit):
After the release: rows under the composer such as |
… held with its reason (#3619) ## Change Follow-ups to #3612 (no chat message is typed into one of Codex's own screens), from the review of its head. All three are about queued input a user can hit. **A queued message refused by one of Codex's own screens is now held with its reason.** It used to go back to `queued` with no reason shown. herdr reports Codex at rest under such a screen and sends no status event when it closes, so the message sat "queued" while Codex was idle and went out by itself at the next status event, usually the end of a turn the user started since. DESIGN.md and the changelog of #3612 already said "held". Now: - The refusal is its own error (`CodexOwnScreenRefusal`, still `agent_blocked` on the wire). The drain settles it without the retry, so the row reads **held** and waits for **Send now**; its reason is said in the reader's language, with the words of a menu waiting in the terminal. - Every other message queued for the pane is held with it in the same step, with the same reason. Tried one by one, a later one was typed ahead of the first when the screen closed between two tries. - Only a screen the user opened is held this way. A prompt Codex asks (an approval, a question: a card the chat reads), and anything herdr already reports `blocked`, keeps the refusal of a waiting menu: the message is queued again, because that prompt's end brings a status event, maybe a moment after the screen. That holds for the last screen read before a write as well. - Two cards count as screens of the other kind: `/model`'s levels (a list the user opened), and the folder question where herdr does not report it. herdr 0.9.5 calls the pane `blocked` under that question at 80 columns and up, and `idle` at 60 and under, where answering it brings no status event. - A refusal after the paste is uncertain, as before. The drain's own note on a reply is not sent to the page. **`/keymap`'s view that waits for a new key** ends with a sentence, `Press the new key now. Esc cancels.`, not a footer, and was not known: the Enter after a paste would have been taken as the new key. Recorded on Codex 0.167 at 100 and 40 columns (herdr: `idle`); it is read as one row or wrapped onto two. **A remapped cancel key.** Recorded on Codex 0.167 by remapping `tui.keymap.list.cancel` in `/keymap`: a footer draws Ctrl+Q as `^q` (`enter select · ^q back`) and Alt+X as `alt+x` (`? help alt+x back …`, `… · alt+x save/close`). Both were read already; the recordings are now fixtures. The hyphen form the keymap and the config write a chord with (`ctrl-g`) is accepted as a key as well, as the review asked. The spaced form (`ctrl + c`) is not: the composer's own hints use it (`ctrl + c again to quit`). **The tests named for it now reach the drain.** The three "types no queued message into X" tests submitted with the screen already up, so the message was refused when queued and nothing was drained. They now queue over the composer while Codex works and bring the screen up before the turn ends, and assert the listed row. Not in this PR (on the list for after the release, as the merge note says): rows under the composer such as `I quit` or a HUD's `esc to dismiss · type to continue` reading as a screen until they go. ## Validation All on commit `9441ac48e` (the second commit is the review round; the comment below says what changed per finding). - `bun run check fast`: passed (unit: 15462 pass, 0 fail, 51 skip; typecheck, build, generated types and themes, workflow syntax). - Contract tests against an isolated herdr session (`bun run check run -- bun test …`): `server/submit.contract.test.ts`, `server/pending-input.contract.test.ts`, `server/prompt.contract.test.ts`, `server/opencode-first-message.contract.test.ts`, 248 pass, 0 fail. My first version failed one of them (`a create request's first message > whose page leaves during its own automatic send …`): it held a message refused by an approval Codex asked. That is why prompts the agent asks keep the retry. - CI runner image (`herdr-ci-runner:local`, a clone of this commit), all passed: `held-rows-demo-regression.ts`, `pending-pane-switch-regression.ts`, `composer-fit-demo-regression.ts`, `restored-draft-demo-regression.ts`, `chat-local-send-follow-demo-regression.ts` (the held row's note is a client change). - Failing first, against main's `server/core/pending.ts`, `server/dialogs/codex.ts` and `src/components/PendingMessages.tsx`: - `server/core/pending-birth-guard.test.ts`: with `/rename`'s field, the theme list or the `/diff` pager up when the turn ends, the message is listed `held` with the reason (main: `queued`, no reason); after the screen closes and one more turn ends over the composer it is still not typed (main: pasted and sent); the messages queued behind it are held with it, also when the screen closes between two tries; `/model`'s levels and the folder question under an idle herdr hold; a screen that opens during the last checks holds the message too. - `server/dialogs/codex-own-screen.test.ts` and `server/core/codex-own-screen-send.test.ts`: the recorded key-capture view at 100 and 40 columns and `enter select · ctrl-g back` (main: not a screen, and the send went out). - `src/components/PendingMessages.test.tsx`: the held reason in ko, ja and zh. - Pins that pass on both: a command's approval queues the message again and it goes after the next turn, also when it comes up during the last checks; a message is still refused when queued with a screen up; a Send now's answer carries no field of the drain's own. - New recordings from Codex 0.167.0 (isolated herdr 0.9.5 session, scratch `CODEX_HOME`, herdr `idle` under each): the key-capture view, the list a shortcut's row opens, and `/permissions`, `/experimental`, `/resume`, `/agents` with the cancel key remapped to Ctrl+Q and Alt+X. Ten files in `src/lib/fixtures-input-rows/codex-0.167.0`. - Not run: `bun run check full`. The branch is based on main as of #3612 and merges with today's main without conflicts. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Fable 5.2 <[email protected]>
…wser (#3708) ## Change Follows #3612. With `[tui] fullscreen_transcript = false`, Ctrl+T opens Codex's transcript pager, whose footer `codexOwnScreenOpen` already reads (`q close · f3 find · esc browse prompts`). Esc there opens the transcript's prompt browser, and the guard misses that one: its footer begins with a word, not a key, so a chat message was pasted into it. There its letters move through the earlier prompts (h, j, k and l) and the Enter after the paste rewinds the conversation to the prompt picked. Codex never wraps that footer: it keeps the first of its forms that fits the pane less two columns (`first_fitting_line` in `prompt_navigation.rs`), down to the label alone. Seen at each width, from 100 to 30 columns on Codex 0.167.0 and 0.167.1, and from 24 columns down on 0.167.2, whose footer code is the same: ``` 100: Browsing transcript · ↑↓/jk scroll · ←→/hl prompts · ^t details · ↵ rewind · esc back 80: Browsing · ↑↓/jk scroll · ←→/hl prompts · ^t details · ↵ rewind · esc back 60: Browsing · ↑↓/jk ←→/hl · ^t details · ↵ rewind · esc back 50: Browsing · ↑↓/jk ←→/hl · ↵ rewind · esc 40: Browsing · ↵ rewind · esc back 30: Browsing · esc back 20: Browsing · esc 15: Browsing ``` `Browsing · esc back` still fits at 24 columns, `Browsing · esc` from 20 down to 16, and the bare label from 15 down to 10. Under 10 Codex draws no footer. The guard now reads it as the screen's last row, as it reads the search through earlier prompts, in each of those forms (`CODEX_TRANSCRIPT_RE`). The bare label counts only on a screen with no row wider than 15 columns, the only panes where Codex draws it, so a wider screen ending in that word stays free. With default settings Ctrl+T leaves the composer, so nothing changes there. A draft of those words in the composer stays free, because the status line stands under it. How it was seen: Codex in a terminal at each width, with a scratch `CODEX_HOME` holding `[tui] fullscreen_transcript = false`, no account and a loopback provider that refuses connections. One prompt was sent (its request failed), then Ctrl+T and Esc. The rows above are as `tmux capture-pane` gave them. Like the pager's footer already in the test, they are seen, not recorded as fixtures. Those captured screens, run through `codexOwnScreenOpen` on main, read the pager as open at 100 and 40 columns and the prompt browser as not open; with this change, both read as open. ## Validation - `bun run check fast` (Bun 1.4.2, herdr variables unset, `TMPDIR` under `~/.cache`) on the head commit: workflow syntax, generated types and themes, typecheck and build passed; unit tests passed in 907 of 908 files. The one failure, `server/herdr-core/discovery.test.ts` "refuses a group-writable folder whose ACL lets another account write, even in a harmless group", fails the same way on `main` here: it runs `setfacl -m g:nogroup:rwx`, and this Arch Linux machine has no `nogroup` group (setfacl exits 2). - `bun scripts/check.ts run bun test server/dialogs/codex-own-screen.test.ts server/core/codex-own-screen-send.test.ts src/lib/inputRow.test.ts scripts/changelog-fold.test.ts`: 52 pass, 0 fail. - Skipped: `bun run check full` and the browser regressions (a server-side reader change, no UI). 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_0136d6wzhMrxFJXcJ14vXD7Y --------- Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: devswha <[email protected]>
Change
Supersedes #3103. The bug and its two halves were reported there by @nocstah, with a first fix. That PR has no signed CLA, so this is a separate implementation written from the report of the bug: the recogniser, the place it is checked and the recorded screens are new here.
A chat message was typed into Codex's own screens. herdr reports Codex at rest while one of its own screens has the input, so
agent.promptpasted the message into it; a list drops the paste, and the Enter 300 ms later takes the row under the cursor. Reproduced on Codex 0.167.0 in an isolated herdr 0.9.5 session (a scratchCODEX_HOME, a loopback stand-in for the provider), with herdr reportingidle:/permissionswith the cursor on Read Only: the list closed and the history gainedPermission selection requested: Read Only. The text landed nowhere./model: the Enter took the row and opened that model's levels, whose footer isenter default · s session · esc back(Enter saves the row for every new session).blockedon a wide pane, butunknownin its first seconds (the Enter then answered Trust and continue and wrote the trust toconfig.toml) andidleat 40 and 60 columns.herdr said
idleunder every other screen recorded:/modeland its levels,/permissions,/review,/theme,/resume,/statusline,/experimental,/rename,/agentsand its help,/keymap,/diff, Find (F3) and the search through earlier prompts (Ctrl+R).The fix:
codexOwnScreenOpen(server/dialogs/codex.ts) knows such a screen by the footer that ends it. It looks only below the last row Codex marks›or», in the last three rows, for a row that begins with a key and what it does (orType to …) and holds, as a whole item, the key that leaves:esc back,esc cancel,esc exit,esc save/close,q close, 0.162'sesc to go back. Items are apart by·or by spaces (the agents view,/resume), a narrow pane wraps the row at a space or after a slash, and only rows of keys may stand under it. The search through earlier prompts has no footer and is known by itsreverse-i-search:row.← for agents · ? for shortcuts; with its shortcuts shown the last row is? / esc close, where no item starts atesc, and the composer still takes what is typed. A thread or folder named like a key hint is one item of the status line; an answer quoting a footer stands above the composer; a draft line that reads like a footer has the status line under it.agent_blocked("Not sent: the agent is waiting for an answer in the terminal"), so the message stays in the box and a queued one stays held. The immediate path reads right beforeagent.prompt(freeCodexInput, asfreeHermesInputand the Claude rewind check do). The queued path uses the read it already made for a masked prompt before every write (noMaskedPrompt) and the one inpendingContext.POST /api/pane/inputis unchanged for the same reason.Codex at Ultra reasoning effort marks its composer
»(0.164 on;codex-queue.tsandcodex-steering.tsknew). Readers that knew only›:server/start-screen.ts, whose effort list also lackedultra: a new pane's chat showed "Conversation unavailable" instead of opening empty.src/lib/inputRow.tscodexInputRow: the notice that a command's screen is still open never armed.server/codex.ts:displayedFirstExchangeran the first answer on through the composer,codexScreenPartstook a draft in the»box for answer text (a draft quoting another conversation's answer could bind the pane to it), andidleTurnFooter/footedViewdid not see the idle composer under a finished turn.On the two findings in the review of #3103's last head:
sameStart), before each write. A new test changes the process at the agent's PID as that last read is answered and expects nothing typed; it fails when the start is read before the screen.…and does not wrap it (recorded at 40 columns). The recogniser still does not count a row that goes on from one ending in·, a row that begins with the model, or a row that names no key that leaves (enter savealone); tests cover the review's example.Not covered, and said so in DESIGN.md: a screen whose footer names no key that leaves is not held. The transcript's own pager was seen once (with
[tui] fullscreen_transcript = false; its last rowq close · f3 find · esc browse promptsis read as a footer in a test) but not recorded; in the default layout Ctrl+T redraws the history in place and leaves the composer.A Codex send now makes one screen read more. Two expectations in
server/submit.contract.test.tsthat counted reads say so, andserver/core/omp-submit.test.ts's synthetic herdr answers that read.Validation
All on commit
21f40c56a.bun run check fast: passed (unit: 15380 pass, 0 fail, 51 skip; typecheck, build, generated types and themes, workflow syntax).bun run check run -- bun test …):server/submit.contract.test.ts,server/pending-input.contract.test.ts,server/prompt.contract.test.ts, 242 pass, 0 fail. Before their two read-count expectations were updated, exactly those two failed and nothing else.herdr-ci-runner:local, a clone of this commit), all passed:terminal-autoswitch-demo-regression.ts,command-outcome-demo-regression.ts,replay-clipboard-demo-regression.ts(the peek and the still-open notice, which readsrc/lib/inputRow.ts) andchat-local-send-follow-demo-regression.ts.server/core/codex-own-screen-send.test.ts(new): a chat send with each recorded own screen up is refusedagent_blockedand types nothing (on mainagent.promptwent out); into the composer (at rest, with a draft, with its shortcuts shown, at Ultra) it goes out; the terminal's input line and other agents are not read.server/core/pending-birth-guard.test.ts: a queued message is not pasted into/rename's field, the theme list or the/diffpager, nor into one that opens during the last checks (all four pasted on main), and the process check after the last screen read still holds.server/start-screen.test.ts,src/lib/inputRow.test.ts(on the recorded Ultra composer), and three cases inserver/codex.test.ts(first exchange, footed turn, a draft in the»box quoting another conversation). All five fail on main.server/dialogs/codex-own-screen.test.ts(new) reads every recorded screen: Codex 0.167.0 at 100 and 40 columns (18 own screens, 8 composer states;src/lib/fixtures-input-rows/codex-0.167.0, recorded for this PR) and main's 22 recordings of 0.163.0, plus the footers of 0.162, remapped keys and the look-alikes above.bun run check full; a real Codex pane through the app end to end (the screens were recorded from a real Codex 0.167.0 and the sends are tested against them); Codex with[tui] fullscreen_transcript = falsebeyond the rows quoted above. The branch is based on main as of fix(chat): tie a Codex pane to its conversation by its last turn in three more cases (#3262) #3582 and merges with today's main without conflicts.🤖 Generated with Claude Code