import { Box, Flex, Input } from '@chakra-ui/react'; import { useState, useEffect, useRef } from 'react'; import type { KeyboardEvent } from 'react'; interface ChatInputProps { onSend: (message: string) => void; isTyping?: boolean; } export const ChatInput = ({ onSend, isTyping }: ChatInputProps) => { const [value, setValue] = useState(''); const [isFocused, setIsFocused] = useState(false); const inputRef = useRef(null); const handleKeyDown = (e: KeyboardEvent) => { if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); if (value.trim()) { onSend(value.trim()); setValue(''); } } }; useEffect(() => { inputRef.current?.focus(); }, []); return ( inputRef.current?.focus()} cursor="text" > {isTyping ? ( luna is processing... ) : ( 'guest@luna:~ $' )} setValue(e.target.value)} onKeyDown={handleKeyDown} onFocus={() => setIsFocused(true)} onBlur={() => setIsFocused(false)} disabled={isTyping} color="gray.200" css={{ caretColor: 'transparent' }} autoComplete="off" spellCheck={false} p={0} h="auto" lineHeight="1.5" borderBottom="none" _focus={{ borderBottom: 'none', boxShadow: 'none' }} _placeholder={{ color: 'transparent' }} /> {!isTyping && isFocused && ( )} ); };