fix(wsl): translate Codex preflight through WSLENV

This commit is contained in:
Brennan Benson
2026-08-27 11:36:13 -07:00
parent 3d98d4742b
commit d591d2fa42
4 changed files with 20 additions and 24 deletions
@@ -343,26 +343,23 @@ describe('Codex shell launch preflight command', () => {
).toBe(launcherPath)
})
it.skipIf(process.platform !== 'win32')(
'carries the packaged Windows launcher as a guest-absolute WSL path',
() => {
const { userDataPath, resourcesPath } = makeCliRoot()
const launcherPath = join(resourcesPath, 'bin', 'orca.exe')
writeExecutable(launcherPath, '#!/bin/sh\nexit 0\n')
it('carries the packaged Windows launcher for WSLENV path translation', () => {
const { userDataPath, resourcesPath } = makeCliRoot()
const launcherPath = join(resourcesPath, 'bin', 'orca.exe')
writeExecutable(launcherPath, '#!/bin/sh\nexit 0\n')
expect(
resolveCodexShellLaunchPreflightCommand({
hooksEnabled: true,
isPackaged: true,
isWsl: true,
managedHomePath: '/home/jin/.local/share/orca/codex-runtime-home/home',
userDataPath,
resourcesPath,
platform: 'win32'
})
).toMatch(/^\/mnt\/[a-z]\//)
}
)
expect(
resolveCodexShellLaunchPreflightCommand({
hooksEnabled: true,
isPackaged: true,
isWsl: true,
managedHomePath: '/home/jin/.local/share/orca/codex-runtime-home/home',
userDataPath,
resourcesPath,
platform: 'win32'
})
).toBe(launcherPath)
})
it('never returns an unqualified command name that a profile-rewritten PATH could hijack', () => {
const { userDataPath, resourcesPath } = makeCliRoot()
+2 -3
View File
@@ -1,6 +1,5 @@
import { accessSync, constants, statSync } from 'node:fs'
import { join } from 'node:path'
import { toLinuxPath } from '../../shared/wsl-paths'
import { getBundledLauncherPath } from '../cli/bundled-cli-launcher-path'
const DEV_LAUNCHER_DIR = ['cli', 'bin']
@@ -49,8 +48,8 @@ export function resolveCodexShellLaunchPreflightCommand(
if (!options.isWsl) {
return candidate
}
// Why: WSL executes the verified Windows launcher through interop; its guest path crosses WSLENV untranslated.
return platform === 'win32' && options.isPackaged ? toLinuxPath(candidate) : null
// Why: WSLENV /p translates the verified Windows launcher with the distro's configured automount root.
return platform === 'win32' && options.isPackaged ? candidate : null
}
function isExecutableFileOnDisk(path: string, platform: NodeJS.Platform): boolean {
+1 -1
View File
@@ -84,7 +84,7 @@ describe('addOrcaWslInteropEnv', () => {
expect(env.WSLENV).toContain('ORCA_TERMINAL_HANDLE/u')
expect(env.WSLENV).toContain('ORCA_USER_DATA_PATH/p')
expect(env.WSLENV).toContain('ORCA_CLI_COMMAND/u')
expect(env.WSLENV).toContain('ORCA_CODEX_LAUNCH_PREFLIGHT/u')
expect(env.WSLENV).toContain('ORCA_CODEX_LAUNCH_PREFLIGHT/p')
expect(env.WSLENV).toContain('ORCA_OMP_STATUS_EXTENSION/p')
expect(env.WSLENV).not.toContain('ORCA_PRIME_AGENT_STATUS_EXTENSION')
expect(env.WSLENV).toContain('ORCA_PANE_KEY/u')
+1 -1
View File
@@ -77,7 +77,7 @@ export function addOrcaWslInteropEnv(env: Record<string, string>): void {
// and it cannot derive the hash segment from ORCA_USER_DATA_PATH alone.
'ORCA_SHELL_READY_ROOT/p',
'ORCA_CLI_COMMAND/u',
'ORCA_CODEX_LAUNCH_PREFLIGHT/u',
'ORCA_CODEX_LAUNCH_PREFLIGHT/p',
'ORCA_PANE_KEY/u',
'ORCA_TAB_ID/u',
'ORCA_WORKTREE_ID/u',