import * as React from 'react'; import { ArrowUp, Square } from 'lucide-react'; import { cn } from '@/lib/utils'; /** * PromptInput — the assistant's primary action. * * A textarea rather than an input, because these prompts are sentences: it grows * with the content up to a cap, keeps Enter as send, and leaves Shift+Enter for a * deliberate newline. That combination is what makes typing a real question feel * natural instead of cramped. * * `placeholders` is a list, but only the first is shown. It used to rotate every * few seconds; that was defensible when the panel opened on demand and wrong once * Owliver became permanent furniture, because a permanently visible field that * rewrites itself forever is movement in the corner of the eye with nothing to * gain — the suggestion chips already teach the range of what can be asked, and * they do it without a timer or a rerender every four seconds. */ export function PromptInput({ value, onChange, onSubmit, onStop, busy = false, placeholders = ['Ask anything…'], autoFocus = false, align = 'left', className, }) { const textareaRef = React.useRef(null); const [focused, setFocused] = React.useState(false); /* Grow to fit the content, up to a cap, then scroll internally. */ React.useEffect(() => { const el = textareaRef.current; if (!el) return; el.style.height = 'auto'; el.style.height = `${Math.min(el.scrollHeight, 148)}px`; }, [value]); React.useEffect(() => { if (autoFocus) textareaRef.current?.focus(); }, [autoFocus]); const submit = () => { if (!value.trim() || busy) return; onSubmit(value); }; const onKeyDown = (event) => { if (event.key === 'Enter' && !event.shiftKey) { event.preventDefault(); submit(); } }; const isCenter = align === 'center'; return (
); }