Skip to content

The agent that grows with you

fix: /reasoning show|hide and /footer hold on every local surface

Teknium831cedb4e21f
diff --git a/apps/desktop/src/app/session/hooks/use-hermes-config.ts b/apps/desktop/src/app/session/hooks/use-hermes-config.ts
index d1f6c7d6f88..1be4b1809f2 100644
--- a/apps/desktop/src/app/session/hooks/use-hermes-config.ts
+++ b/apps/desktop/src/app/session/hooks/use-hermes-config.ts
@@ -8,7 +8,7 @@ import { normalize } from '@/lib/text'
import { $busyInputConfig, busyInputOwnerKey, normalizeBusyInputMode } from '@/store/busy-input-mode'
import { setDisplayTimestampsFromConfig } from '@/store/display-timestamps'
import { $activeGatewayProfile } from '@/store/profile'
-import { setShowReasoningFromConfig } from '@/store/reasoning-disclosure'
+import { localShowReasoning, setShowReasoningFromConfig } from '@/store/reasoning-disclosure'
import { $connection } from '@/store/session'
import {
getComposerSelectionGeneration,
@@ -157,7 +157,7 @@ export function useHermesConfig({ activeSessionIdRef }: HermesConfigOptions) {
}
setDisplayTimestampsFromConfig(config.display?.timestamps)
- setShowReasoningFromConfig(config.display?.show_reasoning)
+ setShowReasoningFromConfig(localShowReasoning(config.display))
setShowToolActivityFromConfig(config.display?.tool_progress)
setTerminalFontFamilyFromConfig(config.terminal?.font_family)
setChatFontFamilyFromConfig(config.desktop?.font_family)
diff --git a/apps/desktop/src/store/reasoning-disclosure.test.ts b/apps/desktop/src/store/reasoning-disclosure.test.ts
new file mode 100644
index 00000000000..9e4f56f7adb
--- /dev/null
+++ b/apps/desktop/src/store/reasoning-disclosure.test.ts
@@ -0,0 +1,16 @@
+import { describe, expect, it } from 'vitest'
+
+import { localShowReasoning } from './reasoning-disclosure'
+
+describe('localShowReasoning', () => {
+ it('reads the local per-platform key over the global one', () => {
+ expect(localShowReasoning({ show_reasoning: true, platforms: { cli: { show_reasoning: false } } })).toBe(false)
+ expect(localShowReasoning({ show_reasoning: false, platforms: { cli: { show_reasoning: true } } })).toBe(true)
+ })
+
+ it('falls back to the global key, and ignores other platforms', () => {
+ expect(localShowReasoning({ show_reasoning: false })).toBe(false)
+ expect(localShowReasoning({ show_reasoning: true, platforms: { telegram: { show_reasoning: false } } })).toBe(true)
+ expect(localShowReasoning(undefined)).toBeUndefined()
+ })
+})
diff --git a/apps/desktop/src/store/reasoning-disclosure.ts b/apps/desktop/src/store/reasoning-disclosure.ts
index 25c26c72098..b292c19fb86 100644
--- a/apps/desktop/src/store/reasoning-disclosure.ts
+++ b/apps/desktop/src/store/reasoning-disclosure.ts
@@ -29,3 +29,19 @@ export const $showReasoning = atom(true)
export function setShowReasoningFromConfig(value: unknown): void {
$showReasoning.set(!(value === false || value === 'false' || value === 0))
}
+
+/** The `display.show_reasoning` a local surface uses: a local session's `/reasoning show|hide` saves the
+ * per-platform `display.platforms.cli` key (the gateway's key for local sessions), which wins over the
+ * global one, as the gateway and the other local clients resolve it. */
+export function localShowReasoning(display: unknown): unknown {
+ if (!display || typeof display !== 'object') {
+ return undefined
+ }
+
+ const block = display as { platforms?: unknown; show_reasoning?: unknown }
+ const platforms = block.platforms && typeof block.platforms === 'object' ? block.platforms : undefined
+ const local = platforms ? (platforms as Record<string, unknown>).cli : undefined
+ const override = local && typeof local === 'object' ? (local as { show_reasoning?: unknown }).show_reasoning : undefined
+
+ return override ?? block.show_reasoning
+}
diff --git a/apps/desktop/src/types/hermes.ts b/apps/desktop/src/types/hermes.ts
index 5f002689f9c..6ba5c54f5e7 100644
--- a/apps/desktop/src/types/hermes.ts
+++ b/apps/desktop/src/types/hermes.ts
@@ -486,6 +486,8 @@ export interface HermesConfig {
}
display?: {
show_reasoning?: boolean | string
+ /** Per-platform overrides; a local session's `/reasoning show|hide` saves `platforms.cli`. */
+ platforms?: Record<string, { show_reasoning?: boolean | string } | undefined>
personality?: string
skin?: string
interim_assistant_messages?: boolean
diff --git a/gateway/display_config.py b/gateway/display_config.py
index 416b4a63ab7..3ed5df030bd 100644
--- a/gateway/display_config.py
+++ b/gateway/display_config.py
@@ -202,3 +202,29 @@ def _normalise(setting: str, value: Any) -> Any:
"""Normalise a user-supplied value for *setting*; unknown settings pass through."""
norm = _NORMALISERS.get(setting)
return norm(value) if norm else value
+
+
+# LOCAL's per-platform config key (``_platform_config_key(Platform.LOCAL)``): where a local session's
+# ``/reasoning show|hide`` and ``/footer`` save, and what every local surface reads.
+LOCAL_DISPLAY_KEY = "cli"
+# The per-platform display settings a local surface takes from the local key over the global one.
+_LOCAL_OVERLAY_KEYS = ("show_reasoning", "runtime_footer")
+
+
+def local_display_config(display: Any) -> dict[str, Any]:
+ """*display* (a ``config.yaml`` ``display`` block) as a local surface (classic CLI, Ink, Desktop,
+ a local turn) resolves it: ``display.platforms.cli.<key>`` over ``display.<key>`` for the settings
+ the local commands save there. No second key is written; the block is returned copied."""
+ display = dict(display) if isinstance(display, dict) else {}
+ platforms = display.get("platforms")
+ local = platforms.get(LOCAL_DISPLAY_KEY) if isinstance(platforms, dict) else None
+ if not isinstance(local, dict):
+ return display
+ for key in _LOCAL_OVERLAY_KEYS:
+ value = local.get(key)
+ if value is None:
+ continue
+ if isinstance(value, dict) and isinstance(display.get(key), dict):
+ value = {**display[key], **value}
+ display[key] = value
+ return display
diff --git a/gateway/local_viewer_events.py b/gateway/local_viewer_events.py
index 5443759f028..3fd85e0a9db 100644
--- a/gateway/local_viewer_events.py
+++ b/gateway/local_viewer_events.py
@@ -82,8 +82,9 @@ def launch_shows_reasoning(policy, authority) -> bool:
"""An unset session flag: ``display.show_reasoning`` for an Ink or Desktop launch, else off."""
if getattr(policy, "source", None) not in _CONFIG_DEFAULT_SOURCES:
return False
- display = policy.config(authority, secrets=False).get("display")
- return bool((display if isinstance(display, dict) else {}).get("show_reasoning", True))
+ from gateway.display_config import local_display_config
+ display = local_display_config(policy.config(authority, secrets=False).get("display"))
+ return bool(display.get("show_reasoning", True))
def _is_active_session_subagent(turn, payload: dict, event_type: str = "") -> bool:
diff --git a/gateway/session_config.py b/gateway/session_config.py
index 83507c60408..f7ed196a5bf 100644
--- a/gateway/session_config.py
+++ b/gateway/session_config.py
@@ -39,6 +39,11 @@ def _client_config(cfg):
from hermes_cli.config import redact_config_value
result = redact_config_value({key: cfg[key] for key in (
'display', 'approvals', 'paste_collapse_threshold', 'paste_collapse_char_threshold') if key in cfg})
+ if 'display' in result:
+ # Its readers are local surfaces (Ink, Desktop): the local key a local /reasoning show|hide or
+ # /footer saved wins over the global one (T7).
+ from gateway.display_config import local_display_config
+ result['display'] = local_display_config(result['display'])
# Allowlisted after redaction: ``record_key`` is a keybinding, not a credential, but the
# structural masker treats every ``*_key`` leaf as one. The voice section's real secrets
# (``api_key``) never enter the projection.
@@ -119,7 +124,9 @@ def _reasoning(agent, policy, cfg, connection=None, ref=None):
elif not isinstance(value, dict):
value = resolve_reasoning_config(cfg, '')
effort = 'none' if value and value.get('enabled') is False else (value or {}).get('effort', 'medium')
- return {'value': effort, 'display': 'show' if cfg.get('display', {}).get('show_reasoning', True) else 'hide'}
+ from gateway.display_config import local_display_config
+ shown = local_display_config(cfg.get('display')).get('show_reasoning', True)
+ return {'value': effort, 'display': 'show' if shown else 'hide'}
def _project(params, policy, cfg):
diff --git a/gateway/slash_commands.py b/gateway/slash_commands.py
index 93817f5234c..28936959b36 100644
--- a/gateway/slash_commands.py
+++ b/gateway/slash_commands.py
@@ -1055,7 +1055,11 @@ class GatewaySlashCommandsMixin(
return t("gateway.footer.usage")
new_state = _FOOTER_STATE_BY_ARG[arg] if arg else not effective["enabled"]
try:
- _write_raw_config_leaf(config_path, ("display", "runtime_footer", "enabled"), new_state)
+ # The per-platform key, as /reasoning show|hide saves: every local surface reads the
+ # ``cli`` key (gateway.display_config.local_display_config), so the setting holds
+ # wherever it was set without a second, global key (T7).
+ _write_raw_config_leaf(config_path, ("display", "platforms", platform_key, "runtime_footer", "enabled"),
+ new_state)
except Exception as e:
logger.warning("Failed to save runtime_footer.enabled: %s", e)
return t("gateway.config_save_failed", error=e)
diff --git a/hermes_cli/cli_commands_mixin.py b/hermes_cli/cli_commands_mixin.py
index 6e3608b948e..1a3193245a6 100644
--- a/hermes_cli/cli_commands_mixin.py
+++ b/hermes_cli/cli_commands_mixin.py
@@ -2264,7 +2264,7 @@ class CLICommandsMixin(CLICommandsSessionToolsMixin):
setattr(self, attr, value)
if attr == "show_reasoning" and self.agent:
self.agent.reasoning_callback = self._current_reasoning_callback()
- _save(f"display.{attr}", value)
+ _save("display.platforms.cli.show_reasoning" if attr == "show_reasoning" else f"display.{attr}", value) # T7
_cp(_accent_line(_t("reasoning.display_saved", headline=_t(f"reasoning.{headline_key}"))))
if note_key:
_cp(_dim_line(f" {_t(f'reasoning.{note_key}')}"))
diff --git a/hermes_cli/cli_init_mixin.py b/hermes_cli/cli_init_mixin.py
index db546771162..6119553d1db 100644
--- a/hermes_cli/cli_init_mixin.py
+++ b/hermes_cli/cli_init_mixin.py
@@ -95,7 +95,9 @@ class CLIInitMixin:
from cli import CLI_CONFIG, _configure_output_history, _int_or
self.console = Console()
self.config = CLI_CONFIG
- display = CLI_CONFIG["display"]
+ # A local /reasoning show|hide or /footer saves the per-platform ``cli`` key: read it (T7).
+ from gateway.display_config import local_display_config
+ display = local_display_config(CLI_CONFIG["display"])
self.compact = compact if compact is not None else display.get("compact", False)
# tool_progress: "off" | "new" | "all" | "verbose"; YAML 1.1 parses bare `off` as False.
_raw_tp = display.get("tool_progress", "all")
diff --git a/tests/gateway/test_local_display_key.py b/tests/gateway/test_local_display_key.py
new file mode 100644
index 00000000000..3786f52f59a
--- /dev/null
+++ b/tests/gateway/test_local_display_key.py
@@ -0,0 +1,119 @@
+"""``/reasoning show|hide`` and ``/footer`` on a local session take effect on every local surface (T7).
+
+The gateway handler keeps writing the per-platform key (``display.platforms.cli.*``: LOCAL's config key,
+``_platform_config_key``). Every local surface reads that key: Ink and Desktop read ``config.get full``'s
+``display`` block, the classic CLI reads its display config at start, and the gateway's local turns
+resolve the launch default. None of them may fall back to the global key the command never wrote.
+"""
+import asyncio
+import json
+import signal
+import threading
+from http.server import ThreadingHTTPServer
+from pathlib import Path
+
+import pytest
+
+from tests.gateway.fixtures.local_recovery_probe import Model, child_env, daemon, rpc, websocket
+
+
[email protected]("linux") # the daemon is stopped with SIGINT, which raises on Windows
+def test_reasoning_hide_and_footer_reach_the_local_clients_config_read(tmp_path):
+ root = Path(__file__).resolve().parents[2]
+ home, user, work = tmp_path / 'state', tmp_path / 'user', tmp_path / 'work'
+ home.mkdir(mode=0o700)
+ user.mkdir()
+ work.mkdir()
+ peer = ThreadingHTTPServer(('127.0.0.1', 0), Model)
+ peer.requests = []
+ peer.blocked, peer.release = threading.Event(), threading.Event()
+ thread = threading.Thread(target=peer.serve_forever, daemon=True)
+ thread.start()
+ url = f'http://127.0.0.1:{peer.server_port}/v1'
+ (home / 'config.yaml').write_text(json.dumps({
+ 'gateway': {'multiplex_profiles': False},
+ 'model': {'provider': 'custom', 'default': 'display-model', 'base_url': url},
+ 'auxiliary': {'title_generation': {'enabled': False}},
+ # An earlier per-platform footer setting: the one /footer must flip for this surface.
+ 'display': {'show_reasoning': True, 'platforms': {'cli': {'runtime_footer': {'enabled': True}}}},
+ }))
+ env = child_env()
+ env.update(HOME=str(user), USERPROFILE=str(user), HERMES_HOME=str(home), PYTHONPATH=str(root),
+ OPENAI_API_KEY='loopback-only', OPENAI_BASE_URL=url, PYTHONUNBUFFERED='1')
+ out = {}
+
+ async def probe(desc):
+ async with websocket(home, desc) as ws:
+ created = await rpc(ws, 'session.create', request_id='display', source='tui', toolsets=[],
+ cwd=str(work))
+ sid = created['result']['session_id']
+ for command in ('reasoning hide', 'footer off'):
+ out[command] = (await rpc(ws, 'slash.exec', session_id=sid, command=command))['result']
+ full = await rpc(ws, 'config.get', session_id=sid, key='full')
+ out['display'] = full['result']['config']['display']
+
+ try:
+ with daemon(root, home, env, barrier=False) as (proc, desc):
+ asyncio.run(probe(desc))
+ proc.send_signal(signal.SIGINT)
+ proc.wait(timeout=20)
+ finally:
+ peer.shutdown()
+ peer.server_close()
+ thread.join(timeout=5)
+
+ from hermes_cli.config import read_user_config_raw
+ saved = read_user_config_raw(home / 'config.yaml')
+ # The per-platform key is what the command wrote; no second, global key appears.
+ assert saved['display']['platforms']['cli']['show_reasoning'] is False, saved
+ assert saved['display']['show_reasoning'] is True, saved
+ assert saved['display']['platforms']['cli']['runtime_footer']['enabled'] is False, saved
+ assert 'runtime_footer' not in {k for k in saved['display'] if k != 'platforms'}, saved
+ # The local clients' config read resolves the local key.
+ assert out['display']['show_reasoning'] is False, out
+ assert out['display']['runtime_footer']['enabled'] is False, out
+
+
+def test_launch_default_reads_the_local_key():
+ """An Ink/Desktop session with no session flag streams per ``display.platforms.cli.show_reasoning``."""
+ from gateway.local_viewer_events import launch_shows_reasoning
+
+ class _Policy:
+ source = 'tui'
+
+ def __init__(self, display):
+ self._display = display
+
+ def config(self, _authority, secrets=False):
+ return {'display': self._display}
+
+ assert launch_shows_reasoning(_Policy({'show_reasoning': True, 'platforms': {'cli': {'show_reasoning': False}}}),
+ None) is False
+ assert launch_shows_reasoning(_Policy({'show_reasoning': True}), None) is True
+ assert launch_shows_reasoning(_Policy({'show_reasoning': False}), None) is False
+
+
+def test_classic_cli_display_reads_the_local_key():
+ from gateway.display_config import local_display_config
+
+ display = local_display_config({'show_reasoning': True, 'runtime_footer': {'enabled': False},
+ 'platforms': {'cli': {'show_reasoning': False,
+ 'runtime_footer': {'enabled': True}}}})
+ assert display['show_reasoning'] is False
+ assert display['runtime_footer']['enabled'] is True
+ # No local key: the global value stands.
+ assert local_display_config({'show_reasoning': True})['show_reasoning'] is True
+
+
+def test_classic_cli_reasoning_hide_saves_the_local_key(monkeypatch):
+ from hermes_cli import cli_commands_mixin as mixin
+
+ saved = {}
+ monkeypatch.setattr(mixin, '_save', lambda key, value: saved.__setitem__(key, value))
+ monkeypatch.setattr(mixin, '_cp', lambda *a, **k: None)
+ cli = object.__new__(mixin.CLICommandsMixin)
+ cli.agent = None
+ cli.show_reasoning = True
+ cli._handle_reasoning_command('/reasoning hide')
+ assert saved == {'display.platforms.cli.show_reasoning': False}
+ assert cli.show_reasoning is False
diff --git a/tests/gateway/test_session_setting_commands.py b/tests/gateway/test_session_setting_commands.py
index 40cccf8162e..cccb2f52750 100644
--- a/tests/gateway/test_session_setting_commands.py
+++ b/tests/gateway/test_session_setting_commands.py
@@ -141,7 +141,8 @@ def test_local_session_settings_run_the_messaging_handlers_and_read_back_through
assert 'OFF' in out['yolo off'] and out['get yolo off']['value'] == '0', out
# /footer: `status` reports without toggling (the handler parsed its argument from a missing field).
assert 'OFF' in out['footer status'] and 'ON' in out['footer on'] and 'ON' in out['footer status 2'], out
- assert saved['display']['runtime_footer']['enabled'] is True
+ # The per-platform key (T7): every local surface reads display.platforms.cli.
+ assert saved['display']['platforms']['cli']['runtime_footer']['enabled'] is True
# /voice: the LOCAL chat's voice state (playback stays in the client).
assert 'On' in out['voice status'] and out['voice off'], out
# /approvals and /personality: profile settings, saved to config.yaml as on every surface.