Repository navigation
Conversation
… per run Every native pane spawn scheduled a Codex hook reconcile, and each run resolved the codex binary twice with a synchronous PATH + install-dir scan (~25ms each on a 95-dir Windows PATH, worst when Codex is not installed). A session restore of 18 panes blocked main ~1.1s in 18 bursts. Spawn-triggered rechecks now run at most once per 10s with a trailing run, so a spawn inside the window is still rechecked. Explicit Codex launches and the startup run are unchanged. Each run resolves the path once and passes it to both lookups. Fixes stablyai#35565
[Medium impact] The PR appears safe to merge. SummaryThis PR limits spawn-triggered Codex hook checks and reuses the resolved Codex path within each run.
Reviews (2) · Last reviewed commit: "fix(codex): rerun a trailing spawn reche..." · Reviewed by Greptile |
Walkthrough
Priority: Severity of issue fixed: Medium Merge Risk:
|
There was a problem hiding this comment.
Actionable comments posted: 1

Review info
-
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
59b0bc1a-cbf5-4168-bb53-895cd0ac7f52
Files selected for processing: 3-
src/main/codex/codex-hook-hash-lookup.tssrc/main/codex/codex-hook-reconcile.test.tssrc/main/codex/codex-hook-reconcile.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
-
…cile A trailing spawn recheck that fired while another reconcile was running returned early, and that run may have resolved Codex before the throttled spawn. Request a rerun instead so the spawn is always rechecked. Refs stablyai#35565
There was a problem hiding this comment.
Actionable comments posted: 1

Review info
-
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
7a1e189d-1f69-49f7-b4ac-e905f5acb6c4
Files selected for processing: 2-
src/main/codex/codex-hook-reconcile.test.tssrc/main/codex/codex-hook-reconcile.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
-
|
Thanks @ctolkien — this landed in #35967 with you as co-author. We kept resolving the Codex path once per reconcile, made the spawn recheck async on Windows only (macOS/Linux keep the fast sync scan, now halved), dropped the 10s throttle so hook rechecks stay immediate, and queue one trailing recheck for spawns that arrive while the async answer is in flight. Fixes #35565. |
ELI5
Every time you opened a terminal, Orca briefly froze its main process (~50ms) while it searched your whole PATH for the Codex CLI, twice, even if you don't use Codex. Opening or restoring many terminals stacked those freezes. Now a burst of terminals triggers one check (plus a catch-up check 10s later), and each check searches once.
What Changed
scheduleCodexHookReconcile()(called on every native PTY spawn) now runs at most once per 10s. A trailing run covers spawns inside the window, so every spawn is still rechecked within 10s. Explicit Codex launches (reconcileCodexHooksForLaunch), the startup run andreconcileCodexHooks()are unthrottled.reconcileOnceresolves the Codex path once and passes it toresolveCodexHookAnswer(codexPath)andreadKnownCodexHookAnswer(codexPath). Both still default to resolving it themselves for their other callers.Why
Each resolution is a synchronous
statSyncscan of PATH plus install dirs. On Windows with a 95-dir PATH and no Codex installed, that's ~25ms per scan, ×2 per run, ×1 run per terminal. On default settings (agentStatusHooksEnabled: true, no agents disabled) every user pays it.Memoizing the resolution or reusing agent detection's batched lookup (#34636) was considered and left out of this PR: the resolved path feeds the hook-trust fingerprint, and detection's PATH and extension order differ from the path panes actually run. Making
resolveCodexCommandcheap for every caller is better done separately.Linked Issue
Fixes #35565
Visual Proof
N/A: no UI change. Before/after main-process CPU profiles instead:
Before:
f5c84eae583(main). After: this branch. Method: V8 sampling profiler (200µs) inside the main process during the threeACK-backpressuredscenarios oftests/e2e/artificial-opencode-terminal-load.spec.ts; unminified e2e build (ORCA_UNMINIFIED_MAIN=1),ORCA_BACKGROUND_LAUNCH=1, Windows 11, 95 PATH dirs, Codex not installed.Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Profiled locally on Windows (above).
Added a test: a burst of pane spawns rechecks once, then once more after the throttle window. Existing spawn-coalescing and ride-along tests pass.
pnpm check:changed --base=upstream/main: all checks pass except 14 unit tests in 3 runtime files that fail withEPERMonC:\WINDOWS\TEMPcleanup; they fail identically on unmodifiedmain(environment).codex-hook-reconcile.test.ts › keeps the approval main's grant recorded for Orca's entryalso fails identically on unmodifiedmainon this machine.Not tested on macOS/Linux; the change is platform-neutral, with a smaller gain there (shorter PATH, faster stat).
AI Disclosure
Investigation, profiling and implementation done with Claude (Opus 5.5) in Claude Code, reviewed by me.