fix: detect agents via install-dir resolver when which misses on GUI launch (#4880)

* fix: detect agents via install-dir resolver when which misses on GUI launch

The Agents settings pane reports every agent as "Not installed" on a cold
GUI launch even when the CLIs are installed and runnable from Terminal.

detectInstalledAgents resolves each agent with `which`, which only sees
process.env.PATH. GUI-launched Electron inherits a stripped PATH from launchd
that omits the user's shell-rc dirs (~/.local/bin, ~/Library/pnpm,
~/.asdf/shims, nvm/volta/fnm/mise shims, ...). The synchronous seed in
patchPackagedProcessPath plus the async shell-PATH hydration both race the
first detection, and the first result is cached for the session, so the pane
can latch onto an empty "nothing installed" snapshot until the user relaunches
from a terminal or clicks Refresh.

Fall back to resolveCliCommand (the same resolver the spawn path uses in
src/main/codex-cli/command.ts) when the PATH lookup misses. Detection now has
the same reach as launch: if Orca can run it, Orca detects it, independent of
PATH-hydration timing. No false positives — an uninstalled agent still resolves
to a bare command name rather than an absolute path.

Verified on macOS that resolveCliCommand resolves claude (~/.local/bin), codex
(~/.asdf/shims), and opencode (~/Library/pnpm) under a stripped PATH.

* fix: bulk resolve agent install-dir detection

Co-authored-by: Orca <help@stably.ai>

* fix: ignore node navigator for linux webgl policy

Co-authored-by: Orca <help@stably.ai>

---------

Co-authored-by: Jinwoo-H <jinwoo0825@gmail.com>
Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
Rai Butera
2026-06-08 19:23:32 -04:00
committed by GitHub
co-authored by Orca Jinwoo-H
parent 612823c9e0
commit 84411b943f
6 changed files with 234 additions and 30 deletions
+51 -1
View File
@@ -2,7 +2,12 @@ import { chmodSync, mkdtempSync, mkdirSync, writeFileSync } from 'node:fs'
import { tmpdir } from 'node:os'
import { delimiter, dirname, join } from 'node:path'
import { afterEach, describe, expect, it } from 'vitest'
import { getVersionManagerBinPaths, resolveClaudeCommand, resolveCodexCommand } from './command'
import {
getVersionManagerBinPaths,
resolveClaudeCommand,
resolveCliCommands,
resolveCodexCommand
} from './command'
function makeExecutable(path: string): void {
mkdirSync(dirname(path), { recursive: true })
@@ -224,6 +229,51 @@ describe('resolveClaudeCommand', () => {
})
})
describe('resolveCliCommands', () => {
afterEach(() => {
delete process.env.PATH
delete process.env.Path
})
it('resolves a batch from PATH and install directories', () => {
const root = mkdtempSync(join(tmpdir(), 'orca-cli-commands-'))
const pathDir = join(root, 'bin')
const pathClaude = join(pathDir, 'claude')
const nvmCodex = join(root, '.nvm', 'versions', 'node', 'v24.13.0', 'bin', 'codex')
const pnpmOpencode = join(root, 'Library', 'pnpm', 'opencode')
makeExecutable(pathClaude)
makeExecutable(nvmCodex)
makeExecutable(pnpmOpencode)
const resolved = resolveCliCommands(['claude', 'codex', 'opencode', 'missing'], {
platform: 'darwin',
pathEnv: pathDir,
homePath: root
})
expect(resolved.get('claude')).toBe(pathClaude)
expect(resolved.get('codex')).toBe(nvmCodex)
expect(resolved.get('opencode')).toBe(pnpmOpencode)
expect(resolved.get('missing')).toBe('missing')
})
it('deduplicates command names in the returned map', () => {
const root = mkdtempSync(join(tmpdir(), 'orca-cli-commands-'))
const pathDir = join(root, 'bin')
const pathClaude = join(pathDir, 'claude')
makeExecutable(pathClaude)
const resolved = resolveCliCommands(['claude', 'claude'], {
platform: 'linux',
pathEnv: pathDir,
homePath: root
})
expect([...resolved.keys()]).toEqual(['claude'])
expect(resolved.get('claude')).toBe(pathClaude)
})
})
describe('getVersionManagerBinPaths', () => {
it('includes volta, asdf, fnm, mise, pnpm, yarn, and bun directories', () => {
const root = mkdtempSync(join(tmpdir(), 'orca-vm-paths-'))