diff --git a/hermes_cli/web_server.py b/hermes_cli/web_server.py index f73a77bb655d..984c23f293dd 100644 --- a/hermes_cli/web_server.py +++ b/hermes_cli/web_server.py @@ -14962,7 +14962,12 @@ async def open_profile_terminal_endpoint(name: str): command = _profile_setup_command(name) if sys.platform.startswith("win"): - subprocess.Popen(["cmd.exe", "/c", "start", "", command]) + # Hide the intermediate cmd.exe flash; `start` still opens a + # visible terminal for the profile setup command. + subprocess.Popen( + ["cmd.exe", "/c", "start", "", command], + creationflags=windows_hide_flags(), + ) elif sys.platform == "darwin": escaped = command.replace("\\", "\\\\").replace('"', '\\"') applescript = ( diff --git a/tests/hermes_cli/test_web_server.py b/tests/hermes_cli/test_web_server.py index 2ae86afdf6c5..f47f210c2604 100644 --- a/tests/hermes_cli/test_web_server.py +++ b/tests/hermes_cli/test_web_server.py @@ -5452,14 +5452,25 @@ def test_profile_open_terminal_uses_windows_cmd(self, monkeypatch): (get_hermes_home() / "profiles" / "coder").mkdir(parents=True) calls = [] monkeypatch.setattr(web_server.sys, "platform", "win32") - monkeypatch.setattr(web_server.subprocess, "Popen", lambda args, **kwargs: calls.append(args)) + monkeypatch.setattr( + web_server, + "windows_hide_flags", + lambda: 0x08000000, + ) + monkeypatch.setattr( + web_server.subprocess, + "Popen", + lambda args, **kwargs: calls.append((args, kwargs)), + ) resp = self.client.post("/api/profiles/coder/open-terminal") assert resp.status_code == 200 assert calls - assert calls[0][:4] == ["cmd.exe", "/c", "start", ""] - assert calls[0][-1] == "coder setup" + args, kwargs = calls[0] + assert args[:4] == ["cmd.exe", "/c", "start", ""] + assert args[-1] == "coder setup" + assert kwargs.get("creationflags") == 0x08000000 def test_profiles_create_rejects_invalid_name(self): resp = self.client.post("/api/profiles", json={"name": "Has Spaces"})