Skip to content

fix(process): add windowsHide to spawn in runCommandWithTimeout#51559

Open
gushiaoke wants to merge 2 commits intoopenclaw:mainfrom
gushiaoke:fix/windows-hide-spawn-cmd-window
Open

fix(process): add windowsHide to spawn in runCommandWithTimeout#51559
gushiaoke wants to merge 2 commits intoopenclaw:mainfrom
gushiaoke:fix/windows-hide-spawn-cmd-window

Conversation

@gushiaoke
Copy link
Copy Markdown
Contributor

Summary

  • Problem: On Windows, runCommandWithTimeout() spawns child processes without windowsHide: true, causing a visible cmd.exe window to flash briefly for every spawned command. This is especially noticeable during gateway startup when ensureGitRepo() invokes git --version and git init.
  • Why it matters: The flashing cmd window is a jarring UX issue for Windows users, particularly for applications that embed OpenClaw as an npm package and run it in the background.
  • What changed: Added windowsHide: true to the spawn() options in runCommandWithTimeout() (src/process/exec.ts).
  • What did NOT change (scope boundary): No other spawn call sites were modified. Only the central runCommandWithTimeout function was touched. No behavioral changes on non-Windows platforms (windowsHide is ignored on macOS/Linux).

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

  • Related: Windows cmd window flashing on gateway startup

User-visible / Behavior Changes

  • Windows: No more visible cmd.exe window flash when OpenClaw spawns background commands (git, npm, etc.)
  • Non-Windows: No change.

Security Impact (required)

  • New permissions/capabilities? No
  • Secrets/tokens handling changed? No
  • New/changed network calls? No
  • Command/tool execution surface changed? No
  • Data access scope changed? No

Repro + Verification

Environment

  • OS: Windows 11
  • Runtime/container: Node.js 22+
  • Model/provider: N/A
  • Integration/channel (if any): N/A
  • Relevant config (redacted): Default gateway config

Steps

  1. Install OpenClaw as an npm package on Windows
  2. Start the gateway (openclaw gateway run)
  3. Observe a cmd.exe window briefly flashing during startup (when ensureGitRepo runs git commands)

Expected

  • No visible cmd window during gateway startup

Actual

  • A cmd.exe window flashes briefly each time spawn() is called without windowsHide: true

Evidence

Human Verification (required)

  • Verified scenarios: Gateway startup on Windows 11 — no cmd window flash after the fix.
  • Edge cases checked: Confirmed windowsHide is ignored on non-Windows platforms (no behavioral change on macOS/Linux).
  • What you did not verify: Other spawn call sites in the codebase (this PR only addresses runCommandWithTimeout; other sites may also benefit from the same fix).

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

Compatibility / Migration

  • Backward compatible? Yes
  • Config/env changes? No
  • Migration needed? No

Failure Recovery (if this breaks)

  • How to disable/revert this change quickly: Revert the single-line addition of windowsHide: true in src/process/exec.ts
  • Files/config to restore: src/process/exec.ts
  • Known bad symptoms reviewers should watch for: None expected — windowsHide is a no-op on non-Windows

Risks and Mitigations

None — this is a well-documented Node.js API option with no side effects on non-Windows platforms.


AI-assisted PR (CodeBuddy). Fully tested on Windows 11. I understand what the code does.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 21, 2026

Greptile Summary

This PR adds windowsHide: true to the spawn() options in runCommandWithTimeout (src/process/exec.ts), preventing the cmd.exe console window from flashing on Windows whenever a child process is spawned. The change is a no-op on macOS/Linux.

  • The fix is correct and minimal — windowsHide is a well-documented Node.js spawn option designed exactly for this purpose.
  • No behavioral change on non-Windows platforms.
  • Note: runExec (also in src/process/exec.ts) uses execFileAsync/execFile without windowsHide: true. The PR author explicitly scoped this fix to runCommandWithTimeout, but runExec call sites on Windows may still flash a console window. This is a known gap acknowledged in the PR description and is a reasonable follow-up rather than a blocker.

Confidence Score: 5/5

  • This PR is safe to merge — it adds a single, well-documented no-op option on non-Windows platforms that solves a clear UX regression on Windows.
  • The change is a one-line addition of a standard Node.js spawn option. It has no behavioral effect outside Windows, is backward compatible, and there are no logic or security concerns. The scope is intentionally narrow and well justified.
  • No files require special attention.

Last reviewed commit: "fix(process): add wi..."

On Windows, child_process.spawn() without windowsHide: true causes
a visible cmd.exe window to flash briefly for every spawned process.
This is especially noticeable during gateway startup when git commands
are invoked by ensureGitRepo().

Add windowsHide: true to the spawn options in runCommandWithTimeout(),
which is the central command execution function. This property is
ignored on non-Windows platforms, so there is no behavioral change
elsewhere.
@gushiaoke gushiaoke force-pushed the fix/windows-hide-spawn-cmd-window branch from 24954ed to f416a00 Compare March 21, 2026 11:09
@gushiaoke
Copy link
Copy Markdown
Contributor Author

The two failing checks — extension-fast (discord) and extension-fast (matrix) — are unrelated to this PR.

This PR only modifies src/process/exec.ts (adding windowsHide: true), and does not touch any extension code.

Error details:

  • discord: TypeError: Message is not a constructor, RateLimitError is not a constructor, TextDisplay is not a constructor — all from __vite_ssr_import failures
  • matrix: TypeError: createClient is not a function — same Vitest SSR module resolution issue

These are Vitest SSR module resolution flaky failures in CI (__vite_ssr_import_xxx imports failing intermittently). All other 73 extension-fast jobs passed successfully.

A re-run should clear these.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant