hermes-agent/apps/desktop/electron
brooklyn! 5db1430af9
fix(windows): stop terminal-window popups from background spawns (#53810)
* fix(windows): stop terminal-window popups from background spawns

Native-Windows desktop/gateway users saw cmd/conhost windows flash on
gateway restart, image paste, the dashboard Projects tree, voice notes,
and ~5 min after closing the app (detached cron). Two root causes:

- Console-subsystem exes (taskkill, schtasks, wmic, netstat, tasklist,
  agent-browser, git, ffmpeg, powershell, git-bash) spawned via raw
  subprocess allocate a fresh console when the launching process has
  none (pythonw desktop backend / detached gateway) - even with output
  captured.
- uv venv pythonw shims re-exec console python.exe, so Python children
  get a console regardless of how they're launched.

Fixes:
- Single hidden-spawn primitive (_subprocess_compat.run/.popen) that ORs
  CREATE_NO_WINDOW on Windows, no-op on POSIX. Route every Hermes-owned
  console-exe spawn through it.
- FreeConsole() catch-all in hermes_bootstrap: any Python child that
  exclusively owns an auto-allocated console detaches it at startup
  (GetConsoleProcessList()==1 gate leaves shared interactive consoles
  untouched).
- Replace PowerShell/wmic gateway PID scans with in-process psutil.
- Skip schtasks queries on non-interactive desktop restarts.
- Prefer native agent-browser .exe over .cmd shims.
- Guard test bans raw subprocess spawns of the Windows-only console
  tools repo-wide so the popup class can't regress.

* fix(windows): scope FreeConsole to background entry points; fix merge fallout

Console detach review (per #53810 feedback): GetConsoleProcessList()==1 can't
tell a uv pythonw->python phantom console apart from a user opening the
interactive CLI/TUI in its own fresh console (double-click, shortcut, ConPTY) —
both report a single attached process with a tty. Running FreeConsole() in the
import-time bootstrap therefore risked detaching a legitimately-interactive
terminal.

- Extract FreeConsole into explicit hermes_bootstrap.detach_orphan_console();
  remove it from apply_windows_utf8_bootstrap() (import side effect).
- Call it only from known background mains: gateway run, dashboard backend
  (start_server, what the desktop spawns), cron standalone, tui_gateway entry,
  slash worker. Interactive CLI/TUI never calls it.
- Behavior-contract tests: frees only when solo owner, leaves shared console,
  no-op without console / on POSIX, and asserts it's not an import side effect.

Merge fallout from origin/main (#53791):
- local.py: 3-way merge left a dangling **_popen_kwargs (NameError crashing
  every terminal init). _subprocess_compat.popen already hides the window, so
  drop it.
- discord adapter: merge stacked an undefined windows_hide_flags() onto the
  primitive call; drop the redundant arg.
- test_gateway: scan now goes psutil-first (zero spawn); rewrite the
  case-variant test to drive that production path.

* test(claw): mock _subprocess_compat.run seam for Windows process scan

claw.py's Windows tasklist/powershell scan routes through the hidden-spawn
primitive; the tests still patched claw_mod.subprocess, so on win32 the mock
was never hit and real spawns returned nothing. Patch the actual seam.
2026-06-27 14:02:24 -07:00
..
backend-env.cjs style(desktop,tui): fix all lint/type/formatting issues 2026-06-26 01:04:33 -05:00
backend-env.test.cjs style(desktop,tui): fix all lint/type/formatting issues 2026-06-26 01:04:33 -05:00
backend-probes.cjs Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00
backend-probes.test.cjs chore(desktop): zero eslint/typecheck debt + prettier pass (#39100) 2026-06-04 14:10:38 +00:00
backend-ready.cjs style(desktop,tui): fix all lint/type/formatting issues 2026-06-26 01:04:33 -05:00
backend-ready.test.cjs style(desktop,tui): fix all lint/type/formatting issues 2026-06-26 01:04:33 -05:00
bootstrap-platform.cjs chore(desktop): zero eslint/typecheck debt + prettier pass (#39100) 2026-06-04 14:10:38 +00:00
bootstrap-platform.test.cjs chore(desktop): zero eslint/typecheck debt + prettier pass (#39100) 2026-06-04 14:10:38 +00:00
bootstrap-runner.cjs style(desktop,tui): fix all lint/type/formatting issues 2026-06-26 01:04:33 -05:00
bootstrap-runner.test.cjs fix(desktop): bootstrap falls back to installed agent install.sh on GitHub 404 2026-06-07 03:46:12 -07:00
connection-config.cjs style(desktop,tui): fix all lint/type/formatting issues 2026-06-26 01:04:33 -05:00
connection-config.test.cjs fix(desktop): route global remote profile REST calls (#47011) 2026-06-15 23:24:55 -05:00
dashboard-token.cjs refactor(desktop): use native fetch in dashboard-token 2026-06-11 18:41:16 -05:00
dashboard-token.test.cjs refactor(desktop): fold served-token adoption + foreign-backend refusal into one helper 2026-06-11 18:33:05 -05:00
desktop-uninstall.cjs style(desktop,tui): fix all lint/type/formatting issues 2026-06-26 01:04:33 -05:00
desktop-uninstall.test.cjs style(desktop,tui): fix all lint/type/formatting issues 2026-06-26 01:04:33 -05:00
embed-referer.cjs feat(desktop): lazy embed renderers + fenced diagrams/alerts 2026-06-26 03:22:08 -05:00
entitlements.mac.inherit.plist fix(desktop): inherit microphone entitlement for macOS helpers 2026-06-03 07:32:00 +07:00
entitlements.mac.plist Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00
fs-read-dir.cjs style(desktop,tui): fix all lint/type/formatting issues 2026-06-26 01:04:33 -05:00
fs-read-dir.test.cjs style(desktop,tui): fix all lint/type/formatting issues 2026-06-26 01:04:33 -05:00
gateway-ws-probe.cjs test(desktop): add injectable gateway WebSocket probe + unit tests 2026-06-04 19:49:06 -07:00
gateway-ws-probe.test.cjs test(desktop): add injectable gateway WebSocket probe + unit tests 2026-06-04 19:49:06 -07:00
git-repo-scan.cjs style(desktop,tui): fix all lint/type/formatting issues 2026-06-26 01:04:33 -05:00
git-review-ops.cjs style(desktop,tui): fix all lint/type/formatting issues 2026-06-26 01:04:33 -05:00
git-review-ops.test.cjs feat(desktop): add git worktree and review IPC 2026-06-25 16:40:27 -05:00
git-root.cjs fix(desktop): Harden local file tree paths (#43618) 2026-06-11 10:05:59 -04:00
git-root.test.cjs fix(desktop): Harden local file tree paths (#43618) 2026-06-11 10:05:59 -04:00
git-worktree-ops.cjs style(desktop,tui): fix all lint/type/formatting issues 2026-06-26 01:04:33 -05:00
git-worktree-ops.test.cjs fix(desktop): clarify branch convert actions 2026-06-25 17:19:36 -05:00
hardening.cjs style(desktop,tui): fix all lint/type/formatting issues 2026-06-26 01:04:33 -05:00
hardening.test.cjs feat(desktop): composer status stack, live subagent windows, editable prompts (#44630) 2026-06-12 08:30:06 -05:00
link-title-window.cjs fix(desktop): mute hidden link-title window so historical links don't autoplay audio 2026-06-20 14:53:05 +05:30
link-title-window.test.cjs test(desktop): cover link-title window audio muting 2026-06-20 14:53:05 +05:30
main.cjs fix(windows): stop terminal-window popups from background spawns (#53810) 2026-06-27 14:02:24 -07:00
oauth-net-request.cjs fix(desktop): avoid restricted oauth request header 2026-06-05 18:04:45 -07:00
oauth-net-request.test.cjs style(desktop,tui): fix all lint/type/formatting issues 2026-06-26 01:04:33 -05:00
preload.cjs feat(desktop): add git worktree and review IPC 2026-06-25 16:40:27 -05:00
session-windows.cjs fix(desktop): keep streaming painting in unfocused secondary chat windows (#47919) 2026-06-17 14:40:13 -04:00
session-windows.test.cjs fix(desktop): keep streaming painting in unfocused secondary chat windows (#47919) 2026-06-17 14:40:13 -04:00
titlebar-overlay-width.cjs fix(desktop): WSL titlebar layout and WSL2 GPU acceleration 2026-06-25 23:50:59 -05:00
titlebar-overlay-width.test.cjs fix(desktop): WSL titlebar layout and WSL2 GPU acceleration 2026-06-25 23:50:59 -05:00
update-count.cjs fix(desktop): skip the rev-list count when it is discarded anyway 2026-06-24 19:12:09 -05:00
update-count.test.cjs style(desktop,tui): fix all lint/type/formatting issues 2026-06-26 01:04:33 -05:00
update-marker.cjs fix(desktop/windows): stop in-app update from cascading into a backend restart loop (#50381) 2026-06-21 13:10:32 -07:00
update-marker.test.cjs fix(desktop/windows): stop in-app update from cascading into a backend restart loop (#50381) 2026-06-21 13:10:32 -07:00
update-rebuild.cjs fix(desktop): retry the self-update rebuild once so the app relaunches (#48122) 2026-06-17 19:33:27 -05:00
update-rebuild.test.cjs fix(desktop): retry the self-update rebuild once so the app relaunches (#48122) 2026-06-17 19:33:27 -05:00
update-relaunch.cjs fix(desktop): relaunch on Linux after in-app update instead of hanging (#45205) 2026-06-21 17:04:52 -07:00
update-relaunch.test.cjs style(desktop,tui): fix all lint/type/formatting issues 2026-06-26 01:04:33 -05:00
update-remote.cjs style(desktop,tui): fix all lint/type/formatting issues 2026-06-26 01:04:33 -05:00
update-remote.test.cjs test(desktop): cover official-SSH remote detection for passive updates 2026-06-11 12:53:19 +05:30
vscode-marketplace.cjs style(desktop,tui): fix all lint/type/formatting issues 2026-06-26 01:04:33 -05:00
vscode-marketplace.test.cjs feat(desktop): install any VS Code theme from the Marketplace 2026-06-09 23:06:44 -05:00
window-state.cjs feat(desktop): remember window size/position/maximized across launches (salvage #39154) 2026-06-24 13:32:05 -05:00
window-state.test.cjs style(desktop,tui): fix all lint/type/formatting issues 2026-06-26 01:04:33 -05:00
windows-child-process.test.cjs style(desktop,tui): fix all lint/type/formatting issues 2026-06-26 01:04:33 -05:00
windows-user-env.cjs style(desktop,tui): fix all lint/type/formatting issues 2026-06-26 01:04:33 -05:00
windows-user-env.test.cjs style(desktop,tui): fix all lint/type/formatting issues 2026-06-26 01:04:33 -05:00
workspace-cwd.cjs style(desktop,tui): fix all lint/type/formatting issues 2026-06-26 01:04:33 -05:00
workspace-cwd.test.cjs style(desktop,tui): fix all lint/type/formatting issues 2026-06-26 01:04:33 -05:00
wsl-clipboard-image.cjs fix(desktop): WSL2 clipboard image paste + Linux titlebar overlay 2026-06-25 23:50:59 -05:00
wsl-clipboard-image.test.cjs fix(desktop): WSL2 clipboard image paste + Linux titlebar overlay 2026-06-25 23:50:59 -05:00