diff --git a/assets/js/collaborative-editor/components/ChatInterface.tsx b/assets/js/collaborative-editor/components/ChatInterface.tsx deleted file mode 100644 index 1a5a53b457..0000000000 --- a/assets/js/collaborative-editor/components/ChatInterface.tsx +++ /dev/null @@ -1,241 +0,0 @@ -import { useEffect, useRef, useState } from 'react'; - -import { cn } from '#/utils/cn'; - -/** - * ChatInterface Component - * - * AI Assistant chat interface for conversing with the AI. - * - * Features: - * - Message list with user and assistant messages - * - Input field for sending messages - * - Auto-scroll to latest message - * - Loading states - * - Error handling - */ - -interface Message { - id: string; - content: string; - role: 'user' | 'assistant'; - status: 'pending' | 'processing' | 'success' | 'error' | 'cancelled'; - code?: string; - inserted_at: string; -} - -interface ChatInterfaceProps { - messages?: Message[]; - onSendMessage?: (content: string) => void; - isLoading?: boolean; -} - -export function ChatInterface({ - messages = [], - onSendMessage, - isLoading = false, -}: ChatInterfaceProps) { - const [input, setInput] = useState(''); - const textareaRef = useRef(null); - - useEffect(() => { - const textarea = textareaRef.current; - if (!textarea) return; - - textarea.style.height = 'auto'; - textarea.style.height = `${textarea.scrollHeight}px`; - }, [input]); - - const handleSubmit = (e: React.FormEvent) => { - e.preventDefault(); - if (!input.trim() || isLoading) return; - - onSendMessage?.(input.trim()); - setInput(''); - }; - - const handleKeyDown = (e: React.KeyboardEvent) => { - if (e.key === 'Enter' && !e.shiftKey) { - e.preventDefault(); - handleSubmit(e); - } - }; - - return ( -
-
- {messages.length === 0 ? ( -
-
- - Loading session... -
-
- ) : ( - messages.map(message => ( -
-
- {message.role === 'assistant' ? ( -
-
-
- {message.content} -
- - {message.code && ( -
-
- - Workflow YAML - - -
-
-                            {message.code}
-                          
-
- )} - - {message.status === 'error' && ( -
- - - Failed to send message. Please try again. - -
- )} - - {message.status === 'processing' && ( -
-
- - - -
-
- )} -
-
- ) : ( -
-
-
-
- {message.content} -
-
- - {message.status === 'error' && ( -
- - - Failed to send - -
- )} -
-
- )} -
-
- )) - )} -
- -
-
-
-
-
-