mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-03 02:11:48 +00:00
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:
parent
c2cb6d1071
commit
faa467ccaf
1 changed files with 9 additions and 9 deletions
|
|
@ -128,6 +128,8 @@ _cfg_path = None
|
||||||
_SLASH_WORKER_TIMEOUT_S = max(
|
_SLASH_WORKER_TIMEOUT_S = max(
|
||||||
5.0, float(os.environ.get("HERMES_TUI_SLASH_TIMEOUT_S", "45") or 45)
|
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) ──────────────────────────────────────
|
# ── Async RPC dispatch (#12546) ──────────────────────────────────────
|
||||||
# A handful of handlers block the dispatcher loop in entry.py for seconds
|
# 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":
|
if key == "details_mode":
|
||||||
nv = str(value or "").strip().lower()
|
nv = str(value or "").strip().lower()
|
||||||
allowed_dm = frozenset({"hidden", "collapsed", "expanded"})
|
if nv not in _DETAIL_MODES:
|
||||||
if nv not in allowed_dm:
|
|
||||||
return _err(rid, 4002, f"unknown details_mode: {value}")
|
return _err(rid, 4002, f"unknown details_mode: {value}")
|
||||||
cfg = _load_cfg()
|
cfg = _load_cfg()
|
||||||
display = cfg.get("display") if isinstance(cfg.get("display"), dict) else {}
|
display = cfg.get("display") if isinstance(cfg.get("display"), dict) else {}
|
||||||
sections = display.get("sections") if isinstance(display.get("sections"), dict) else {}
|
sections = display.get("sections") if isinstance(display.get("sections"), dict) else {}
|
||||||
display["details_mode"] = nv
|
display["details_mode"] = nv
|
||||||
for section in ("thinking", "tools", "subagents", "activity"):
|
for section in _DETAIL_SECTION_NAMES:
|
||||||
sections[section] = nv
|
sections[section] = nv
|
||||||
display["sections"] = sections
|
display["sections"] = sections
|
||||||
cfg["display"] = display
|
cfg["display"] = display
|
||||||
|
|
@ -3143,11 +3144,11 @@ def _(rid, params: dict) -> dict:
|
||||||
|
|
||||||
if key.startswith("details_mode."):
|
if key.startswith("details_mode."):
|
||||||
# Per-section override: `details_mode.<section>` writes to
|
# Per-section override: `details_mode.<section>` writes to
|
||||||
# `display.sections.<section>`. Empty value clears the override
|
# `display.sections.<section>`. Empty value clears the explicit
|
||||||
# and lets the section fall back to the global details_mode.
|
# override and lets frontend resolution apply built-in section defaults
|
||||||
|
# before the global details_mode.
|
||||||
section = key.split(".", 1)[1]
|
section = key.split(".", 1)[1]
|
||||||
allowed_sections = frozenset({"thinking", "tools", "subagents", "activity"})
|
if section not in _DETAIL_SECTION_NAMES:
|
||||||
if section not in allowed_sections:
|
|
||||||
return _err(rid, 4002, f"unknown section: {section}")
|
return _err(rid, 4002, f"unknown section: {section}")
|
||||||
|
|
||||||
cfg = _load_cfg()
|
cfg = _load_cfg()
|
||||||
|
|
@ -3164,8 +3165,7 @@ def _(rid, params: dict) -> dict:
|
||||||
_save_cfg(cfg)
|
_save_cfg(cfg)
|
||||||
return _ok(rid, {"key": key, "value": ""})
|
return _ok(rid, {"key": key, "value": ""})
|
||||||
|
|
||||||
allowed_dm = frozenset({"hidden", "collapsed", "expanded"})
|
if nv not in _DETAIL_MODES:
|
||||||
if nv not in allowed_dm:
|
|
||||||
return _err(rid, 4002, f"unknown details_mode: {value}")
|
return _err(rid, 4002, f"unknown details_mode: {value}")
|
||||||
|
|
||||||
sections_cfg[section] = nv
|
sections_cfg[section] = nv
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue