fix(cli): import file_signature in TUI run-state init
#111408 widened the MCP config watcher seed from mtime to utils.file_signature but omitted the import in cli_tui_mixin. The NameError only fires when config.yaml exists, so isolated-home tests short-circuited past it and every real CLI launch crashed. Signed-off-by: mr-r0b0t <adam.manning@gmail.com>
This commit is contained in:
@@ -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 {}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user