fix: pass env to SDK subprocess and hide server Dock icon
1. Explicitly pass process.env to the Claude Agent SDK's env option, ensuring user shell env vars (ANTHROPIC_AUTH_TOKEN, ANTHROPIC_BASE_URL, etc.) reach the claude subprocess in packaged builds. 2. Spawn the standalone server via /bin/sh with exec to prevent the Electron binary from appearing as a separate Dock icon on macOS. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
185e138833
commit
e4ae2154af
2 files changed
+8
-1
No files matched your search
+4
-1
@@ -122,7 +122,10 @@ function startServer(port: number): ChildProcess {
|
||||
PATH: `${basePath}:${home}/.npm-global/bin:${home}/.local/bin:${home}/.claude/bin:${shellPath}`,
|
||||
};
|
||||
|
||||
const child = spawn(nodePath, [serverPath], {
|
||||
// Spawn via /bin/sh to prevent the Electron binary from appearing
|
||||
// as a separate Dock icon on macOS (even with ELECTRON_RUN_AS_NODE=1,
|
||||
// macOS may show a Dock entry for the Electron Framework binary).
|
||||
const child = spawn('/bin/sh', ['-c', `exec "${nodePath}" "${serverPath}"`], {
|
||||
env,
|
||||
stdio: 'pipe',
|
||||
cwd: standaloneDir,
|
||||
|
||||
@@ -137,6 +137,10 @@ export function streamClaude(options: ClaudeStreamOptions): ReadableStream<strin
|
||||
abortController,
|
||||
includePartialMessages: true,
|
||||
permissionMode: (permissionMode as Options['permissionMode']) || 'acceptEdits',
|
||||
// Explicitly pass the full process.env to the Claude Code subprocess.
|
||||
// In packaged Electron, this includes user shell env vars (API keys, etc.)
|
||||
// loaded by the main process via loadUserShellEnv().
|
||||
env: process.env as Record<string, string>,
|
||||
};
|
||||
|
||||
// Find claude binary for packaged app where PATH is limited
|
||||
|
||||
Reference in new issue
Block a user