Repository navigation
fix(native-chat): send on the Enter that commits a Hangul composition (#30159) - #30192
AmoabaKelvin merged 4 commits into
Conversation
…stablyai#30159) The chat composer swallowed the unmarked Enter that follows compositionend, because for Japanese and Chinese that Enter only confirms a candidate. Korean has no candidate step, so the same swallow made a message that ends in a composing syllable need a second Enter. The composer now passes compositionend's data to the shared Enter gesture owner; a Hangul-only commit releases the carry so the redispatched Enter reaches the send path after the value has settled. The composing keydown itself is still owned, so the last syllable is not sent early or twice. Other scripts, Hanja picks, and callers that pass no text keep the swallow. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to
|
ELI5
When you type Korean in the chat box, the last letter is still "being built" when you press Enter. Orca treated that Enter like the Japanese/Chinese "pick this word" Enter and threw it away, so you had to press Enter a second time to send. Korean has no word-picking step, so now that one Enter finishes the letter and sends the message. Japanese and Chinese work the same as before.
What Changed
Before: In Chat view, typing
안녕하세요with the Microsoft Korean IME and pressing Enter right after the last syllable only finished요. The message went out on the second Enter. Typing a space first avoided it.After: The same single Enter finishes
요and sends안녕하세요once, with the last syllable in it, not missing and not doubled.Mechanism: The chat composer uses the shared Enter gesture owner (
useImeEnterGestureOwnership). Ending a composition with Enter produces two keydowns: the composing one (Process/229) and a plainEnter/13 sent again aftercompositionend. The owner remembers the first one and swallows the second, because for Japanese and Chinese that second Enter only confirms a candidate.setComposing(false, committedText)now takes an optionalcommittedText. If that text is only Hangul (\p{Script=Hangul}: syllables and jamo), the owner forgets the remembered Enter, so the second keydown goes through to the normal send path.NativeChatComposerFieldpassescompositionend'sdatathrough. The composer still owns the first, composing keydown, and the value has settled (onImeSettled) before the second keydown arrives. That keeps the [Bug]: Create-worktree name field duplicates the last Hangul syllable on Enter (missing isComposing guard) #9525 duplicated-syllable problem from coming back.Why
Hangul composition has no candidate-confirm step. The Enter that commits a syllable is the user's own Enter, and that's how native Windows/macOS text fields treat it. Basing the decision on the committed text, not on the platform or the IME, keeps everything else as it is:
Alternatives considered:
ImeInput/ImeTextarea(soui/inputandui/textarea, including the AskUserQuestion "Other" field), the quick-commands menu, the workspace comment box, and the file-explorer inline input. They work exactly as before. Each one can opt in later with one argument if wanted. I kept this PR to the reported surface.Linked Issue
Fixes #30159
Visual Proof
Not attached yet. This changes keyboard behavior, and I have not recorded a before/after with a real Microsoft Korean IME session (see Testing). Recording to follow, or N/A if a maintainer prefers the automated coverage.
Testing
Not checked with a real Windows Korean IME session. The event sequences in the tests copy the orderings this hook already documents. Nobody has captured them from Microsoft Korean IME in DevTools yet.
Automated (run locally on Windows 11, Node 24.22.0, pnpm 12.8.1, Bun 1.4.3):
native-chat-composer-composition.test.tsx: I split the old Hangul "swallow" test into:안녕하세요, for both the Windows and macOS orderings日本語: the confirm Enter is still swallowed, and the next Enter still submits, for both orderingsnative-chat-structured-send-composition-clear.test.tsx: with the full composer, the Hangul message is sent once as안녕하세요, and the Japanese confirm Enter sends nothing.ime-composition-keyboard-event.test.ts:日本語,漢字,''and no text keep itisHangulCompositionCommit)endCompositiontest helper: happy-dom has noCompositionEvent, sofireEvent.compositionEnd(el, { data })dropsdata. The helper dispatches it withdataset.Commands:
pnpm typecheck: passpnpm lint: passpnpm run check:code-quality:changed: passoxfmt --checkon changed files: passsrc/renderer/src/components/native-chat,src/renderer/src/lib/ime*,src/renderer/src/components/tab-bar,src/renderer/src/components/sidebar/WorktreeMetaDialog*,src/renderer/src/components/right-sidebar/file-explorer*: 490 files / 5135 tests. OneTabBar.context-menu.test.tscase hit the 30 s timeout under load, then passed on its own.pnpm test/pnpm buildlocally, because this machine has no Visual Studio build tools for the nativenode-ptyrebuild. CI will cover those.Manual check, Windows 11 + Microsoft Korean IME (2-set), Chat view:
안녕하세요and press Enter right after요. It should send once, the sent text should be안녕하세요, and the composer should be empty afterwards, with no leftover요.한, press the Hanja key, pick韓with Enter. It should not send.にほんご, press Space, press Enter to confirm. It should not send; the next Enter sends.안녕and press Shift+Enter. You should get a newline, not a send.AI Disclosure
Written with Claude Code (Claude Opus 5.5). The cause was traced by reading the source, and the code and tests were written by the agent. A second agent pass reviewed the diff. The human reporter has not yet tried the fix with a real Korean IME.
Review
AI self-review:
NativeChatComposerFielddidn't use the IBus re-arm inonCompositionEnd()before this change, and still doesn't.compositionend.committedTextis optional, and existing callers are unchanged.Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
mobile/has its own Korean IME handling).ImeInput/ImeTextareafields (e.g. AskUserQuestion "Other") still need two Enters there. That's the same opt-in applied to more surfaces, so I left it out to keep this PR focused.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred).lintandtypecheckpass locally;testcovered for the affected suites only;buildleft to CIMaintainer changes
The fix is unchanged: Hangul-only
compositionenddata releases the remembered Enter, and only the chat composer passes the data. On top of it:maininto the branch.isHangulCompositionCommitwas only there for its own unit tests.안녕하세요once on the committing Enter. The field test that used to pin the swallow with가now pins it with a Japanese commit (日本語), sent with realdatathroughendComposition. The hook-level Hangul tests and the predicate table are gone, because the two composer tests cover the same behaviour. Both remaining tests fail when the fix is removed, and the Japanese one also fails when the rule is widened to any text.Not in this PR: Korean users still need two Enters in
ImeInput/ImeTextareafields, the file-explorer rename, the workspace comment box and the quick-commands menu. Those fields can opt in later, one argument each.ime-text-fieldalso needs the Hangul check before its IBus re-arm inonCompositionEnd.Visual proof: N/A, keyboard-only change.