Skip to content

fix(windows): hide backend console-flash legs main missed (Electron base-pythonw, ffmpeg, netstat) - #53892

Merged
OutThisLife merged 1 commit into
mainfrom
bb/windows-popup-spawn-legs
Jun 28, 2026
Merged

fix(windows): hide backend console-flash legs main missed (Electron base-pythonw, ffmpeg, netstat)#53892
OutThisLife merged 1 commit into
mainfrom
bb/windows-popup-spawn-legs

Conversation

@OutThisLife

@OutThisLife OutThisLife commented Jun 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

Follow-up to the Windows console-flash fix that landed on main (cb982ad99). That commit wired windows_hide_flags() into the auxiliary git/gh/wmic/bash/powershell/taskkill legs (notably the dashboard Projects-tree git probe — the ~118-spawns/60s flurry, #53178). This PR covers the legs it didn't reach, using the same pattern.

Confirmed still-broken on main (native Windows)

A user on main (0c2e6c00) reports terminals still flashing every ~20s, only while the Desktop GUI is running (closing the app but leaving the gateway headless → no flashes). Their desktop.log shows the cause directly:

[boot] Using existing Hermes no-console Python at C:\Users\...\venv\Scripts\pythonw.exe
[boot] Starting Hermes backend via ...\venv\Scripts\pythonw.exe
Hermes backend exited (SIGTERM)   ← then relaunched, repeatedly

The desktop launches/relaunches its Python backend through the venv Scripts\pythonw.exe, a uv launcher shim that re-execs the base console python.exe and allocates a conhost CREATE_NO_WINDOW can't suppress. main's fix is Python-only and explicitly deferred this Electron leg ("needs a Windows-tested change of its own"). It is GUI-only because only the desktop spawns the backend this way; the standalone gateway already runs windowless.

(Why it relaunches on a ~20s cadence is a separate matter — likely a slow local Ollama model, ~20s/call, tripping a desktop health-check restart — but each relaunch flashes purely because of the shim. This PR makes the relaunch windowless regardless.)

What main left open (this PR)

  • Electron backend launch (apps/desktop/electron/main.cjs)getNoConsoleVenvPython now resolves the base pythonw.exe instead of the venv Scripts\pythonw.exe re-exec shim; both backend creators put the venv site-packages on PYTHONPATH so imports still resolve under the base interpreter. This is the exact line in the log above.
  • ffmpeg in TTS / STT / Discord voice (tools/tts_tool.py, tools/transcription_tools.py, plugins/platforms/discord/adapter.py) — voice-note/speech conversions ran bare; now creationflags=windows_hide_flags().
  • netstat + taskkill in the WhatsApp bridge-port cleanup (plugins/platforms/whatsapp/adapter.py).

All windows_hide_flags() returns 0 on POSIX, so every change is a no-op off Windows. This intentionally does not re-introduce a competing chokepoint primitive or a FreeConsole bootstrap — it matches the per-call-site windows_hide_flags() convention already on main.

Tests

  • apps/desktop/electron/windows-child-process.test.cjs — asserts getNoConsoleVenvPython prefers base pythonw before the venv re-exec shim.
  • tests/test_windows_subprocess_no_window_flags.py — TTS opus conversion and local-STT audio prep pass CREATE_NO_WINDOW.

Test plan

  • Native Windows: rebuild the packaged desktop app, open Desktop, leave it running — no recurring backend-launch terminal flashes. (The Electron change requires the packaged app to be rebuilt to take effect.)

@github-actions

github-actions Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

🔎 Lint report: bb/windows-popup-spawn-legs vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 11664 on HEAD, 11662 on base (🆕 +2)

🆕 New issues (2):

Rule Count
unresolved-attribute 2
First entries
run_agent.py:3040: [unresolved-attribute] unresolved-attribute: Object of type `Self@get_credits_spent_micros` has no attribute `_credits_session_start_micros`
tests/run_agent/test_credits_notices_toggle.py:76: [unresolved-attribute] unresolved-attribute: Unresolved attribute `_credits_session_start_micros` on type `AIAgent`

✅ Fixed issues (1):

Rule Count
invalid-assignment 1
First entries
tests/run_agent/test_credits_notices_toggle.py:76: [invalid-assignment] invalid-assignment: Object of type `None` is not assignable to attribute `_credits_session_start_micros` of type `int`

Unchanged: 6123 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

@alt-glitch alt-glitch added type/bug Something isn't working comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery comp/cron Cron scheduler and job management comp/tui Terminal UI (ui-tui/ + tui_gateway/) platform/windows Native Windows-specific behavior or breakage P2 Medium — degraded but workaround exists 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: focused retry of the Windows console-flash family after the merged revert #53853 (which rolled back #53791/#53810/#53829). This PR targets only the two concrete spawn legs the revert called out — the periodic Projects-tree git probe (#53178) and the uv pythonw->python.exe re-exec phantom — rather than the rejected call-site sweep. Not a duplicate of the reverted work. Related open siblings: #53844, #44105. Flagging for the maintainer.

@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

Clean Windows-specific fixes for orphan console windows and git probe flashing.

Two well-separated concerns:

  1. detach_orphan_console(): Frees a console auto-allocated by uv's pythonw->python re-exec. Uses GetConsoleProcessList() to distinguish phantom consoles (single process) from user-interactive consoles (multiple processes). Called from gateway, web_server, and cron scheduler — never from the interactive CLI.
  2. Git probe hidden: run_git routes through windows_hide_flags() to prevent console flashing on the periodic Projects-tree probe.

Excellent test coverage:

  • POSIX no-op, solo-owner console freed, shared console preserved, no-console no-op
  • Import-time guard: FreeConsole only inside detach_orphan_console(), not in bootstrap
  • run_git routes through windows_hide_flags()

The design is careful: the function is intentionally NOT wired into import-time bootstrap because the discriminator can't tell phantom consoles apart from interactive ones. Only known-background mains call it.

No concerns. Ready to merge.


Reviewed by Hermes Agent

lpaiu-cs added a commit to lpaiu-cs/hermes-agent that referenced this pull request Jun 28, 2026
…ch#53853 revert

The first cut routed these probes through _subprocess_compat.run/popen (the
NousResearch#53810 chokepoint), but NousResearch#53853 reverted NousResearch#53791/NousResearch#53810/NousResearch#53829 — so those calls
would now AttributeError on main (the wrappers are gone; windows_hide_flags()
survived). Switch the two sites to pass creationflags=windows_hide_flags()
directly, the same surviving-helper approach NousResearch#53892 took post-revert.

Also drop the now-moot footgun changes: the console-spawn rule was reverted, so
adding tui_gateway to its --all roots no longer buys anything (and would only
surface unrelated, hasattr-guarded signal handlers in entry.py). Net change is
now just the two gateway probe sites + the test, which asserts the no-window
flag is passed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@OutThisLife OutThisLife changed the title fix(windows): hide periodic git probe + scoped console detach for re-exec phantom fix(windows): stop terminal-window popups on gateway restart and background spawns Jun 28, 2026
main (cb982ad) wired windows_hide_flags() into the auxiliary git/gh/wmic/
bash/powershell/taskkill legs but left two it didn't reach, plus the Electron
backend-launch leg it explicitly deferred. Cover them the same way:

- apps/desktop/electron/main.cjs: getNoConsoleVenvPython resolves the BASE
  pythonw.exe instead of the venv Scripts\pythonw.exe shim, which re-execs a
  console python.exe and flashes a conhost the desktop backend can't suppress.
  Both backend creators put the venv site-packages on PYTHONPATH so imports
  still resolve under the base interpreter. (main's commit said this Electron
  leg "needs a Windows-tested change of its own".)
- tools/tts_tool.py, tools/transcription_tools.py, plugins/platforms/discord:
  ffmpeg conversions (voice notes / TTS / STT) via windows_hide_flags().
- plugins/platforms/whatsapp: netstat + taskkill bridge-port cleanup via
  windows_hide_flags().

All no-ops on POSIX. Tests assert the base-pythonw preference and the ffmpeg
legs pass CREATE_NO_WINDOW.
@OutThisLife
OutThisLife force-pushed the bb/windows-popup-spawn-legs branch from 393b040 to eeca59f Compare June 28, 2026 15:19
@OutThisLife OutThisLife changed the title fix(windows): stop terminal-window popups on gateway restart and background spawns fix(windows): hide backend console-flash legs main missed (Electron base-pythonw, ffmpeg, netstat) Jun 28, 2026
@OutThisLife
OutThisLife merged commit 0209665 into main Jun 28, 2026
35 checks passed
@OutThisLife
OutThisLife deleted the bb/windows-popup-spawn-legs branch June 28, 2026 16:16
This was referenced Jun 28, 2026
waefrebeorn pushed a commit to waefrebeorn/slermes that referenced this pull request Jul 2, 2026
habarmc1223-sudo pushed a commit to habarmc1223-sudo/hermes-agent-fluxmem that referenced this pull request Jul 8, 2026
santhreal pushed a commit to santhreal/hermes-agent that referenced this pull request Jul 13, 2026
Gravezzz pushed a commit to Gravezzz/hermes-agent that referenced this pull request Jul 21, 2026
leewenjie pushed a commit to leewenjie/hermes-agent that referenced this pull request Aug 7, 2026
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 comp/cron Cron scheduler and job management comp/gateway Gateway runner, session dispatch, delivery comp/tui Terminal UI (ui-tui/ + tui_gateway/) 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.

3 participants