import { ChevronDown, ChevronUp, Loader } from 'lucide-react' import { create } from 'zustand' import { RenderMarkdown } from './RenderMarkdown' import { useAppState } from '@/hooks/useAppState' interface Props { text: string id: string } // Zustand store for thinking block state type ThinkingBlockState = { thinkingState: { [id: string]: boolean } toggleState: (id: string) => void } const useThinkingStore = create((set) => ({ thinkingState: {}, toggleState: (id) => set((state) => ({ thinkingState: { ...state.thinkingState, [id]: !state.thinkingState[id], }, })), })) const ThinkingBlock = ({ id, text }: Props) => { const { thinkingState, toggleState } = useThinkingStore() const { streamingContent } = useAppState() const loading = !text.includes('') && streamingContent const isExpanded = thinkingState[id] ?? false const handleClick = () => toggleState(id) if (!text.replace(/<\/?think>/g, '').trim()) return null return (
{loading && ( )}
{isExpanded && (
/g, '').trim()} />
)}
) } export default ThinkingBlock