Skip to content

fix(windows): hide backend subprocess windows by default - #53879

Closed
helix4u wants to merge 1 commit into
NousResearch:mainfrom
helix4u:fix/windows-hidden-subprocess-defaults
Closed

fix(windows): hide backend subprocess windows by default#53879
helix4u wants to merge 1 commit into
NousResearch:mainfrom
helix4u:fix/windows-hidden-subprocess-defaults

Conversation

@helix4u

@helix4u helix4u commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Suppresses Windows terminal/cmd/conhost flashes from Hermes background subprocesses by making hidden child process launches the default for Hermes Python backend entry points, then tightens the remaining no-window paths hit while reproducing Desktop startup/session-load flashes.

The main behavioral change is in hermes_bootstrap.py: on Windows, Hermes now patches subprocess.Popen at bootstrap time so raw Python subprocess.run(...) / Popen(...) call sites inherit CREATE_NO_WINDOW and hidden STARTUPINFO unless the caller explicitly asks for a new console. This matches the product expectation that Desktop/gateway/provider/session loading should not flash terminals while doing background work.

The PR also keeps the MCP stdio launcher hidden even through the MCP SDK fallback path, and routes several Git/GitHub/catalog/TUI helper subprocesses through the existing no-window subprocess helper.

This branch has been rebased onto current main after #53853 reverted the prior terminal-popup PR stack (#53791, #53810, #53829). It is intentionally a single squashed commit on top of that rollback.

This overlaps the Windows terminal-popup PR family, especially #53291, #41078, #53390, and #53542. This branch packages the local Windows/Desktop repro work as one reviewable bundle rather than another single callsite patch.

Related Issue

Fixes #53282
Related: #53370, #53342, #53273, #53065, #53016, #53424
Related PRs / overlap: #53291, #41078, #53390, #53542

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • hermes_bootstrap.py: install a Windows-only, idempotent subprocess.Popen subclass wrapper from the existing bootstrap path so Python backend children default to hidden console/window settings.
  • tools/mcp_tool.py: patch the MCP SDK stdio Windows process factory so configured stdio MCP servers keep CREATE_NO_WINDOW and hidden startup info even if AnyIO process creation falls back to synchronous subprocess.Popen.
  • hermes_cli/banner.py, hermes_cli/copilot_auth.py, hermes_cli/main.py, hermes_cli/mcp_catalog.py, tui_gateway/server.py: route Git/GitHub/catalog/update/TUI helper subprocesses through Hermes' existing no-window subprocess helper.
  • hermes_cli/main.py: preserve quarantined Windows entry-point shims if an install/update exits successfully without rewriting the replacement shim.
  • apps/desktop/electron/windows-child-process.test.cjs: tighten desktop child-process invariants around hidden Windows child options.
  • tests/hermes_cli/test_update_autostash.py, tests/hermes_cli/test_update_concurrent_quarantine.py: update focused tests for the update/quarantine behavior touched here.

How to Test

  1. On Windows, launch Hermes Desktop from a GUI context and watch startup through blank/silent load, connecting screen, and session/sidebar load. No terminal/cmd/conhost windows should flash during those background transitions.
  2. With a configured stdio MCP server such as Docker MCP, relaunch Desktop and verify MCP startup does not create visible terminal windows.
  3. Send a simple prompt from Desktop and verify provider/session/tool initialization does not flash terminal windows.
  4. Run the focused checks listed below.

Focused local checks run after rebase:

  • git diff --check origin/main...HEAD
  • venv\Scripts\python.exe -m py_compile hermes_bootstrap.py tools\mcp_tool.py hermes_cli\banner.py hermes_cli\copilot_auth.py hermes_cli\main.py hermes_cli\mcp_catalog.py tui_gateway\server.py
  • No-spawn assertion that hermes_bootstrap patches subprocess.Popen, injects CREATE_NO_WINDOW, preserves explicit CREATE_NEW_CONSOLE, and adds hidden startup info.
  • No-spawn assertion that the MCP stdio process factory is patched and injects CREATE_NO_WINDOW plus hidden startup info.

Not run locally:

  • Full pytest tests/ -q. Local Windows full-suite runs have been unsafe/noisy in this checkout, and this PR was validated with focused compile/static/no-spawn checks plus manual Desktop observation.

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: Windows 11 / Hermes Desktop local AppData checkout

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

For New Skills

N/A

Screenshots / Logs

N/A. This is a Windows process-window visibility fix; local verification used no-spawn assertions and manual Desktop startup/prompt observation.

@helix4u
helix4u force-pushed the fix/windows-hidden-subprocess-defaults branch 2 times, most recently from 12ed42b to e761fc0 Compare June 28, 2026 00:49
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/cli CLI entry point, hermes_cli/, setup wizard platform/windows Native Windows-specific behavior or breakage sweeper:risk-platform-windows Sweeper risk: may break or behave differently on native Windows labels Jun 28, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Related to the open Windows console-flash cluster: #53358 (CREATE_BREAKAWAY_FROM_JOB under the Desktop Win32 Job Object), #53390 (copilot_auth gh-token site), #53542, #53291, #41078, and #44043 (tools_config subprocess calls), plus issue #53282 which this Fixes. This PR takes a different, broader approach -- a bootstrap-wide subprocess.Popen monkeypatch that makes hidden launches the default -- rather than patching individual call sites. Flagging the cluster so a maintainer can choose between this consolidated bundle and the per-callsite PRs; not closing either.

@helix4u
helix4u force-pushed the fix/windows-hidden-subprocess-defaults branch from e761fc0 to ead0f4e Compare June 28, 2026 00:57

@tonydwb tonydwb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review Summary

Verdict: Approved

Windows subprocess window hiding (11 files, +334/-63). Well-structured fix:

  • Extends the existing hiddenWindowsChildOptions pattern to additional spawn sites (updater, etc.)
  • Properly tests all call sites via requireAllHiddenChildOptions test helper
  • Removes the windowsHide: false assertion that was covering one intentional case (now handled by the test helper)
  • hermes_bootstrap.py changes add Windows-specific subprocess handling with proper platform guards

The test helper approach is thorough — it catches future regressions when new spawn sites are added. No concerns about the implementation.

@helix4u
helix4u marked this pull request as ready for review June 28, 2026 01:08

@tonydwb tonydwb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review Summary

Verdict: Approved

Comprehensive fix for Windows child process window flashing (11 files, +334/-63). Well-structured approach:

  1. hermes_bootstrap.py: Adds apply_windows_subprocess_defaults() — process-wide Popen wrapper that defaults to CREATE_NO_WINDOW + hidden STARTUPINFO
  2. hermes_cli/_subprocess_compat.py: Adds run() and popen() convenience wrappers with hidden defaults
  3. All call sites updated to use the compat wrappers where appropriate
  4. HERMES_ALLOW_VISIBLE_SUBPROCESSES=1 escape hatch for debugging
  5. Tests extended with requireAllHiddenChildOptions helper to verify all updater spawn sites

The test helper approach is thorough — it catches future regressions when new spawn sites are added. The CREATE_NEW_CONSOLE guard ensures explicit console requests are respected.

No concerns. Ready to merge.


Reviewed by Hermes Agent

@helix4u

helix4u commented Jun 28, 2026

Copy link
Copy Markdown
Contributor Author

i mean... it's working wonders for me rn. so... idk.

@teknium1

Copy link
Copy Markdown
Contributor

Closing as superseded by the consolidated Windows console-flash work tracked in #54220.

The relevant pieces from this PR/cluster have now landed through the targeted follow-up PRs #54236, #53892, and #54417, or are recorded in the umbrella tracker for any remaining native-Windows verification. Keeping this separate PR open would duplicate the tracker and the merged follow-up work.

Thanks for digging into this — the reports and PRs in this cluster helped identify the remaining spawn legs.

@teknium1 teknium1 closed this Jun 28, 2026
@helix4u

helix4u commented Jun 28, 2026

Copy link
Copy Markdown
Contributor Author

rip. kinda still think we need that catch all for python in bootstrap or something similar. the shouldnt be a find and fix every place thing. and i'm getting them a lot again an main, just not as persistent. spurts.

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

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists platform/windows Native Windows-specific behavior or breakage sweeper:risk-platform-windows Sweeper risk: may break or behave differently on native Windows type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows: Console window flashes on every subprocess call (missing CREATE_NO_WINDOW)

4 participants