diff --git a/hermes_cli/cli_tui_mixin.py b/hermes_cli/cli_tui_mixin.py index 9562a9eafb..909dedd445 100644 --- a/hermes_cli/cli_tui_mixin.py +++ b/hermes_cli/cli_tui_mixin.py @@ -1818,6 +1818,7 @@ class CLITuiMixin: # Config file watcher — detect mcp_servers changes and auto-reload. from hermes_cli.config import get_config_path as _get_config_path + from utils import file_signature _cfg_path = _get_config_path() self._config_sig: tuple | None = file_signature(_cfg_path.stat()) if _cfg_path.exists() else None self._config_mcp_servers: dict = self.config.get("mcp_servers") or {} diff --git a/tests/hermes_cli/test_cli_mcp_config_watch.py b/tests/hermes_cli/test_cli_mcp_config_watch.py index 0f033518b4..85cd3d7028 100644 --- a/tests/hermes_cli/test_cli_mcp_config_watch.py +++ b/tests/hermes_cli/test_cli_mcp_config_watch.py @@ -195,6 +195,29 @@ class TestMCPConfigWatch: assert "MCP server config changed" not in capsys.readouterr().out +def test_tui_init_run_state_seeds_config_sig_when_config_exists(monkeypatch): + """REPL init must seed _config_sig from on-disk config.yaml. + + file_signature is only evaluated when the file exists (short-circuit + otherwise). Isolated-home tests without a config file therefore never + exercised the call, and a missing import crashed every real CLI launch. + """ + from hermes_cli.config import get_config_path + import cli as cli_mod + + monkeypatch.setenv("HERMES_DEFER_AGENT_STARTUP", "1") + cfg_file = get_config_path() + cfg_file.parent.mkdir(parents=True, exist_ok=True) + cfg_file.write_text("mcp_servers: {}\n") + + obj = object.__new__(cli_mod.HermesCLI) + obj.config = {"mcp_servers": {}} + obj._tui_init_run_state() + + assert obj._config_sig == file_signature(cfg_file.stat()) + assert obj._config_mcp_servers == {} + + def test_pinned_mtime_same_size_replacement_triggers_reload(tmp_path): """#111105: cp -p / rsync -t style replacement (same mtime, same size) must still reload.""" import os