Skip to content

fix(windows): hide conhost window spawned with core sidecar#731

Merged
M3gA-Mind merged 1 commit into
tinyhumansai:mainfrom
CodeGhost21:fix/windows-hide-core-console-window
Apr 21, 2026
Merged

fix(windows): hide conhost window spawned with core sidecar#731
M3gA-Mind merged 1 commit into
tinyhumansai:mainfrom
CodeGhost21:fix/windows-hide-core-console-window

Conversation

@CodeGhost21
Copy link
Copy Markdown
Contributor

@CodeGhost21 CodeGhost21 commented Apr 21, 2026

Summary

On Windows, launching the installed OpenHuman.exe pops a stray conhost (terminal) window on top of the app. The GUI shell is built with windows_subsystem = "windows" (no console), but the openhuman-core sidecar is a console-subsystem executable — kept that way intentionally so that openhuman core run works as a normal CLI in a terminal. When the GUI shell spawns the console sidecar as a child without CREATE_NO_WINDOW, Windows allocates a fresh console window for it.

Fix: pass CREATE_NO_WINDOW (0x08000000) at every site where the GUI launches a core subprocess. Non-Windows platforms get a no-op helper so the call sites stay identical.

Changes

  • app/src-tauri/src/core_process.rs
    • New apply_core_no_window(&mut Command) helper — sets CREATE_NO_WINDOW on Windows, no-op elsewhere.
    • Applied at both sidecar spawn paths (CoreRunMode::InProcess fallback and CoreRunMode::ChildProcess).
  • app/src-tauri/src/lib.rs
    • Same flag applied to the short-lived run_core_cli subprocess used by service_install_direct / service_start_direct / service_stop_direct / service_status_direct.

Stdout/stderr piping (used for our log forwarding) is unaffected — CREATE_NO_WINDOW only suppresses the window, not the handles.

Why the core binary stays console-subsystem

The core binary at src/main.rs is intentionally not marked windows_subsystem = "windows" so that running it directly from a terminal (openhuman core run, service CLI, etc.) behaves like a normal CLI tool with visible stdout/stderr. Flipping the subsystem would break that UX. Suppressing the window at the spawner is the right layer.

Test plan

  • Build a Windows installer from this branch and launch the installed app — verify no conhost window appears on top.
  • Run openhuman core run directly from a Windows terminal — CLI output still visible (unchanged).
  • Trigger a service CLI command from the app UI (service_install_direct etc.) — no window flash; command still returns expected output.
  • macOS / Linux regression check: yarn tauri dev still starts the sidecar and RPC becomes ready as before.
  • Log forwarding from the sidecar to the shell's logs is unaffected.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed unnecessary console window appearing on Windows when running the core process in the background. The window is now suppressed while maintaining all logging and output functionality.

The core binary is a console-subsystem .exe so `openhuman core run`
works correctly in a terminal. When the GUI shell (which is built with
`windows_subsystem = "windows"`) spawns it as a child without the
`CREATE_NO_WINDOW` creation flag, Windows allocates a fresh conhost
window that pops up on top of the app.

Apply `CREATE_NO_WINDOW` (0x08000000) at every site where the GUI
launches a core subprocess:

- `core_process.rs`: both sidecar spawn paths (`CoreRunMode::InProcess`
  fallback and `CoreRunMode::ChildProcess`).
- `lib.rs`: the short-lived `run_core_cli` used by `service_*_direct`
  commands.

Non-Windows builds get a no-op helper, so the cross-platform call sites
stay identical. Stdout/stderr piping for log forwarding is unaffected.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 21, 2026

📝 Walkthrough

Walkthrough

The changes suppress console windows for Tauri core sidecar processes spawned on Windows by adding platform-specific command configuration. Two separate code paths are updated to set the CREATE_NO_WINDOW flag while maintaining stdout/stderr piping for logging.

Changes

Cohort / File(s) Summary
Windows Console Suppression
app/src-tauri/src/core_process.rs, app/src-tauri/src/lib.rs
Added platform-specific helpers to suppress console windows for core process spawning. Introduces apply_core_no_window() helper in core_process.rs and inline CommandExt::creation_flags(CREATE_NO_WINDOW) configuration in lib.rs's run_core_cli(), preserving stdout/stderr piping for logging.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 Console windows fade from sight,
Hidden flags make processes right,
Logs still flow where they belong,
A quieter dance, clean and strong! ✨

🚥 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 clearly and specifically describes the main change: hiding the conhost window on Windows when spawning the core sidecar process.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
app/src-tauri/src/lib.rs (1)

225-230: Deduplicate CREATE_NO_WINDOW configuration across spawn paths.

This block duplicates the Windows flag logic already introduced in app/src-tauri/src/core_process.rs (apply_core_no_window). Centralizing this behavior would reduce drift risk between service-direct CLI execution and core sidecar spawning.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/src-tauri/src/lib.rs` around lines 225 - 230, The Windows-specific
CREATE_NO_WINDOW setup in the lib.rs spawn path is a duplicate of the logic in
apply_core_no_window (core_process.rs); remove the inline #[cfg(windows)] block
that defines CREATE_NO_WINDOW and calls cmd.creation_flags(...) and instead
factor that behavior into a shared helper (or directly call
apply_core_no_window) so both the service-direct CLI spawn and the core sidecar
spawn use the same function; ensure the helper accepts the Command (or mutable
reference used as cmd) and applies creation_flags(CREATE_NO_WINDOW) on Windows
to keep behavior centralized.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@app/src-tauri/src/lib.rs`:
- Around line 225-230: The Windows-specific CREATE_NO_WINDOW setup in the lib.rs
spawn path is a duplicate of the logic in apply_core_no_window
(core_process.rs); remove the inline #[cfg(windows)] block that defines
CREATE_NO_WINDOW and calls cmd.creation_flags(...) and instead factor that
behavior into a shared helper (or directly call apply_core_no_window) so both
the service-direct CLI spawn and the core sidecar spawn use the same function;
ensure the helper accepts the Command (or mutable reference used as cmd) and
applies creation_flags(CREATE_NO_WINDOW) on Windows to keep behavior
centralized.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8d7bcf9a-24ad-4dca-9eb8-f0558956ea44

📥 Commits

Reviewing files that changed from the base of the PR and between 1792135 and 35baed1.

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

@M3gA-Mind M3gA-Mind merged commit 63bc463 into tinyhumansai:main Apr 21, 2026
7 of 8 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
…nsai#731)

The core binary is a console-subsystem .exe so `openhuman core run`
works correctly in a terminal. When the GUI shell (which is built with
`windows_subsystem = "windows"`) spawns it as a child without the
`CREATE_NO_WINDOW` creation flag, Windows allocates a fresh conhost
window that pops up on top of the app.

Apply `CREATE_NO_WINDOW` (0x08000000) at every site where the GUI
launches a core subprocess:

- `core_process.rs`: both sidecar spawn paths (`CoreRunMode::InProcess`
  fallback and `CoreRunMode::ChildProcess`).
- `lib.rs`: the short-lived `run_core_cli` used by `service_*_direct`
  commands.

Non-Windows builds get a no-op helper, so the cross-platform call sites
stay identical. Stdout/stderr piping for log forwarding is unaffected.
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