Skip to content

fix(server): open the browser on Windows without sharing the caller's console (#1893) - #3851

Open
stphliyz-lgtm wants to merge 2 commits into
backnotprop:mainfrom
stphliyz-lgtm:fix/opencode-tui-windows-browser-open
Open

stphliyz-lgtm wants to merge 2 commits into
backnotprop:mainfrom
stphliyz-lgtm:fix/opencode-tui-windows-browser-open

Conversation

@stphliyz-lgtm

Copy link
Copy Markdown
Contributor

Summary

Fixes #1893.

On Windows the Bun runtime opened the plan review with cmd.exe /c start <url> through Bun Shell ($), which attaches cmd.exe to the caller's console. In OpenCode's embedded plan review (apps/opencode-plugin/embedded.ts -> handleServerReady -> openBrowser) that is the TUI's own console, so cmd.exe changing its modes made OpenCode's render output appear as text in the input box. The CLI fallback path was not affected because it already spawns the CLI with piped stdio and windowsHide.

openBrowser now runs the cmd.exe opener on Windows through spawn with stdio: "ignore" and windowsHide: true, so cmd.exe gets its own hidden console (libuv uses CREATE_NO_WINDOW when no stdio is inherited). start still opens the browser window normally; openBrowserDetached already launches the same argv this way. Every other launch (macOS, Linux, WSL, a configured browser executable) still goes through $ unchanged.

Tests: new Windows default browser launch case in packages/server/browser.test.ts fakes win32, puts a cmd.exe shim on PATH and checks it runs with /c start <url> and none of the caller's stdio (it fails on the old code). browser.test.ts, browser-intent-launch.test.ts and tests/windows-hide-guard.test.ts pass. I could not run OpenCode on a Windows machine to reproduce the TUI glitch end to end.

e2e:

stphliyz-lgtm and others added 2 commits November 21, 2026 18:42
… console (backnotprop#1893)

The Bun runtime ran 'cmd.exe /c start <url>' through Bun Shell, which
attaches cmd.exe to the caller's console. In OpenCode's embedded plan
review that is the TUI's console, and cmd.exe changing its modes made
OpenCode's render output show up as text in the input box. Run the
cmd.exe opener through spawn with no stdio and windowsHide, so it gets
its own hidden console; start still opens the browser normally.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

This branch has not been deployed

No deployments
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.

[Bug] OpenCode TUI breaks during submit_plan

1 participant