fix(codex): pair structured launches with the CLI runtime (#32061)

* fix(codex): pair structured launches with the CLI runtime

* test(codex): align launch snapshots with runtime pairing

* fix(agent-session): keep this app's CLI ahead of the paired runtime dir

Pairing ran after the Orca CLI prepend, so a runtime dir that also holds an
`orca` (e.g. /usr/local/bin with node+codex+orca) shadowed this app's
launcher for the child. Pair first; the CLI dir stays first on PATH.
Drops a PATH-shape test the parity snapshots already cover.

Co-Authored-By: Claude <noreply@anthropic.com>

* fix(cli-runtime): skip compiled CLIs and keep inherited PATH when pairing a sibling node

A native codex/claude beside a node (Homebrew, /usr/bin) never runs on it, so
pairing only reordered PATH. An env naming no PATH now pairs over the PATH the
child inherits instead of replacing it with the CLI dir alone.

Co-Authored-By: Claude <noreply@anthropic.com>

* test(cli-runtime): type the PATH-less env fixture

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Neil
2026-10-22 21:23:04 -07:00
committed by GitHub
co-authored by Claude
parent f4a1b0586a
commit 26f677ee94
9 changed files with 141 additions and 35 deletions
+27
View File
@@ -349,6 +349,33 @@ describe('withCliRuntimeOnPath', () => {
expect(withCliRuntimeOnPath(join(brew, 'codex'), env, { platform: 'darwin' })).toBe(env)
})
it('leaves PATH untouched for a compiled CLI beside a node (Homebrew, /usr/bin)', () => {
const root = makeCommandFixture('orca-pair-')
const brew = join(root, 'opt', 'homebrew', 'bin')
makeExecutable(join(brew, 'node'))
makeExecutable(join(brew, 'codex'))
writeFileSync(join(brew, 'codex'), Buffer.from([0xcf, 0xfa, 0xed, 0xfe, 0x07]))
const env = { PATH: '/usr/bin' }
expect(withCliRuntimeOnPath(join(brew, 'codex'), env, { platform: 'darwin' })).toBe(env)
})
it('pairs over the inherited PATH when the env names none, instead of replacing it', () => {
const root = makeCommandFixture('orca-pair-')
const v20 = join(root, '.nvm', 'versions', 'node', 'v20.11.0', 'bin')
makeExecutable(join(v20, 'node'))
makeExecutable(join(v20, 'codex'))
const inherited = process.env.PATH
onTestFinished(() => {
process.env.PATH = inherited
})
process.env.PATH = ['/opt/inherited/bin', '/usr/bin'].join(delimiter)
const noPath: NodeJS.ProcessEnv = {}
const paired = withCliRuntimeOnPath(join(v20, 'codex'), noPath, { platform: 'darwin' })
expect(paired.PATH).toBe([v20, '/opt/inherited/bin', '/usr/bin'].join(delimiter))
})
it('leaves PATH untouched for a bare command name', () => {
const env = { PATH: '/usr/bin' }
expect(withCliRuntimeOnPath('codex', env, { platform: 'darwin' })).toBe(env)