Repository navigation
fix(codex): Orca writes its Codex status hook once, approved by Codex, so every launch gets status and no review screen - #24234
brennanb2025 wants to merge 70 commits into
Conversation
…nothing writes ~/.codex
Orca put its status hook entry into ~/.codex/hooks.json (and into every
managed Codex home) on each pane launch and resume, then asked Codex to
approve it in the background. Until that approval landed, a Codex started in
that home showed Codex's "Hooks need review" screen, and several races (a
failed approval, a Codex update, hooks off racing an approval, two Orca
builds) could leave a user looking at it.
Codex reads hooks and their approvals from `-c` session flags as well as
from files. Each native Codex launch now carries one flag,
`-c hooks={<8 events>, state={<key>={trusted_hash=...}}}`: Orca's hook plus
Codex's own approval of it. Nothing about Orca's hook is written to any
Codex home, and a flag never carries a hook without its approval.
- The key and hash come from Codex itself: `hooks/list` in a throwaway
CODEX_HOME. Codex hashes a hook with no path or position in it, so the
answer holds everywhere. Saved per `codex --version`, re-asked on any
mismatch.
- The pane `codex` function (bash/zsh, fish, PowerShell) adds the flag only
when its binary reports that version and the Codex home holds no Orca file
entry (an older build's, which already posts status). Otherwise it adds
nothing: no status, never a review screen.
- cmd.exe has no function: its pane defines a doskey macro in the existing
/K startup that calls a gate script in the same cmd.exe. Main adds the
flag to Orca-launched commands that name codex by absolute path.
- On Windows the flag holds no `"` or `%`; a profile path that needs the
quoted cmd.exe spelling is carried by the script's 8.3 name.
- App start and turning hooks on remove Orca's entries from ~/.codex (with
the user's hooks' approvals moved, as the opt-out does), run the
retired-form sweep, refresh the managed home's user-hook mirror, and ask
Codex for the flag. Turning hooks off is unchanged.
- Native launch prep, resume, structured chats and commit messages only
mirror the user's own hooks into managed homes. WSL and SSH keep their
installers.
Deleted: the per-launch real-home install, its background approval,
cooldown, withdrawal and launch/resume waits, the real-home lane gate, and
the managed-home install of Orca's entry.
…dex too Its hook is a .cmd script named by a bare forward-slash path, the spelling the Windows flag carries, so the same five checks pin the synthetic session-flags key and approval on Windows.
The status hook flag and its Codex version were copied into each pane's env at spawn, from state derived only at app start or when the setting turned on. Panes outlive Orca restarts in the terminal daemon, so a Codex update, a codex installed later, one failed derivation, a pane spawned before the derivation landed, or the hooks setting changing left panes with no status (or with Orca's hook after the opt-out) until they were reopened. Panes now carry only ORCA_CODEX_HOOK_FLAGS, the path of a per-profile table in userData (codex-hook-flags/<codex --version>.flag, plus .no-daemon), and each launch reads the entry for its own binary's version. A launch that finds none writes <version>.request with its codex path; the main process watches the table and derives an entry for that binary, at most three times per binary and version with backoff. The opt-out empties the table, and a derivation in flight when it lands publishes nothing. An entry is the single store of the derived answer: it holds the whole flag, is re-derived when its hook definition differs from this build's, and is published only after Codex lists the complete flag as trusted. getStatus and the CLI read the table from disk. Also: carriers skip the flag beside the user's own `-c hooks...`, match older Orca entries by the sweep's agent-hooks/codex-hook. needle with either separator, take --no-daemon from the entry instead of probing --help, and the cmd gate tries every version line. Codex resumes wait at most 3 s for a derivation in flight. Shell wrapper snapshots regenerated for the new function text.
… shells in CI App start now strips Orca's entries from ~/.codex on every launch, and the tests that pinned that removal went with the deleted installer. Restore them against removeRealHomeCodexHookEntries: no ~/.codex creates nothing; a malformed or unreadable hooks.json keeps its bytes, Orca's trust and the ownership ledger; a mixed hook group loses only hash-proven Orca trust; a user hook after Orca's keeps its approval. The pane CLI load-boundary test mocked a module this branch deleted, so it guarded nothing; it now forbids loading the hook service and the flag derivation. The shell carrier suite joins the shell contracts job, the only CI job with fish, and fails there without pwsh or fish.
…heck; comments name the flag The contract now calls the same check Orca runs before publishing a table entry, against the real binary: the complete flag reads as trusted, and a wrong hash does not. Passed on Codex 0.150.1 and 0.159.2. Comments that still described install(), the real-home grant lane, or the opt-out as the only ~/.codex writer now describe the managed-home refresh and app start's removal.
The changed-code quality gate rejects type assertions; five migrated suites cast JSON.parse results, and one imported a module twice.
macOS reports a write burst under the watched directory's own name, so filtering events by the .request suffix dropped most requests: a launch that missed waited for the next event or an Orca restart. The watcher test was red 2 runs in 3 on this laptop before this change, 5 in 5 green after.
… switch When a user switches Orca's hook off in Codex's /hooks screen, Codex writes enabled = false for the session-flag key into the home's config.toml and merges it per field with the flag's approval. The flag carried only trusted_hash, so the hook stayed off for good; a Stop switched off left the pane stuck on "working". Only Orca's own setting may turn Orca's hook off (#23289). Each event's state now carries enabled = true beside trusted_hash, in both spellings (the Windows one still holds no " or %). The pre-publish check also requires Codex to list every event as enabled, and an entry published before this shape is re-derived. A real-binary contract case writes enabled = false at every session-flag key and expects the flag to list each hook trusted and enabled; it passes on Codex 0.150.1 and 0.159.2 and fails on 0.159.2 when the field is dropped.
With hooks off, every typed codex still ran a --version probe and left a request for Orca to delete, because the table directory stayed in place and only its entries were removed. The directory is now the switch. The opt-out and disabling Codex remove it; app start with hooks on and the setting turning on create it, the latter even when codex is not installed yet (a new per-agent enabler runs before the presence-gated installers), so a later launch's miss still asks for its entry. Every carrier (bash/zsh, fish, PowerShell, the cmd gate, Orca-launched path-named codex) checks the directory first and runs plain codex, with no probe and no request, when it is missing. Publishing never creates the directory, and the generation guard still stops a derivation in flight at the opt-out. The request watch is re-armed whenever the directory is created again. Shell wrapper snapshots regenerated for the new check.
The codex hook service, which the CLI's managed-hook controls load, now imports codex-hook-flag-requests.ts; tc:cli rejects a file outside its explicit list (TS6307).
…lows the setting Round-2 review of the session-flag table found these problems: - A failed delete at app start (a request racing rm -rf, a Windows file held open, a request that is a directory) threw out of startup, so Orca would not start. The same throw skipped the rest of the opt-out. - A codex installed after start got an entry, but no hook script. - The resume wait had nothing to wait on until after the claude installers. - An ON right after an OFF joined a run the OFF had voided. - The table's presence followed whichever toggle ran last, not the setting. - A missed file-watch event waited for the next launch. - Entries for old versions and old definitions were never pruned. Now: - Every table and request delete is best-effort (retries, logged, never thrown); requests that are not files are skipped; a failed publish removes its temp file. - One reconcile makes the table exist exactly while Codex hooks are on. It reads the setting when it runs and is called from app start, the ON enabler and the opt-out (outside the trust lane). - A derivation writes the hook script and cmd gate before publishing. - App start schedules the default derivation right after shell PATH hydration, and the 3 s resume wait counts it. - Runs are deduped per (codex path, generation); a voided run is never a failed try. - Requests drain right after the watch opens, again a second later, on every native pane spawn and Orca-launched miss; a failed watch falls back to those drains. - Reconcile prunes entries with another definition and keeps the eight newest; status reports the entry for this process's codex version. Carriers: - The user hooks override is also caught as -c=hooks…, with whitespace before the key, and --config= hooks…. - npm's codex.ps1 maps to its sibling codex.cmd for requests and probes. - fish writes its request through sh, so a failed write is silent. - PowerShell and Orca-launched commands try every --version line, as the cmd gate does. - The cmd gate's findstr is case-insensitive. The flag lookup helpers move to codex-hook-session-flag-lookup.ts. Tests (watcher ones now use a fake watch and fake timers) cover each item.
…contracts for the codex function The vitest guard now unsets ORCA_CODEX_HOOK_FLAGS (and guards it as live state), ORCA_CODEX_HOOK_GATE and ORCA_CODEX_HOOK_ARG: a shell suite that spreads process.env inside an Orca pane wrote five requests into the live table, which the live app would have served by running the test's fake codex. The shell contracts job now runs when only src/shared/codex-shell-function.ts changes.
…lag table machinery The table lifecycle had grown a generation counter, generation-keyed in-flight runs, pending starts, per-request failure counters with backoff, an open/close/reconcile/nudge split, two settle drains, a process-wide default version, and main writing request files to itself. Each patched one race the others created. One function now does it all, and every call site calls it: - It reads the setting when it runs. Off: remove the table, forget what it knew, close the watch. On: create the table, write the hook script and cmd gate when they differ (nothing is derived if the script cannot be written), watch the table, then derive in a single-flight run with at most one rerun. - A run derives for Orca's own codex, for any binary an Orca-side launch names, and for each request's binary (codex.ps1 maps to its codex.cmd; cmd's path-less request means Orca's codex). - A binary is derived again only when its fingerprint (realpath, size, mtime, inode) changed or its entry is gone; a failure is cached per fingerprint until the binary changes or hooks are toggled. - A publish is checked against the setting and the table synchronously right before the write, which is what stops a run that an opt-out overtook. The run then prunes entries of another definition (cap 8). Call sites: - app start, once shell PATH hydration settles (running is set at once, so a cold-start resume's bounded wait sees it); - every setting change, on or off, even when the codex CLI is not found; - each native pane spawn, next tick; - Orca-side launch prep for the binary it runs; - a resume, which waits for the sync at most 3 s; - any event from the table watch, debounced 100 ms. The installer keeps only the ~/.codex, retired-form and managed-home cleanup plus its shared scripts. Status reports the entry for the version of the codex this process resolves; the CLI learns that version once, within the 5 s version timeout, before printing status. The CLI's process follows the saved setting for the table but derives nothing: the app does at its next start.
… idle, and never latches a timeout Round-3 review of syncCodexHookFlags found: - S1: a request's version was ignored. A version manager's shim keeps its bytes when the codex behind it updates, so the new version never got an entry. A requested version without an entry is now derived whatever the fingerprint says; a binary that answers another version is remembered for that request. - S2: on Windows profiles that need the 8.3 name, every sync spawned cmd.exe for the short path. The carriable hook command is now remembered per process for the script path; a failed lookup is retried after 60 s. A codex that is not installed is recorded without spawning it. - S3: a failed 8.3 lookup during the prune deleted every entry. Nothing is pruned while this build's definition is unknown. - S4: failures are now cached per fingerprint and per requested version. Timeouts (--version, app-server, 8.3 lookup) retry after 60 s; other failures stay cached until the binary changes or hooks are toggled. A derivation an opt-out overtook writes into the replaced map, so its failure never reaches the answers after the toggle. - S5: a call landing between a run's last check and its end was lost. The run now decides to rerun or finish and clears `running` in one step. Also: one pane spawn schedules one sync however many env builders ask; tests for the bounded wait's timeout, a codex request that is not a codex binary, and the 8.3 cases. The trust tests read the approval in either flag spelling (W2-1).
…filter On the Windows box every PowerShell lane was red: the machine's cmd AutoRun fails against the sandboxed USERPROFILE and its error names the sandbox, whose 'orca-codex-hook-flag-' prefix matched /codex|ORCA_|hooks/i. The sandbox is now 'shell-carrier-'.
…ing a rerun ends the run N3-1: every derivation throw counted as transient, so a codex without the app-server, or one whose app-server exits early, cost a --version and an app-server spawn every 60 s for the life of the process. Only app-server timeouts and failed spawns retry soon now; other failures stay cached per fingerprint until the binary changes or hooks are toggled. N3-2: reading the setting to decide a rerun sat outside the run's try, so a throw there left 'running' set to a rejected promise that every later sync returned. The decision now happens inside it; a throw ends the run cleanly.
…sts resolve on Windows RC-3: every native Windows pane defines the cmd codex macro, but the gate script was written only while Codex hooks were on. In a build that never ran with them on, every typed codex printed cmd's "not recognized". The gate is now written at app start whatever the setting (it is inert without the table), and the macro clears the flag variable and calls the gate only if the file exists, so a missing gate runs plain codex quietly and never reuses a flag an earlier launch left set. RC-4: a Git Bash pane writes its codex path as /c/Users/..., which Node cannot resolve, so the binary read as missing and its failure stayed cached. Requests' /<drive>/... paths are read as <drive>:\... on Windows. RC-5: the registry comment named the retired app-server trust grant.
…Codex is older Codex 0.131 and 0.132 list only 6 hook events in hooks/list (no SubagentStart or SubagentStop), so a derivation for them always failed with a detail that did not tell the user what to do. 0.133.0 and newer pass the full real-binary contract. MIN_CODEX_HOOK_FLAG_VERSION is 0.133.0. A `codex-cli X.Y.Z` below it is not asked anything beyond --version: no app-server spawn, and the failure is cached per fingerprint like any deterministic one. Status, in the app (Settings) and in `orca agent hooks status`, reads "Codex <v> is older than 0.133; update Codex for Orca status". A version Orca cannot parse (a dev build) is not treated as old and derives as before. The CI contract pins (0.150.1, 0.158.0) are above the minimum and need no change.
…elds CI's anti-slop lint rejects Reflect.get. readSessionFlagTrust now builds the trust record straight from the typed hooks/list listings (the untrusted-input parser it went through served the retired memo file), and a spawn error is recognised by a narrowed 'syscall' field.
…mock carries the status reader codex-cmd-hook-flag-gate.test.ts holds a runIf(win32) block that runs the gate in cmd.exe, so it self-skipped everywhere in CI. It joins both Windows registration lists the lane test requires (the package_windows argv and WINDOWS_PACKAGE_TESTS); the same cases passed 10/10 on the Windows box. The CLI deferral suite mocks the managed-hook controls. The CLI handler now also takes readManagedAgentHookStatuses from that module, and reading an export the mock did not define threw before `agent hooks off` applied the setting. The handler's call is unchanged (applyAgentStatusHooksEnabled(false, the saved settings)), so the mock gains the export and the expectation stays.
…oks-write-once Conflicts with #24332 (Codex's Interrupt hook): - codex-hook-local-install.ts, codex-real-home-hook-entry-plan.ts and codex-real-home-frozen-entry.test.ts stay deleted: this branch removed the managed-home and real-home installers they belong to. - hook-service-managed-install.test.ts and hook-service-trust-grant.test.ts keep this branch's side: main's side extends tests of those deleted installers. #24332's intent carried into the session flag: - The flag defines Interrupt too, and every event's timeout comes from buildCodexManagedHook, so Codex's per-event normalization (Interrupt capped at 3 s) is what the flag carries and codexHookSessionFlagDefines checks. - Interrupt is optional: derivation requires the original 8 events, adds Interrupt's approval when Codex lists it, and the pre-publish check requires it trusted and enabled only then. An older Codex drops the definition silently. Real-binary runs: 0.133.0 lists 8 and verifies, with Interrupt defined and no warning; 0.150.1 and 0.159.2 list and trust all 9. - The contract accepts either shape and checks Interrupt is trusted wherever Codex lists it, and that a real turn prints no hook warning.
…the retrying helper Now that the file runs in the Windows CI lane, its raw recursive rmSync calls trip the lane's tree-removal boundary: a cmd.exe child still holding the sandbox can fail a single-shot delete there. Both use removeTreeSync.
… widen its CI scope The contract now starts a real Codex TUI in a pty with Orca's reconciled entry (no review, the hook posts) and a mis-keyed control (review shown), checks a config.toml with inline hook approvals stays loadable, and matches only 'need(s) review' in exec output. The contract job also runs when any file that decides whether Codex accepts Orca's approval changes. Drops a deleted test from the shard timings.
On Windows Codex resolves its default home from the Profile folder, not USERPROFILE, so a check with CODEX_HOME removed could list, and start an app-server in, a different home than the one Orca wrote. Pass CODEX_HOME explicitly there; Orca already approves the resolved spelling Codex keys an explicit home by. POSIX keeps the default-home check.
…able config.toml The managed refresh's mirrored user-trust upsert, the user-trust moves, the rollback restore, the mirrored enabled states and the SSH writer now all go through the same check: a write that would turn a config.toml Codex can load into one it cannot (a user's inline or dotted hooks.state) is refused. A file that is already broken may still be repaired.
- An event that also holds an older build's entry keeps the approval of Orca's own frozen entry: deferred events are never swept as stale. - A refusal of Orca's approval survives the per-process re-probe, so a refused binary is not written, checked and withdrawn on every app start. - A timed-out answer keeps a managed home's approved entry, like a late one. - The routing gate re-reads ~/.codex/hooks.json when asked, and runs with a managed account selected also keep it current. - A write whose check waited for Codex's session index is checked once more on a later reconcile; any finished check drops that. - Removing approvals goes through the same must-still-load guard.
…e hashes Without hashes the managed home could not approve Orca's entry either, so moving panes there gains nothing; before any answer the lane stays open too.
… that times out A non-zero exit was never remembered, so every pane spawn and managed install spawned it again. It now waits out the same 60 s window as a timeout.
The mocked real-home ensure and trust wait were removed by this PR.
Status: v2 (durable, write-once status hook), ready for review, not mergedThe problem. Orca re-added its Codex status hook to What changes for users.
Review. Three full reviewers, three narrow re-checks and a readiness checklist (PASS, no P0/P1). Fixed along the way:
Deferred / Intended.
Verified.
Not verified.
CI. The one red check, Not merged. |
There was a problem hiding this comment.
ℹ️ No critical issues — one missed-cleanup edge and a comment nitpick.
Reviewed changes
This run re-reviewed the PR at its current head, where the mechanism differs from the earlier snapshot: Orca now writes Codex's own approval of its status hook into ~/.codex once and reconciles on change, instead of carrying the hook per launch as a -c hooks=… flag. Read the full 80-file diff.
- Write-once approval then entry —
reconcileRealHomeCodexHookEntriesplans the frozen entry per event and writes Codex-derived approvals before the hooks.json entry, with state-guarded rollback (codex-hook-approval-first-write.ts,codex-real-home-hook-install.ts). - Codex-derived hashes — a throwaway
CODEX_HOMEapp-serverhooks/listsupplies Codex's per-event hash; binary fingerprints and per-version hashes are memoized with a 60 s transient retry (codex-hook-trust-derivation.ts,codex-hook-trust-memo.ts,codex-hook-hash-lookup.ts). - Never break
config.toml— everyhooks.statewrite is refused if it would make a loadable file unloadable; reads now also surface dotted/inline approvals (config-toml-trust.ts,config-toml-hook-trust-read.ts). - Reconcile singleton + routing gate —
codex-hook-reconcile.tscoalesces app-start/setting/pane-spawn/launch triggers, gates launches to the managed home when~/.codexcan't take the entry, and post-checks a write with one read-onlyhooks/list. - Deletions and wiring — background-grant/withdrawal/entry-trust/per-launch-flag modules removed; the codex installer now calls
reconcileHooks; CLI status prints the home it read; CI adds the real-binary file-entry contract on both pins and@latest.
ℹ️ Nitpicks
codex-hook-reconcile.ts:107— the comment "it reads the files after this spawn anyway" is not strictly guaranteed: a run already past its file read won't re-read, so a freshness reconcile can be delayed to the next spawn or app start. The behavior is bounded, and setting changes use the never-droppedrerunpath — the comment just overstates the guarantee.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
| } | ||
| return (verdict = install.verdict) | ||
| try { | ||
| removeHookTrustEntries(tomlPath, stale) |
There was a problem hiding this comment.
The new readParsedHookTrust fallback surfaces dotted/inline hooks.state approvals to readHookTrustEntries, but removeHookTrustEntries only matches [hooks.state."…"] blocks, so an approval that findStaleOrcaApprovals selects from the fallback is silently left in place. Orca only ever writes block form, so this is an edge case with no user-visible impact, but the sweep's intent and its reach don't match.
Technical details
# Stale-approval sweep can't remove the dotted/inline approvals it now selects
## Affected sites
- `src/main/codex/codex-real-home-hook-install.ts:203` — `removeHookTrustEntries(tomlPath, stale)` is a silent no-op for a key that `findStaleOrcaApprovals` returned from the smol-toml fallback.
- `src/main/codex/config-toml-hook-trust-read.ts:31-40` — `readParsedHookTrust` now surfaces dotted/inline `hooks.state` approvals.
- `src/main/codex/config-toml-hook-trust-edit.ts:40-53` — `removeHookTrustContent` only matches `[hooks.state."…"]` table headers.
## Required outcome
- Either the stale set excludes keys the block remover cannot act on, or removal handles dotted/inline approvals, so the sweep's reach matches its intent (or the no-op is documented).
## Open questions for the human
- Is a dotted/inline Orca-hash approval reachable outside a hand-edited `config.toml`? If not, documenting the no-op may be enough.…oks-write-once # Conflicts: # config/tsconfig.cli.json
There was a problem hiding this comment.
ℹ️ No new issues in this delta — the one prior informational finding still stands, so this is a comment review rather than an approval.
Reviewed changes
This run re-reviewed the delta since the prior pullfrog review at f06ceb1 — a single merge of origin/main (dbc57ef), with no PR-authored behavior change.
- Merge-up of
origin/main. The merge folds in main'sprovider-processrename (codex-process-exit-deadline→provider-process/provider-process-exit-deadline,codex-app-server-record-reader→provider-process/provider-record-reader, plusprovider-process-launch). The PR's own staged-list hunks inconfig/scripts/pr-code-change-scope.mjsandconfig/tsconfig.cli.jsonwere updated to the new paths; the rest of the merge is main's unrelated work. - Merged state is coherent. No dangling references to the old
codex-process-exit-deadline/codex-app-server-record-readernames remain anywhere, and every path the merged scope/tsconfig lists reference exists on disk.
ℹ️ Prior stale-approval sweep finding still open
The earlier review's informational finding at src/main/codex/codex-real-home-hook-install.ts:203 is unchanged by this merge: removeHookTrustEntries still matches only [hooks.state."…"] blocks, so a dotted/inline approval that findStaleOrcaApprovals selects from the new smol-toml fallback is silently left in place. No user-visible impact (Orca only writes block form), so it is not a merge blocker; the thread is left open for the author to decide whether to reconcile the sweep's reach with its selection or document the no-op.
Technical details
# Stale-approval sweep can't remove the dotted/inline approvals it now selects
## Affected sites
- `src/main/codex/codex-real-home-hook-install.ts:203` — `removeHookTrustEntries(tomlPath, stale)` is a silent no-op for a key `findStaleOrcaApprovals` returned from the smol-toml fallback.
- `src/main/codex/config-toml-hook-trust-read.ts` — `readParsedHookTrust` now surfaces dotted/inline `hooks.state` approvals.
- `src/main/codex/config-toml-hook-trust-edit.ts` — `removeHookTrustContent` only matches `[hooks.state."…"]` table headers.
## Required outcome
- Either exclude keys the block remover cannot act on from the stale set, handle dotted/inline approvals in removal, or document the intentional no-op.deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
The hook-approval paths this PR adds pushed pr-code-change-scope.test.mjs past its 600-line limit once merged with main.

ELI5
Orca shows whether Codex is working, waiting or done by giving Codex a small "status hook". Until now, Orca re-added that hook to your Codex settings folder (
~/.codex) on every Codex launch, then asked Codex to approve it in the background. Until the approval landed, Codex could stop on its "Hooks need review" screen for Orca's hook, inside Orca or outside it.Now Orca writes its hook and Codex's own approval of it once: the approval first, then the hook. After that it touches
~/.codexonly when something actually changed. Status works however you start Codex in an Orca pane, and Codex never asks you to review Orca's hook.How it works (not a shim)
Orca doesn't wrap, replace or rename the
codexcommand, and it doesn't change how any terminal starts Codex. It writes one entry into Codex's own hooks file (~/.codex/hooks.json), the same file Codex reads every time it starts, however it was started. The entry only does anything when Codex runs inside an Orca terminal (it checks for environment variables only Orca sets), so Codex run anywhere else ignores it. Orca also writes Codex's own approval for that entry into~/.codex/config.toml, so Codex never asks you to review it. Orca rewrites these files only when something changes.Main's existing
codexshell function, which adds--no-daemon(from #23900, widened to more shells by #23933), is unchanged by this PR.What Changed
The problem. #23552 stopped terminal launches from stripping your hooks. It still wrote Orca's entry into
~/.codex/hooks.jsonon every Codex launch and resume, and approved it with a background Codex session that took up to 30 s. Its own description listed three races where the review screen could still appear:New panes also quietly switched to an Orca-managed Codex folder while the approval was pending, and resumes waited for it.
What changes for you:
~/.codexon every launch. It writes only when something changed: first enable, a Codex update that changes the approval, an edit of yours that moved Orca's entry, or turning status hooks on or off. Otherwise it writes nothing and starts no Codex process./hooksscreen, Orca turns it back on at its next check (the next terminal you open or Codex launch Orca starts). Orca's status-hooks setting is the one off switch.Which Codex launches get status
codextyped in an Orca terminal (bash, zsh, fish, PowerShell, cmd.exe, Git Bash)codexcodexby full path,command codex,npx @openai/codex, a company launcher that ends in Codexorca agent hooks statussays to update CodexMechanism:
codex app-serverandhooks/listin a throwaway Codex folder, and remembers the answer per Codex binary and version. Orca writes that hash, plusenabled = true, into~/.codex/config.tomlbefore it adds the hook to~/.codex/hooks.json. If the hook write fails, it takes back only its own approvals.reconcileCodexHooksruns at app start, when you turn status hooks on or off, when a terminal opens, and before Orca launches Codex. It never throws, and it reads your setting when it runs. When nothing changed, it reads two files and stops.hooks/listagainst~/.codexchecks that Codex trusts Orca's hook. It's skipped while Codex is rebuilding its session index.~/.codex, new terminals use Orca's managed Codex folder instead, as before, and status says why. That covers ahooks.jsonOrca can't read, approvals you wrote in a form Orca can't add to safely, or Codex refusing the approval. The folder is chosen afresh each time, from the current state.config.toml. Every approval write is refused if the file would no longer load.Why
Main's per-launch write and background approval are what left room for the review screen and the churn. A hook file written once and kept up to date covers every way Codex starts, which a per-launch command-line flag or a
codexwrapper can't.Alternatives considered:
-c hooks=…flag (this PR's first version). It only reaches launches that go through Orca's shell function, and Codex started by full path, from scripts, from tmux or from company launchers lost status. Dropped.codexwrapper on PATH. Orca's earlier PATH wrappers needed tombstones and PATH scrubbing across upgrades (rm git shim #14141, fix terminal attribution shim removal edge cases #14187, rm git shim: neutralize stale wrappers without a host gate #14255). On Windows, acodex.cmdwrapper pushes every prompt through cmd.exe, where&truncates arguments. Rejected.--dangerously-bypass-hook-trust. It skips review for every hook, including any repository's own.codexhooks in every folder Orca trusts. Rejected.Differences from the common pattern
The common pattern for a Codex terminal writes a durable status hook into the Codex folder, gated on the host's terminal environment so it does nothing elsewhere. It then either lets Codex show its review screen outside the host's own launcher, or passes Codex's hook-trust bypass flag. This PR follows the durable, environment-gated hook.
~/.codex/hooks.json(first in Orca-managed folders, which Orca rewrites on every launch). Intended. Codex keys approvals by position, so a hook you add later can't shift Orca's.config.toml(state = { … }) stop Orca adding its own. Those terminals get no Orca status, and status says why. Intended: Orca never makes yourconfig.tomlunloadable.Linked Issue
Follow-up to #23552.
Visual Proof
QA ran this branch's real dev app (2bc3ec5) on macOS and Windows 11. Each rig had an isolated home and Codex folder,
codexwent through a guard that refused the real~/.codex, and turns went to a local mock model, with no login. The machines' real~/.codex,~/.claudeand~/.orcafiles, plus the Windows box's WSL~/.codex, were hash-checked before the first launch, after it, after every scenario and after quitting. They never changed. Drivers: Grok on macOS; Codex, then opencode, on Windows.macOS
command codex, a scriptcodex resume --last,codex exec/hooks: the same terminal stays off, and the next new terminal turns it back onWindows 11
codex, a doskey macro,resume --lastTesting
Real Codex, opt-in contract (
src/main/codex/codex-hook-file-entry-binary-contract.test.ts). It passes on Codex 0.131.0, 0.133.0, 0.150.1 and 0.159.2, isolated; CI runs both pinned versions and the latest. It checks:/hooksswitch-off;config.tomlis left loadable;Unit tests cover:
~/.codex;Each guard was removed in turn, and its test went red.
Related suites: about 150 files pass; the node and CLI typechecks are clean.
QA in the real app: macOS and Windows, run against 2bc3ec5. Later commits only fix edge cases the review found, and their unit tests and the real-Codex contract pass.
command codex, scripts, cmd.exe (plain, doskey,cmd /c), PowerShell (pwsh -Command, scripts),resumeandexec.I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
Author: @BrennanKB5