Repository navigation
fix(studio): allow Enter to send with idle macOS Pinyin IME - #12138
danielhanchen merged 6 commits into
Conversation
macOS Pinyin can report plain Enter as composing even when no candidate session is active, which left the composer treating it as IME-owned and never reaching submit. Send on idle plain Enter when composingRef was false; keep blocking Enter during an active composition session. Fixes unslothai#12137
Allow plain Enter when macOS Pinyin marks keyCode 229 without an active composition, but keep blocking after compositionstart until compositionend so watchdog-cleared composingRef still re-pins candidate Enter (unslothai#5546). Update structural IME contract tests to scope the stuck-recovery guard.
|
Confirmed the IME branch in the composer onKeyDown returns before submit even when no composition session is open, which is why plain Enter fails under macOS Pinyin. Will get this reviewed. |
… idle-IME Enter WebKit fires compositionend before the committing keydown (keyCode 229), so the idle-Enter path sent the message when a CJK user confirmed a conversion in Safari or the macOS desktop app. Treat a 229 keydown within 500 ms of compositionend as IME-owned, drop the composingRef input that the WebKit commit keydown re-pins, and reset the open-session flag on blur in the main composer too.
|
Review record for #12138, carried over from the mirror it was reviewed on: danielhanchen/unsloth-staging-review#294. Findings are quoted as posted and attributed to the account that posted them. The reactions shown are the triage recorded on the mirror; none were re-applied here. Commits are named as the mirror's, with this PR's equivalent where one was found. Round 1: reviewed mirror
|
Summary
Fixes #12137.
With macOS built-in Pinyin selected, plain Enter in Chat did not send while Cmd+Enter still worked. The composer treated every IME-marked Enter (
isComposingor keyCode 229) as candidate confirmation and returned before submit, even when no composition was open.Fix
compositionstarttocompositionend, reset on blur) and when the last one ended.imeKeydownBlocksComposerSubmit,composerKeyEventForImeSubmit), in both the main composer and the compare composer.compositionendbefore the keydown of the Enter that confirms a candidate, and that keydown carries keyCode 229 (WebKit bug 165004). A keyCode 229 keydown within 500 ms ofcompositionendstays IME-owned, the same window ProseMirror uses, so confirming a Japanese or Chinese conversion never sends.Tests
studio/frontend/tests/composer-ime-enter.test.tsstudio/frontend/tests/composer-submit-path.test.ts: the shipped main-composer handler sends an idle IME Enter and holds the WebKit confirming Entertests/studio/test_composer_rtl_bidi_attribute.py: the stuck-Enter source checks now look only at the stuck-composition blockBefore / after
Both builds (merge base and this PR) were installed side by side. The same key sequences were replayed on the real composer textarea in Chromium and WebKit. The events are synthetic, since headless browsers have no OS input method.
Plain Enter with keyCode 229 and no composition open (idle macOS Pinyin). Before: the draft stays in the composer. After: it is sent.
WebKit's candidate-confirming order (compositionstart, compositionend, then keydown Enter with keyCode 229). The draft stays unsent on both sides, so confirming a conversion never sends. The greeting line is picked at random, and the Recents entry on the right is the chat from the first run.