From faa467ccaf88ebf8d8cfadaf062fc9bafd6c537c Mon Sep 17 00:00:00 2001 From: Brooklyn Nicholson Date: Wed, 29 Apr 2026 17:05:51 -0500 Subject: [PATCH] fix(tui): share detail section constants Reuse one gateway detail-section list for global and per-section detail mode config handling. --- tui_gateway/server.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tui_gateway/server.py b/tui_gateway/server.py index 6b8ce6b2679..c5863f50087 100644 --- a/tui_gateway/server.py +++ b/tui_gateway/server.py @@ -128,6 +128,8 @@ _cfg_path = None _SLASH_WORKER_TIMEOUT_S = max( 5.0, float(os.environ.get("HERMES_TUI_SLASH_TIMEOUT_S", "45") or 45) ) +_DETAIL_SECTION_NAMES = ("thinking", "tools", "subagents", "activity") +_DETAIL_MODES = frozenset({"hidden", "collapsed", "expanded"}) # ── Async RPC dispatch (#12546) ────────────────────────────────────── # A handful of handlers block the dispatcher loop in entry.py for seconds @@ -3127,14 +3129,13 @@ def _(rid, params: dict) -> dict: if key == "details_mode": nv = str(value or "").strip().lower() - allowed_dm = frozenset({"hidden", "collapsed", "expanded"}) - if nv not in allowed_dm: + if nv not in _DETAIL_MODES: return _err(rid, 4002, f"unknown details_mode: {value}") cfg = _load_cfg() display = cfg.get("display") if isinstance(cfg.get("display"), dict) else {} sections = display.get("sections") if isinstance(display.get("sections"), dict) else {} display["details_mode"] = nv - for section in ("thinking", "tools", "subagents", "activity"): + for section in _DETAIL_SECTION_NAMES: sections[section] = nv display["sections"] = sections cfg["display"] = display @@ -3143,11 +3144,11 @@ def _(rid, params: dict) -> dict: if key.startswith("details_mode."): # Per-section override: `details_mode.
` writes to - # `display.sections.
`. Empty value clears the override - # and lets the section fall back to the global details_mode. + # `display.sections.
`. Empty value clears the explicit + # override and lets frontend resolution apply built-in section defaults + # before the global details_mode. section = key.split(".", 1)[1] - allowed_sections = frozenset({"thinking", "tools", "subagents", "activity"}) - if section not in allowed_sections: + if section not in _DETAIL_SECTION_NAMES: return _err(rid, 4002, f"unknown section: {section}") cfg = _load_cfg() @@ -3164,8 +3165,7 @@ def _(rid, params: dict) -> dict: _save_cfg(cfg) return _ok(rid, {"key": key, "value": ""}) - allowed_dm = frozenset({"hidden", "collapsed", "expanded"}) - if nv not in allowed_dm: + if nv not in _DETAIL_MODES: return _err(rid, 4002, f"unknown details_mode: {value}") sections_cfg[section] = nv