fix(computer-use): hide Windows cua-driver subprocess consoles

Apply windows_hide_flags() (CREATE_NO_WINDOW; 0 on POSIX) at the
Windows-reachable cua-driver subprocess boundaries: manifest probe,
update checker, CLI fallback transport, doctor health-report spawn,
and the permissions/status runner. Prevents OpenConsole/Windows
Terminal windows flashing into the foreground when spawned from
GUI-backed Gateway/Desktop processes.

The env-probe half of the original PR was already implemented on main
and is not re-applied here.

Salvaged from #62821 by @ZundamonnoVRChatkaisetu (original commits
carried a placeholder 'Claude Code Enterprise' identity; re-authored
to the contributor's GitHub identity).
This commit is contained in:
ZundamonnoVRChatkaisetu 2026-07-29 08:57:36 -07:00 committed by Teknium
parent 88c19a4edf
commit 50e27abdd3
4 changed files with 120 additions and 0 deletions

View file

@ -50,6 +50,7 @@ import threading
import uuid
from typing import Any, Dict, List, Optional, Tuple
from hermes_cli._subprocess_compat import windows_hide_flags
from tools.computer_use.backend import (
ActionResult,
CaptureResult,
@ -381,6 +382,7 @@ def _resolve_mcp_invocation(
[driver_cmd, "manifest"],
capture_output=True, text=True, encoding="utf-8", errors="replace", timeout=timeout,
stdin=subprocess.DEVNULL,
creationflags=windows_hide_flags(),
# cua-driver is a third-party binary — never hand it provider
# API keys via inherited env (same policy as the MCP and CLI
# fallback spawns below; #53503/#55709/#58889 lineage).
@ -589,6 +591,7 @@ def cua_driver_update_check(*, timeout: Optional[float] = None) -> Optional[Dict
# stdin-reading mode rather than erroring — DEVNULL gives them EOF
# so they exit fast instead of blocking until the timeout.
stdin=subprocess.DEVNULL,
creationflags=windows_hide_flags(),
# Sanitized like every other cua-driver spawn: third-party
# binary, no inherited provider keys (#53503/#55709/#58889).
env=_sanitize_subprocess_env(cua_driver_child_env()),
@ -1330,6 +1333,7 @@ class _CuaDriverSession:
try:
proc = _subprocess.run(
cmd, capture_output=True, text=True, encoding="utf-8", errors="replace", timeout=max(15.0, timeout),
creationflags=windows_hide_flags(),
env=_sanitize_subprocess_env(cua_driver_child_env()),
)
except Exception as e: # pragma: no cover - subprocess spawn failure

View file

@ -30,6 +30,8 @@ import subprocess
import sys
from typing import Any, Dict, List, Optional, Sequence, Tuple
from hermes_cli._subprocess_compat import windows_hide_flags
# Match the ALLOWED_STATUS_VALUES + ALLOWED_OVERALL_VALUES the cua-driver
# integration test pins. If health_report widens its vocabulary, add here.
@ -215,6 +217,7 @@ def _open_mcp(binary: str) -> subprocess.Popen:
encoding="utf-8",
errors="replace",
bufsize=1,
creationflags=windows_hide_flags(),
env=_sanitized_cua_env(),
)

View file

@ -29,6 +29,8 @@ import subprocess
import sys
from typing import Any, Dict, List, Optional
from hermes_cli._subprocess_compat import windows_hide_flags
# Platforms with a cua-driver runtime backend (mirrors the toolset platform_gate).
_RUNTIME_PLATFORMS = frozenset({"darwin", "win32", "linux"})
_BOOLS = ("accessibility", "screen_recording", "screen_recording_capturable")
@ -70,6 +72,7 @@ def _run(binary: str, *args: str, timeout: float) -> subprocess.CompletedProcess
timeout=timeout,
env=_child_env(),
stdin=subprocess.DEVNULL,
creationflags=windows_hide_flags(),
)