MCPcopy Create free account
hub / github.com/Icecubesaad/OpenLLM-Studio / ChatInput

Function ChatInput

src/components/ChatInput.tsx:14–125  ·  view source on GitHub ↗
({ 
  onSend, 
  onStop,
  disabled = false, 
  placeholder = 'Message',
  selectedModel,
  availableModels,
  onModelChange,
  isGenerating = false
}: ChatInputProps)

Source from the content-addressed store, hash-verified

12}
13
14export function ChatInput({
15 onSend,
16 onStop,
17 disabled = false,
18 placeholder = 'Message',
19 selectedModel,
20 availableModels,
21 onModelChange,
22 isGenerating = false
23}: ChatInputProps) {
24 const [value, setValue] = useState('');
25 const textareaRef = useRef<HTMLTextAreaElement>(null);
26
27 useEffect(() => {
28 if (textareaRef.current) {
29 textareaRef.current.style.height = 'auto';
30 textareaRef.current.style.height = `${Math.min(textareaRef.current.scrollHeight, 150)}px`;
31 }
32 }, [value]);
33
34 const handleSend = () => {
35 if (!value.trim() || disabled || isGenerating) return;
36
37 onSend(value);
38 setValue('');
39 if (textareaRef.current) {
40 textareaRef.current.style.height = 'auto';
41 }
42 };
43
44 const handleKeyDown = (e: KeyboardEvent<HTMLTextAreaElement>) => {
45 if (e.key === 'Enter' && !e.shiftKey) {
46 e.preventDefault();
47 handleSend();
48 }
49 };
50
51 const selectedModelLabel = getModelDisplayName(selectedModel);
52
53 return (
54 <div className="p-4 pb-6">
55 <div className="max-w-3xl mx-auto">
56 {/* Floating input container */}
57 <div className="glass-strong rounded-2xl p-1 glow-crail-sm">
58 <div className="flex items-center gap-2 bg-[#1C1C1C] rounded-xl p-2">
59 {/* Model selector */}
60 <div className="relative flex-shrink-0 max-w-[240px]">
61 <span
62 className="pointer-events-none absolute left-3 right-8 top-1/2 -translate-y-1/2 truncate text-white text-xs font-medium"
63 title={selectedModel}
64 >
65 {selectedModelLabel}
66 </span>
67 <select
68 value={selectedModel}
69 onChange={(e) => onModelChange(e.target.value)}
70 disabled={disabled || isGenerating}
71 className="appearance-none h-10 w-[240px] px-3 py-2 bg-[#1F1F1F] hover:bg-[#2A2A2A] border border-[#333] hover:border-[#C15F3C] rounded-lg text-transparent focus:outline-none focus:border-[#C15F3C] transition-all disabled:opacity-50 pr-8 cursor-pointer [&>option]:text-white [&>option]:bg-[#1F1F1F]"

Callers

nothing calls this directly

Calls 1

getModelDisplayNameFunction · 0.85

Tested by

no test coverage detected