Skip to content

The agent that grows with you

feat(desktop): reasoning rests collapsed in the onboarding chat

alt-glitch34f22a188a12
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 6d8bde8b858..719d22b8edf 100644
--- a/apps/desktop/src/components/assistant-ui/thread/message-parts.tsx
+++ b/apps/desktop/src/components/assistant-ui/thread/message-parts.tsx
@@ -7,8 +7,9 @@ import {
useMessagePartText
} from '@assistant-ui/react'
import { useStore } from '@nanostores/react'
-import { type ComponentProps, type FC, type ReactNode, useEffect, useRef, useState } from 'react'
+import { type ComponentProps, type FC, type ReactNode, useEffect, useMemo, useRef, useState } from 'react'
+import { useSessionView } from '@/app/chat/session-view'
import { CatalogInstallTool } from '@/components/assistant-ui/catalog-install-tool'
import { ClarifyTool } from '@/components/assistant-ui/clarify'
import { ConnectorExecution, ConnectorTool } from '@/components/assistant-ui/connector-tool'
@@ -34,6 +35,7 @@ import { isTodoToolName } from '@/lib/todos'
import { type CardToolName, isCardTool, isCardToolName } from '@/lib/tool-render-class'
import { useEnterAnimation } from '@/lib/use-enter-animation'
import { cn } from '@/lib/utils'
+import { onboardingChatStore } from '@/store/onboarding-session'
import { $reasoningCollapsedByDefault, $showReasoning } from '@/store/reasoning-disclosure'
import { useForcedTextDirection } from '@/store/text-direction'
import { $showToolActivity } from '@/store/tool-activity'
@@ -225,7 +227,10 @@ const ThinkingDisclosure: FC<{
timerKey: string
}> = ({ children, completedAt, messageRunning = false, pending = false, timestamp, timerKey }) => {
const { t } = useI18n()
- const reasoningCollapsedByDefault = useStore($reasoningCollapsedByDefault)
+ const sessionId = useStore(useSessionView().$runtimeId)
+ const onboardingChat = useStore(useMemo(() => onboardingChatStore(sessionId), [sessionId]))
+ // The first-run chat rests reasoning collapsed: its cards and short replies carry the run.
+ const reasoningCollapsedByDefault = useStore($reasoningCollapsedByDefault) || onboardingChat
// `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)
@@ -240,7 +245,8 @@ const ThinkingDisclosure: FC<{
// a still-running turn) never latch, so they stay collapsed.
const [sawLivePreview, setSawLivePreview] = useState(false)
- if (pending && !sawLivePreview) {
+ // Not while collapsed: a block that never showed a preview must not open when the preference lifts.
+ if (pending && !sawLivePreview && !reasoningCollapsedByDefault) {
setSawLivePreview(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 a25a9ca38e5..b0614e95951 100644
--- a/apps/desktop/src/components/assistant-ui/thread/streaming.test.tsx
+++ b/apps/desktop/src/components/assistant-ui/thread/streaming.test.tsx
@@ -9,7 +9,10 @@ import { act, fireEvent, render, screen, waitFor, within } from '@testing-librar
import { useEffect, useState } from 'react'
import { beforeEach, describe, expect, it, vi } from 'vitest'
+import { $onboardingPhase } from '@/store/onboarding-phase'
+import { $onboardingSession } from '@/store/onboarding-session'
import { $reasoningCollapsedByDefault, setShowReasoningFromConfig } from '@/store/reasoning-disclosure'
+import { $activeSessionId } from '@/store/session'
import { stubThreadEnvironment, stubThreadViewportSize, ThreadRuntime } from '../test-utils'
@@ -435,6 +438,9 @@ describe('assistant-ui streaming renderer', () => {
resizeObservers.clear()
$reasoningCollapsedByDefault.set(false)
setShowReasoningFromConfig(undefined)
+ $activeSessionId.set(null)
+ $onboardingSession.set(null)
+ $onboardingPhase.set('idle')
})
it.each([true, false])('honors reasoning visibility %j for grouped and standalone parts', async enabled => {
@@ -698,6 +704,17 @@ describe('assistant-ui streaming renderer', () => {
expect(container.querySelector('[data-slot="aui_reasoning-text"]')?.textContent).toContain('const answer = 42')
})
+ it('keeps streaming reasoning collapsed in the onboarding chat', () => {
+ $activeSessionId.set('onboarding-chat')
+ $onboardingSession.set({ runId: 'run-1', runtimeId: 'onboarding-chat', storedId: 'stored-onboarding' })
+ $onboardingPhase.set('shown')
+
+ const { container } = render(<RunningReasoningHarness />)
+
+ expect(within(container).getByRole('button', { name: /thinking/i }).getAttribute('aria-expanded')).toBe('false')
+ expect(container.querySelector('[data-slot="aui_reasoning-text"]')).toBeNull()
+ })
+
it('renders reasoning text without a leading token space', () => {
const { container } = render(<ReasoningHarness />)
const ui = within(container)