Skip to content

Don't send the chat message on an IME composition Enter - #280

Merged
maxwellpeterson merged 1 commit into
cloudflare:mainfrom
kochizufan:ime-composition-fix
Aug 20, 2026
Merged

maxwellpeterson merged 1 commit into
cloudflare:mainfrom
kochizufan:ime-composition-fix

Conversation

@kochizufan

@kochizufan kochizufan commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

What does this change?

The chat textarea treats every un-shifted Enter as "send". An IME commits a composition with Enter, and the browser delivers that as an ordinary keydown, so the first Enter of a Japanese, Chinese or Korean sentence sends the message half-typed. Reproducing it needs only an IME: type かんじ, press Enter to pick the conversion, and the partial message is already on its way.

The same handler drives the slash-command picker, where Escape cancels a composition and the arrow keys walk the IME's candidate list — both are currently taken from the IME.

This returns early from the handler while a composition is in flight, handing the whole keystroke back to the IME.

Why is this obviously correct and trivially verifiable?

isComposing is true only between compositionstart and compositionend. Outside a composition — which is every keystroke for anyone not typing through an IME — it is false, the guard falls through, and the handler below runs exactly as before. So the patch cannot change behaviour for existing users; the only difference is that keydowns delivered mid-composition no longer reach the handlers underneath.

Six added lines in one file. No new state, no new props, no API change. The property lives on the native event because React's synthetic KeyboardEvent does not re-expose it.

Verified against a deployment: composition Enter no longer sends, ordinary Enter still sends, Shift+Enter still breaks the line, and the slash-command picker's Enter, arrows and Escape are unchanged when no IME is involved.

Checklist

Checking every item does not guarantee acceptance. Maintainers determine whether
a pull request meets the contribution policy.

  • 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.

There are ~24 other key === 'Enter' handlers in the frontend (renames, share dialogs, the command palette) with the same defect. I kept this to the chat input, where the damage is unrecoverable, rather than exceed the size the guidelines ask for. Happy to open a discussion about the rest.


Open in Devin Review

Committing a composition presses Enter, and the browser delivers that as
an ordinary keydown, so the first Enter of every Japanese, Chinese or
Korean sentence sent the message half-typed. The same keydown also
reaches the slash-command picker, where Escape and the arrow keys belong
to the IME's candidate list rather than the picker.

Return early while a composition is in flight, which hands the whole
keystroke back to the IME. `isComposing` lives on the native event;
React's synthetic KeyboardEvent does not re-expose it.
@github-actions github-actions Bot added the workshop/frontend Changes to the Workshop frontend label Aug 20, 2026

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

@maxwellpeterson

Copy link
Copy Markdown
Member

Thanks @kochizufan!

@maxwellpeterson
maxwellpeterson merged commit 01e733f into cloudflare:main Aug 20, 2026
15 of 18 checks passed
tosaka07 added a commit to tosaka07/cloudflare-os that referenced this pull request Aug 21, 2026
* upstream/main:
  Seed Linear and Spotify OAuth creds in local dev (cloudflare#90)
  add IME composition guards across the board (cloudflare#291)
  follow-up fixes from cloudflare#274 (cloudflare#290)
  Don't send the chat message on an IME composition Enter (cloudflare#280)
  Lay the foundation for a Google Drive gatekeeper (cloudflare#286)
  fix gatekeeper connection modal on mobile (cloudflare#289)
  make context collection settings visible on mobile (cloudflare#288)
  fix modal presentation for embedded gatekeeper UI (cloudflare#287)
  Frontend reconnect hardening: tab wake & reconnect probe (cloudflare#172)
  store context files as byte arrays instead of JS strings (cloudflare#274)
  Pin @cloudflare/* to the public registry, and move CI onto setup-vp (cloudflare#283)
  Make the Workshop UI fully responsive on phones (cloudflare#284)
darjss pushed a commit to darjss/cloudflare-os-erxes that referenced this pull request Aug 26, 2026
Committing a composition presses Enter, and the browser delivers that as
an ordinary keydown, so the first Enter of every Japanese, Chinese or
Korean sentence sent the message half-typed. The same keydown also
reaches the slash-command picker, where Escape and the arrow keys belong
to the IME's candidate list rather than the picker.

Return early while a composition is in flight, which hands the whole
keystroke back to the IME. `isComposing` lives on the native event;
React's synthetic KeyboardEvent does not re-expose it.
gmackie pushed a commit to gmackie/educate-os that referenced this pull request Nov 2, 2026
…strict Worker' (cloudflare#280) from SCHO-179-launch-wiring into main
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.

2 participants