Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

fix(chat): prevent IME Enter from submitting during composition (#2976)

stbison7eeb60e376b9
diff --git a/apps/screenpipe-app-tauri/components/standalone-chat.tsx b/apps/screenpipe-app-tauri/components/standalone-chat.tsx
index 1f16fce80..c0d0f7da1 100644
--- a/apps/screenpipe-app-tauri/components/standalone-chat.tsx
+++ b/apps/screenpipe-app-tauri/components/standalone-chat.tsx
@@ -1100,6 +1100,7 @@ export function StandaloneChat({ className }: { className?: string } = {}) {
const [deletingConvId, setDeletingConvId] = useState<string | null>(null);
const [activePreset, setActivePreset] = useState<AIPreset | undefined>();
const [showMentionDropdown, setShowMentionDropdown] = useState(false);
+ const [isComposing, setIsComposing] = useState(false);
const [mentionFilter, setMentionFilter] = useState("");
const [selectedMentionIndex, setSelectedMentionIndex] = useState(0);
const [speakerSuggestions, setSpeakerSuggestions] = useState<MentionSuggestion[]>([]);
@@ -1635,6 +1636,14 @@ export function StandaloneChat({ className }: { className?: string } = {}) {
e.stopPropagation();
}
+ const nativeEvent = e.nativeEvent as KeyboardEvent & { isComposing?: boolean; keyCode?: number };
+ const nativeIsComposing = nativeEvent.isComposing || nativeEvent.keyCode === 229;
+
+ // Ignore Enter while an IME composition is active so confirmation does not submit the message.
+ if (isComposing || nativeIsComposing) {
+ return;
+ }
+
// Enter without shift submits the form
if (e.key === "Enter" && !e.shiftKey && !showMentionDropdown) {
e.preventDefault();
@@ -3960,6 +3969,8 @@ export function StandaloneChat({ className }: { className?: string } = {}) {
ref={inputRef}
value={input}
onChange={handleInputChange}
+ onCompositionStart={() => setIsComposing(true)}
+ onCompositionEnd={() => setIsComposing(false)}
onKeyDown={handleKeyDown}
placeholder={
disabledReason