import React from 'react' import { atom, useAtom } from 'jotai' import { ChevronDown, ChevronUp, Loader } from 'lucide-react' import { MarkdownTextMessage } from './MarkdownTextMessage' interface Props { text: string status: string id: number } const thinkingBlockStateAtom = atom<{ [id: number]: boolean }>({}) const ThinkingBlock = ({ id, text, status }: Props) => { const [thinkingState, setThinkingState] = useAtom(thinkingBlockStateAtom) const isExpanded = thinkingState[id] ?? false const loading = !text.includes('') && status === 'pending' const handleClick = () => { setThinkingState((prev) => ({ ...prev, [id]: !isExpanded })) } if (!text.replace(/<\/?think>/g, '').trim()) return null return (