Repository navigation
fix(server): open the browser on Windows without sharing the caller's console (#1893) - #3851
Open
stphliyz-lgtm wants to merge 2 commits into
Open
stphliyz-lgtm wants to merge 2 commits into
stphliyz-lgtm wants to merge 2 commits into
Conversation
… 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 andwindowsHide.openBrowsernow runs thecmd.exeopener on Windows throughspawnwithstdio: "ignore"andwindowsHide: true, so cmd.exe gets its own hidden console (libuv usesCREATE_NO_WINDOWwhen no stdio is inherited).startstill opens the browser window normally;openBrowserDetachedalready 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 launchcase inpackages/server/browser.test.tsfakeswin32, puts acmd.exeshim 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.tsandtests/windows-hide-guard.test.tspass. I could not run OpenCode on a Windows machine to reproduce the TUI glitch end to end.e2e: