Skip to content

Commit 4783158

Browse files
committed
fix: add windowsHide to all spawn calls to prevent visible console windows on Windows
Fixes #96835 Multiple spawn() calls across the codebase were missing the windowsHide: true option, causing visible cmd/PowerShell console windows to flash on every command execution on Windows. This was a regression from previous behavior. Files fixed: - src/agents/sessions/exec.ts - src/agents/sessions/tools/find.ts - src/agents/sessions/tools/grep.ts - src/agents/tool-search.ts - src/agents/provider-local-service.ts - src/agents/sandbox/ssh.ts (3 spawn calls) - src/auto-reply/reply/stage-sandbox-media.ts - src/daemon/launchd-restart-handoff.ts - src/process/respawn-child-runner.ts
1 parent 7fefc5f commit 4783158

9 files changed

Lines changed: 11 additions & 3 deletions

File tree

src/agents/provider-local-service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ async function startAndWaitForLocalService(params: {
266266
env: service.env ? { ...process.env, ...service.env } : process.env,
267267
stdio: "ignore",
268268
detached: shouldDetachChildForProcessTree(),
269+
windowsHide: true,
269270
});
270271
const child = managed.process;
271272
managed.lastExit = undefined;

src/agents/sandbox/ssh.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,7 @@ export async function runSshSandboxCommand(
624624
stdio: ["pipe", "pipe", "pipe"],
625625
env: sshEnv,
626626
signal: params.signal,
627+
windowsHide: true,
627628
});
628629
const stdoutChunks: Buffer[] = [];
629630
const stderrChunks: Buffer[] = [];
@@ -723,11 +724,13 @@ export async function uploadDirectoryToSshTarget(params: {
723724
const tar = spawn("tar", ["-C", params.localDir, "-cf", "-", "."], {
724725
stdio: ["ignore", "pipe", "pipe"],
725726
signal: params.signal,
727+
windowsHide: true,
726728
});
727729
const ssh = spawn(sshArgv[0], sshArgv.slice(1), {
728730
stdio: ["pipe", "pipe", "pipe"],
729731
env: sshEnv,
730732
signal: params.signal,
733+
windowsHide: true,
731734
});
732735
const tarStderr: Buffer[] = [];
733736
const sshStdout: Buffer[] = [];

src/agents/sessions/exec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ export async function execCommand(
8383
cwd,
8484
shell: false,
8585
stdio: ["ignore", "pipe", "pipe"],
86+
windowsHide: true,
8687
});
8788

8889
let stdout: OutputCapture = { text: "", truncatedChars: 0 };

src/agents/sessions/tools/find.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ export function createFindToolDefinition(
271271
}
272272
args.push("--", effectivePattern, searchPath);
273273

274-
const child = spawn(fdPath, args, { stdio: ["ignore", "pipe", "pipe"] });
274+
const child = spawn(fdPath, args, { stdio: ["ignore", "pipe", "pipe"], windowsHide: true });
275275
const rl = createInterface({ input: child.stdout });
276276
let stderr = "";
277277
const lines: string[] = [];

src/agents/sessions/tools/grep.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ export function createGrepToolDefinition(
235235
}
236236
args.push("--", pattern, searchPath);
237237

238-
const child = spawn(rgPath, args, { stdio: ["ignore", "pipe", "pipe"] });
238+
const child = spawn(rgPath, args, { stdio: ["ignore", "pipe", "pipe"], windowsHide: true });
239239
const rl = createInterface({ input: child.stdout });
240240
let stderr = "";
241241
let matchCount = 0;

src/agents/tool-search.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2107,6 +2107,7 @@ function runCodeModeChild(params: {
21072107
cwd: os.tmpdir(),
21082108
env: {},
21092109
stdio: ["ignore", "pipe", "pipe", "ipc"],
2110+
windowsHide: true,
21102111
});
21112112
const stderr: string[] = [];
21122113
let settled = false;

src/auto-reply/reply/stage-sandbox-media.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ async function scpFile(remoteHost: string, remotePath: string, localPath: string
331331
`${safeRemoteHost}:${safeRemotePath}`,
332332
localPath,
333333
],
334-
{ stdio: ["ignore", "ignore", "pipe"] },
334+
{ stdio: ["ignore", "ignore", "pipe"], windowsHide: true },
335335
);
336336

337337
let stderr = "";

src/daemon/launchd-restart-handoff.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ export function scheduleDetachedLaunchdRestartHandoff(params: {
246246
detached: true,
247247
stdio: "ignore",
248248
env: restartEnv,
249+
windowsHide: true,
249250
},
250251
);
251252
child.unref();

src/process/respawn-child-runner.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export function runRespawnChildWithSignalBridge(params: {
3030
stdio: "inherit",
3131
env,
3232
detached: detachForProcessTree,
33+
windowsHide: true,
3334
});
3435

3536
// Let the child honor forwarded signals first; then terminate it so the

0 commit comments

Comments
 (0)