Skip to content

fix(gateway): hide child process windows to prevent startup flicker on Windows #70238#70308

Closed
PratikRai0101 wants to merge 2 commits intoopenclaw:mainfrom
PratikRai0101:fix/windows-gateway-flicker
Closed

fix(gateway): hide child process windows to prevent startup flicker on Windows #70238#70308
PratikRai0101 wants to merge 2 commits intoopenclaw:mainfrom
PratikRai0101:fix/windows-gateway-flicker

Conversation

@PratikRai0101
Copy link
Copy Markdown
Contributor

@PratikRai0101 PratikRai0101 commented Apr 22, 2026

Summary

  • Problem: Gateway processes on Windows spawn visible cmd.exe windows during startup due to missing spawn options, causing screen flickering.
  • Why it matters: Degrades user experience and makes the application appear unstable or misconfigured.
  • What changed: Added windowsHide: true to the child_process.spawn() options in the gateway process launcher.
  • What did NOT change (scope boundary): No changes to process lifecycle, logging, or behavior on non-Windows platforms.

Change Type (select all)

  • Bug fix

Scope (select all touched areas)

  • Gateway / orchestration

Linked Issue/PR


Root Cause

  • Root cause: child_process.spawn() was invoked without windowsHide: true, causing Windows to create a visible console window for each child process.
  • Missing detection / guardrail: No platform-specific handling for background process spawning on Windows.
  • Contributing context: Gateway processes are spawned during startup, amplifying the visual impact due to multiple rapid spawns.

Regression Test Plan

  • Coverage level that should have caught this:

    • Seam / integration test
  • Target test or file:

    • Gateway process spawn behavior on Windows
  • Scenario the test should lock in:

    • Spawning a gateway process does not create a visible console window on Windows
  • Why this is the smallest reliable guardrail:

    • Issue occurs at process orchestration boundary, not within isolated logic
  • Existing test that already covers this (if any):

    • None
  • If no new test is added, why not:

    • Visual OS-level behavior is difficult to assert reliably in CI environments

User-visible / Behavior Changes

  • Gateway startup no longer causes command prompt windows to flash on Windows
  • Startup experience is visually clean and uninterrupted

Diagram

Before:
App start -> spawn gateway -> visible cmd window flashes

After:
App start -> spawn gateway (windowsHide) -> no visible window -> clean startup

## 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: Arch Linux x86_64 
- Kernel: 6.19.11-arch1-1
- Runtime/container: Node v22 .22.2
- Model/provider: N/A  
- Integration/channel (if any): Gateway process  
- Relevant config (redacted): default setup  

### Steps

1. Launch OpenClaw on Windows  
2. Observe startup behavior  
3. Monitor for visible terminal windows  

### Expected

- No command prompt windows appear  
- Gateway runs fully in background  

### Actual (before fix)

- Command prompt windows flash repeatedly during startup  

---

## Evidence

- [x] Issue reproduced before fix (visible flicker)  
- [x] Verified no window spawn after fix  

---

## Human Verification (required)

- Verified scenarios:
  - Standard startup on Windows  
  - Multiple gateway respawns do not produce flicker  

- Edge cases checked:
  - Rapid restart / respawn scenarios  
  - Background execution stability  

- What you did **not** verify:
  - All Windows versions  
  - Non-standard terminal environments  

---

## Review Conversations

- [x] I replied to or resolved every bot review conversation I addressed in this PR.  
- [x] 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  

---

## Risks and Mitigations

- Risk:
  - Potential unintended suppression of console output visibility on Windows  

- Mitigation:
  - Logging remains unaffected (stdout/stderr still captured)  
  - Behavior aligns with expected background process execution  

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 22, 2026

Greptile Summary

This PR adds windowsHide: true to the spawn() options to suppress visible console windows during gateway startup on Windows. However, the existing if (process.platform === 'win32') guard at line 46 returns early with mode: "disabled" before spawn() is ever called on Windows, so the new option is dead code on the only platform it targets. The fix needs to be rethought alongside the orphan-process concern that motivated the Windows early-return.

Confidence Score: 4/5

The change is a no-op on Windows due to the early-return guard; safe to merge in the sense it cannot regress, but it does not fix the reported issue.

One unresolved P1 finding: the added option is unreachable on Windows, so the stated bug is not actually fixed.

src/infra/process-respawn.ts — the Windows platform guard and spawn call need to be restructured for the fix to take effect.

Comments Outside Diff (1)

  1. src/infra/process-respawn.ts, line 46-62 (link)

    P1 windowsHide: true is unreachable on Windows

    The if (process.platform === 'win32') guard at line 46 returns { mode: "disabled" } before the spawn() call is ever reached, so the newly added windowsHide: true option is never exercised on any Windows process. The fix has no effect on the platform it targets.

    For windowsHide to have any impact, the Windows early-return must either be removed (if the orphaning risk is now acceptable) or the spawn must be restructured to allow detached spawning on Windows — windowsHide alone does not address the orphan-process concern that motivated the guard.

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: src/infra/process-respawn.ts
    Line: 46-62
    
    Comment:
    **`windowsHide: true` is unreachable on Windows**
    
    The `if (process.platform === 'win32')` guard at line 46 returns `{ mode: "disabled" }` before the `spawn()` call is ever reached, so the newly added `windowsHide: true` option is never exercised on any Windows process. The fix has no effect on the platform it targets.
    
    For `windowsHide` to have any impact, the Windows early-return must either be removed (if the orphaning risk is now acceptable) or the spawn must be restructured to allow detached spawning on Windows — `windowsHide` alone does not address the orphan-process concern that motivated the guard.
    
    How can I resolve this? If you propose a fix, please make it concise.
Prompt To Fix All With AI
This is a comment left during a code review.
Path: src/infra/process-respawn.ts
Line: 46-62

Comment:
**`windowsHide: true` is unreachable on Windows**

The `if (process.platform === 'win32')` guard at line 46 returns `{ mode: "disabled" }` before the `spawn()` call is ever reached, so the newly added `windowsHide: true` option is never exercised on any Windows process. The fix has no effect on the platform it targets.

For `windowsHide` to have any impact, the Windows early-return must either be removed (if the orphaning risk is now acceptable) or the spawn must be restructured to allow detached spawning on Windows — `windowsHide` alone does not address the orphan-process concern that motivated the guard.

How can I resolve this? If you propose a fix, please make it concise.

Reviews (2): Last reviewed commit: "Merge branch 'main' into fix/windows-gat..." | Re-trigger Greptile

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c2685fae99

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/infra/process-respawn.ts
@PratikRai0101 PratikRai0101 force-pushed the fix/windows-gateway-flicker branch from c2685fa to 19f82f2 Compare April 22, 2026 19:03
@PratikRai0101
Copy link
Copy Markdown
Contributor Author

Heyyy,
After a catch by the automated review.

I did a full audit of the actual Windows-supervised spawn paths (windows-task-restart.ts, daemon/schtasks.ts, and update-cli/restart-helper.ts) and verified that they already have windowsHide: true applied correctly.

I am leaving windowsHide: true here on the detached spawn as a defensive guardrail. If this spawn path is ever reached on a Windows-like environment (e.g., WSL interop, MSYS) or if the early return guard is refactored in the future, this ensures the flicker regression won't occur.

Since Node silently ignores the windowsHide flag on non-Windows operating systems, it is completely safe to include here for future-proofing.

@PratikRai0101 PratikRai0101 force-pushed the fix/windows-gateway-flicker branch from 85faa18 to f7c2284 Compare April 23, 2026 07:44
@clawsweeper
Copy link
Copy Markdown
Contributor

clawsweeper Bot commented Apr 26, 2026

Closing this as duplicate or superseded after Codex automated review.

PR #70308 should close in favor of the canonical linked bug #70238. Current main shows the proposed windowsHide additions are unreachable for Windows gateway respawn, while the actual Windows supervised/restart helpers already set windowsHide: true; any remaining flicker needs a fix against #70238’s real Windows startup path.

Best possible solution:

Close this PR and keep #70238 as the canonical tracker for the reported Windows gateway flicker. A real fix should start from a current Windows repro and target the actual scheduled-task/gateway startup path; defensive windowsHide flags on unreachable respawn branches should not be merged as the bug fix.

What I checked:

So I’m closing this here and keeping the remaining discussion on the canonical linked item.

Codex Review notes: model gpt-5.5, reasoning high; reviewed against c74fb781943f.

@clawsweeper clawsweeper Bot closed this Apr 26, 2026
XuZehan-iCenter added a commit to XuZehan-iCenter/openclaw that referenced this pull request May 6, 2026
The execLoginShellEnvZero helper was missing windowsHide: true, causing
a PowerShell console window to flash briefly during gateway startup on
Windows. This completes the fix started in openclaw#48320 and openclaw#70308 for the
v2026.5.4 code path.

Closes openclaw#78159
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.

[Bug]: Gateway OpenCLAW spawns flashing command prompt windows in background on Windows

1 participant