mirror of
https://github.com/stablyai/orca.git
synced 2026-11-18 11:54:46 +00:00
fix(agent-availability): ignore unexpanded ~ PATH entries when checking chat programs (#43185)
Some installers write a literal `~/...` entry to PATH (e.g. the macOS .NET installer's /etc/paths.d/dotnet-cli-tools). observeChatProgram treated it as workspace-relative and reported every uninstalled chat program as `unknown`, so the new-tab menu showed "Couldn't check chat availability" instead of "Not installed" or the setup chat. execvp/libuv never expand `~`, so bare `~` and `~/`/`~\` entries no longer force workspace resolution; other relative entries still yield `unknown`. Fixes #43184 Co-authored-by: Neil <neil@stably.ai>
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import { delimiter } from 'node:path'
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import { getDefaultSettings } from '../../../../shared/orca-profiles/constants'
|
||||
import { structuredAgentChatProgramNeedsInstall } from './structured-agent-availability'
|
||||
|
||||
const pathEntries = vi.hoisted((): { current: string[] } => ({ current: [] }))
|
||||
|
||||
vi.mock('./structured-agent-launch-support', () => ({
|
||||
resolveHostStructuredAgentLaunchEnvironment: async () => ({})
|
||||
}))
|
||||
vi.mock('../installation/structured-agent-runtime-metadata', () => ({
|
||||
structuredAgentRuntimeMetadata: (agent: string) => ({
|
||||
definition: { agent },
|
||||
supportsLocation: () => true,
|
||||
chatProgram: {
|
||||
resolve: () => ({ command: agent, env: { PATH: pathEntries.current.join(delimiter) } }),
|
||||
installable: () => true
|
||||
}
|
||||
})
|
||||
}))
|
||||
|
||||
const runtime = { requireStore: () => ({ getSettings: () => getDefaultSettings('/home/test') }) }
|
||||
|
||||
describe('structuredAgentChatProgramNeedsInstall', () => {
|
||||
it('offers the install when PATH only adds an unexpanded home entry', async () => {
|
||||
pathEntries.current = ['/usr/bin', '~/.dotnet/tools']
|
||||
await expect(structuredAgentChatProgramNeedsInstall('codex', runtime)).resolves.toBe(true)
|
||||
})
|
||||
})
|
||||
@@ -99,7 +99,15 @@ async function observeChatProgram(
|
||||
return 'available'
|
||||
}
|
||||
const path = (env.PATH ?? env.Path ?? '').split(delimiter)
|
||||
if (/[\\/]/.test(command) || path.some((entry) => entry.trim() && !isAbsolute(entry.trim()))) {
|
||||
// A literal `~` entry (e.g. macOS /etc/paths.d/dotnet-cli-tools) practically never names a
|
||||
// workspace dir: execvp/libuv never expand it.
|
||||
if (
|
||||
/[\\/]/.test(command) ||
|
||||
path.some((rawEntry) => {
|
||||
const entry = rawEntry.trim()
|
||||
return entry && !isAbsolute(entry) && !/^~(?:[\\/]|$)/.test(entry)
|
||||
})
|
||||
) {
|
||||
return 'unknown'
|
||||
}
|
||||
} catch {
|
||||
|
||||
Reference in New Issue
Block a user