Skip to content

The agent that grows with you

feat(desktop): collapse thinking by default

Isak du Plessis10bf145e303e
diff --git a/apps/desktop/src/app/settings/appearance-settings.tsx b/apps/desktop/src/app/settings/appearance-settings.tsx
index 998f84bb6cf..a53757f0fb6 100644
--- a/apps/desktop/src/app/settings/appearance-settings.tsx
+++ b/apps/desktop/src/app/settings/appearance-settings.tsx
@@ -16,6 +16,7 @@ import { $backdrop, setBackdrop } from '@/store/backdrop'
import { $embedAllowed, $embedMode, clearEmbedAllowed, type EmbedMode, setEmbedMode } from '@/store/embed-consent'
import { $activeGatewayProfile, $profiles, normalizeProfileKey } from '@/store/profile'
import { $reactionsEnabled, setReactionsEnabled } from '@/store/reactions-enabled'
+import { $reasoningCollapsedByDefault, setReasoningCollapsedByDefault } from '@/store/reasoning-disclosure'
import { $toolViewMode, setToolViewMode } from '@/store/tool-view'
import { $translucency, setTranslucency } from '@/store/translucency'
import { $zoomPercent, setZoomPercent } from '@/store/zoom'
@@ -248,6 +249,7 @@ export function AppearanceSettings() {
const { t, isSavingLocale } = useI18n()
const { themeName, mode, resolvedMode, availableThemes, setTheme, setMode } = useTheme()
const toolViewMode = useStore($toolViewMode)
+ const reasoningCollapsedByDefault = useStore($reasoningCollapsedByDefault)
const zoomPercent = useStore($zoomPercent)
const embedMode = useStore($embedMode)
const embedAllowed = useStore($embedAllowed)
@@ -510,6 +512,24 @@ export function AppearanceSettings() {
title={a.toolViewTitle}
/>
+ <ListRow
+ action={
+ <SegmentedControl
+ onChange={id => {
+ triggerHaptic('selection')
+ setReasoningCollapsedByDefault(id === 'on')
+ }}
+ options={[
+ { id: 'off', label: t.common.off },
+ { id: 'on', label: t.common.on }
+ ]}
+ value={reasoningCollapsedByDefault ? 'on' : 'off'}
+ />
+ }
+ description={a.reasoningCollapsedDesc}
+ title={a.reasoningCollapsedTitle}
+ />
+
<ListRow
action={
<div className="flex flex-col items-end gap-1.5">
diff --git a/apps/desktop/src/components/assistant-ui/thread/message-parts.tsx b/apps/desktop/src/components/assistant-ui/thread/message-parts.tsx
index dd0a2e2204f..e328867af9e 100644
--- a/apps/desktop/src/components/assistant-ui/thread/message-parts.tsx
+++ b/apps/desktop/src/components/assistant-ui/thread/message-parts.tsx
@@ -4,6 +4,7 @@ import {
useAuiState,
useMessagePartReasoning
} from '@assistant-ui/react'
+import { useStore } from '@nanostores/react'
import { type ComponentProps, type FC, type ReactNode, useEffect, useRef, useState } from 'react'
import { ClarifyTool } from '@/components/assistant-ui/clarify-tool'
@@ -21,6 +22,7 @@ import { generatedImageFromResult } from '@/lib/generated-images'
import { separateGluedReasoningBlocks } from '@/lib/reasoning-blocks'
import { useEnterAnimation } from '@/lib/use-enter-animation'
import { cn } from '@/lib/utils'
+import { $reasoningCollapsedByDefault } from '@/store/reasoning-disclosure'
const ImageGenerateTool: FC<ToolCallMessagePartProps> = props => {
const { args, result } = props
@@ -103,10 +105,9 @@ const ThinkingDisclosure: FC<{
timerKey: string
}> = ({ children, messageRunning = false, pending = false, timerKey }) => {
const { t } = useI18n()
- // `null` = no explicit user toggle yet, defer to the streaming default.
- // The default is "auto-open while streaming, auto-collapse when done" so
- // reasoning surfaces a live preview without manual interaction. The first
- // explicit toggle wins from then on.
+ const reasoningCollapsedByDefault = useStore($reasoningCollapsedByDefault)
+ // `null` = no explicit user toggle yet. Live reasoning remains visible by
+ // default, unless the user opts into the low-jitter collapsed presentation.
const [userOpen, setUserOpen] = useState<boolean | null>(null)
const elapsed = useElapsedSeconds(pending, timerKey)
const thoughtFor = useMeasuredDuration(pending, timerKey)
@@ -114,8 +115,8 @@ const ThinkingDisclosure: FC<{
const contentRef = useRef<HTMLDivElement | null>(null)
const enterRef = useEnterAnimation(messageRunning, timerKey)
- const open = userOpen ?? pending
- const isPreview = pending && userOpen === null
+ const open = userOpen ?? (pending && !reasoningCollapsedByDefault)
+ const isPreview = pending && userOpen === null && !reasoningCollapsedByDefault
// Three ways a finished block can report itself. With a measured duration it
// says so, unless the timer's whole seconds round it to "0s" — accurate and
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 0cedda1e7b1..566e5b04e81 100644
--- a/apps/desktop/src/components/assistant-ui/thread/streaming.test.tsx
+++ b/apps/desktop/src/components/assistant-ui/thread/streaming.test.tsx
@@ -3,6 +3,8 @@ import { act, fireEvent, render, screen, waitFor, within } from '@testing-librar
import { useEffect, useState } from 'react'
import { beforeEach, describe, expect, it, vi } from 'vitest'
+import { $reasoningCollapsedByDefault } from '@/store/reasoning-disclosure'
+
import { Thread } from '.'
const createdAt = new Date('2026-05-01T00:00:00.000Z')
@@ -475,6 +477,7 @@ function DismissibleErrorHarness({ onDismissError }: { onDismissError: (messageI
describe('assistant-ui streaming renderer', () => {
beforeEach(() => {
resizeObservers.clear()
+ $reasoningCollapsedByDefault.set(false)
})
it('renders assistant text incrementally before completion', async () => {
@@ -602,6 +605,21 @@ describe('assistant-ui streaming renderer', () => {
expect(container.textContent).not.toContain('```ts')
})
+ it('keeps streaming reasoning collapsed by default when the preference is enabled', () => {
+ $reasoningCollapsedByDefault.set(true)
+
+ const { container } = render(<RunningReasoningHarness />)
+ const thinkingToggle = within(container).getByRole('button', { name: /thinking/i })
+
+ expect(thinkingToggle.getAttribute('aria-expanded')).toBe('false')
+ expect(container.querySelector('[data-slot="aui_reasoning-text"]')).toBeNull()
+
+ fireEvent.click(thinkingToggle)
+
+ expect(thinkingToggle.getAttribute('aria-expanded')).toBe('true')
+ expect(container.querySelector('[data-slot="aui_reasoning-text"]')?.textContent).toContain('const answer = 42')
+ })
+
it('renders reasoning text without a leading token space', () => {
const { container } = render(<ReasoningHarness />)
const ui = within(container)
diff --git a/apps/desktop/src/i18n/ar.ts b/apps/desktop/src/i18n/ar.ts
index 1397b6f4aa2..87ef6febddf 100644
--- a/apps/desktop/src/i18n/ar.ts
+++ b/apps/desktop/src/i18n/ar.ts
@@ -397,6 +397,8 @@ export const ar = defineLocale({
colorModeDesc: 'اختر الوضع الفاتح أو الداكن أو اتبع النظام.',
toolViewTitle: 'عرض الأدوات',
toolViewDesc: 'تحكم في كيفية عرض نشاط الأدوات داخل المحادثة.',
+ reasoningCollapsedTitle: 'طي التفكير افتراضيًا',
+ reasoningCollapsedDesc: 'أبقِ التفكير المتدفق متاحًا دون توسيعه حتى تفتحه.',
translucencyTitle: 'شفافية النافذة',
translucencyDesc: 'إظهار سطح المكتب من خلال النافذة بالكامل. متاح على macOS وWindows فقط.',
backdropTitle: 'خلفية النافذة',
diff --git a/apps/desktop/src/i18n/en.ts b/apps/desktop/src/i18n/en.ts
index f5f021424c0..27cd9c38bc5 100644
--- a/apps/desktop/src/i18n/en.ts
+++ b/apps/desktop/src/i18n/en.ts
@@ -458,6 +458,8 @@ export const en: Translations = {
colorModeDesc: 'Pick a fixed mode or let Hermes follow your system setting.',
toolViewTitle: 'Tool Call Display',
toolViewDesc: 'Product hides raw tool payloads; Technical shows full input/output.',
+ reasoningCollapsedTitle: 'Collapse thinking by default',
+ reasoningCollapsedDesc: 'Keep streamed reasoning available without expanding it until you open it.',
uiScaleTitle: 'UI Scale',
uiScaleDesc: (percent: number) =>
`Scales text and controls across the whole app. Cmd/Ctrl with +, - and 0 also works. Current: ${percent}%.`,
diff --git a/apps/desktop/src/i18n/ja.ts b/apps/desktop/src/i18n/ja.ts
index db3799c83b2..ddfac57f4c8 100644
--- a/apps/desktop/src/i18n/ja.ts
+++ b/apps/desktop/src/i18n/ja.ts
@@ -317,6 +317,8 @@ export const ja = defineLocale({
colorModeDesc: '固定モードを選ぶか、Hermes をシステム設定に合わせます。',
toolViewTitle: 'ツール呼び出しの表示',
toolViewDesc: 'プロダクト表示は生のツールペイロードを隠し、テクニカル表示は入出力をすべて表示します。',
+ reasoningCollapsedTitle: '思考ブロックをデフォルトで折りたたむ',
+ reasoningCollapsedDesc: 'ストリーミング中の推論を、開くまで折りたたんだまま利用できるようにします。',
uiScaleTitle: 'UI スケール',
uiScaleDesc: (percent: number) =>
`アプリ全体の文字と UI を拡大縮小します。Cmd/Ctrl と +、-、0 でも変更できます。現在: ${percent}%`,
diff --git a/apps/desktop/src/i18n/runtime.test.ts b/apps/desktop/src/i18n/runtime.test.ts
index 499fc1de6c9..dcf743dc5a6 100644
--- a/apps/desktop/src/i18n/runtime.test.ts
+++ b/apps/desktop/src/i18n/runtime.test.ts
@@ -44,6 +44,12 @@ describe('desktop i18n runtime translator', () => {
setRuntimeI18nLocale('zh-hant')
expect(translateNow('settings.appearance.title')).toBe('外觀')
expect(translateNow('settings.nav.providerApiKeys')).toBe('API 金鑰')
+
+ setRuntimeI18nLocale('ar')
+ expect(translateNow('settings.appearance.reasoningCollapsedTitle')).toBe('طي التفكير افتراضيًا')
+ expect(translateNow('settings.appearance.reasoningCollapsedDesc')).toBe(
+ 'أبقِ التفكير المتدفق متاحًا دون توسيعه حتى تفتحه.'
+ )
})
it('keeps translated settings field copy addressable from schema keys', () => {
diff --git a/apps/desktop/src/i18n/types.ts b/apps/desktop/src/i18n/types.ts
index ac803a37821..fd2fda62ee5 100644
--- a/apps/desktop/src/i18n/types.ts
+++ b/apps/desktop/src/i18n/types.ts
@@ -361,6 +361,8 @@ export interface Translations {
colorModeDesc: string
toolViewTitle: string
toolViewDesc: string
+ reasoningCollapsedTitle: string
+ reasoningCollapsedDesc: string
uiScaleTitle: string
uiScaleDesc: (percent: number) => string
terminalFontTitle: string
diff --git a/apps/desktop/src/i18n/zh-hant.ts b/apps/desktop/src/i18n/zh-hant.ts
index d3100740451..8ee30ed1f21 100644
--- a/apps/desktop/src/i18n/zh-hant.ts
+++ b/apps/desktop/src/i18n/zh-hant.ts
@@ -309,6 +309,8 @@ export const zhHant = defineLocale({
colorModeDesc: '選擇固定模式,或讓 Hermes 跟隨系統設定。',
toolViewTitle: '工具呼叫顯示',
toolViewDesc: '產品模式會隱藏原始工具 payload;技術模式會顯示完整輸入/輸出。',
+ reasoningCollapsedTitle: '預設摺疊推理過程',
+ reasoningCollapsedDesc: '保留串流推理內容,但在您開啟前維持摺疊。',
uiScaleTitle: '介面縮放',
uiScaleDesc: (percent: number) =>
`縮放整個應用程式的文字與介面。也可使用 Cmd/Ctrl 加 +、- 或 0 調整。目前:${percent}%`,
diff --git a/apps/desktop/src/i18n/zh.ts b/apps/desktop/src/i18n/zh.ts
index a1b03f9e450..b8e0696903e 100644
--- a/apps/desktop/src/i18n/zh.ts
+++ b/apps/desktop/src/i18n/zh.ts
@@ -448,6 +448,8 @@ export const zh: Translations = {
colorModeDesc: '选择固定模式,或让 Hermes 跟随系统设置。',
toolViewTitle: '工具调用显示',
toolViewDesc: '产品模式隐藏原始工具数据;技术模式显示完整输入/输出。',
+ reasoningCollapsedTitle: '默认折叠推理过程',
+ reasoningCollapsedDesc: '保留流式推理内容,但在您打开前保持折叠。',
uiScaleTitle: '界面缩放',
uiScaleDesc: (percent: number) =>
`缩放整个应用的文字和界面。也可使用 Cmd/Ctrl 加 +、- 或 0 调整。当前:${percent}%`,
diff --git a/apps/desktop/src/store/reasoning-disclosure.ts b/apps/desktop/src/store/reasoning-disclosure.ts
new file mode 100644
index 00000000000..08821f80341
--- /dev/null
+++ b/apps/desktop/src/store/reasoning-disclosure.ts
@@ -0,0 +1,16 @@
+import { atom } from 'nanostores'
+
+import { persistBoolean, storedBoolean } from '@/lib/storage'
+
+const REASONING_COLLAPSED_BY_DEFAULT_STORAGE_KEY = 'hermes.desktop.reasoning.collapsedByDefault'
+
+/** Desktop-local presentation preference; shared backend config must not be changed by a single window. */
+export const $reasoningCollapsedByDefault = atom(
+ storedBoolean(REASONING_COLLAPSED_BY_DEFAULT_STORAGE_KEY, false)
+)
+
+$reasoningCollapsedByDefault.subscribe(value => persistBoolean(REASONING_COLLAPSED_BY_DEFAULT_STORAGE_KEY, value))
+
+export function setReasoningCollapsedByDefault(value: boolean) {
+ $reasoningCollapsedByDefault.set(value)
+}