小橙子 ca4e7f65ce
fix(server): stop hiding GUI windows when opening external IDEs on Windows (#52)
* fix(server): stop hiding GUI windows when opening external IDEs on Windows

Symptom: clicking the right-side 'Open in...' menu and picking VS Code or
Cursor on Windows starts the process (visible in Task Manager) but no
window ever appears. Repeated clicks pile up zombie processes which
eventually starves the system and makes the app feel hung.

Cause: defaultLaunch passed { detached: true, stdio: 'ignore',
windowsHide: true } to spawn. On Windows, windowsHide sets
STARTUPINFO.wShowWindow = SW_HIDE. For console-subsystem commands
(cmd.exe /c start ...) that hides the cmd flash, which is what we
wanted. But for GUI-subsystem executables (Code.exe, Cursor.exe,
explorer.exe, ...) Windows treats SW_HIDE as the initial nCmdShow
handed to the app's first ShowWindow() call, so the main window is
created and immediately hidden.

Fix: drop windowsHide. The brief cmd flash from the explorer
file-manager fallback (cmd.exe /c start "" path) is acceptable;
cmd /c start exits in milliseconds and is rarely visible.

Tested: server open-target tests 28/28 still pass (ran via
  bun test src/server/__tests__/open-target-*.test.ts).
Spawn-option behavior is platform-specific and not unit-testable
without mocking node:child_process — verified by inspection against
Node.js docs and Windows STARTUPINFO semantics.

Confidence: high
Scope-risk: narrow

* test(server): freeze defaultLaunch spawn options as a regression guard

Extracts the spawn options into a pure helper getDefaultLaunchSpawnOptions and adds 4 cases asserting (a) detached:true, (b) stdio:ignore, (c) windowsHide unset (the regression guard for the VS Code hidden-window bug fixed in the parent commit), (d) no extra fields silently changing spawn semantics.

Tested: 32/32 (28 previous open-target tests still green plus 4 new)

---------

Co-authored-by: 你的姓名 <you@example.com>
2026-06-16 00:46:15 +08:00
..
2026-06-09 02:35:06 +08:00