Skip to content

fix(windows): suppress console flash for netstat/taskkill spawns#1338

Merged
senamakel merged 1 commit into
tinyhumansai:mainfrom
M3gA-Mind:fix/windows-no-console-flash
May 7, 2026
Merged

fix(windows): suppress console flash for netstat/taskkill spawns#1338
senamakel merged 1 commit into
tinyhumansai:mainfrom
M3gA-Mind:fix/windows-no-console-flash

Conversation

@M3gA-Mind
Copy link
Copy Markdown
Contributor

@M3gA-Mind M3gA-Mind commented May 7, 2026

Summary

  • Added CREATE_NO_WINDOW (0x08000000) flag to all Windows std::process::Command spawns in the Tauri shell that were missing it.
  • Fixes a visible console window that flashed on-screen every time the app checked for a stale RPC listener or killed a stale process on Windows.
  • No behaviour change on macOS/Linux — all three changed call sites are inside #[cfg(windows)] blocks.

Problem

On Windows, std::process::Command inherits or allocates a console for the child process unless CREATE_NO_WINDOW is explicitly set in the PROCESS_CREATION_FLAGS. Three call sites were spawning visible console windows:

  1. find_pid_on_port (core_process.rs) — runs netstat -ano on every ensure_running call to detect a stale listener on the RPC port.
  2. kill_pid_term (process_kill.rs) — runs taskkill /PID as a graceful-shutdown best-effort.
  3. kill_pid_force (process_kill.rs) — runs taskkill /F /T /PID for the force-kill follow-up.

Because ensure_running is invoked periodically from the frontend (and during bootstrap/restart flows), users could see a console window flash every few seconds.

Solution

Use std::os::windows::process::CommandExt::creation_flags(0x0800_0000) (stdlib — no new deps) on each of the three Windows Command instances. The constant is defined locally at the call site to avoid pulling in a winapi/windows crate.

Submission Checklist

  • N/A: no new Rust logic or branching — flag-only addition to existing Windows-only call sites; unit-testing PROCESS_CREATION_FLAGS requires a live Windows build
  • N/A: diff coverage gate — only two files changed, no new logic paths, 0 changed lines of testable behaviour
  • N/A: coverage matrix — no feature row maps to CREATE_NO_WINDOW flag on a process spawn helper
  • N/A: feature IDs — no matrix feature affected
  • N/A: no external network dependencies introduced
  • N/A: no release-cut surfaces touched
  • N/A: no linked issue (user-reported symptom, no issue opened)

Impact

  • Windows only: eliminates the black console window that flashed on every app startup/restart cycle and on any stale-listener recovery.
  • No impact on macOS or Linux (all changes are inside #[cfg(windows)]).
  • No behaviour change — processes still run to completion; they just do so without a visible window.

Related

  • Closes:
  • Follow-up PR(s)/TODOs: consider adding CREATE_NO_WINDOW to the taskkill call in ollama_admin.rs and nvidia-smi in device.rs in a follow-up.

AI Authored PR Metadata (required for Codex/Linear PRs)

Linear Issue

  • Key: N/A
  • URL: N/A

Commit & Branch

  • Branch: fix/windows-no-console-flash
  • Commit SHA: 8fdce34

Validation Run

  • pnpm --filter openhuman-app format:check — passed
  • pnpm typecheck — N/A (no TS changes)
  • Focused tests: N/A (Windows-only flag; no testable logic change)
  • Rust fmt/check (if changed): N/A (no root-crate Rust changes)
  • Tauri fmt/check (if changed): cargo check --manifest-path app/src-tauri/Cargo.toml — passed, 0 errors

Validation Blocked

  • command: N/A
  • error: N/A
  • impact: N/A

Behavior Changes

  • Intended behavior change: Windows child processes (netstat, taskkill) no longer create a visible console window.
  • User-visible effect: Console flash on Windows is eliminated.

Parity Contract

  • Legacy behavior preserved: Yes — process spawn semantics are identical; only the window-creation flag is added.
  • Guard/fallback/dispatch parity checks: N/A

Duplicate / Superseded PR Handling

  • Duplicate PR(s): N/A
  • Canonical PR: this PR
  • Resolution (closed/superseded/updated): N/A

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Eliminated unwanted console windows from appearing during port checking and process termination operations on Windows.

Windows shows a brief console window whenever a child process is
spawned without the CREATE_NO_WINDOW (0x08000000) creation flag.
Three call sites were missing it:

- `find_pid_on_port` (core_process.rs): spawns `netstat` on startup
  to locate any stale listener on the RPC port.
- `kill_pid_term` / `kill_pid_force` (process_kill.rs): spawn
  `taskkill` to signal/force-kill that stale process.

Added `CommandExt::creation_flags(CREATE_NO_WINDOW)` to all three
Windows-only `std::process::Command` calls so the helper processes
run silently in the background.
@M3gA-Mind M3gA-Mind requested a review from a team May 7, 2026 13:48
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 7, 2026

Review Change Stack
No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 51595d7e-bb70-488a-8def-c3470015517b

📥 Commits

Reviewing files that changed from the base of the PR and between ca8e4f6 and 8fdce34.

📒 Files selected for processing (2)
  • app/src-tauri/src/core_process.rs
  • app/src-tauri/src/process_kill.rs

📝 Walkthrough

Walkthrough

This PR adds Windows console window suppression to process management operations. The find_pid_on_port function now hides the netstat console window, and both kill_pid_term and kill_pid_force now hide taskkill console windows using the CREATE_NO_WINDOW creation flag.

Changes

Windows Console Window Suppression

Layer / File(s) Summary
Port discovery window suppression
app/src-tauri/src/core_process.rs
Windows find_pid_on_port applies CREATE_NO_WINDOW to the netstat invocation to suppress console window appearance.
Process termination window suppression
app/src-tauri/src/process_kill.rs
Windows kill_pid_term and kill_pid_force apply CREATE_NO_WINDOW to taskkill invocations. kill_pid_term remains best-effort; kill_pid_force preserves existing error handling for spawn and exit failures.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • tinyhumansai/openhuman#731: Also modifies Windows Command creation in app/src-tauri/src/core_process.rs to set CREATE_NO_WINDOW for suppressing spawned console windows.

Poem

🐰 A rabbit hops through Windows bright,
No console windows in the night—
Process whispers, silent, clean,
The hidden spawns you've never seen!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding CREATE_NO_WINDOW flag to suppress console windows for netstat and taskkill spawns on Windows, which is the core objective of the PR.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@senamakel senamakel merged commit 6262070 into tinyhumansai:main May 7, 2026
20 checks passed
sanil-23 added a commit to sanil-23/openhuman that referenced this pull request May 11, 2026
/tinyhumansai#1338 follow-up)

On Windows, `CreateProcess` allocates a conhost for every child
unless `CREATE_NO_WINDOW` (creation flag `0x0800_0000`) is set. The
shell-side spawns were fixed in tinyhumansai#731 (core sidecar) and tinyhumansai#1338
(netstat/taskkill). The core-side spawns were not — so any
frontend-polled RPC that fans out into a native command (e.g.
`local_ai_device_profile` -> `nvidia-smi`) flashes a console window
on every poll. On a fresh Windows install with no Ollama, the
combined effect was a continuous terminal-flash storm before the
auth screen had even rendered.

Sites covered:

- `local_ai/install.rs`: PowerShell wrapper that runs OllamaSetup.exe
- `local_ai/service/ollama_admin.rs`: `ollama --version`, `ollama serve`,
  candidate probe in `command_works`, `taskkill /F /IM ollama.exe`
- `local_ai/device.rs`: `nvidia-smi --query-gpu` — re-probed by
  `handle_local_ai_device_profile` on every poll
- `doctor/core.rs`: PowerShell `Get-PSDrive` for disk space, and
  `<cmd> --version` for `git` / `curl` / etc.
- `node_runtime/resolver.rs`: `<bin> --version` in `probe_subcommand_version`
- `service/common.rs` helpers (`run_checked`, `run_capture`,
  `run_best_effort`, `run_check_silent`) — silences every Windows
  `schtasks` call at the helper boundary (covers `status`, `start`,
  `stop`, `install`, `uninstall`, `is_task_exists_windows`).
  Linux `systemctl` and macOS `launchctl` callers go through the
  same helpers; `no_window` is a `cfg(not(windows))` no-op for them.

New helper `local_ai/process_util::apply_no_window` keeps the
`cfg(windows)` + `creation_flags` detail out of call sites.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
senamakel pushed a commit that referenced this pull request May 11, 2026
… follow-up) (#1498)

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
AusAgentSmith pushed a commit to AusAgentSmith/openhuman that referenced this pull request May 23, 2026
AusAgentSmith pushed a commit to AusAgentSmith/openhuman that referenced this pull request May 23, 2026
…nsai#731/tinyhumansai#1338 follow-up) (tinyhumansai#1498)

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

2 participants