Skip to content

The agent that grows with you

fix(dashboard): reclassify profile=default as current when it resolves to the process home

vectorcontexte24f07239fe0
diff --git a/hermes_cli/web_server_profiles.py b/hermes_cli/web_server_profiles.py
index f3d91b99a3a..9f20d081d51 100644
--- a/hermes_cli/web_server_profiles.py
+++ b/hermes_cli/web_server_profiles.py
@@ -233,11 +233,23 @@ def _config_profile_scope(profile: Optional[str]):
"""Await-safe, config-only profile scope: touches ONLY the task-local HERMES_HOME
contextvar, never the process-global skills-module attributes ``_profile_scope`` swaps
(holding those across an ``await`` lets a concurrent request restore THIS request's dir
- on its ``finally``). None/""/"current" = no override."""
+ on its ``finally``). None/""/"current" = no override.
+
+ A named profile that resolves to the SAME directory as this process's own
+ HERMES_HOME (e.g. ``profile=default`` on a default-home process — the desktop app
+ always sends ``default``) is treated as current: the scoped branch derives
+ enablement from config.yaml only and would report an env-enabled platform as
+ disabled. Classify by resolved path, not by string: a named-profile process
+ (``-p worker``) has a different HERMES_HOME, so its ``profile=default`` still
+ scopes correctly. Issue #104614.
+ """
if _is_current_profile(profile):
yield None
return
profile_dir = _resolve_profile_dir(profile.strip())
+ if profile_dir.resolve() == get_process_hermes_home().resolve():
+ yield None
+ return
with _hermes_home_scope(profile_dir):
yield profile_dir
diff --git a/tests/hermes_cli/test_web_server_messaging_profiles.py b/tests/hermes_cli/test_web_server_messaging_profiles.py
index 6f787fbc142..2074fa82566 100644
--- a/tests/hermes_cli/test_web_server_messaging_profiles.py
+++ b/tests/hermes_cli/test_web_server_messaging_profiles.py
@@ -268,3 +268,43 @@ class TestMultiplexPortBindingGuard:
)
assert resp.status_code == 200
+
+class TestProfileDefaultOnDefaultHomeReportsEnvEnabled:
+ """``profile=default`` on a process whose HERMES_HOME IS the default home must
+ take the unscoped path, not the profile-scoped one.
+
+ The desktop app always sends ``profile=default``. ``_is_current_profile()`` only
+ recognized None/""/"current" — NOT "default" — so a single-profile install (the
+ standard ``hermes gateway setup`` flow: token in ``.env``, no ``platforms:``
+ section in ``config.yaml``) entered the scoped branch, which derives enablement
+ from ``config.yaml`` only and never calls ``load_gateway_config()``'s
+ env-override pass. Result: a platform connected via ``.env`` reported
+ ``enabled=false, state="disabled"`` while it was actually running. The unscoped
+ GET (no profile param) correctly reported ``enabled=true``. Issue #104614.
+ """
+
+ def test_default_profile_param_matches_unscoped_enablement(
+ self, client, isolated_profiles, monkeypatch
+ ):
+ # Simulate the gateway having loaded .env into os.environ at startup
+ # (load_hermes_dotenv in gateway/run.py): the dashboard process shares
+ # that environment, so the unscoped load_gateway_config() env-override
+ # pass sees the token and enables the platform.
+ monkeypatch.setenv("TELEGRAM_BOT_TOKEN", "root-token")
+
+ # config.yaml has NO platforms: section (isolated_profiles writes "{}"),
+ # so enablement can ONLY come from the env-override pass — exactly the
+ # standard setup flow the bug hits.
+
+ unscoped = client.get("/api/messaging/platforms")
+ assert unscoped.status_code == 200
+ telegram_unscoped = _telegram(unscoped.json())
+ assert telegram_unscoped["enabled"] is True
+
+ scoped_default = client.get(
+ "/api/messaging/platforms", params={"profile": "default"}
+ )
+ assert scoped_default.status_code == 200
+ telegram_scoped = _telegram(scoped_default.json())
+ assert telegram_scoped["enabled"] is True
+