The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(gateway): let config.set write the desktop's Appearance switches
Brooklyn Nicholsond0e41cda6942
diff --git a/tests/tui_gateway/test_config_set_display_toggles.py b/tests/tui_gateway/test_config_set_display_toggles.pynew file mode 100644index 00000000000..2139314f266--- /dev/null+++ b/tests/tui_gateway/test_config_set_display_toggles.py@@ -0,0 +1,56 @@+"""`config.set` has to accept the Appearance switches the desktop mirrors.++The handler matches an explicit key list and answers 4002 for everything else,+so a renderer mirroring an unlisted key writes nothing at all — and the+renderer's `.catch()` swallows the refusal, which is how message reactions+shipped with a toggle that never reached the backend gating the tool.+"""++import pytest+import yaml++from tui_gateway import server+++def config_home(tmp_path, monkeypatch):+ """Point the server's config read/write at a temp file."""+ monkeypatch.setattr(server, "_hermes_home", tmp_path)+ server._cfg_cache = server._cfg_mtime = server._cfg_path = None+ yield tmp_path / "config.yaml"+ server._cfg_cache = server._cfg_mtime = server._cfg_path = None+++def _set(key, value):+ return server._methods["config.set"](1, {"key": key, "value": value})++[email protected]("key", sorted(server._DISPLAY_TOGGLE_KEYS))+def test_a_mirrored_switch_reaches_the_config_file(config_home, key):+ """Both directions land on disk, where the tools' check_fn reads them."""+ assert _set(key, "false")["result"] == {"key": key, "value": False}++ section, name = key.split(".")+ assert yaml.safe_load(config_home.read_text())[section][name] is False++ assert _set(key, "true")["result"] == {"key": key, "value": True}+ assert yaml.safe_load(config_home.read_text())[section][name] is True+++def test_a_non_boolean_is_refused_rather_than_written(config_home):+ answer = _set("display.in_app_tips", "sometimes")++ assert answer["error"]["code"] == 4002+ assert not config_home.exists()+++def test_every_key_the_renderer_mirrors_is_listed():+ """The list is the contract: a switch missing from it silently does nothing.++ Kept as a relationship rather than a snapshot — it asserts that the tools+ which gate on `display.<x>` all have `<x>` reachable through config.set,+ not that the set has some particular size.+ """+ gated = {"display.message_reactions", "display.in_app_tips", "display.in_app_tours"}++ assert gated <= server._DISPLAY_TOGGLE_KEYSdiff --git a/tui_gateway/server.py b/tui_gateway/server.pyindex 0fc10e8cd94..5f5c8249b46 100644--- a/tui_gateway/server.py+++ b/tui_gateway/server.py@@ -5838,6 +5838,34 @@ def _write_config_key(key_path: str, value):_STATUSBAR_MODES = frozenset({"off", "top", "bottom"})_APPROVAL_MODES = frozenset({"manual", "smart", "off"})+# Appearance switches the desktop renderer owns but the AGENT has to see: each+# one gates a tool's `check_fn`, so the toggle has to reach the config of+# whichever gateway the app is actually talking to — local, SSH, URL, or cloud.+#+# `config.set` matches an explicit key list and answers 4002 for anything else,+# so a renderer mirroring a key that is not listed here writes nothing at all.+# That is not hypothetical: the reactions toggle shipped mirroring+# `display.message_reactions`, every write was rejected into a swallowed+# `.catch()`, and `react_to_message` therefore stayed dark no matter what the+# user picked. Adding a mirrored switch to the renderer means adding it here.+_DISPLAY_TOGGLE_KEYS = frozenset(+ {+ "display.message_reactions",+ "display.in_app_tips",+ "display.in_app_tours",+ }+)+_BOOL_WORDS = {+ "1": True,+ "on": True,+ "true": True,+ "yes": True,+ "0": False,+ "off": False,+ "false": False,+ "no": False,+}+def _load_approval_mode() -> str:"""Resolve the effective ``approvals.mode`` for the TUI surface.@@ -14883,6 +14911,13 @@ def _(rid, params: dict) -> dict:except Exception as e:return _err(rid, 5001, str(e))+ if key in _DISPLAY_TOGGLE_KEYS:+ on = _BOOL_WORDS.get(str(value).strip().lower())+ if on is None:+ return _err(rid, 4002, f"{key} takes true or false")+ _write_config_key(key, on)+ return _ok(rid, {"key": key, "value": on})+return _err(rid, 4002, f"unknown config key: {key}")