Repository navigation
fix(native-chat): ignore IME confirmation Enter in the AskUserQuestion free-text field - #19288
tb-soshiro wants to merge 1 commit into
Conversation
…n free-text field The "Other" input submitted the answer on the Enter that only confirms a CJK IME conversion candidate, so Japanese/Chinese/Korean users delivered a half-converted string mid-composition. Guard the keydown with the shared IME helpers (isComposing / keyCode 229, plus the gesture carry that covers the unmarked Enter macOS redispatches after keyup), matching the other Enter-to-commit inputs. Fixes stablyai#17820 Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NB7zwBTfSVwgYrnUzpXRYo
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthrough
Merge Risk: ⚪ Minimal · up to The free-text answer field now commits CJK IME conversions without submitting them, while normal Enter submission remains covered. No concrete merge-blocking risk remains. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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. Comment |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- IME confirm-Enter guard on the free-text input —
NativeChatQuestionCard.tsxnow returns early fromonKeyDownfor IME-owned keydowns viaimeEnter.ownsKeyDown(e) || isImeCompositionKeyDown(e), and wiresonKeyUp,onCompositionStart,onCompositionEnd, andonBlur={imeEnter.reset}. - Seven-case happy-dom test —
NativeChatQuestionCard.ime-enter.test.tsxcoversisComposing,keyCode 229, the macOS unmarked-redispatch carry, carry expiry, blur-without-compositionendrelease, and the unaffected plain-Enter path.
The change is well-scoped and correctly reuses the shared IME helpers. The pairing matches ComposerParentWorktreePicker exactly (same ownsKeyDown || isImeCompositionKeyDown guard plus onKeyUp/onCompositionStart/onCompositionEnd), and the added onBlur={imeEnter.reset} is the same defensive reset NativeChatComposerField and the tab-bar search already use. The input here is controlled (value/onChange), so omitting the composer field's settleImeValue is correct. Non-IME input is unaffected (no isComposing, keyCode 13 falls through to the existing Enter path), and the assertions pin exact values, so they would fail without the guard, the onKeyUp wiring, or the blur reset.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
nwparker
left a comment
There was a problem hiding this comment.
Thanks for this — the explanation of how Japanese input actually works was the useful part, and it is exactly why the bug is easy to miss.
I checked and it is still broken on main: the answer field's Enter handler is a bare
if (e.key === 'Enter') { e.preventDefault(); confirm(true) }with no composition check at all (NativeChatQuestionCard.tsx:208). Yours really was the one input in the app that got skipped — the mobile question card has no Enter-submit handler, so there is no second site to fix.
Reaching for the shared Enter helper rather than a plain "is something being composed" test was the right call. It also catches the case where the confirming Enter is delivered a second time without being marked, which a simpler check would let through and send.
Two process notes:
- Your CI had never actually run — this is a fork PR and the workflow runs were sitting in
action_required, so only the AI reviewer had executed. I have approved them; merging once they are green. - One of the automated reviewers asked for more doc comments on the new code. Please ignore that. Our guidance is short comments only where they explain something non-obvious, and the one you wrote does exactly that.
Separately, you are right that Shift+Enter also submits when nothing is being composed. I would rather not widen this change to cover it — I will track that on its own ticket.
Your branch is a couple of weeks old and still applies without a conflict, so there is nothing to rebase. Good to go.
|
Taking this over and continuing it in #22627, with your commit and authorship preserved. Nothing was wrong with the fix — it is kept verbatim. Two mechanical reasons for a new PR:
I checked the bug is still live before doing any of that: the answer field's Enter handler on Reaching for the shared Enter helper instead of a plain "is something being composed" test was the right instinct, and I said so in the new PR. It catches the confirming Enter being delivered a second time unmarked, which a simpler check would let through and send. One of the automated reviewers asked for more doc comments on the new code. That was wrong and I ignored it — our guidance is short comments only where they explain something non-obvious, which yours does. You are right that Shift+Enter also submits when nothing is being composed. I left it out of scope deliberately and will track it separately rather than widen this. Closing in favour of #22627. Thank you — the explanation of how Japanese input actually behaves is what made this easy to verify. |

ELI5
Japanese, Chinese and Korean keyboards use Enter to confirm a converted word before it is really typed. The "Other" answer box in the AskUserQuestion card treated that confirm-Enter as "send", so the answer was sent while the user was still choosing the word. Now that Enter only confirms the word, and the next Enter sends.
What Changed
NativeChatQuestionCard.tsx: the free-text ("Other") input'sonKeyDownnow returns early when the keydown belongs to the IME, using the existing helpersuseImeEnterGestureOwnership+isImeCompositionKeyDownfrom@/lib/ime-composition-keyboard-event. The input also wiresonKeyUp/onCompositionStart/onCompositionEndso the gesture carry works, andonBlur={imeEnter.reset}so a composition that never seescompositionend(paste replaced it, the row unmounted) cannot leave the card swallowing every later Enter. This is the same pairingComposerParentWorktreePickeruses, plus the blur resetNativeChatComposerFieldand the tab-bar search field already do.NativeChatQuestionCard.ime-enter.test.tsx(new): seven cases.isComposingalone,isComposing+keyCode 229,keyCode 229alone, and the macOS "marked Enter → keyup → unmarked Enter" sequence do not submit; the next deliberate Enter after the carry expires does submit; blur withoutcompositionendreleases ownership; a plain Enter still submits the typed text. RemovingonKeyUporonBlurfrom the input fails a test.No behavior change for non-IME input: a plain Enter submits exactly as before, and an empty-field Enter stays a no-op.
Why
The handler only checked
e.key === 'Enter', so the confirm keystroke and the submit keystroke were indistinguishable. Every other Enter-to-commit input in Orca (workspace name, rename fields, comment composer, search bar) already guards this; the question card was the one left out. Using the shared helpers rather than a bareisComposingcheck also covers macOS, where the confirm redispatches an unmarked Enter after keyup (see the comment inime-composition-keyboard-event.ts).Note: #17820 is assigned to @nwparker — apologies if this crosses an in-flight branch. It is a small, self-contained change, so I hope it is useful as-is; happy to close it in favor of yours otherwise.
Linked Issue
Fixes #17820
Visual Proof
Chat UI, Japanese locale, macOS. In the "Other" field,
にほんごis typed through the IME and converted to日本語(underlined = still composing), then Enter is pressed to confirm the conversion.After, with a real IME (Google Japanese Input), by hand:
The confirming Enter commits
日本語into the field and nothing is sent; the card stays open with "Submit".Before vs. after, same scripted input on both builds:
日本語main)Submitted immediately — the card flips to "Sending…" while the IME is still open.
Enter only confirms
日本語; the card stays open with "Submit".A second, plain Enter then delivers the answer:
The before/after pair was captured on a
pnpm devbuild (before = the component hot-swapped to itsmainversion). That composition was driven through CDP (Input.imeSetComposition+ an Enter keydown with keyCode 229 while composing) so both runs are identical; the real-IME screenshots above show the same fixed build by hand.Testing
macOS 26 (arm64), macOS built-in Japanese IME and Google Japanese Input, Claude Code in the Chat UI (terminal-backed path; the structured native chat path renders the same card).
Reproduced the bug on the released 1.4.197 build, then confirmed the fix on a
pnpm devbuild of this branch.pnpm lintandpnpm typecheckpass locally.pnpm test: 7960 files / 73,846 tests pass; the one failing suite isconfig/scripts/workflow-ref-reachability.test.mjs, which needsgit init --ref-format=reftable(git ≥ 2.45) and my machine has git 2.41 — unrelated to this change.pnpm buildnot run locally; relying on CI.I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Claude Code (Claude Fable 5.1) drafted the change and tests; I reviewed the diff and did the manual IME verification.
Review
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
Renderer-only change; no platform, SSH/remote, or mobile impact beyond the desktop card. Benefits all CJK IME users (Japanese, Chinese Pinyin/Zhuyin, Korean).
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)