Skip to content

The agent that grows with you

refactor(desktop): mirror display.show_reasoning the way display.timestamps is mirrored

kshitijk4poord12736c95989
diff --git a/apps/desktop/src/app/session/hooks/use-hermes-config.test.ts b/apps/desktop/src/app/session/hooks/use-hermes-config.test.ts
index 5a3040cf49a..57af4c10e86 100644
--- a/apps/desktop/src/app/session/hooks/use-hermes-config.test.ts
+++ b/apps/desktop/src/app/session/hooks/use-hermes-config.test.ts
@@ -46,18 +46,22 @@ describe('useHermesConfig refreshHermesConfig', () => {
persistString(WORKSPACE_CWD_KEY, null)
})
- it.each([
- [true, true], [false, false], ['false', false], ['off', false], ['0', false],
- [' True ', true], ['yes', true], [1, true], [0, false], [undefined, true]
- ])('resolves reasoning display %j to %j and resets missing config to the default', async (value, expected) => {
- mockConfig({ display: { show_reasoning: value } })
+ // #49664: the Reasoning Blocks toggle wrote config but the renderer never
+ // read it. A refresh mirrors the key (quoted "false" included) and a
+ // missing key falls back to the DEFAULT_CONFIG default (on).
+ it('mirrors display.show_reasoning and resets a missing key to the default', async () => {
+ mockConfig({ display: { show_reasoning: 'false' } })
const { result } = renderHook(() => useHermesConfig({ activeSessionIdRef: { current: null } }))
- await act(async () => { await result.current.refreshHermesConfig() })
- expect($showReasoning.get()).toBe(expected)
+ await act(async () => {
+ await result.current.refreshHermesConfig()
+ })
+ expect($showReasoning.get()).toBe(false)
mockConfig({})
- await act(async () => { await result.current.refreshHermesConfig() })
+ await act(async () => {
+ await result.current.refreshHermesConfig()
+ })
expect($showReasoning.get()).toBe(true)
})
diff --git a/apps/desktop/src/components/assistant-ui/thread/streaming.test.tsx b/apps/desktop/src/components/assistant-ui/thread/streaming.test.tsx
index dc64fb764d9..6441f14602d 100644
--- a/apps/desktop/src/components/assistant-ui/thread/streaming.test.tsx
+++ b/apps/desktop/src/components/assistant-ui/thread/streaming.test.tsx
@@ -1,4 +1,10 @@
-import { AssistantRuntimeProvider, MessagePrimitive, type ThreadMessage, ThreadPrimitive, useExternalStoreRuntime } from '@assistant-ui/react'
+import {
+ AssistantRuntimeProvider,
+ MessagePrimitive,
+ type ThreadMessage,
+ ThreadPrimitive,
+ useExternalStoreRuntime
+} from '@assistant-ui/react'
import { act, fireEvent, render, screen, waitFor, within } from '@testing-library/react'
import { useEffect, useState } from 'react'
import { beforeEach, describe, expect, it, vi } from 'vitest'
@@ -485,18 +491,22 @@ describe('assistant-ui streaming renderer', () => {
it.each([true, false])('honors reasoning visibility %j for grouped and standalone parts', async enabled => {
setShowReasoningFromConfig(enabled)
- const UngroupedMessage = () => <MessagePrimitive.Root>
- <MessagePrimitive.Parts components={{ Reasoning: MESSAGE_PARTS_COMPONENTS.Reasoning }} />
- </MessagePrimitive.Root>
-
- const { container } = render(<>
- <RunningReasoningHarness />
- <ThreadRuntime messages={[assistantReasoningMessage('standalone reasoning', true)]}>
- <ThreadPrimitive.Root>
- <ThreadPrimitive.Messages components={{ AssistantMessage: UngroupedMessage, UserMessage: () => null }} />
- </ThreadPrimitive.Root>
- </ThreadRuntime>
- </>)
+ const UngroupedMessage = () => (
+ <MessagePrimitive.Root>
+ <MessagePrimitive.Parts components={{ Reasoning: MESSAGE_PARTS_COMPONENTS.Reasoning }} />
+ </MessagePrimitive.Root>
+ )
+
+ const { container } = render(
+ <>
+ <RunningReasoningHarness />
+ <ThreadRuntime messages={[assistantReasoningMessage('standalone reasoning', true)]}>
+ <ThreadPrimitive.Root>
+ <ThreadPrimitive.Messages components={{ AssistantMessage: UngroupedMessage, UserMessage: () => null }} />
+ </ThreadPrimitive.Root>
+ </ThreadRuntime>
+ </>
+ )
await waitFor(() => {
expect(container.querySelectorAll('[data-slot="aui_reasoning-text"]')).toHaveLength(enabled ? 2 : 0)
diff --git a/apps/desktop/src/store/reasoning-disclosure.ts b/apps/desktop/src/store/reasoning-disclosure.ts
index fa59aa0d625..fd42d198207 100644
--- a/apps/desktop/src/store/reasoning-disclosure.ts
+++ b/apps/desktop/src/store/reasoning-disclosure.ts
@@ -13,15 +13,11 @@ export function setReasoningCollapsedByDefault(value: boolean) {
$reasoningCollapsedByDefault.set(value)
}
-// Mirrors backend display.show_reasoning; omission follows DEFAULT_CONFIG.
+// Mirrors `display.show_reasoning` (Settings → Chat → Reasoning Blocks). On
+// by default like DEFAULT_CONFIG; a quoted "false" in config.yaml still
+// means off (sibling: display-timestamps.ts).
export const $showReasoning = atom(true)
export function setShowReasoningFromConfig(value: unknown): void {
- const enabled = value === undefined
- ? true
- : typeof value === 'string'
- ? ['1', 'true', 'yes', 'on'].includes(value.trim().toLowerCase())
- : Boolean(value)
-
- $showReasoning.set(enabled)
+ $showReasoning.set(!(value === false || value === 'false' || value === 0))
}