/** * ChatInput -- Shared chat input component. * * Simple text input with send button, usable by both Workspace and Editor. */ import React, { useState, useCallback, useRef, useEffect } from 'react'; import { useLanguage } from '../../providers/language/LanguageContext'; interface ChatInputProps { onSend: (message: string) => void; isProcessing?: boolean; placeholder?: string; disabled?: boolean; autoFocus?: boolean; style?: React.CSSProperties; } export const ChatInput: React.FC = ({ onSend, isProcessing, placeholder, disabled, autoFocus = true, style, }) => { const { t } = useLanguage(); const resolvedPlaceholder = placeholder ?? t('Nachricht eingeben…'); const [value, setValue] = useState(''); const inputRef = useRef(null); useEffect(() => { if (autoFocus) inputRef.current?.focus(); }, [autoFocus]); const _handleSend = useCallback(() => { const trimmed = value.trim(); if (!trimmed || isProcessing || disabled) return; onSend(trimmed); setValue(''); }, [value, isProcessing, disabled, onSend]); const _handleKeyDown = useCallback( (e: React.KeyboardEvent) => { if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); _handleSend(); } }, [_handleSend] ); return (