'use client' import { useState } from 'react' import { toast } from 'sonner' import { TextArea } from '@/components/ui/textarea' import { Button } from '@/components/ui/button' import { usePlaygroundStore } from '@/store' import useAIChatStreamHandler from '@/hooks/useAIStreamHandler' import { useQueryState } from 'nuqs' import Icon from '@/components/ui/icon' const ChatInput = () => { const { chatInputRef } = usePlaygroundStore() const { handleStreamResponse } = useAIChatStreamHandler() const [selectedAgent] = useQueryState('agent') const [inputMessage, setInputMessage] = useState('') const isStreaming = usePlaygroundStore((state) => state.isStreaming) const handleSubmit = async () => { if (!inputMessage.trim()) return const currentMessage = inputMessage setInputMessage('') try { await handleStreamResponse(currentMessage) } catch (error) { toast.error( `Error in handleSubmit: ${ error instanceof Error ? error.message : String(error) }` ) } } return (