import React from 'react' import { atom, useAtom } from 'jotai' import { ChevronDown, ChevronUp, Loader } from 'lucide-react' interface Props { text: string status: string id: string } const thinkingBlockStateAtom = atom<{ [id: string]: 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 (
{loading && ( )}
{isExpanded && (
{text.replace(/<\/?think>/g, '').trim()}
)}
) } export default ThinkingBlock