Skip to content

fix: hide the console window of child processes on Windows - #22

Merged
dhaern merged 1 commit into
mainfrom
fix/windows-hide-console
Nov 6, 2026
Merged

dhaern merged 1 commit into
mainfrom
fix/windows-hide-console

Conversation

@dhaern

@dhaern dhaern commented Nov 6, 2026

Copy link
Copy Markdown
Owner

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 without windowsHide gets a new console window. With Windows Terminal as the default terminal, every grep and glob call 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_process without the option.

Production changes

All spawn and spawnSync calls in production code now pass windowsHide: true. Node ignores the option on other platforms.

  • bettergrep: utils/compat.ts (the rg and grep searches), tools/grep/cli-probe.ts and tools/grep/rg-cache.ts (version probes), and the two probes in utils/zip-extractor.ts.
  • betterglob: utils/process-output.ts and tools/glob/runner.ts.
  • betterread: tools/read/pdf-reader.ts (pdfinfo).
  • Version 1.2.2 for the three packages and the root.

The POSIX-only process supervisor in betterglob is unchanged.

Verification

  • A detached Node process with no console spawned rg --version with spawn and with spawnSync. A window hook saw a Windows Terminal window open for both calls without windowsHide and none with it.
  • check, typecheck and build are clean on Windows 11 and on Linux (Ubuntu 26.04 under WSL 2), Bun 1.4.4.
  • The test results are the same on main and on this branch, test by test, on both systems. Some tests already fail on main in these environments: on Linux 12 in bettergrep (the GNU grep mtime characterizations) and 16 in betterglob, and more on Windows. This change does not add or fix any.

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.
@dhaern
dhaern merged commit 8419806 into main Nov 6, 2026
@dhaern
dhaern deleted the fix/windows-hide-console branch November 6, 2026 23:46
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.

1 participant