import { useState, useRef, useEffect } from "react" import { Button } from "@/components/ui/button" import { Textarea } from "@/components/ui/textarea" import { Badge } from "@/components/ui/badge" import { Paperclip, Mic, Send, Loader2, Search, Sparkles } from "lucide-react" import { FileUpload } from "./FileUpload" import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu" import { ChevronDown, MessageSquare } from "lucide-react" interface ChatInputProps { input: string setInput: (value: string) => void isLoading: boolean isResearchMode: boolean useHybrid: boolean selectedFiles: File[] setSelectedFiles: React.Dispatch> onSendMessage: (content: string) => void enableAutocomplete?: boolean autocompleteSuggestions?: string[] showAutocomplete?: boolean setShowAutocomplete?: (show: boolean) => void onToggleResearch: () => void onToggleHybrid: () => void } export function ChatInput({ input, setInput, isLoading, isResearchMode, useHybrid, selectedFiles, setSelectedFiles, onSendMessage, enableAutocomplete = true, autocompleteSuggestions = [], showAutocomplete = false, setShowAutocomplete, onToggleResearch, onToggleHybrid }: ChatInputProps) { const inputRef = useRef(null) const textareaRef = useRef(null) // Auto-resize textarea useEffect(() => { if (textareaRef.current) { textareaRef.current.style.height = "auto" textareaRef.current.style.height = `${Math.min(textareaRef.current.scrollHeight, 200)}px` } }, [input]) const handleSubmit = (e: React.FormEvent) => { e.preventDefault() if (input.trim() || selectedFiles.length > 0) { onSendMessage(input) } } const getCurrentMode = () => { if (isResearchMode) return { label: "Research", icon: Search, color: "text-blue-500" } if (useHybrid) return { label: "Hybrid", icon: Sparkles, color: "text-purple-500" } return { label: "Chat", icon: MessageSquare, color: "text-muted-foreground" } } const currentMode = getCurrentMode() const ModeIcon = currentMode.icon return (
{selectedFiles.length > 0 && (
)}
{ if (isResearchMode) onToggleResearch() if (useHybrid) onToggleHybrid() }}> Standard Chat { if (isResearchMode) onToggleResearch() if (!useHybrid) onToggleHybrid() }}> Hybrid RAG { if (!isResearchMode) onToggleResearch() if (useHybrid) onToggleHybrid() // Ensure hybrid is off when research is on, though logic might handle this upstream }}> Agentic Research