Skip to content

fix(spawn): hide Windows console windows on the remaining child launches - #679

Merged
jeff-r2026 merged 1 commit into
Tencent:mainfrom
CarlosWonMore:fix/windowshide-remaining-spawn-points
Sep 20, 2026
Merged

jeff-r2026 merged 1 commit into
Tencent:mainfrom
CarlosWonMore:fix/windowshide-remaining-spawn-points

Conversation

@CarlosWonMore

Copy link
Copy Markdown
Contributor

Summary

spawn() defaults windowsHide to false, so a child of a process that has no console of its own — an editor, or the hook dispatcher — is handed a fresh console window by Windows. #506 fixed that for the two detached hook children and #559 for the updater; three async spawn call sites were still missing it:

Site Child it starts
src/utils/exec.ts:29 (execCommand) whatever the caller asks for: probeBinary probes <cli> --version (a .cmd shim on Windows), and the plugin lifecycle runs install / update / uninstall commands
src/utils/ai-client.ts:121 (callClaude) the AI CLI (claude / codebuddy / …), also a .cmd shim
src/utils/clone.ts:92 (runCommand) git

This sets windowsHide: true on all three, matching src/update.ts:141 and src/hook-dispatch-cli.ts:103. No other behaviour change: same stdio configuration, same timeout handling, same error propagation. The option is ignored on POSIX.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature causing existing behavior to change)
  • Documentation only
  • Refactor / internal cleanup

Test Plan

  • npx tsc --noEmit passes
  • npx vitest run --coverage passes
  • Added/updated tests for the change

CI runs only ubuntu-latest / macos-latest, so a test cannot observe a Windows console — the spawn options are the only thing it can pin, and that is what the three guards assert:

  • src/__tests__/exec.test.ts (new) — execCommand still resolves stdout / stderr / exit code and still spawns with shell: false; plus the windowsHide guard.
  • src/__tests__/clone.test.ts (new) — drives shallowClone against a mocked git and asserts every child it starts carries the flag.
  • src/__tests__/ai-client.test.ts — the same guard for the CLI child in callClaude.

The guards were verified to actually fail without the fix: stripping the three windowsHide: true lines makes exactly those three tests fail (expected undefined to be true) while the other 19 in those files keep passing.

Related Issues

Fixes #672

Notes for Reviewers

Two corrections to #672, found while sweeping the repo for this class.

  1. windowsHide is also already set in src/builtin-hooks.ts:172. The issue's table listed three files carrying it and missed this one, so "only three source files" was wrong even though the three gaps it named are real.

  2. src/post-pull.ts does not go through execCommand as the issue claims. It imports only captureTail / detachChild from utils/exec.ts and spawns node:child_process directly, and its header (lines 13–18) states that it deliberately inherits the already-hidden console of the pull process. It is therefore intentionally left alone here.

One remaining site I did not touch — worth a second opinion.

src/openclaw-hooks.ts:87 builds the OpenClaw-family handler.ts, and the handler it generates spawns teamai hook-dispatch without windowsHide. Same class of gap, but it differs in two ways: it is a generated artefact written into the user's workspace, so the fix only reaches existing installs on the next hooks inject / pull, and the file header notes the claw engines' console behaviour is still unconfirmed (WorkBuddy itself turned out to use the CodeBuddy engine). I left it out to keep this PR to the sites #672 named — say the word and I will send it as a follow-up.

Deliberately not covered: the synchronous launches (spawnSync / execFileSync — roughly twenty call sites across the providers, ci/, machine-id.ts, utils/cli-path.ts, …). They also default windowsHide to false, so they are plausibly the same class, but #672 did not report them and I have not verified reachability for each, so this PR does not touch them.

Docs: I did not add a usage-guide line. The one Windows-console sentence that exists (docs/usage-guide.md:1561 and its zh-CN twin) sits in the auto-update section and is about the updater; these three launches belong to no single documented feature, so a sentence there would have been misplaced. Happy to add one elsewhere if you would rather have it written down.

Why this keeps recurring: the CI matrix is ubuntu-latest / macos-latest only, so this whole family of defects is invisible to automation and can only be caught by review — which is why it keeps arriving a few call sites at a time. A windows-latest job running the unit suite would close that gap for good. Out of scope here, but I can draft it separately if it is welcome.

#672 lists three async spawn sites that still omit windowsHide, so a child of a
process with no console of its own - an editor, or the hook dispatcher - is
handed a fresh console window by Windows. #506 covered the two detached hook
children and #559 the updater; these are the rest:

  src/utils/exec.ts       execCommand, which also backs probeBinary
  src/utils/ai-client.ts  the AI CLI, a .cmd shim on Windows
  src/utils/clone.ts      runCommand, which starts git

Option only: stdio, timeouts and error propagation are unchanged, and
windowsHide is ignored on POSIX.

CI has no Windows runner, so the spawn options are the only thing a test can
pin. The three new guards assert exactly that, and each one fails when its
option is removed.

Fixes #672
@CarlosWonMore
CarlosWonMore force-pushed the fix/windowshide-remaining-spawn-points branch from 50c7015 to d0c9165 Compare September 20, 2026 14:24
@jeff-r2026 jeff-r2026 self-assigned this Sep 20, 2026
@github-actions

Copy link
Copy Markdown
  • [P1 blocking] Missing required real-CLI/E2E verification. The PR description lists only type checking and mocked unit tests. Repository policy requires npm run build followed by actual CLI end-to-end testing, with the commands, scenarios, and results recorded in the PR. Add real-CLI verification covering the affected spawn paths before merge.

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] 仍有 3 处子进程启动点缺少 windowsHide(utils/exec.ts、utils/ai-client.ts、clone.ts),#506 与 #559 未覆盖

2 participants