import { createSignal, Show } from 'solid-js' import { IconX, IconSend, IconUser, IconChevronDown } from '@tabler/icons-solidjs' import longcatIcon from '@/assets/longcat-color.svg' interface FloatingAIProps { onToggleChat: () => void isChatOpen: boolean } interface Message { id: string role: 'user' | 'assistant' content: string timestamp: Date } export function FloatingAI(props: FloatingAIProps) { const [messages, setMessages] = createSignal([ { id: '1', role: 'assistant', content: 'Hello! I\'m your AI assistant. How can I help you today?', timestamp: new Date() } ]) const [inputValue, setInputValue] = createSignal('') const [selectedModel, setSelectedModel] = createSignal('longcat-flash-chat') const [showModelSelector, setShowModelSelector] = createSignal(false) const aiModels = [ { id: 'longcat-flash-chat', name: 'LongCat Flash', description: 'Fast and efficient' }, { id: 'gpt-4', name: 'GPT-4', description: 'Most capable' }, { id: 'claude-3', name: 'Claude 3', description: 'Balanced performance' } ] const handleSendMessage = () => { const value = inputValue().trim() if (!value) return const userMessage: Message = { id: Date.now().toString(), role: 'user', content: value, timestamp: new Date() } setMessages(prev => [...prev, userMessage]) setInputValue('') // Simulate AI response setTimeout(() => { const aiMessage: Message = { id: (Date.now() + 1).toString(), role: 'assistant', content: 'I understand your question. Let me help you with that...', timestamp: new Date() } setMessages(prev => [...prev, aiMessage]) }, 1000) } const handleKeyPress = (e: KeyboardEvent) => { if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault() handleSendMessage() } } return ( <> {/* Floating AI Button */} {/* AI Chat Modal */}
{/* Header */}
AI Assistant

AI Assistant

Always here to help

{/* Model Selector Dropdown */}
{aiModels.map((model) => ( ))}
{/* Messages */}
{messages().map((message) => (
{message.role === 'assistant' && (
AI Assistant
)}

{message.content}

{message.timestamp.toLocaleTimeString()}

{message.role === 'user' && (
)}
))}
{/* Input */}
setInputValue(e.currentTarget.value)} onKeyPress={handleKeyPress} placeholder="Type your message..." class="flex-1 h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring" />
) }