From 24ff4b7d937ed6ccf32c17ee654b1106cb90908c Mon Sep 17 00:00:00 2001 From: yagitoshiro Date: Sun, 28 Jun 2026 13:13:46 +0900 Subject: [PATCH] fix(web): don't submit chat on Enter during IME composition The chat composers submit on Enter without checking whether an IME composition is active. For Japanese/Chinese/Korean input, pressing Enter to confirm a conversion fires the submit handler and sends a half-typed message. Guard the Enter handlers with e.nativeEvent.isComposing in the main chat editor, the anonymous free composer, and the mention/prompt picker key navigation. --- .../components/assistant-ui/inline-mention-editor.tsx | 4 +++- surfsense_web/components/assistant-ui/thread.tsx | 4 ++++ surfsense_web/components/free-chat/free-composer.tsx | 4 +++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/surfsense_web/components/assistant-ui/inline-mention-editor.tsx b/surfsense_web/components/assistant-ui/inline-mention-editor.tsx index 5fc942e54..ee2d1c873 100644 --- a/surfsense_web/components/assistant-ui/inline-mention-editor.tsx +++ b/surfsense_web/components/assistant-ui/inline-mention-editor.tsx @@ -696,7 +696,9 @@ export const InlineMentionEditor = forwardRef { // Arrow / Enter / Escape navigation for the active picker. const handleKeyDown = useCallback( (e: React.KeyboardEvent) => { + // While an IME composition is active (e.g. confirming a Japanese/Chinese/ + // Korean conversion), let the Enter/Arrow keys reach the IME instead of + // driving picker navigation/selection. + if (e.nativeEvent.isComposing) return; if (showPromptPicker) { if (e.key === "ArrowDown") { e.preventDefault(); diff --git a/surfsense_web/components/free-chat/free-composer.tsx b/surfsense_web/components/free-chat/free-composer.tsx index 162b906ad..d4523a4f9 100644 --- a/surfsense_web/components/free-chat/free-composer.tsx +++ b/surfsense_web/components/free-chat/free-composer.tsx @@ -99,7 +99,9 @@ export const FreeComposer: FC = () => { gate("mention documents"); return; } - if (e.key === "Enter" && !e.shiftKey) { + // Ignore Enter while an IME composition is active (e.g. confirming a + // Japanese/Chinese/Korean conversion) so it doesn't submit the message. + if (e.key === "Enter" && !e.shiftKey && !e.nativeEvent.isComposing) { e.preventDefault(); if (text.trim()) { aui.composer().send();