summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMogamiTsuchikawa <[email protected]>2026-01-06 03:38:38 +0900
committerGitHub <[email protected]>2026-01-05 12:38:38 -0600
commit6b207b09d6a19aec70c7e312016779721f64a377 (patch)
tree3d51e67c69dec851d3be5a43077b208e908e9b71
parent9771325026f23ea6083bad9a47b97a0ed68b9251 (diff)
downloadopencode-6b207b09d6a19aec70c7e312016779721f64a377.tar.gz
opencode-6b207b09d6a19aec70c7e312016779721f64a377.zip
fix(app): avoid unintended submits during IME composition (#6952)
-rw-r--r--packages/app/src/components/prompt-input.tsx22
1 files changed, 21 insertions, 1 deletions
diff --git a/packages/app/src/components/prompt-input.tsx b/packages/app/src/components/prompt-input.tsx
index 02f584b99..4a3a96d67 100644
--- a/packages/app/src/components/prompt-input.tsx
+++ b/packages/app/src/components/prompt-input.tsx
@@ -1,5 +1,17 @@
import { useFilteredList } from "@opencode-ai/ui/hooks"
-import { createEffect, on, Component, Show, For, onMount, onCleanup, Switch, Match, createMemo } from "solid-js"
+import {
+ createEffect,
+ on,
+ Component,
+ Show,
+ For,
+ onMount,
+ onCleanup,
+ Switch,
+ Match,
+ createMemo,
+ createSignal,
+} from "solid-js"
import { createStore, produce } from "solid-js/store"
import { createFocusSignal } from "@solid-primitives/active-element"
import { useLocal } from "@/context/local"
@@ -246,6 +258,8 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
})
const isFocused = createFocusSignal(() => editorRef)
+ const [composing, setComposing] = createSignal(false)
+ const isImeComposing = (event: KeyboardEvent) => event.isComposing || composing() || event.keyCode === 229
const addImageAttachment = async (file: File) => {
if (!ACCEPTED_FILE_TYPES.includes(file.type)) return
@@ -868,6 +882,10 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
}
}
+ if (event.key === "Enter" && isImeComposing(event)) {
+ return
+ }
+
if (store.popover && (event.key === "ArrowUp" || event.key === "ArrowDown" || event.key === "Enter")) {
if (store.popover === "at") {
atOnKeyDown(event)
@@ -1489,6 +1507,8 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
}}
contenteditable="true"
onInput={handleInput}
+ onCompositionStart={() => setComposing(true)}
+ onCompositionEnd={() => setComposing(false)}
onKeyDown={handleKeyDown}
classList={{
"select-text": true,