From a5b7b499fa219a1a2899d0cd3258b93fffc6d10f Mon Sep 17 00:00:00 2001 From: Vitalii Kulish Date: Mon, 16 Nov 2026 20:02:40 +0200 Subject: [PATCH] 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 --- .../structured-agent-availability.test.ts | 29 +++++++++++++++++++ .../launch/structured-agent-availability.ts | 10 ++++++- 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 src/main/runtime/agent-session/launch/structured-agent-availability.test.ts diff --git a/src/main/runtime/agent-session/launch/structured-agent-availability.test.ts b/src/main/runtime/agent-session/launch/structured-agent-availability.test.ts new file mode 100644 index 00000000000..a1b9dfdb66d --- /dev/null +++ b/src/main/runtime/agent-session/launch/structured-agent-availability.test.ts @@ -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) + }) +}) diff --git a/src/main/runtime/agent-session/launch/structured-agent-availability.ts b/src/main/runtime/agent-session/launch/structured-agent-availability.ts index e4a56c9889b..e072129ff0e 100644 --- a/src/main/runtime/agent-session/launch/structured-agent-availability.ts +++ b/src/main/runtime/agent-session/launch/structured-agent-availability.ts @@ -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 {