Skip to content
This repository was archived by the owner on Sep 23, 2026. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix(web): guard IME composition Enter submission
Fixes #2643
  • Loading branch information
dvd233 committed Sep 20, 2026
commit 76f5c4c6361f9cd1b892e52f979cb289e2744806
3 changes: 2 additions & 1 deletion web/src/components/ai-elements/prompt-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,8 @@ export const PromptInputTextarea = forwardRef<
}

if (e.key === "Enter") {
if (isComposing || e.nativeEvent.isComposing) {
// WebKit may clear isComposing before keydown; 229 is the IME fallback.
if (isComposing || e.nativeEvent.isComposing || e.keyCode === 229) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 IME Enter still selects autocomplete

With autocomplete open, IME Enter reaches handleTextareaKeyDown and selects an option before this guard runs. The defaultPrevented return bypasses the fallback, replacing the IME candidate with an autocomplete choice.

Learn more

The shared keydown handler invokes the caller before checking whether Enter belongs to an active IME composition. The chat composer delegates that callback to the open slash-command or file-mention menu. Both menu handlers call preventDefault() and selectOption() for Enter when choices exist, so control returns to the shared handler with defaultPrevented set. The shared handler exits before evaluating the new keyCode === 229 fallback.

Example: A user types a file mention using a CJK IME while matching files keep the mention menu open. Pressing Enter to confirm the IME candidate selects the highlighted file instead, and the shared composition guard never runs.

Recommended fix: Apply the full composition check before invoking the consumer onKeyDown for Enter, or make both autocomplete keydown handlers ignore isComposing and key code 229 before consuming Enter. Add coverage for IME Enter with each autocomplete menu open.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

return;
}
if (e.shiftKey) {
Expand Down
Loading