Skip to content

Fix: respect IME composition state on Enter key send - #16922

Merged
JinHai-CN merged 1 commit into
infiniflow:mainfrom
iwasaki1112:fix/ime-composition-enter-key
Aug 28, 2026
Merged

JinHai-CN merged 1 commit into
infiniflow:mainfrom
iwasaki1112:fix/ime-composition-enter-key

Conversation

@iwasaki1112

@iwasaki1112 iwasaki1112 commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

What

Pressing Enter to confirm IME (e.g. Japanese/Chinese/Korean) text
composition was incorrectly treated as the chat "send" trigger,
causing an unintended message to be sent before the user finished
composing their input.

Why

NextMessageInput and FloatingChatWidget both bind their Enter-to-send
handler with only e.key === 'Enter' && !e.shiftKey, without checking
whether the Enter key press was part of an IME composition
(event.nativeEvent.isComposing). This is a common pitfall for React
onKeyDown handlers and breaks the chat input for CJK IME users.

Fix

Added && !e.nativeEvent.isComposing to the existing Enter/shiftKey
check in both components, so Enter presses used to confirm IME
composition no longer trigger message submission.

Testing

Built the patched frontend from source and deployed it against a
running RAGFlow instance (Docker, docker-ragflow-cpu-1 container),
then exercised the actual NextMessageInput textarea in the Agent
Canvas chat panel:

  • Dispatched compositionstart -> typed text -> keydown (Enter,
    isComposing: true) -> compositionend, simulating an IME
    conversion-confirm Enter press. Confirmed the textarea content was
    preserved and no message was sent.
  • Dispatched a normal keydown (Enter, isComposing: false)
    afterwards on the same input and confirmed the message was sent
    and processed by the agent as expected.

Both cases behaved correctly with this fix applied.

Pressing Enter to confirm IME (e.g. Japanese) text conversion was
incorrectly treated as the send trigger, sending an unintended
message before composition was finished. Check
event.nativeEvent.isComposing alongside the existing Enter/shiftKey
check in NextMessageInput and FloatingChatWidget so composition-confirm
Enter presses no longer submit the message.
@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. 🐞 bug Something isn't working, pull request that fix bug. labels Jul 15, 2026
@coderabbitai

coderabbitai Bot commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Enter-key submission in the floating chat widget and next message input now ignores IME composition events while preserving existing Shift+Enter behavior and message submission actions.

Changes

IME-safe message submission

Layer / File(s) Summary
Add composition guards
web/src/components/floating-chat-widget.tsx, web/src/components/message-input/next.tsx
Both Enter-key handlers now require !e.nativeEvent.isComposing before sending or submitting messages.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Possibly related PRs

  • infiniflow/ragflow#16739: Updates the same message input’s Enter-to-submit behavior with loading/state-based duplicate-send prevention.

Suggested labels: size:S

Suggested reviewers: cike8899

Poem

I’m a bunny guarding each key,
Keeping composed words safe and free.
Enter waits while letters blend,
Then sends the message at the end.
Hop, type, submit!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly matches the PR’s core change: guarding Enter-to-send during IME composition.
Description check ✅ Passed The description covers the purpose and context well, though it doesn’t use the template’s single Summary section heading.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@JinHai-CN
JinHai-CN requested a review from cike8899 July 15, 2026 07:44
@cike8899 cike8899 added the ci Continue Integration label Aug 28, 2026
@JinHai-CN
JinHai-CN merged commit 2f36949 into infiniflow:main Aug 28, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants