Repository navigation
Description
Details
Opening any local (non-WSL) terminal schedules a Codex hook reconcile. That happens whether or not the terminal runs Codex. The reconcile resolves the codex binary twice, and each resolution is a full synchronous statSync scan of PATH and the install dirs. On Windows with a long PATH, that blocks the Electron main process for ~50ms per terminal spawned. Restoring or opening N terminals costs N × 50ms.
It's worst for users who don't have Codex installed, because every scan misses and walks every directory. This is the same sync-scan pattern as #35562.
Evidence
I profiled the main process with V8 sampling during the ACK-backpressured scenarios in artificial-opencode-terminal-load.spec.ts. The build was an unminified e2e build on Windows, with 95 PATH dirs and Codex not installed.
- There were 18–19 blocking bursts per profile window, each about 45–65ms. That's one burst per spawned pane, roughly once a second while panes were opening.
- In total it was about 0.8s of main-thread time per window (about 3%).
Cause
- Every non-WSL PTY spawn schedules a reconcile:
orca/src/main/ipc/pty/host-env/assembly.ts
Lines 278 to 281 in 5748d11
if (!opts.isWsl) { // Native panes may run Codex later by typing it; recheck hooks against any updated Codex install. scheduleCodexHookReconcile() }
orca/src/main/codex/codex-hook-reconcile.ts
Lines 66 to 71 in 5748d11
export function scheduleCodexHookReconcile(): void { // One run already reads after the spawn; coalesce calls from its multiple env builders. if (config && !running) { void reconcileCodexHooks() } } - reconcileOnce resolves Codex twice: once through resolveCodexHookAnswer() and again through readKnownCodexHookAnswer():
orca/src/main/codex/codex-hook-reconcile.ts
Lines 123 to 135 in 5748d11
async function reconcileOnce(realHomeLaunch: boolean): Promise<void> { const current = config if (!current?.isEnabled() || !(realHomeLaunch || resolveHome(current).kind === 'real')) { return } const lookup = resolveCodexHookAnswer() const live = await withTimeout<CodexHookAnswer | null>(lookup, ANSWER_WAIT_MS, null) if (!live) { // Replace stopgap approvals once Codex's answer arrives. void lookup.then(() => reconcileCodexHooks({ realHomeLaunch })) } // Reuse Codex's saved answer so a slow startup probe does not disturb existing hooks. const answer = live && live.kind !== 'pending' ? live : readKnownCodexHookAnswer() - Each of those calls resolveCodexCommand() synchronously:
orca/src/main/codex/codex-hook-hash-lookup.ts
Lines 111 to 120 in 5748d11
export async function resolveCodexHookAnswer(): Promise<CodexHookAnswer> { // Resolve the same hydrated PATH that panes use. await appPathReady return lookupCodexHookAnswer(resolveCodexCommand(), getManagedCommand(getManagedScriptPath())) } /** Read status from memory or disk without spawning Codex. */ export function readKnownCodexHookAnswer(): CodexHookAnswer | null { const codexPath = resolveCodexCommand() const fingerprint = fingerprintCodex(codexPath)
orca/src/main/codex-cli/command.ts
Lines 21 to 34 in 5748d11
export function resolveGuestNativeAgentCommand( name: string, options: ResolveCommandOptions = {}, mounts?: readonly string[] ): string { return ( resolveGuestNativeProgram(name, options, resolveCliCommand, mounts) ?? `${WINDOWS_ONLY_AGENT_CLI_DIR}/${name}` ) } export function resolveCodexCommand(options: ResolveCommandOptions = {}): string { return resolveGuestNativeAgentCommand('codex', options) } - resolveCodexCommand() ends up in resolveCliCommand, which runs statSync over every PATH dir × 4 names and then every install dir:
orca/src/shared/node-cli-command-resolution.ts
Lines 236 to 254 in 5748d11
export function resolveCliCommand( commandName: string, options: ResolveCommandOptions = {} ): string { const platform = options.platform ?? process.platform const executableNames = getExecutableNames(platform, commandName) const pathEnv = options.pathEnv ?? process.env.PATH ?? process.env.Path ?? null const pathCandidate = findFirstExecutable(platform, splitPath(pathEnv), executableNames) if (pathCandidate) { return pathCandidate } const homePath = options.homePath ?? homedir() const installCandidate = findFirstExecutable( platform, getCliInstallDirectories(platform, homePath), executableNames ) return installCandidate ?? commandName
orca/src/shared/node-cli-command-resolution.ts
Lines 76 to 91 in 5748d11
function isRunnableCommand(platform: NodeJS.Platform, candidate: string): boolean { try { const stats = statSync(candidate) if (!stats.isFile()) { return false } if (platform === 'win32') { return true } // Skip nonexecutables/placeholders now so GUI probing reaches a runnable CLI instead of later EACCES/EISDIR. accessSync(candidate, constants.X_OK) return true } catch { return false } }
Activity
perf(codex): throttle spawn-time hook rechecks and resolve Codex once…
ctolkien commentedon Oct 29, 2026
My 2c, is that making a user restart Orca to pickup new agents is a better option that constantly checking every time we open a terminal. That is a product decision however.
fix(codex): rerun a trailing spawn recheck that lands on a busy recon…
perf(codex): resolve the Codex CLI once per spawn recheck, off the ma…