Skip to content

The agent that grows with you

feat(desktop): report how long the model thought

Brooklyn Nicholsona77c75f3e0b2
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 05c9809eacb..c3ddb255c7f 100644
--- a/apps/desktop/src/components/assistant-ui/thread/message-parts.tsx
+++ b/apps/desktop/src/components/assistant-ui/thread/message-parts.tsx
@@ -9,7 +9,7 @@ import { type ComponentProps, type FC, type ReactNode, useEffect, useRef, useSta
import { ClarifyTool } from '@/components/assistant-ui/clarify-tool'
import { MarkdownText, MarkdownTextContent } from '@/components/assistant-ui/markdown-text'
import { ToolFallback, ToolGroupSlot } from '@/components/assistant-ui/tool/fallback'
-import { useElapsedSeconds } from '@/components/chat/activity-timer'
+import { formatElapsed, useElapsedSeconds } from '@/components/chat/activity-timer'
import { ActivityTimerText } from '@/components/chat/activity-timer-text'
import { DisclosureRow } from '@/components/chat/disclosure-row'
import { GeneratedImage } from '@/components/chat/generated-image-result'
@@ -73,6 +73,22 @@ const ThinkingDisclosure: FC<{
const open = userOpen ?? pending
const isPreview = pending && userOpen === null
+ // How long the model thought is only knowable by having watched it happen —
+ // nothing in the persisted turn records it. So freeze the number the moment
+ // this block finishes in front of us, and stay quiet on a rehydrated turn
+ // rather than reporting whatever a timer that never ran would say.
+ const [watching, setWatching] = useState(false)
+ const [thoughtFor, setThoughtFor] = useState<null | number>(null)
+
+ useEffect(() => {
+ if (pending) {
+ setWatching(true)
+ } else if (watching) {
+ setWatching(false)
+ setThoughtFor(elapsed)
+ }
+ }, [elapsed, pending, watching])
+
// While the preview is live, pin the scroll container to the bottom on
// every content growth so the latest tokens are always visible.
useEffect(() => {
@@ -127,7 +143,9 @@ const ThinkingDisclosure: FC<{
pending && 'shimmer text-foreground/55'
)}
>
- {t.assistant.thread.thinking}
+ {pending || thoughtFor === null
+ ? t.assistant.thread.thinking
+ : t.assistant.thread.thoughtFor(formatElapsed(thoughtFor))}
</span>
{pending && (
<ActivityTimerText
diff --git a/apps/desktop/src/i18n/ar.ts b/apps/desktop/src/i18n/ar.ts
index 75dd38cd937..ee1fe3b2079 100644
--- a/apps/desktop/src/i18n/ar.ts
+++ b/apps/desktop/src/i18n/ar.ts
@@ -2273,6 +2273,7 @@ export const ar = defineLocale({
resumeWhenBackgroundDone: count =>
count === 1 ? 'سيُستأنف عند انتهاء المهمة الخلفية' : `سيُستأنف عند انتهاء ${count} مهام خلفية`,
thinking: 'يفكر...',
+ thoughtFor: duration => `فكّر لمدة ${duration}`,
today: time => `اليوم ${time}`,
yesterday: time => `أمس ${time}`,
copy: 'نسخ',
diff --git a/apps/desktop/src/i18n/en.ts b/apps/desktop/src/i18n/en.ts
index 459792634bb..f68b2657bc8 100644
--- a/apps/desktop/src/i18n/en.ts
+++ b/apps/desktop/src/i18n/en.ts
@@ -2668,6 +2668,7 @@ export const en: Translations = {
? 'Will resume when the background task finishes'
: `Will resume when ${count} background tasks finish`,
thinking: 'Thinking',
+ thoughtFor: duration => `Thought for ${duration}`,
today: time => `Today, ${time}`,
yesterday: time => `Yesterday, ${time}`,
copy: 'Copy',
diff --git a/apps/desktop/src/i18n/ja.ts b/apps/desktop/src/i18n/ja.ts
index 3783e47ff0d..ab01313842d 100644
--- a/apps/desktop/src/i18n/ja.ts
+++ b/apps/desktop/src/i18n/ja.ts
@@ -2517,6 +2517,7 @@ export const ja = defineLocale({
? 'バックグラウンドタスクの完了後に再開します'
: `${count} 件のバックグラウンドタスクの完了後に再開します`,
thinking: '考え中',
+ thoughtFor: duration => `${duration} 思考`,
today: time => `今日 ${time}`,
yesterday: time => `昨日 ${time}`,
copy: 'コピー',
diff --git a/apps/desktop/src/i18n/types.ts b/apps/desktop/src/i18n/types.ts
index 65496157153..f566b17f8cf 100644
--- a/apps/desktop/src/i18n/types.ts
+++ b/apps/desktop/src/i18n/types.ts
@@ -2267,6 +2267,7 @@ export interface Translations {
loadingResponse: string
resumeWhenBackgroundDone: (count: number) => string
thinking: string
+ thoughtFor: (duration: string) => string
today: (time: string) => string
yesterday: (time: string) => string
copy: string
diff --git a/apps/desktop/src/i18n/zh-hant.ts b/apps/desktop/src/i18n/zh-hant.ts
index c785aaebb42..e133f4ff3e7 100644
--- a/apps/desktop/src/i18n/zh-hant.ts
+++ b/apps/desktop/src/i18n/zh-hant.ts
@@ -2438,6 +2438,7 @@ export const zhHant = defineLocale({
resumeWhenBackgroundDone: count =>
count === 1 ? '背景工作完成後將自動繼續' : `${count} 個背景工作完成後將自動繼續`,
thinking: '思考中',
+ thoughtFor: duration => `思考了 ${duration}`,
today: time => `今天,${time}`,
yesterday: time => `昨天,${time}`,
copy: '複製',
diff --git a/apps/desktop/src/i18n/zh.ts b/apps/desktop/src/i18n/zh.ts
index f4b3377edcf..eebbba53eb8 100644
--- a/apps/desktop/src/i18n/zh.ts
+++ b/apps/desktop/src/i18n/zh.ts
@@ -2839,6 +2839,7 @@ export const zh: Translations = {
resumeWhenBackgroundDone: count =>
count === 1 ? '后台任务完成后将自动继续' : `${count} 个后台任务完成后将自动继续`,
thinking: '思考中',
+ thoughtFor: duration => `思考了 ${duration}`,
today: time => `今天,${time}`,
yesterday: time => `昨天,${time}`,
copy: '复制',