Content without ENDTHINKFLAG
,
)
- // Initial state should show "Thinking..."
- expect(screen.getByText(/Thinking\.\.\./)).toBeInTheDocument()
-
- // Advance timer
- act(() => {
- vi.advanceTimersByTime(2000)
- })
-
- // Timer should still be running (showing "Thinking..." not "Thought")
- expect(screen.getByText(/Thinking\.\.\./)).toBeInTheDocument()
- expect(screen.getByText(/\(2\.0s\)/)).toBeInTheDocument()
+ // Timer should be stopped immediately — isResponding undefined means not in active response
+ expect(screen.getByText(/Thought/)).toBeInTheDocument()
})
})
diff --git a/web/app/components/base/markdown-blocks/think-block.tsx b/web/app/components/base/markdown-blocks/think-block.tsx
index f920218152..184ed89274 100644
--- a/web/app/components/base/markdown-blocks/think-block.tsx
+++ b/web/app/components/base/markdown-blocks/think-block.tsx
@@ -39,9 +39,10 @@ const removeEndThink = (children: any): any => {
const useThinkTimer = (children: any) => {
const { isResponding } = useChatContext()
+ const endThinkDetected = hasEndThink(children)
const [startTime] = useState(() => Date.now())
const [elapsedTime, setElapsedTime] = useState(0)
- const [isComplete, setIsComplete] = useState(false)
+ const [isComplete, setIsComplete] = useState(() => endThinkDetected)
const timerRef = useRef