diff --git a/src/renderer/src/components/pages/chat/ChatInput.tsx b/src/renderer/src/components/pages/chat/ChatInput.tsx index c88fedd..8e37953 100644 --- a/src/renderer/src/components/pages/chat/ChatInput.tsx +++ b/src/renderer/src/components/pages/chat/ChatInput.tsx @@ -198,6 +198,7 @@ const ChatInput = React.memo(forwardRef( ref ) => { const textAreaRef = useRef(null) + const isComposingRef = useRef(false) const { settings } = useSettingsStore() const insertQuote = useCallback((text: string) => { @@ -225,16 +226,24 @@ const ChatInput = React.memo(forwardRef( })) const handleKeyDown = useCallback((e: React.KeyboardEvent) => { - if (e.key === 'Enter' && !e.shiftKey) { + if (e.key === 'Enter' && !e.shiftKey && !isComposingRef.current) { e.preventDefault() onSend() } }, [onSend]) - + const handleTextChange = useCallback((e: React.ChangeEvent) => { onChange(e.target.value) }, [onChange]) + const handleCompositionStart = useCallback(() => { + isComposingRef.current = true + }, []) + + const handleCompositionEnd = useCallback(() => { + isComposingRef.current = false + }, []) + const hasNoModels = !llmConfigs || llmConfigs.length === 0 const hasNoSelectedModel = !selectedModel @@ -288,6 +297,8 @@ const ChatInput = React.memo(forwardRef( value={value} onChange={handleTextChange} onKeyDown={handleKeyDown} + onCompositionStart={handleCompositionStart} + onCompositionEnd={handleCompositionEnd} autoSize={{ minRows: 1, maxRows: 10 }} disabled={hasNoModels} />