diff --git a/src/main/ipc/pty-daemon-spawn-agent-home-env.test.ts b/src/main/ipc/pty-daemon-spawn-agent-home-env.test.ts index 8895666706e..273f08580f3 100644 --- a/src/main/ipc/pty-daemon-spawn-agent-home-env.test.ts +++ b/src/main/ipc/pty-daemon-spawn-agent-home-env.test.ts @@ -462,7 +462,8 @@ describe('registerPtyHandlers', () => { // Why: bare `orca` must resolve to the Orca CLI before /usr/bin/orca (the GNOME screen reader) in Orca terminals (#7904). expect(entries.indexOf(shimDir)).toBeGreaterThanOrEqual(0) expect(entries.indexOf(shimDir)).toBeLessThan(entries.indexOf('/usr/bin')) - expect(env.ORCA_CLI_COMMAND).toBeUndefined() + // The same absolute spelling a structured session gets, so a terminal view keeps it too. + expect(env.ORCA_CLI_COMMAND).toBe(join(shimDir, 'orca')) } finally { Object.defineProperty(process, 'platform', { configurable: true, @@ -479,6 +480,7 @@ describe('registerPtyHandlers', () => { try { const env = await daemonSpawnAndGetEnv({ PATH: '/usr/bin' }) expect(env.PATH.split(delimiter)[0]).toBe(join('/tmp/orca-resources', 'bin')) + expect(env.ORCA_CLI_COMMAND?.startsWith(join('/tmp/orca-resources', 'bin'))).toBe(true) } finally { if (resourcesPathDescriptor) { Object.defineProperty(process, 'resourcesPath', resourcesPathDescriptor) diff --git a/src/main/ipc/pty/host-env/assembly.ts b/src/main/ipc/pty/host-env/assembly.ts index dedd44e70e3..80826e3f29c 100644 --- a/src/main/ipc/pty/host-env/assembly.ts +++ b/src/main/ipc/pty/host-env/assembly.ts @@ -274,19 +274,24 @@ export function buildPtyHostEnv( // Why: WSL shells need the managed userData root for shell-ready wrappers; dev-mode terminals need the same export so `orca` targets the live dev instance. if (opts.isWsl) { baseEnv.ORCA_USER_DATA_PATH = opts.userDataPath - // Why: managed WSL registration uses `orca-ide`; exposing that literal scopes agent guidance to WSL without a bare-orca shim. - baseEnv.ORCA_CLI_COMMAND = opts.isPackaged ? 'orca-ide' : 'orca-dev' - } else { - if (!opts.isPackaged) { - baseEnv.ORCA_USER_DATA_PATH ??= opts.userDataPath - } - delete baseEnv.ORCA_CLI_COMMAND + } else if (!opts.isPackaged) { + baseEnv.ORCA_USER_DATA_PATH ??= opts.userDataPath } - prependOrcaCliDirToChildPath(baseEnv, { + const launcher = prependOrcaCliDirToChildPath(baseEnv, { isPackaged: opts.isPackaged, userDataPath: opts.userDataPath, resourcesPath: opts.resourcesPath }) + if (opts.isWsl) { + // Why: managed WSL registration uses `orca-ide`; a guest cannot run the host launcher's path. + baseEnv.ORCA_CLI_COMMAND = opts.isPackaged ? 'orca-ide' : 'orca-dev' + } else if (launcher) { + // Why the absolute launcher, the same spelling a structured session gets: a login shell can + // reorder PATH behind a global install, and a current CLI re-runs itself as this one. + baseEnv.ORCA_CLI_COMMAND = launcher + } else { + delete baseEnv.ORCA_CLI_COMMAND + } if ( opts.routeBrowserOpensToClient === true &&