Repository navigation
Conversation
| 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) { |
There was a problem hiding this comment.
🟡 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.
Was this helpful? React with 👍 or 👎 to provide feedback.
Fixes #2643
Problem
In
kimi web, pressing Enter while a CJK IME composition is still active can submit the prompt instead of confirming the composition. The issue is reproducible with multiple IMEs in macOS/WKWebView; WebKit can clearisComposingbefore the keydown handler runs.Fix
Extend the shared
PromptInputTextareaEnter guard with the browser compatibility fallbackKeyboardEvent.keyCode === 229. Normal Enter (keyCode === 13) and Shift+Enter behavior remain unchanged, while the native IME composition is allowed to commit without submitting the form.Verification
npm run typecheck— passed.npm run build— passed; 8,778 modules transformed.git diff --check— passed.