Skip to content
Closed
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
7 changes: 6 additions & 1 deletion hermes_cli/web_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand Down
17 changes: 14 additions & 3 deletions tests/hermes_cli/test_web_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"})
Expand Down