Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions tests/test_windows_subprocess_no_window_flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,42 @@ def fake_run(cmd, **kwargs):
assert captured[0][0][0] == "ffmpeg"
assert captured[0][1]["creationflags"] == _CREATE_NO_WINDOW

def test_checkpoint_manager_git_hides_windows(monkeypatch):
from tools import checkpoint_manager

captured = []

def fake_run(cmd, **kwargs):
captured.append((cmd, kwargs))
return _Completed(stdout="clean\n")

monkeypatch.setattr(checkpoint_manager, "windows_hide_flags", lambda: _CREATE_NO_WINDOW)
monkeypatch.setattr(checkpoint_manager.subprocess, "run", fake_run)

ok, _, _ = checkpoint_manager._run_git(["status", "--short"], Path("C:/store"), ".")
assert ok
assert captured[0][0][0] == "git"
assert captured[0][1]["creationflags"] == _CREATE_NO_WINDOW


def test_skills_hub_gh_token_hides_windows(monkeypatch):
from tools import skills_hub

captured = []

def fake_run(cmd, **kwargs):
captured.append((cmd, kwargs))
return _Completed(stdout="gho_from_cli\n")

monkeypatch.setattr(skills_hub, "windows_hide_flags", lambda: _CREATE_NO_WINDOW)
monkeypatch.setattr(skills_hub.subprocess, "run", fake_run)

auth = skills_hub.GitHubAuth.__new__(skills_hub.GitHubAuth)
assert auth._try_gh_cli() == "gho_from_cli"
assert captured[0][0] == ["gh", "auth", "token"]
assert captured[0][1]["creationflags"] == _CREATE_NO_WINDOW


def test_tui_slash_worker_hides_python_window(monkeypatch):
from tui_gateway import server

Expand Down
7 changes: 7 additions & 0 deletions tools/checkpoint_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
import time
from pathlib import Path
from hermes_constants import get_hermes_home
from hermes_cli._subprocess_compat import windows_hide_flags
from typing import Dict, List, Optional, Set, Tuple

from utils import env_int
Expand Down Expand Up @@ -321,6 +322,7 @@ def _run_git(
env = _git_env(store, str(normalized_working_dir), index_file=index_file)
cmd = ["git"] + list(args)
allowed_returncodes = allowed_returncodes or set()

try:
result = subprocess.run(
cmd,
Expand All @@ -330,6 +332,10 @@ def _run_git(
env=env,
cwd=str(normalized_working_dir),
stdin=subprocess.DEVNULL,
# Checkpoints fire several bare git calls per turn from the
# console-less desktop/gateway backend; suppress the per-call
# conhost flash on Windows (no-op on POSIX).
creationflags=windows_hide_flags(),
)
ok = result.returncode == 0
stdout = result.stdout.strip()
Expand Down Expand Up @@ -450,6 +456,7 @@ def _init_store(store: Path, working_dir: str) -> Optional[str]:
capture_output=True, text=True,
env=init_env, timeout=_GIT_TIMEOUT,
stdin=subprocess.DEVNULL,
creationflags=windows_hide_flags(),
)
if result.returncode != 0:
return f"Shadow store init failed: {result.stderr.strip()}"
Expand Down
2 changes: 2 additions & 0 deletions tools/skills_hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from datetime import datetime, timezone
from pathlib import Path, PurePosixPath
from hermes_constants import get_hermes_home
from hermes_cli._subprocess_compat import windows_hide_flags
from agent.skill_utils import is_excluded_skill_path
from typing import Any, Dict, List, Optional, Tuple, Union
from urllib.parse import urljoin, urlparse, urlunparse
Expand Down Expand Up @@ -302,6 +303,7 @@ def _try_gh_cli(self) -> Optional[str]:
["gh", "auth", "token"],
capture_output=True, text=True, timeout=5,
stdin=subprocess.DEVNULL,
creationflags=windows_hide_flags(),
)
if result.returncode == 0 and result.stdout.strip():
return result.stdout.strip()
Expand Down
7 changes: 6 additions & 1 deletion tui_gateway/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -9126,8 +9126,13 @@ def _(rid, params: dict) -> dict:
"-f", str(first_page), "-l", str(last_page),
str(pdf_path), str(out_prefix),
]
from hermes_cli._subprocess_compat import windows_hide_flags

try:
res = subprocess.run(argv, capture_output=True, text=True, timeout=120, stdin=subprocess.DEVNULL)
res = subprocess.run(
argv, capture_output=True, text=True, timeout=120, stdin=subprocess.DEVNULL,
creationflags=windows_hide_flags(),
)
except subprocess.TimeoutExpired:
return _err(rid, 5028, "pdftoppm timed out (>120s)")
if res.returncode != 0:
Expand Down
Loading