Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/main/process-manager/spawners/ChildProcessSpawner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ export class ChildProcessSpawner {

// Check if prompt will be sent via stdin instead of command line
// This is critical for SSH remote execution to avoid shell escaping issues
const promptViaStdin = sendPromptViaStdin || sendPromptViaStdinRaw;
// Also critical on Windows: when using stream-json output mode, the prompt is sent
// via stdin (see stream-json stdin write below). Adding it as a CLI arg too would
// exceed cmd.exe's ~8191 character command line limit, causing immediate exit code 1.
const argsHaveStreamJson = args.some((arg) => arg.includes('stream-json'));
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The detection logic using .includes('stream-json') could potentially match unintended patterns. For example, if a hypothetical flag like --no-stream-json or --stream-json-disabled were used, it would incorrectly trigger stdin mode. Consider using a more precise check that matches the specific expected patterns like arg === 'stream-json' after splitting on equals signs, or check for --output-format followed by stream-json, or --input-format followed by stream-json.

Suggested change
const argsHaveStreamJson = args.some((arg) => arg.includes('stream-json'));
const argsHaveStreamJson = args.some((arg, index) => {
// Match common patterns:
// - bare "stream-json"
// - "--input-format stream-json" / "--output-format stream-json"
// - "--input-format=stream-json" / "--output-format=stream-json"
if (arg === 'stream-json') {
return true;
}
if (arg === '--input-format' || arg === '--output-format') {
return args[index + 1] === 'stream-json';
}
if (arg.startsWith('--input-format=') || arg.startsWith('--output-format=')) {
const [, value] = arg.split('=', 2);
return value === 'stream-json';
}
return false;
});

Copilot uses AI. Check for mistakes.
const promptViaStdin = sendPromptViaStdin || sendPromptViaStdinRaw || argsHaveStreamJson;
Comment on lines +79 to +80
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no test coverage for the new behavior where promptViaStdin is set to true when args contain 'stream-json'. While there are tests that verify isStreamJsonMode detection (lines 132-243 in ChildProcessSpawner.test.ts), there should be a test that verifies the prompt is NOT added to the command line arguments when args contain 'stream-json'. This would ensure the Windows command line length fix is properly covered by tests.

Copilot uses AI. Check for mistakes.

// Build final args based on batch mode and images
let finalArgs: string[];
Expand Down