fix(desktop): CJK IME Enter blocked — draft never updates during composition - #44208
fix(desktop): CJK IME Enter blocked — draft never updates during composition#44208questionjie-max wants to merge 1 commit into
Conversation
|
The diff shows the entire 1,830-line replaced with a single base64-encoded line. The committed file appears to be binary-encoded rather than valid TypeScript/TSX source. This will cause:
The file needs to be re-committed as plain text source. This typically happens when:
Please re-commit the file with the intended source code changes, then the review can proceed. |
…osition Two interacting problems prevented CJK IME users from sending messages via Enter in the desktop composer: 1. handleEditorInput skipped draft updates when composingRef was true, so the React draft state stayed empty during IME typing. This meant hasComposerPayload was always false — the Send button never appeared, and the submit path had nothing to send. 2. (Upstream already fixed) submitDraft() now uses draftRef.current Fixes: - Remove the composingRef guard from handleEditorInput. Draft now updates during IME composition so the Send button appears as soon as text is in the editor. The Enter guard in handleEditorKeyDown still blocks premature submission via event.nativeEvent.isComposing. - Add imeEnterRef to track Enter during IME composition. On compositionend, if set, the committed text is synced from the DOM into state and submitDraft() is scheduled — CJK users get one-Enter send instead of needing a second Enter. - Self-heal stale composition flag: clear composingRef on keydown when nativeEvent.isComposing is false, and reset on blur unconditionally (upstream fix from NousResearch#44149 applied locally). Closes NousResearch#44135
5422f9c to
f8f949b
Compare
|
Fixed — the PR branch was rebuilt from upstream/main. The diff now shows only the actual changes (45 additions, 8 deletions, 1 file). Ready for re-review. |
teknium1
left a comment
There was a problem hiding this comment.
Thanks for the focused CJK IME investigation. The stale composition-ref failure remains on current main, but this branch needs a targeted salvage rather than a direct merge.
Problems
- Current main already intentionally skips uncommitted preedit input at
apps/desktop/src/app/chat/composer/index.tsx:303-312and flushes committed text at:727-737(commit8e629b9f386d12b726bccb32e9d7b48402ea73ea), so the stated no-op input premise is no longer current. - The new
imeEnterRefis set at the PR'sindex.tsx:786-788and cleared only at:1644-1645. A missedcompositionendcan therefore leave it armed and let a later unrelated composition end submit unexpectedly. - No regression tests cover the new auto-submit or latch lifecycle; existing
ime-composition-dom-repro.test.tsx:61-106only covers committed-text visibility.
Suggested changes
- Resolve the stale-ref recovery into current main's composer structure and add focused tests for one-Enter submit, genuine-composition suppression, missed-composition-end recovery, and blur recovery.
- Reset the IME-enter latch on abort/new-composition paths as well as normal composition end.
Automated hermes-sweeper review.
| // `hasComposerPayload` stays false and the send button stays hidden | ||
| // until an unrelated edit forces a sync (#39614). | ||
| flushEditorToDraft(event.currentTarget) | ||
| if (imeEnterRef.current) { |
There was a problem hiding this comment.
imeEnterRef is only cleared after a normal compositionend. In the missed-compositionend failure mode this PR also targets, it remains armed; a later unrelated composition end can then call submitDraft() without a new Enter. Reset this latch on abort/new-composition paths and add that regression case.
|
This fix landed on main via #86760, which consolidated the duplicate PRs for this bug (earliest submission by @satotakumi in #37487; all contributors credited in that PR's body). Closing as the fix is now merged. Thanks for catching it! |
Summary
Fixes #44135 — CJK IME users cannot send messages via Enter in the desktop composer.
Root Cause
Three remaining gaps after #39614 (which added
flushEditorToDraftand removed thecomposingRefguard):handleEditorInputleft as no-op — after thecomposingRefguard was removed, the function body was empty. Draft state was never synced on input events, so the Send button stayed hidden during IME typing.No auto-submit after IME Enter —
imeEnterRefwas already tracked inhandleEditorKeyDown, butonCompositionEnddidn't check it. Enter is consumed by IME to commit the preedit, sosubmitDraft()never fires. Users needed a second Enter.Blur doesn't reset stale composition flag — if
compositionendis missed, the wedgedcomposingRefpermanently blocks the Send button ([Bug]: Desktop app composer Enter key has no effect — cannot send messages in new or existing sessions #44135 / fix(desktop): recover from a stale IME composition flag that silently blocks all sends #44149).Fix (3 changes, 1 file:
apps/desktop/src/app/chat/composer/index.tsx)handleEditorInputcallsflushEditorToDraft()onCompositionEndauto-submits onimeEnterRefonBlurresetscomposingRefunconditionallyTesting
Related