Skip to content

The agent that grows with you

fix(desktop): Settings Reasoning Blocks follows the local reasoning key

Tekniumfcedb90cfb3f
diff --git a/apps/desktop/src/app/settings/config-settings.tsx b/apps/desktop/src/app/settings/config-settings.tsx
index 37eadb7dbb5..7b09731371a 100644
--- a/apps/desktop/src/app/settings/config-settings.tsx
+++ b/apps/desktop/src/app/settings/config-settings.tsx
@@ -41,12 +41,13 @@ import { configSubpageForField } from './config-subpages'
import { DELEGATION_ROUTE_COMPANION_KEY, DelegationRouteRow } from './delegation-route-row'
import {
clearsEnabledToolsets,
+ configFieldValue,
diffConfig,
enumOptionsFor,
getNested,
isExternalMemoryProvider,
sectionFieldEntries,
- setNested,
+ setConfigField,
voiceFieldVisible
} from './helpers'
import { MemoryConnect } from './memory/connect'
@@ -524,11 +525,11 @@ function ConfigSettingsInner({
? enumOptionsFor(key, getNested(config, key), config, elevenLabsVoiceOptions ?? undefined)
: enumOptionsFor(key, getNested(config, key), config)
}
- onChange={value => updateConfig(setNested(config, key, value))}
+ onChange={value => updateConfig(setConfigField(config, key, value))}
optionLabels={key === 'tts.elevenlabs.voice_id' ? elevenLabsVoiceLabels : undefined}
schema={field}
schemaKey={key}
- value={getNested(config, key)}
+ value={configFieldValue(config, key)}
/>
)}
{key === 'memory.provider' && isExternalMemoryProvider(getNested(config, key)) ? (
diff --git a/apps/desktop/src/app/settings/helpers.test.ts b/apps/desktop/src/app/settings/helpers.test.ts
index 35c675f3bb6..19745762fd7 100644
--- a/apps/desktop/src/app/settings/helpers.test.ts
+++ b/apps/desktop/src/app/settings/helpers.test.ts
@@ -6,6 +6,7 @@ import { BUILTIN_PERSONALITIES } from './constants'
import { defineFieldCopy, fieldCopyForSchemaKey, schemaKeyToFieldCopyKey } from './field-copy'
import {
clearsEnabledToolsets,
+ configFieldValue,
credentialPreview,
diffConfig,
enumOptionsFor,
@@ -13,6 +14,7 @@ import {
isExternalMemoryProvider,
providerGroup,
sectionFieldEntries,
+ setConfigField,
setNested,
stripToolsetLabel
} from './helpers'
@@ -105,6 +107,22 @@ describe('settings helpers', () => {
expect(getNested(config, 'display.theme')).toBe('mono')
})
+ it('Reasoning Blocks shows and writes the local key a local /reasoning saved', () => {
+ // After a local `/reasoning hide`: the local key wins on every local surface.
+ const config: HermesConfigRecord = { display: { show_reasoning: true, platforms: { cli: { show_reasoning: false } } } }
+
+ expect(configFieldValue(config, 'display.show_reasoning')).toBe(false)
+ const next = setConfigField(config, 'display.show_reasoning', true)
+
+ expect(getNested(next, 'display.platforms.cli.show_reasoning')).toBe(true)
+ expect(getNested(next, 'display.show_reasoning')).toBe(true)
+ expect(configFieldValue(next, 'display.show_reasoning')).toBe(true)
+ // The autosave patch carries the local key, so PUT /api/config's deep merge replaces it.
+ expect(diffConfig(config, next)).toEqual({ display: { platforms: { cli: { show_reasoning: true } } } })
+ // Other fields are untouched.
+ expect(setConfigField({}, 'display.skin', 'ares')).toEqual({ display: { skin: 'ares' } })
+ })
+
it('rejects prototype-polluting config paths', () => {
const config: HermesConfigRecord = {}
diff --git a/apps/desktop/src/app/settings/helpers.ts b/apps/desktop/src/app/settings/helpers.ts
index bb99f61f8a3..d508b935b92 100644
--- a/apps/desktop/src/app/settings/helpers.ts
+++ b/apps/desktop/src/app/settings/helpers.ts
@@ -1,5 +1,6 @@
import { foldPersonalityName } from '@/lib/personalities'
import { asText, normalize } from '@/lib/text'
+import { localShowReasoning } from '@/store/reasoning-disclosure'
import type { ConfigFieldSchema, HermesConfigRecord, ToolsetInfo } from '@/types/hermes'
import { BUILTIN_PERSONALITIES, ENUM_OPTIONS, PROVIDER_GROUPS, SECTIONS } from './constants'
@@ -256,6 +257,26 @@ export function setNested(obj: HermesConfigRecord, path: string, value: unknown)
return clone
}
+// Reasoning Blocks edits what local surfaces show, and they read the local key a local
+// `/reasoning show|hide` saves (`display.platforms.cli.show_reasoning`) before the global one.
+// The schema has no entry for that per-platform key, so the field stays on the global key and
+// shows the local value, and a change writes both.
+const LOCAL_SHOW_REASONING = 'display.platforms.cli.show_reasoning'
+
+/** The value a Settings field shows. */
+export function configFieldValue(config: HermesConfigRecord, key: string): unknown {
+ return key === 'display.show_reasoning'
+ ? localShowReasoning(config.display)
+ : getNested(config, key)
+}
+
+/** The config after a Settings field edit. */
+export function setConfigField(config: HermesConfigRecord, key: string, value: unknown): HermesConfigRecord {
+ const next = setNested(config, key, value)
+
+ return key === 'display.show_reasoning' ? setNested(next, LOCAL_SHOW_REASONING, value) : next
+}
+
function personalityOptions(config: HermesConfigRecord): string[] {
// The Python runtime (`hermes_cli.personality.available_personalities`) honours both
// the root-level `personalities` block and `agent.personalities` (agent wins on a name
diff --git a/tests/gateway/test_local_display_key.py b/tests/gateway/test_local_display_key.py
index 0a31e4755fc..ec4c1a4b56e 100644
--- a/tests/gateway/test_local_display_key.py
+++ b/tests/gateway/test_local_display_key.py
@@ -159,3 +159,41 @@ def test_footer_writes_global_from_chat_and_cli_key_locally(tmp_path, monkeypatc
assert node is True, saved
if platform == 'telegram':
assert 'platforms' not in saved['display'], saved
+
+
+# What Desktop Settings -> Chat -> Reasoning Blocks PUTs when switched on (apps/desktop/src/app/settings/helpers.ts
+# setConfigField; pinned by its vitest): the global key and the local key every local surface reads first.
+_SETTINGS_REASONING_ON = {'display': {'show_reasoning': True, 'platforms': {'cli': {'show_reasoning': True}}}}
+
+
+def test_settings_reasoning_toggle_wins_after_a_local_reasoning_hide(tmp_path, monkeypatch):
+ """After a local ``/reasoning hide`` saved the ``cli`` key, the Settings toggle still turns reasoning on:
+ the real ``PUT /api/config`` keeps the nested key, and ``config.get full`` and the launch default follow it."""
+ from starlette.testclient import TestClient
+
+ import hermes_cli.config as config_mod
+ from gateway.local_viewer_events import launch_shows_reasoning
+ from gateway.session_config import _client_config
+ from hermes_cli.web_server import _SESSION_HEADER_NAME, _SESSION_TOKEN, app
+
+ monkeypatch.setenv('HERMES_HOME', str(tmp_path))
+ config_mod._LOAD_CONFIG_CACHE.clear()
+ config_mod._RAW_CONFIG_CACHE.clear()
+ # The state a local `/reasoning hide` leaves (test_reasoning_hide_and_footer_reach_the_local_clients_config_read).
+ (tmp_path / 'config.yaml').write_text(json.dumps(
+ {'display': {'show_reasoning': True, 'platforms': {'cli': {'show_reasoning': False}}}}))
+ response = TestClient(app).put('/api/config', json={'config': _SETTINGS_REASONING_ON},
+ headers={_SESSION_HEADER_NAME: _SESSION_TOKEN})
+ assert response.status_code == 200, response.text
+ config_mod._LOAD_CONFIG_CACHE.clear()
+ config_mod._RAW_CONFIG_CACHE.clear()
+ saved = config_mod.load_config()
+
+ class _Policy:
+ source = 'gui'
+
+ def config(self, _authority, secrets=False):
+ return saved
+
+ assert _client_config(saved)['display']['show_reasoning'] is True, saved['display']
+ assert launch_shows_reasoning(_Policy(), None) is True