Repository navigation
Description
Summary
On Windows, a console window (a Windows Terminal window on Win11) pops up every time the browse server starts. Several console-subprocess spawns are missing windowsHide: true.
Environment
- Windows 11 (10.0.26200), gstack v1.58.5.0
- bun 1.3.14, node v22.23.1
Root cause
On Windows, spawning a console subprocess without windowsHide: true allocates a console window (windowsHide maps to the CREATE_NO_WINDOW creation flag; Node's default is false). Enumerating top-level windows (EnumWindows) during server start showed the popup owned by WindowsTerminal, running:
icacls.exe— ACL lockdown of state/log files at startup (file-permissions.ts,execFileSync)tasklist.exe— PID liveness probe (error-handling.ts, via theBun.spawnSyncpolyfill)
The Bun polyfill wrapper (bun-polyfill.cjs) also drops any windowsHide the caller passes, so per-call fixes wouldn't stick — best fixed centrally there. Also patched the detached server launcher (cli.ts) and the detached telemetry spawn (security.ts) defensively.
Fix
diff --git a/browse/src/bun-polyfill.cjs b/browse/src/bun-polyfill.cjs
index e0ada11..4307659 100644
--- a/browse/src/bun-polyfill.cjs
+++ b/browse/src/bun-polyfill.cjs
@@ -75,6 +75,7 @@ globalThis.Bun = {
timeout: options.timeout,
env: options.env,
cwd: options.cwd,
+ windowsHide: true, // don't pop a console window for CLI tools (icacls, tasklist, …) on Windows
});
return {
@@ -91,6 +92,7 @@ globalThis.Bun = {
stdio,
env: options.env,
cwd: options.cwd,
+ windowsHide: true, // don't pop a console window for CLI tools on Windows
});
return {
diff --git a/browse/src/cli.ts b/browse/src/cli.ts
index 59327b7..e4a9f91 100644
--- a/browse/src/cli.ts
+++ b/browse/src/cli.ts
@@ -323,7 +323,9 @@ async function startServer(extraEnv?: Record<string, string>): Promise<ServerSta
const launcherCode =
`const{spawn}=require('child_process');` +
`spawn(process.execPath,[${JSON.stringify(NODE_SERVER_SCRIPT)}],` +
- `{detached:true,stdio:['ignore','ignore','ignore'],env:Object.assign({},process.env,` +
+ // windowsHide: a detached child otherwise gets its own console window on
+ // Windows (Node default windowsHide:false) — suppress that popup.
+ `{detached:true,windowsHide:true,stdio:['ignore','ignore','ignore'],env:Object.assign({},process.env,` +
`${extraEnvStr})}).unref()`;
Bun.spawnSync(['node', '-e', launcherCode], { stdio: ['ignore', 'ignore', 'ignore'] });
} else {
diff --git a/browse/src/file-permissions.ts b/browse/src/file-permissions.ts
index d3d404a..df204c7 100644
--- a/browse/src/file-permissions.ts
+++ b/browse/src/file-permissions.ts
@@ -71,7 +71,7 @@ export function restrictFilePermissions(filePath: string): void {
execFileSync(
'icacls',
[filePath, '/inheritance:r', '/grant:r', `${user}:(F)`],
- { stdio: 'ignore' },
+ { stdio: 'ignore', windowsHide: true },
);
} catch (err) {
warnIcaclsFailure(filePath, err);
@@ -101,7 +101,7 @@ export function restrictDirectoryPermissions(dirPath: string): void {
execFileSync(
'icacls',
[dirPath, '/inheritance:r', '/grant:r', `${user}:(OI)(CI)(F)`],
- { stdio: 'ignore' },
+ { stdio: 'ignore', windowsHide: true },
);
} catch (err) {
warnIcaclsFailure(dirPath, err);
diff --git a/browse/src/security.ts b/browse/src/security.ts
index d0e4039..fec8762 100644
--- a/browse/src/security.ts
+++ b/browse/src/security.ts
@@ -494,6 +494,7 @@ function reportAttemptTelemetry(record: AttemptRecord): void {
const child = spawn(result.cmd, result.cmdArgs, {
stdio: 'ignore',
detached: true,
+ windowsHide: true, // detached child would otherwise pop a console window on Windows
});
// unref so this subprocess doesn't hold the event loop open
child.unref();Verification
Re-ran the EnumWindows diff around server start before/after — the icacls/tasklist Windows Terminal popups are gone. Windows-only; windowsHide is ignored on other platforms, so no behavior change elsewhere.
Note (separate, upstream)
There's a second popup source: Playwright's own browser spawn (chrome-headless-shell.exe) also lacks windowsHide in playwright-core's processLauncher.js. Filed separately upstream — not part of this change.
Activity
tomfluff commentedon Jul 12, 2026
Still reproduces on v1.60.1.0. Re-verified the diff above and found a third popup source that the same central fix already covers, plus a detection gotcha that made me (briefly) conclude the fix didn't work.
Third source:
bun run terminal-agent.tsBeyond
icaclsandtasklist, a popup appears whose window title is the bun binary path:It comes from the terminal-agent:
spawnTerminalAgent()(browse/src/terminal-agent-control.ts) launches it viaBun.spawn(['bun', 'run', script], …). On Windows the browse server runs under node (server-node.mjs), so thatBun.spawnresolves to thebun-polyfill.cjsshim — i.e. it is already covered by the centralwindowsHidefix in the diff above. No extra change needed.Why it pops: the server is spawned detached and has no console of its own, so any console-subsystem child it spawns (here
bun.exe) causes Windows to allocate a new console — with a window. Also note the server's watchdog respawns the terminal-agent when it dies, which is why the popup keeps recurring rather than appearing once.Detection gotcha (worth knowing before verifying)
windowsHide→CREATE_NO_WINDOWdoes not stop the console from being created — it stops the console's window. A headlessconhost.exeis still spawned as a child of the console app in both cases.So these two checks show no difference and will make you think the fix is a no-op:
conhost.exeprocessesProcess.MainWindowHandleonbun.exe(it's always 0 — on Win11 the window belongs to the console host, not the app)The signal is the Windows Terminal window (
EnumWindows, as in the original report). A/B on the exact code path (console-less detached node parent → polyfillBun.spawn→bun.exe), run twice:C:\Users\<user>\.bun\bin\bun.exeOne more verification trap
A browse server started before the rebuild keeps running the old polyfill and keeps respawning agents, so the popups continue even after
./setuprebuilds the binary. The stalenode …/server-node.mjs(and itsbun.exechildren) must be killed before testing, otherwise the fix looks ineffective.Related (upstream, separate)
The 4th source,
chrome-headless-shell.exe, is Playwright's own spawn and is tracked at microsoft/playwright#41630 (processLauncher.jsmissingwindowsHide). Note the discussion there: an unconditionalwindowsHide: trueinlaunchProcess()was previously landed (microsoft/playwright#38776) and then reverted (microsoft/playwright#39994) because it also hid the Inspector and codegen windows, which go through the same path — so that one needs to be opt-in for headless launches. Not applicable to the gstack-side spawns in this issue, which are all non-interactive CLI tools and the terminal-agent.biker2000on commentedon Jul 13, 2026
I independently reproduced the detached browse-server part of this on Windows 11 with gstack v1.58.5.0 and traced it to browse/src/cli.ts in startServer(). The Windows launcher creates a detached Node child without windowsHide, so the minimal fix for that persistent console window is:
I applied that locally, rebuilt browse/dist/browse.exe, and restarted the old daemon so the rebuilt launcher was actually exercised. The focused daemonization regression suite passes (5/5), browse reports healthy, and repeated commands reuse the same server PID.
I also added a static regression assertion around launcherCode so this cannot silently regress:
The broader patch in the issue body still looks right: fixing bun-polyfill.cjs centrally is necessary for the recurring bun terminal-agent and CLI-tool child windows, while windowsHide:true in cli.ts is the direct fix for the detached browse server itself. This affects any host using the same gstack browse runtime (Claude Code or Codex), rather than being host-specific.
time-attack commentedon Jul 15, 2026
@16francej Close this because the selected Windows browse-server console-window item already covers the same subprocess windowsHide problem.
capy-ai commentedon Oct 2, 2026
Verified on main (v1.91.13.0): every
child_processandBun.spawncall inbrowse/srcpasseswindowsHide, and the Node polyfill forwards it.browse/test/windows-spawn-hide.test.ts(a sweep over all spawn sites) and the polyfill tests pass natively on thewindows-free-testslane (run 37033755836). Fixed across v1.64–v1.67 (#2571, #2604). Thanks! If a console window still flashes on your machine, reply with your gstack version and we'll reopen.