diff --git a/frontend/src/components/editor-ai/ChatTab.tsx b/frontend/src/components/editor-ai/ChatTab.tsx new file mode 100644 index 00000000..a5ad067e --- /dev/null +++ b/frontend/src/components/editor-ai/ChatTab.tsx @@ -0,0 +1,80 @@ +import { useRef, useEffect } from 'react' +import { Send, Sparkles } from 'lucide-react' +import type { EditorAIChatMessage } from '@/types' + +interface ChatTabProps { + messages: EditorAIChatMessage[] + input: string + onInputChange: (value: string) => void + onSend: () => void + isLoading: boolean +} + +export function ChatTab({ messages, input, onInputChange, onSend, isLoading }: ChatTabProps) { + const messagesEndRef = useRef(null) + + useEffect(() => { + messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' }) + }, [messages]) + + const handleKeyDown = (e: React.KeyboardEvent) => { + if (e.key === 'Enter' && !e.shiftKey) { + e.preventDefault() + if (input.trim() && !isLoading) onSend() + } + } + + return ( +
+
+ {messages.length === 0 && ( +
+ +

Ask me to help build your flow

+
+ )} + {messages.map((msg, i) => ( +
+

{msg.content}

+
+ ))} + {isLoading && ( +
+
+
+
+
+
+
+ )} +
+
+
+
+