import { useRef, useCallback, useEffect } from 'react'; import { Send, Paperclip, Square, ListOrdered } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { Textarea } from '@/components/ui/textarea'; import { cn } from '@/lib/utils'; import { AgentModelSelector } from '../shared/agent-model-selector'; import type { PhaseModelEntry } from '@automaker/types'; interface InputControlsProps { input: string; onInputChange: (value: string) => void; onSend: () => void; onStop: () => void; onToggleImageDropZone: () => void; onPaste: (e: React.ClipboardEvent) => Promise; /** Current model selection (model + optional thinking level) */ modelSelection: PhaseModelEntry; /** Callback when model is selected */ onModelSelect: (entry: PhaseModelEntry) => void; isProcessing: boolean; isConnected: boolean; hasFiles: boolean; isDragOver: boolean; showImageDropZone: boolean; // Drag handlers onDragEnter: (e: React.DragEvent) => void; onDragLeave: (e: React.DragEvent) => void; onDragOver: (e: React.DragEvent) => void; onDrop: (e: React.DragEvent) => Promise; // Refs inputRef?: React.RefObject; } export function InputControls({ input, onInputChange, onSend, onStop, onToggleImageDropZone, onPaste, modelSelection, onModelSelect, isProcessing, isConnected, hasFiles, isDragOver, showImageDropZone, onDragEnter, onDragLeave, onDragOver, onDrop, inputRef: externalInputRef, }: InputControlsProps) { const internalInputRef = useRef(null); const inputRef = externalInputRef || internalInputRef; const handleKeyDown = (e: React.KeyboardEvent) => { if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); onSend(); } }; const adjustTextareaHeight = useCallback(() => { const textarea = inputRef.current; if (!textarea) return; textarea.style.height = 'auto'; textarea.style.height = `${textarea.scrollHeight}px`; }, [inputRef]); useEffect(() => { adjustTextareaHeight(); }, [input, adjustTextareaHeight]); const canSend = (input.trim() || hasFiles) && isConnected; return ( <> {/* Text Input and Controls */}