Skip to content

fix: add windowsHide to browse detached server spawn on Windows#1863

Closed
mvanhorn wants to merge 1 commit into
garrytan:mainfrom
mvanhorn:fix/1835-windows-windowshide-detached-spawn
Closed

fix: add windowsHide to browse detached server spawn on Windows#1863
mvanhorn wants to merge 1 commit into
garrytan:mainfrom
mvanhorn:fix/1835-windows-windowshide-detached-spawn

Conversation

@mvanhorn

@mvanhorn mvanhorn commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds windowsHide: true to the detached server-launcher spawns in browse/src/cli.ts so starting the gstack browse server on Windows no longer flashes a black console window.

Why this matters

Issue #1835 reports that on Windows, starting the browse server flashes two black console windows: the detached bun.exe server process and Playwright's chrome-headless-shell.exe. The detached launcher spawn near line 326 of browse/src/cli.ts sets {detached:true,stdio:['ignore','ignore','ignore'],...} but omits windowsHide:true, and child_process.spawn({detached:true}) allocates a new console window on Windows unless windowsHide:true (Win32 CREATE_NO_WINDOW) is set; the headless-shell window is a secondary effect of the parent having a visible console. This adds windowsHide:true to the inlined launcher options object and to the sibling child_process.spawn detach call. windowsHide is a no-op on POSIX, so it is safe unconditionally.

Testing

browse/test/cli-windows-hide.test.ts is a static-grep regression test in the repo's tripwire style: it asserts the launcher options string carries both detached:true and windowsHide:true, that the second detached child_process.spawn site also includes windowsHide, and fails if any future detached:true spawn site in browse/src/cli.ts drops it. Full suite runs in CI.

Fixes #1835

@trunk-io

trunk-io Bot commented Jun 4, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@buddy7599bot

Copy link
Copy Markdown

Flagging an overlap so this and your #1864 don't collide in the queue: both target the same defect class — Windows console flashes from browse cold-start spawns (#1835 here, #1784 there) — and both add a new browse/test/cli-windows-hide.test.ts, so they will conflict on that file as soon as one merges.

They also fix disjoint spawn sites, so neither is complete on its own:

  • This PR adds windowsHide:true to the inner detached server spawn inside launcherCode (spawn(process.execPath,[...],{detached:true,...})) plus the macOS nodeSpawn('bun',...)/osascript sites (the latter two are no-ops on Windows). It leaves the outer launcher Bun.spawnSync(['node','-e',launcherCode], ...) in startServer unchanged.
  • fix: suppress Windows console flashes from browse cold-start child spawns #1864 does the opposite: it replaces that outer Bun.spawnSync(['node',...]) launcher with nodeSpawnSync('node', ..., { windowsHide: true }) (its Win32_ProcessStartTrace shows the transient node -e launcher is itself a console-subsystem child, and that Bun.spawnSync ignores windowsHide on Bun 1.3.11) and also hides taskkill, the git rev-parse/git remote probes, and the icacls calls — but it does not add windowsHide inside launcherCode's detached spawn.

So by each PR's own premise, #1863 alone still flashes the transient node -e launcher console, and #1864 alone still flashes the detached server. The complete fix is the union of both.

Suggest consolidating into a single PR covering every spawn site (outer launcher + inner detached spawn + taskkill + git probes + icacls), with one cli-windows-hide.test.ts, and closing the other as superseded. Validation: the detachedSpawns <= windowsHideFlags static check in this PR's test is a good invariant — extend it to also assert the outer Bun.spawnSync(['node',...]) launcher is gone (the #1864 change), so the merged version pins both halves.

@mvanhorn

mvanhorn commented Jun 4, 2026

Copy link
Copy Markdown
Contributor Author

Closing this in favor of #1864, which now carries both halves of the fix: the spawnSync conversion for the outer cold-start flash and (as of 77ebc14) the windowsHide flags on the inner detached server spawn, the osascript raise helper, and the POSIX server spawn that this PR added. The test invariant from this branch (every detached spawn site carries windowsHide) moved over as well, so nothing here is lost.

@mvanhorn mvanhorn closed this Jun 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(windows): bun server and chrome-headless-shell show black console windows on Windows

2 participants