Skip to content

The agent that grows with you

fix(desktop): forward --profile on the bundled-install launch too

Hermes Agent2f86fae3bea1
diff --git a/hermes_cli/main_desktop.py b/hermes_cli/main_desktop.py
index 9c0d52c310c..1bb6334ca6d 100644
--- a/hermes_cli/main_desktop.py
+++ b/hermes_cli/main_desktop.py
@@ -1543,11 +1543,7 @@ def cmd_gui(args: argparse.Namespace):
launch_command.extend(config_electron_flags)
if getattr(args, "local", False):
launch_command.append("--local")
- # Explicit -p/--profile only. A bare `hermes desktop` must not forward the
- # sticky CLI profile — Electron would persist it over the stored desktop one.
- from hermes_cli.main import explicit_cli_profile
- if profile := explicit_cli_profile():
- launch_command.extend(["--profile", profile])
+ launch_command.extend(_explicit_profile_args())
if not source_mode:
desktop_launch_notice(f"→ Launching packaged Hermes Desktop: {' '.join(launch_command)}")
pass_fds: tuple[int, ...] = ()
@@ -1613,6 +1609,18 @@ def cmd_gui(args: argparse.Namespace):
sys.exit(launch_result.returncode)
+def _explicit_profile_args() -> list[str]:
+ """``--profile <name>`` for Electron when ``-p``/``--profile`` was on argv.
+
+ Explicit flag only. A bare `hermes desktop` must not forward the sticky CLI
+ profile — Electron would persist it over the stored desktop one.
+ """
+ from hermes_cli.main import explicit_cli_profile
+
+ profile = explicit_cli_profile()
+ return ["--profile", profile] if profile else []
+
+
def _launch_bundled_desktop(
args: argparse.Namespace, env: dict, electron_flags: list[str]
) -> None:
@@ -1668,6 +1676,7 @@ def _launch_bundled_desktop(
sys.exit(1)
launch_command.extend(electron_flags)
+ launch_command.extend(_explicit_profile_args())
pid = launch_detached(launch_command, env=env, cwd=layout.app_root)
print(f"→ Launched Hermes Desktop: {' '.join(launch_command)} (pid {pid})")
sys.exit(0)
diff --git a/tests/hermes_cli/test_bundled_desktop_launch.py b/tests/hermes_cli/test_bundled_desktop_launch.py
index 14c383ab389..23e8303afc7 100644
--- a/tests/hermes_cli/test_bundled_desktop_launch.py
+++ b/tests/hermes_cli/test_bundled_desktop_launch.py
@@ -269,6 +269,25 @@ class TestCmdGuiOnABundle:
assert builds == []
assert launches == [[str(launcher)]]
+ def test_explicit_profile_reaches_the_bundled_launcher(self, tmp_path, monkeypatch):
+ """`hermes -p work desktop` on a bundle hands Electron --profile work."""
+ repo, launcher = _host_bundle(tmp_path / "app")
+ # HERMES_HOME outside the platform home is the root itself on every OS.
+ root = tmp_path / "hermes-root"
+ profile = root / "profiles" / "work"
+ profile.mkdir(parents=True)
+ (profile / "config.yaml").write_text("{}\n", encoding="utf-8")
+ monkeypatch.setenv("HERMES_HOME", str(root))
+ monkeypatch.setattr(sys, "argv", ["hermes", "-p", "work", "desktop"])
+ monkeypatch.setattr(cli_main, "_explicit_cli_profile", None)
+ cli_main._apply_profile_override()
+
+ code, builds, launches = self._run(monkeypatch, repo, self._args())
+
+ assert code == 0
+ assert builds == []
+ assert launches == [[str(launcher), "--profile", "work"]]
+
def test_a_checkout_still_takes_the_build_ladder(self, tmp_path, monkeypatch):
checkout = tmp_path / "hermes-agent"
(checkout / "apps" / "desktop").mkdir(parents=True)
diff --git a/tests/hermes_cli/test_desktop_profile_launch.py b/tests/hermes_cli/test_desktop_profile_launch.py
index 88fa3bed248..9e4387e0ca0 100644
--- a/tests/hermes_cli/test_desktop_profile_launch.py
+++ b/tests/hermes_cli/test_desktop_profile_launch.py
@@ -99,6 +99,8 @@ def _launch_command(tmp_path, monkeypatch, argv: list[str], *, active_profile: s
monkeypatch.setattr(sys, "argv", argv)
monkeypatch.setattr(cli_main, "PROJECT_ROOT", project)
monkeypatch.setattr(main_desktop, "_desktop_exe_integrity_error", lambda _path: None)
+ # Module global: restore it so a later cmd_gui test does not inherit a flag.
+ monkeypatch.setattr(cli_main, "_explicit_cli_profile", None)
cli_main._apply_profile_override()