Skip to content
This repository was archived by the owner on Sep 23, 2026. It is now read-only.

fix(web): preserve IME composition on Enter submission - #2658

Open
dvd233 wants to merge 1 commit into
MoonshotAI:mainfrom
dvd233:codex/fix/web-ime-enter-2643
Open

dvd233 wants to merge 1 commit into
MoonshotAI:mainfrom
dvd233:codex/fix/web-ime-enter-2643

Conversation

@dvd233

@dvd233 dvd233 commented Sep 20, 2026 •

Copy link
Copy Markdown

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 clear isComposing before the keydown handler runs.

Fix

Extend the shared PromptInputTextarea Enter guard with the browser compatibility fallback KeyboardEvent.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.
  • Target-file Biome check through stdin — passed.
  • git diff --check — passed.
  • The web package has no independent component-test runner; the fix is a one-line guard in the existing shared submit path and the production bundle compiles successfully.

Devin Review

Copilot AI lite review requested due to automatic review settings September 20, 2026 23:02

Copilot AI left a comment

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@devin-ai-integration devin-ai-integration Bot left a comment

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.

Devin Review found 1 potential issue.

Devin Review

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.

This branch has not been deployed

No deployments
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[kimi web] Enter pressed during IME composition is treated as 'send message'

2 participants