The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(dashboard): scope terminal config to selected profile
Gille5a85c4a77b8d
diff --git a/hermes_cli/web_server.py b/hermes_cli/web_server.pyindex 75cf956df7a..23dd7b53132 100644--- a/hermes_cli/web_server.py+++ b/hermes_cli/web_server.py@@ -16372,12 +16372,29 @@ def _resolve_chat_argv(argv, cwd = _make_tui_argv(PROJECT_ROOT / "ui-tui", tui_dev=False)# Hermes TUI child: build via the single spawn-env factory (profile-home# contract applied; secrets kept — the spawned agent needs provider creds).- # An explicit profile scope below still overrides HERMES_HOME afterwards.+ # An explicit profile scope still overrides HERMES_HOME before config is+ # bridged into the child environment.from tools.environments.local import build_subprocess_envenv = build_subprocess_env(scrub_secrets=False, inherit_profile_home=True)+ if profile_dir is not None:+ env["HERMES_HOME"] = str(profile_dir)try:- from hermes_cli.config import apply_terminal_config_to_env- apply_terminal_config_to_env(env=env)+ from hermes_cli.config import (+ TERMINAL_CONFIG_ENV_MAP,+ apply_terminal_config_to_env,+ )++ if profile_dir is not None:+ # The dashboard process already bridged its own terminal config+ # into os.environ at startup. build_subprocess_env() snapshots that+ # process env, so remove every bridged value before applying the+ # selected profile or omitted keys leak from the launch profile.+ for env_var in TERMINAL_CONFIG_ENV_MAP.values():+ env.pop(env_var, None)+ with _config_profile_scope(requested):+ apply_terminal_config_to_env(env=env)+ else:+ apply_terminal_config_to_env(env=env)except Exception:_log.debug("Failed to apply terminal config bridge for dashboard chat", exc_info=True)_apply_tui_python_env(env)@@ -16403,9 +16420,6 @@ def _resolve_chat_argv(env.setdefault("COLORTERM", "truecolor")env["HERMES_TUI_DASHBOARD"] = "1"- if profile_dir is not None:- env["HERMES_HOME"] = str(profile_dir)-if resume:_resume_db = _open_session_db_for_profile(requested if profile_dir is not None else None,diff --git a/tests/hermes_cli/test_web_server_profile_unification.py b/tests/hermes_cli/test_web_server_profile_unification.pyindex d525f497e8c..db941056e1d 100644--- a/tests/hermes_cli/test_web_server_profile_unification.py+++ b/tests/hermes_cli/test_web_server_profile_unification.py@@ -650,6 +650,37 @@ class TestProfileScopedChatPty:# Scoped chat must NOT attach to the dashboard's in-memory gateway.assert "HERMES_TUI_GATEWAY_URL" not in env+ def test_chat_argv_bridges_selected_profile_terminal_config(+ self, isolated_profiles, monkeypatch+ ):+ import hermes_cli.web_server as web_server++ (isolated_profiles["worker_beta"] / "config.yaml").write_text(+ "terminal:\n"+ " backend: ssh\n"+ " ssh_host: worker.example.test\n"+ " cwd: '~'\n",+ encoding="utf-8",+ )+ monkeypatch.setenv("TERMINAL_ENV", "docker")+ monkeypatch.setenv("TERMINAL_DOCKER_IMAGE", "launch-profile-image")+ monkeypatch.setenv("TERMINAL_SSH_USER", "launch-profile-user")+ monkeypatch.setattr(+ "hermes_cli.main._make_tui_argv",+ lambda root, tui_dev=False: (["cat"], None),+ raising=False,+ )++ _argv, _cwd, env = web_server._resolve_chat_argv(profile="worker_beta")++ assert env is not None+ assert env["HERMES_HOME"] == str(isolated_profiles["worker_beta"])+ assert env["TERMINAL_ENV"] == "ssh"+ assert env["TERMINAL_SSH_HOST"] == "worker.example.test"+ assert env["TERMINAL_CWD"] == "~"+ assert env["TERMINAL_DOCKER_IMAGE"] != "launch-profile-image"+ assert "TERMINAL_SSH_USER" not in env+class TestProfileScopedAudio:"""Audio endpoints must honor ``profile`` like the rest of the dashboard.