Repository navigation
fix: hide the console window of child processes on Windows - #22
Merged
Merged
Conversation
When OpenCode runs the tools from a process without a console, such as `opencode serve`, every rg, pdfinfo or probe started without windowsHide gets a new console window. With Windows Terminal as the default terminal, each grep or glob call flashed a terminal window for a moment. All node:child_process spawn and spawnSync calls in production code now pass windowsHide: true. Other platforms ignore the option. The POSIX-only process supervisor in betterglob is left as it is. Release 1.2.2 for the three packages.
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.
On Windows, OpenCode can run the tools from a process with no console of its own, for example
opencode serve. A console program spawned from such a process withoutwindowsHidegets a new console window. With Windows Terminal as the default terminal, everygrepandglobcall flashed a terminal window for a fraction of a second.OpenCode's own shell tool already hides its child processes. The plugins called
node:child_processwithout the option.Production changes
All
spawnandspawnSynccalls in production code now passwindowsHide: true. Node ignores the option on other platforms.utils/compat.ts(the rg and grep searches),tools/grep/cli-probe.tsandtools/grep/rg-cache.ts(version probes), and the two probes inutils/zip-extractor.ts.utils/process-output.tsandtools/glob/runner.ts.tools/read/pdf-reader.ts(pdfinfo).The POSIX-only process supervisor in betterglob is unchanged.
Verification
rg --versionwithspawnand withspawnSync. A window hook saw a Windows Terminal window open for both calls withoutwindowsHideand none with it.check,typecheckandbuildare clean on Windows 11 and on Linux (Ubuntu 26.04 under WSL 2), Bun 1.4.4.mainand on this branch, test by test, on both systems. Some tests already fail onmainin these environments: on Linux 12 in bettergrep (the GNU grepmtimecharacterizations) and 16 in betterglob, and more on Windows. This change does not add or fix any.