import React, { useState, useRef, useEffect } from 'react'; import './InputBar.css'; export default function InputBar({ onSend, isLoading, config, setConfig, models }) { const [value, setValue] = useState(''); const textareaRef = useRef(null); useEffect(() => { if (!isLoading && textareaRef.current) { textareaRef.current.focus(); } }, [isLoading]); function autoResize() { const ta = textareaRef.current; if (!ta) return; ta.style.height = 'auto'; ta.style.height = Math.min(ta.scrollHeight, 160) + 'px'; } function handleChange(e) { setValue(e.target.value); autoResize(); } function handleKeyDown(e) { if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); handleSend(); } } function handleSend() { const trimmed = value.trim(); if (!trimmed || isLoading) return; onSend(trimmed); setValue(''); if (textareaRef.current) { textareaRef.current.style.height = 'auto'; } } const canSend = value.trim().length > 0 && !isLoading; return (
Temp setConfig(c => ({ ...c, temperature: parseFloat(e.target.value) || 0 }))} />
Chunks setConfig(c => ({ ...c, topK: parseInt(e.target.value) || 1 }))} />
⌵ Enter to send · Shift+Enter for newline