Skip to content

The agent that grows with you

refactor(desktop): type localShowReasoning's display block

Tekniumb6c34ead9ebf
diff --git a/apps/desktop/src/app/settings/helpers.ts b/apps/desktop/src/app/settings/helpers.ts
index d508b935b92..616aafe41fd 100644
--- a/apps/desktop/src/app/settings/helpers.ts
+++ b/apps/desktop/src/app/settings/helpers.ts
@@ -1,7 +1,7 @@
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 type { ConfigFieldSchema, HermesConfig, HermesConfigRecord, ToolsetInfo } from '@/types/hermes'
import { BUILTIN_PERSONALITIES, ENUM_OPTIONS, PROVIDER_GROUPS, SECTIONS } from './constants'
@@ -266,7 +266,7 @@ 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)
+ ? localShowReasoning((config as HermesConfig).display)
: getNested(config, key)
}
diff --git a/apps/desktop/src/store/reasoning-disclosure.ts b/apps/desktop/src/store/reasoning-disclosure.ts
index b292c19fb86..cb66d9c7dc5 100644
--- a/apps/desktop/src/store/reasoning-disclosure.ts
+++ b/apps/desktop/src/store/reasoning-disclosure.ts
@@ -2,6 +2,7 @@ import { atom } from 'nanostores'
import { persistBoolean, storedBoolean } from '@/lib/storage'
import { modeBound } from '@/store/interface-mode'
+import type { HermesConfig } from '@/types/hermes'
const REASONING_COLLAPSED_BY_DEFAULT_STORAGE_KEY = 'hermes.desktop.reasoning.collapsedByDefault'
@@ -33,15 +34,6 @@ export function setShowReasoningFromConfig(value: unknown): void {
/** 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
+export function localShowReasoning(display: HermesConfig['display']): boolean | string | undefined {
+ return display?.platforms?.cli?.show_reasoning ?? display?.show_reasoning
}