@@ -24,7 +24,6 @@ export const ChatPane = ({ projectId, chatId }: ChatPaneProps) => {
2424 const { chat, chatSource, isLoading : isLoadingChat } = useChat ( currentChatId ) ;
2525 const { createChat, isCreating } = useChats ( ) ;
2626 const { toast } = useToast ( ) ;
27- const [ status , setStatus ] = useState ( 'ready' ) ;
2827 const [ messages , setMessages ] = useState < any [ ] > ( [ ] ) ;
2928 const [ isLoadingMessages , setIsLoadingMessages ] = useState ( false ) ;
3029 const isFirstRender = useRef ( true ) ;
@@ -56,27 +55,11 @@ export const ChatPane = ({ projectId, chatId }: ChatPaneProps) => {
5655 } , [ setMessages , chatId ] ) ;
5756
5857 // Fetch chat status
59- const fetchChatStatus = useCallback ( async ( ) => {
60- if ( chatId === - 1 ) return ;
61- const { data, error } = await supabase
62- . from ( 'chats' )
63- . select ( 'status' )
64- . eq ( 'id' , chatId )
65- . single ( ) ;
66-
67- if ( error && error . code !== 'PGRST116' ) {
68- console . error ( 'Error fetching chat status:' , error ) ;
69- } else if ( data ) {
70- setStatus ( data . status ) ;
71- }
72- } , [ setStatus , chatId ] ) ;
73-
7458 useEffect ( ( ) => {
7559 setCurrentChatId ( chatId ) ;
7660 if ( chatId === - 1 ) return ;
7761
7862 fetchMessages ( ) ;
79- fetchChatStatus ( ) ;
8063
8164 // Subscribe to chat_messages
8265 const messagesChannel : RealtimeChannel = supabase
@@ -181,11 +164,10 @@ export const ChatPane = ({ projectId, chatId }: ChatPaneProps) => {
181164 < div className = "relative flex flex-col gap-1 w-full max-w-4xl mx-auto p-2 pt-0" >
182165 < ChatInput
183166 chatId = { chatId }
184- onSubmit = { handleSend }
167+ onSend = { handleSend }
185168 onReset = { handleReset }
186169 disabled = { true }
187170 className = "w-full"
188- sampleMessages = { [ 'sample message' ] }
189171 />
190172 </ div >
191173 </ div >
@@ -208,7 +190,10 @@ export const ChatPane = ({ projectId, chatId }: ChatPaneProps) => {
208190 const config = chatSource ?. flow ?. nodes ?. find (
209191 ( node : any ) => node . type === 'initializer'
210192 ) ;
211- const sampleMessages = config ?. data ?. sample_messages ?. split ( '\n' ) ?? [ ] ;
193+ let sampleMessages = config ?. data ?. sample_messages ; // string or array
194+ if ( sampleMessages && typeof sampleMessages === 'string' ) {
195+ sampleMessages = sampleMessages . split ( '\n' ) ;
196+ }
212197
213198 return (
214199 < div className = "flex flex-col w-full h-full bg-muted" >
@@ -236,10 +221,9 @@ export const ChatPane = ({ projectId, chatId }: ChatPaneProps) => {
236221 < div className = "relative flex flex-col gap-1 w-full max-w-4xl mx-auto p-2 pt-0" >
237222 < ChatInput
238223 chatId = { chatId }
239- onSubmit = { handleSend }
224+ onSend = { handleSend }
240225 onReset = { handleReset }
241- loading = { status === 'running' }
242- disabled = { status === 'failed' || currentChatId === - 1 }
226+ disabled = { currentChatId === - 1 }
243227 className = "w-full"
244228 sampleMessages = { sampleMessages }
245229 />
0 commit comments