Skip to content

Don't treat IME composition keys as Enter - #82

Open
arakawayasuaki wants to merge 1 commit into
cloudflare:mainfrom
arakawayasuaki:fix-ime-composition-enter
Open

Don't treat IME composition keys as Enter#82
arakawayasuaki wants to merge 1 commit into
cloudflare:mainfrom
arakawayasuaki:fix-ime-composition-enter

Conversation

@arakawayasuaki

Copy link
Copy Markdown

Problem

Typing Japanese (or any other IME-composed text) sends the prompt half-written. The Enter that commits a kana-kanji conversion reaches our onKeyDown handlers as a plain Enter, so the chat input submits mid-word.

The same bug hits every rename and inline-edit field across the app, and in the ⌘K command palette the arrow keys that pick a conversion candidate move the result selection instead.

There was no isComposing guard anywhere in the frontend.

Fix

Add isComposingKeyEvent() in src/utils/imeComposition.ts — checks nativeEvent.isComposing, plus the legacy keyCode === 229 that Safari still reports on the commit key — and bail out of the affected handlers while composition is in progress.

Guarded inputs:

  • ChatInterface.tsx — prompt input, chat-list rename, title edit
  • CommandPalette.tsx — ⌘K palette (Enter and the candidate-selection arrow keys)
  • FileSidebar.tsx — new-file name, file rename
  • ShareModal.tsx — add collaborator, create share link, link name
  • GadgetEditor.tsx, WorkpiecePicker.tsx, GadgetList.tsx, SidebarGadgetRow.tsx — title / rename fields
  • SettingsPage.tsx, Connections.tsx, ConnectionConfigModal.tsx, AdminFormatsPanel.tsx

Left alone: the Enter/Space handlers on role="button" divs in AdminPage.tsx, routes/outputs.tsx, routes/gatekeepers.tsx, routes/providers.tsx. Those activate buttons rather than edit text, so no IME is ever composing over them.

Testing

tsc --noEmit and oxlint pass with no new findings. Verified manually against a local pnpm run-local build: Japanese conversion now commits without submitting.

🤖 Generated with Claude Code

Typing Japanese (or any other IME-composed text) sent the prompt half-written:
the Enter that commits a kana-kanji conversion reached our keydown handlers as a
plain Enter, so the chat input submitted mid-word. The same bug hit every rename
and inline-edit field, and in the command palette the arrow keys that pick a
conversion candidate moved the result selection instead.

Add an isComposingKeyEvent() helper (nativeEvent.isComposing, plus the legacy
keyCode 229 that Safari still reports on the commit key) and bail out of the
affected handlers while composition is in progress.

The Enter/Space handlers on role="button" divs are left alone — they aren't text
inputs, so no IME is ever composing over them.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Aug 8, 2026

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.

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.

1 participant