From d079ea042ea6569c4d6593f192bc6ef4d4e9a206 Mon Sep 17 00:00:00 2001 From: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> Date: Sun, 8 Nov 2026 17:38:41 -0800 Subject: [PATCH] fix(claude): keep a differently cased Windows entrypoint override Windows env names are case-insensitive, so a launch value spelled claude_code_entrypoint lost to the uppercase Orca default when Node deduplicated the keys. --- .../claude-structured-child-env.test.ts | 17 +++++++++- .../launch/claude-structured-child-env.ts | 33 +++++++++++++++---- 2 files changed, 43 insertions(+), 7 deletions(-) diff --git a/src/main/claude/structured/launch/claude-structured-child-env.test.ts b/src/main/claude/structured/launch/claude-structured-child-env.test.ts index 6c8b1e729c6..514e56cf1b0 100644 --- a/src/main/claude/structured/launch/claude-structured-child-env.test.ts +++ b/src/main/claude/structured/launch/claude-structured-child-env.test.ts @@ -2,7 +2,11 @@ import { chmodSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs' import { tmpdir } from 'node:os' import { join } from 'node:path' import { afterEach, expect, it, vi } from 'vitest' -import { claudeChildEnv, resolveClaudeChildEnvSources } from './claude-structured-child-env' +import { + claudeChildEnv, + resolveClaudeChildEnvSources, + withOrcaClaudeEntrypoint +} from './claude-structured-child-env' import { resolveStructuredAgentCommand } from '../../../native-chat/structured-agent-command-resolution' afterEach(() => vi.unstubAllEnvs()) @@ -42,3 +46,14 @@ it('names Orca as the Claude client unless the launch environment sets one', () 'custom' ) }) + +it('keeps a differently cased Windows launch value over the Orca default', () => { + const inherited = { Claude_Code_Entrypoint: 'cli', PATH: 'C:\\bin' } + expect( + withOrcaClaudeEntrypoint(inherited, { claude_code_entrypoint: 'company-client' }, 'win32') + ).toEqual({ PATH: 'C:\\bin', claude_code_entrypoint: 'company-client' }) + expect(withOrcaClaudeEntrypoint(inherited, undefined, 'win32')).toEqual({ + PATH: 'C:\\bin', + CLAUDE_CODE_ENTRYPOINT: 'orca' + }) +}) diff --git a/src/main/claude/structured/launch/claude-structured-child-env.ts b/src/main/claude/structured/launch/claude-structured-child-env.ts index c73b39d3b1e..5903242f31c 100644 --- a/src/main/claude/structured/launch/claude-structured-child-env.ts +++ b/src/main/claude/structured/launch/claude-structured-child-env.ts @@ -82,6 +82,26 @@ async function readClaudeChildEnvSources(deps: ClaudeEnvDeps): Promise, + overlay: Record | undefined, + platform: NodeJS.Platform +): Record { + // Windows env names are case-insensitive, so a differently cased twin is the same variable. + const isEntrypointKey = (key: string): boolean => + (platform === 'win32' ? key.toUpperCase() : key) === CLAUDE_ENTRYPOINT_ENV + const env = Object.fromEntries( + Object.entries(inheritedEnv).filter(([key]) => !isEntrypointKey(key)) + ) + if (!Object.keys(overlay ?? {}).some(isEntrypointKey)) { + env[CLAUDE_ENTRYPOINT_ENV] = 'orca' + } + return { ...env, ...overlay } +} + // Merge onto the shell environment to retain PATH and ambient Anthropic auth. export function claudeChildEnv( sources: ClaudeChildEnvSources, @@ -89,12 +109,13 @@ export function claudeChildEnv( /** False when the session's seal pairs the CLI runtime itself, behind this app's CLI. */ { runtimeOnPath = true }: { runtimeOnPath?: boolean } = {} ): Record { - const env = decorateEnv({ - ...withoutInheritedClaudeConfigDir(sources.inheritedEnv, process.platform), - // Name Orca as the client instead of the SDK's sdk-ts default or a launching Claude's value. - CLAUDE_CODE_ENTRYPOINT: 'orca', - ...sources.overlay - }) + const env = decorateEnv( + withOrcaClaudeEntrypoint( + withoutInheritedClaudeConfigDir(sources.inheritedEnv, process.platform), + sources.overlay, + process.platform + ) + ) return runtimeOnPath ? withCliRuntimeOnPath(sources.command, env, { platform: process.platform }) : env