🐛 Bugfix: Do not send chat message when Enter confirms IME composition by Tomato-1101 · Pull Request #4063 · ModelEngine-Group/nexent · GitHub
Skip to content

🐛 Bugfix: Do not send chat message when Enter confirms IME composition - #4063

Open
Tomato-1101 wants to merge 1 commit into
ModelEngine-Group:developfrom
Tomato-1101:fix/chat-input-ime-enter
Open

Tomato-1101 wants to merge 1 commit into
ModelEngine-Group:developfrom
Tomato-1101:fix/chat-input-ime-enter

Conversation

@Tomato-1101

Copy link
Copy Markdown

Fixes #2783

Symptom

In the chat input, pressing Enter to confirm an IME conversion (Japanese / Chinese / Korean, etc.) sends the half-typed message instead of just confirming the composition.

Root cause

handleKeyDown in frontend/app/[locale]/chat/components/chatInput.tsx treated every Enter keydown (without Shift) as "send" and did not check whether an IME composition was in progress.

Fix

Return early from handleKeyDown while composing: e.nativeEvent.isComposing || e.keyCode === 229 (keyCode 229 covers Safari, which reports isComposing=false on the keydown right after compositionend).

newchat/assistant-ui/composer.tsx is not affected: its input is ComposerPrimitive.Input from assistant-ui, which already ignores Enter during composition.

Tests

  • Added frontend/tests/component/chatInputImeEnter.test.tsx (plain Enter sends; Shift+Enter does not; Enter with isComposing or keyCode 229 neither sends nor has its keydown cancelled, i.e. event.defaultPrevented stays false so IME confirmation is not broken; the next plain Enter on the same input then sends exactly once). With the guard removed 2 of 4 fail (also when a preventDefault() is added to the guard); with the guard all pass.
  • npx vitest run: 7 files, 43 tests passed.
  • eslint / tsc --noEmit: no new errors (pre-existing ones are unchanged).

This PR was prepared with AI assistance; I reviewed and tested the changes.

Skip the Enter-to-send handler while an IME composition is active
(isComposing, or keyCode 229 for Safari) and add a regression test.

Fixes ModelEngine-Group#2783

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Pressing Enter once in Chinese input mode sends unfinished English directly

1 participant