Skip to content

Defer chat composer keyboard handling to active IME composition - #237

Open
aideepmind wants to merge 1 commit into
cloudflare:mainfrom
aideepmind:fix/chat-ime-composition
Open

Defer chat composer keyboard handling to active IME composition#237
aideepmind wants to merge 1 commit into
cloudflare:mainfrom
aideepmind:fix/chat-ime-composition

Conversation

@aideepmind

Copy link
Copy Markdown

What does this change?

When a user types Chinese (or other IME-composed text) in the chat composer and presses Enter to confirm a candidate character, the message was being sent instead of inserting the chosen character. The same bug affected the chat-list rename input and the chat-title edit input.

This adds a single early-return guard at the top of three onKeyDown handlers in packages/workshop-frontend/src/ChatInterface.tsx. While the IME is composing, the guard (if (e.nativeEvent.isComposing || e.keyCode === 229) return;) defers to the IME, so Enter confirms a CJK candidate, Backspace edits the IME buffer, and arrow keys move within the IME instead of triggering application shortcuts.

Why is this obviously correct and trivially verifiable?

Three identical one-line guards in three known locations. The check is the standard, well-known IME-composition pattern used by antd, Radix, and GitHub Primer. isComposing is the modern spec-correct flag; keyCode === 229 is the legacy fallback for browsers / IMEs that fail to set it.

The complete effects are:

  • The composer <textarea> onKeyDown defers to the IME while composing. This covers Enter-send, Enter-on-slash-picker, Backspace-on-token, ArrowLeft/Right-on-token, and Escape-on-slash-picker — all of which were at risk of misfiring during composition.
  • The chat-list rename <input> onKeyDown defers to the IME, so Enter no longer prematurely saves the rename while the user is still picking CJK characters.
  • The chat-title edit <input> onKeyDown defers to the IME, with the same effect for chat titles.

pnpm types:check and pnpm lint:check both pass on the change.

Checklist

  • This is a small, concrete change; it is not a feature, refactor, or low-value cleanup.
  • I understand that maintainers decide whether the change is obviously correct and trivially verifiable.
  • I have read and followed the contribution guidelines.

@github-actions

Copy link
Copy Markdown


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@github-actions github-actions Bot added the workshop/frontend Changes to the Workshop frontend label Aug 17, 2026
@aideepmind

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@aideepmind

Copy link
Copy Markdown
Author

recheck

1 similar comment
@aideepmind

Copy link
Copy Markdown
Author

recheck

@aideepmind

Copy link
Copy Markdown
Author

@kentonv — friendly request: this is my first PR to cloudflare-os, so the
"2 workflows awaiting approval" gate is blocking the CLA bot from recording
the signature. Could a maintainer click "Approve" on the workflow runs
in the PR's Checks tab? Diff is 3 lines, see PR description.

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

Labels

workshop/frontend Changes to the Workshop frontend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant