From cb446a5bed37d54554dbc77119f5bd919de7f69d Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Tue, 1 Sep 2026 21:23:28 -0700 Subject: [PATCH] fix(config): canonicalize platforms.. at one chokepoint; mirror on get/unset (#71047 Problem A) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Follow-up to @zoser69's #78111 cherry-pick: - lift the redirect into _redirect_platform_display_key() and apply it BEFORE _validate_config_key / type coercion, so the unknown-key hint and the string-vs-bool coercion both see the canonical path - widen to the sibling surfaces: config get resolves the canonical key (previously echoed the dead top-level value — the misleading half of the report) and config unset removes the canonical leaf - regression tests: get mirrors gateway resolve_display_setting, unset removes the redirected leaf, note printed, helper touches ONLY OVERRIDEABLE_KEYS (connection keys / 4-segment / already-canonical paths untouched) - docs: configuration.md per-platform section names the canonical CLI path and the accepted shorthand --- .../test_config_set_platforms_redirect.py | 62 +++++++++++++++++++ website/docs/user-guide/configuration.md | 2 + 2 files changed, 64 insertions(+) diff --git a/tests/hermes_cli/test_config_set_platforms_redirect.py b/tests/hermes_cli/test_config_set_platforms_redirect.py index d4b83876aa..803a70e58f 100644 --- a/tests/hermes_cli/test_config_set_platforms_redirect.py +++ b/tests/hermes_cli/test_config_set_platforms_redirect.py @@ -93,3 +93,65 @@ class TestPerPlatformDisplayRedirect: result = yaml.safe_load((home / "config.yaml").read_text()) assert result["display"]["platforms"]["telegram"]["streaming"] is True assert "platforms" not in result # no stray top-level platforms block + + +class TestRedirectSiblingSurfaces: + """The canonicalization must hold for every CLI surface that takes a dotted + key — set, get, unset — and the written value must be what the gateway's + resolver actually reads (the #71047 symptom was CLI and runtime disagreeing). + """ + + def test_get_mirrors_gateway_resolution_after_set(self, hermes_home, monkeypatch, capsys): + from gateway.display_config import resolve_display_setting + from hermes_cli.config import get_config_value + + _set(monkeypatch, hermes_home, "platforms.telegram.streaming", "false") + capsys.readouterr() + get_config_value("platforms.telegram.streaming") + assert capsys.readouterr().out.strip() == "false" + + raw = yaml.safe_load((hermes_home / "config.yaml").read_text()) + assert resolve_display_setting(raw, "telegram", "streaming") is False + + def test_unset_removes_the_redirected_leaf(self, hermes_home, monkeypatch): + from hermes_cli.config import unset_config_value + + _set(monkeypatch, hermes_home, "platforms.telegram.streaming", "false") + unset_config_value("platforms.telegram.streaming") + result = yaml.safe_load((hermes_home / "config.yaml").read_text()) + assert "streaming" not in result["display"]["platforms"]["telegram"] + # Sibling display override and connection block untouched. + assert result["display"]["platforms"]["telegram"]["show_reasoning"] is True + assert result["platforms"]["telegram"] == {"token": "secret-bot-token"} + + def test_unset_missing_redirected_leaf_exits_nonzero(self, hermes_home, monkeypatch): + from hermes_cli.config import unset_config_value + + monkeypatch.setenv("HERMES_HOME", str(hermes_home)) + with pytest.raises(SystemExit) as exc: + unset_config_value("platforms.telegram.streaming") + assert exc.value.code == 1 + + def test_set_prints_redirect_note(self, hermes_home, monkeypatch, capsys): + _set(monkeypatch, hermes_home, "platforms.telegram.streaming", "false") + out = capsys.readouterr().out + assert "saved as display.platforms.telegram.streaming" in out + assert "Set display.platforms.telegram.streaming = False" in out + + def test_redirect_helper_only_touches_known_display_keys(self): + from gateway.display_config import OVERRIDEABLE_KEYS + from hermes_cli.config import _redirect_platform_display_key + + for setting in OVERRIDEABLE_KEYS: + canonical, note = _redirect_platform_display_key(f"platforms.discord.{setting}") + assert canonical == f"display.platforms.discord.{setting}" + assert note + for key in ( + "platforms.telegram.token", + "platforms.telegram.reply_to_mode", + "platforms.telegram.extra.foo", # 4 segments — not a display leaf + "platforms.telegram", + "display.platforms.telegram.streaming", # already canonical + "streaming.enabled", + ): + assert _redirect_platform_display_key(key) == (key, None) diff --git a/website/docs/user-guide/configuration.md b/website/docs/user-guide/configuration.md index 0c270e5660..b1d5570576 100644 --- a/website/docs/user-guide/configuration.md +++ b/website/docs/user-guide/configuration.md @@ -2064,6 +2064,8 @@ display: tool_progress: 'off' # quiet in shared Slack workspace ``` +From the CLI, use the canonical path — `hermes config set display.platforms.telegram.streaming false`. The shorthand `hermes config set platforms.telegram.streaming false` is accepted too: because per-platform *display* settings (`streaming`, `show_reasoning`, `tool_progress`, …) are only ever read from `display.platforms`, `config set`/`get`/`unset` redirect that shorthand to the canonical key and print a note. Connection keys under the top-level `platforms.` block (`token`, `enabled`, `reply_to_mode`, `extra`) are not redirected. + Platforms without an override fall back to the global `tool_progress` value. Valid platform keys: `telegram`, `discord`, `slack`, `signal`, `whatsapp`, `matrix`, `mattermost`, `email`, `sms`, `homeassistant`, `dingtalk`, `feishu`, `wecom`, `weixin`, `bluebubbles`, `qqbot`. The legacy `display.tool_progress_overrides` key still loads for backward compatibility but is deprecated and migrated into `display.platforms` on first load. Signal is listed as a valid platform key because the setting can be saved per platform, but the current Signal adapter cannot edit sent messages and does not render tool-progress bubbles. Keep Signal `tool_progress` set to `off`; use the CLI or an editing-capable messaging platform if you need to watch each tool call live.