fix(windows): align escaped wrapper shell handling

Use ComSpec-aware shell selection for escaped wrapper launches.

Apply it to the remaining Windows Claude launch paths.

Rewrite the Codex exec regression test to use scoped spies so the full suite stays isolated.
This commit is contained in:
Tam Nhu Tran
2026-04-19 14:27:27 -04:00
parent a945b0b104
commit ccdd0b6e8e
6 changed files with 117 additions and 64 deletions
+10 -6
View File
@@ -4,7 +4,7 @@
* Cross-platform shell execution utilities for CCS.
*/
import { spawn, spawnSync, ChildProcess } from 'child_process';
import { spawn, spawnSync, ChildProcess, type SpawnOptions } from 'child_process';
import { ErrorManager } from './error-manager';
import { getWebSearchHookEnv } from './websearch-manager';
import { wireChildProcessSignals } from './signal-forwarder';
@@ -108,13 +108,17 @@ export function escapeShellArg(arg: string): string {
}
/**
* Return the Windows shell that matches escapeShellArg() quoting semantics.
* Return the shell that matches escapeShellArg() quoting semantics.
*
* `shell: true` is not strict enough for npm `.cmd` wrappers because Node may
* route through a different quoting path than the one escapeShellArg() expects.
* On Windows, prefer ComSpec over a bare `cmd.exe` so escaped wrapper launches
* keep the same shell contract without depending on PATH lookup.
*/
export function getWindowsEscapedCommandShell(): string {
return 'cmd.exe';
export function getWindowsEscapedCommandShell(): SpawnOptions['shell'] {
if (process.platform !== 'win32') {
return true;
}
return process.env.ComSpec || process.env.COMSPEC || 'cmd.exe';
}
/**