The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(dashboard): isolate packaged renderer from browser launches
fangliquanaa14b81423fc
diff --git a/hermes_cli/main.py b/hermes_cli/main.pyindex 09c2b6efbde..8ff5d0ddcc2 100644--- a/hermes_cli/main.py+++ b/hermes_cli/main.py@@ -2555,14 +2555,15 @@ def _dashboard_sanitize_desktop_env(headless_backend) -> None:HERMES_SERVE_HEADLESS=1). A shell inheriting those then running`hermes dashboard` would serve the desktop renderer ("Desktop IPC bridgeis unavailable", #52945) or disable the SPA. Only Electron-packaged- WEB_DIST contamination is stripped — caller-managed overrides (dev /- custom builds) must still work, and the desktop-spawned backend itself- (HERMES_DESKTOP=1) keeps its dist. Headless `serve` re-sets- HERMES_SERVE_HEADLESS itself.+ WEB_DIST contamination is stripped from browser dashboards — caller-managed+ overrides (dev / custom builds) must still work, while headless `serve`+ keeps the packaged path used by the Desktop backend. Headless `serve`+ re-sets HERMES_SERVE_HEADLESS itself."""- if os.environ.get("HERMES_DESKTOP") != "1":- if _is_electron_packaged_web_dist(os.environ.get("HERMES_WEB_DIST", "")):- os.environ.pop("HERMES_WEB_DIST", None)+ if not headless_backend and _is_electron_packaged_web_dist(+ os.environ.get("HERMES_WEB_DIST", "")+ ):+ os.environ.pop("HERMES_WEB_DIST", None)if not headless_backend:os.environ.pop("HERMES_SERVE_HEADLESS", None)diff --git a/tests/hermes_cli/test_dashboard_web_dist_validation.py b/tests/hermes_cli/test_dashboard_web_dist_validation.pyindex c44d273e35b..13a076f4f7b 100644--- a/tests/hermes_cli/test_dashboard_web_dist_validation.py+++ b/tests/hermes_cli/test_dashboard_web_dist_validation.py@@ -9,6 +9,7 @@ the dist has no index.html, and proceed when it does.Design credit: PR #17845 (@Caelier)."""+import osimport sysimport types@@ -140,6 +141,39 @@ def test_skip_build_missing_dist_attempts_one_recovery_build(# ---------------------------------------------------------------------------+def test_desktop_child_dashboard_drops_packaged_renderer(main_mod, monkeypatch):+ """A browser dashboard must not trust Desktop identity inherited by a child."""+ packaged = "/Applications/Hermes.app/Contents/Resources/app.asar.unpacked/dist"+ monkeypatch.setenv("HERMES_DESKTOP", "1")+ monkeypatch.setenv("HERMES_WEB_DIST", packaged)+ monkeypatch.setenv("HERMES_SERVE_HEADLESS", "1")++ main_mod._dashboard_sanitize_desktop_env(headless_backend=False)++ assert "HERMES_WEB_DIST" not in os.environ+ assert "HERMES_SERVE_HEADLESS" not in os.environ+++def test_desktop_headless_serve_keeps_packaged_renderer(main_mod, monkeypatch):+ """The real Desktop backend remains distinguished by the `serve` entry path."""+ packaged = "/Applications/Hermes.app/Contents/Resources/app.asar.unpacked/dist"+ monkeypatch.setenv("HERMES_DESKTOP", "1")+ monkeypatch.setenv("HERMES_WEB_DIST", packaged)++ main_mod._dashboard_sanitize_desktop_env(headless_backend=True)++ assert os.environ["HERMES_WEB_DIST"] == packaged+++def test_dashboard_keeps_caller_managed_web_dist(main_mod, monkeypatch, tmp_path):+ """Only Electron-packaged renderer paths are removed from dashboards."""+ custom_dist = tmp_path / "custom-dashboard"+ monkeypatch.setenv("HERMES_DESKTOP", "1")+ monkeypatch.setenv("HERMES_WEB_DIST", str(custom_dist))++ main_mod._dashboard_sanitize_desktop_env(headless_backend=False)++ assert os.environ["HERMES_WEB_DIST"] == str(custom_dist)