fix(tui): share detail section constants

Reuse one gateway detail-section list for global and per-section detail mode config handling.
This commit is contained in:
Brooklyn Nicholson 2026-04-29 17:05:51 -05:00
parent c2cb6d1071
commit faa467ccaf

View file

@ -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.<section>` writes to
# `display.sections.<section>`. Empty value clears the override
# and lets the section fall back to the global details_mode.
# `display.sections.<section>`. 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