From 71ea6f52ba089ecbaab46527fc672343d983d146 Mon Sep 17 00:00:00 2001 From: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> Date: Mon, 20 Jul 2026 12:07:43 -0700 Subject: [PATCH] fix(codex): address CodeRabbit review on the landing PR - carry envToDelete through the mobile agent-resume startup plan so a real-home Codex resume cannot inherit an ambient CODEX_HOME - strip Orca-owned Codex overrides in the commit-message WSL fallback, matching the host fallback - strip ELECTRON_RUN_AS_NODE in the computer-e2e driver like every other home-isolation caller - drop the unused hooksEnabled parameter from isRealHomeCodexHookLaneUsable --- src/main/codex/codex-real-home-hook-install.ts | 2 +- src/main/index.ts | 4 +--- src/main/runtime/orca-runtime.ts | 3 +++ .../text-generation/commit-message-agent-environment.ts | 6 ++++-- tests/e2e/helpers/computer-cli-driver.ts | 6 +++++- 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/main/codex/codex-real-home-hook-install.ts b/src/main/codex/codex-real-home-hook-install.ts index 24e295560d2..02e52f74a10 100644 --- a/src/main/codex/codex-real-home-hook-install.ts +++ b/src/main/codex/codex-real-home-hook-install.ts @@ -52,7 +52,7 @@ export function getRealHomeCodexHookLane(): RealHomeCodexHookLane { * a failed opt-out cleanup use the managed lane so no half-mutated hook state * can diverge from PTY, rate-limit, or commit-message routing. */ -export function isRealHomeCodexHookLaneUsable(_hooksEnabled: boolean): boolean { +export function isRealHomeCodexHookLaneUsable(): boolean { return currentLane !== 'unavailable' } diff --git a/src/main/index.ts b/src/main/index.ts index 3cbbdc8b6e2..b991afe1690 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -1764,9 +1764,7 @@ app.whenReady().then(async () => { codexRuntimeHome = new CodexRuntimeHomeService(store) // Why: an incapable trust-grant host must fall back to the managed home for // every consumer (PTY env, rate limits, commit messages) in one place. - codexRuntimeHome.setRealHomeLaneGate(() => - isRealHomeCodexHookLaneUsable(isAgentStatusHooksEnabled(store?.getSettings())) - ) + codexRuntimeHome.setRealHomeLaneGate(() => isRealHomeCodexHookLaneUsable()) // Why: while the real-home lane owns ~/.codex/hooks.json, the legacy // system-home sweep inside managed installs would delete the entry the // real-home installer just appended. Flag OFF, hooks off, or an incapable diff --git a/src/main/runtime/orca-runtime.ts b/src/main/runtime/orca-runtime.ts index 4ddc83cfa08..cd291d7bd33 100644 --- a/src/main/runtime/orca-runtime.ts +++ b/src/main/runtime/orca-runtime.ts @@ -19609,6 +19609,9 @@ export class OrcaRuntimeService { return { command: startupPlan.launchCommand, env: startupPlan.env, + // Why: a real-home Codex resume strips inherited CODEX_HOME via + // envToDelete; dropping it here would resume against the wrong home. + envToDelete: opts.envToDelete, launchConfig: startupPlan.launchConfig, launchAgent: opts.agent, startupCommandDelivery: startupPlan.startupCommandDelivery diff --git a/src/main/text-generation/commit-message-agent-environment.ts b/src/main/text-generation/commit-message-agent-environment.ts index 587007c9aed..4f5e1eed010 100644 --- a/src/main/text-generation/commit-message-agent-environment.ts +++ b/src/main/text-generation/commit-message-agent-environment.ts @@ -100,11 +100,13 @@ export async function prepareLocalCommitMessageAgentEnv( const wslCodexHome = codexHomePath ? parseWslUncPath(codexHomePath) : null if (target?.runtime === 'wsl') { const codexHomeForTarget = wslCodexHome?.linuxPath ?? null + // Why: the fallback must still strip Orca-owned overrides, or a + // system-default WSL run inherits the managed CODEX_HOME. return { ok: true, env: codexHomeForTarget - ? { ...cloneProcessEnv(), CODEX_HOME: codexHomeForTarget } - : undefined + ? { ...cloneProcessEnvWithoutOrcaCodexHomeOverride(), CODEX_HOME: codexHomeForTarget } + : cloneProcessEnvWithoutOrcaCodexHomeOverride() } } if (codexHomePath && wslCodexHome) { diff --git a/tests/e2e/helpers/computer-cli-driver.ts b/tests/e2e/helpers/computer-cli-driver.ts index 61ffe5efb36..7e9d8b1a6ec 100644 --- a/tests/e2e/helpers/computer-cli-driver.ts +++ b/tests/e2e/helpers/computer-cli-driver.ts @@ -166,8 +166,12 @@ async function ensureOrcaRuntimeServed(): Promise { async function createComputerE2ERuntimeEnv(): Promise { const userDataDir = process.env.ORCA_DEV_USER_DATA_PATH ?? (await getComputerE2eOrcaDevUserDataPath()) + // Why: agent runtimes export ELECTRON_RUN_AS_NODE, which would make the + // spawned Electron behave as plain Node; strip it like every other caller. + const { ELECTRON_RUN_AS_NODE: _electronRunAsNode, ...inheritedEnv } = process.env + void _electronRunAsNode const isolation = createElectronHomeIsolation({ - inheritedEnv: process.env, + inheritedEnv, launchEnv: {}, extraEnv: {}, userDataDir,