Skip to content

fix(desktop): show send button for committed IME text (Chinese/Japanese/Korean) - #40210

Merged
teknium1 merged 3 commits into
mainfrom
hermes/hermes-8d2534a6
Jun 6, 2026
Merged

fix(desktop): show send button for committed IME text (Chinese/Japanese/Korean)#40210
teknium1 merged 3 commits into
mainfrom
hermes/hermes-8d2534a6

Conversation

@teknium1

@teknium1 teknium1 commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Committed IME text (Chinese/Japanese/Korean) now makes the desktop send button appear immediately, instead of staying hidden until an unrelated edit.

Salvage of #39650 by @xxxigm onto current main, with a one-line test-isolation follow-up.

Root cause

The composer's send-button visibility is driven by hasComposerPayload (reads AUI composer state). onInput intentionally skips state writes while composingRef is true, on the assumption that a trailing input event fires after compositionend. Chromium (Electron renderer) does not reliably emit that trailing event on Windows IMEs, so committed text lands in the DOM but never reaches composer state — the button stays hidden until a non-composition edit (e.g. Backspace) forces a sync. Confirmed live on main: onCompositionEnd only set composingRef = false.

Changes

  • apps/desktop/src/app/chat/composer/index.tsx: extract the per-keystroke sync into a shared flushEditorToDraft(editor), called from both onInput and onCompositionEnd. Committed IME text now reaches state through whichever event the platform delivers. (@xxxigm)
  • ime-composition-dom-repro.test.tsx: real-DOM repro driving compositionstart → input(preedit) → compositionend with no trailing input event; asserts the send button becomes visible for 你好, こんにちは, 안녕하세요. (@xxxigm)
  • Follow-up: add afterEach(cleanup) to the test — the desktop suite registers no global testing-library auto-cleanup, so the two it() blocks leaked editors across renders and getByTestId('editor') matched multiple nodes. (teknium1)

Validation

Before After
Send button after committing 你好 (no further edit) hidden visible
vitest ime-composition-dom-repro n/a 2/2 pass
tsc -b (desktop) exit 0

Closes #39614. Original PR #39650.

Infographic

ime-composition-flush

xxxigm and others added 3 commits June 5, 2026 17:45
…button appears

Typing committed multi-character IME text (e.g. Chinese "你好", and equally
Japanese/Korean or any IME-composed script) left the send button hidden until
an unrelated edit. Input events during composition carry uncommitted preedit
text and are intentionally skipped; the code assumed a trailing input event
after compositionend would deliver the finalized text, but Chromium does not
reliably emit one on Windows IMEs. The committed text therefore never reached
composer state, so `hasComposerPayload` stayed false and the send button stayed
hidden (deleting a char fired a non-composition input that finally synced it).

Flush the live editor text into composer state in onCompositionEnd. Extract the
shared sync into flushEditorToDraft so input and compositionend both update
state.

Fixes #39614
…anese/Korean)

DOM repro that drives compositionstart -> input(preedit) -> compositionend with
no trailing input event and asserts the composer payload (send button) becomes
visible for committed CJK/IME input. Regression guard for #39614.
The new IME repro test has two it() blocks but the desktop suite registers
no global testing-library auto-cleanup, so the first render() leaked its
editor into the second test and getByTestId('editor') matched two nodes.
Add afterEach(cleanup) so each case renders into a fresh DOM.
@github-actions

github-actions Bot commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

🔎 Lint report: hermes/hermes-8d2534a6 vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 9868 on HEAD, 9868 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 5117 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

@teknium1
teknium1 merged commit aa52cd3 into main Jun 6, 2026
20 checks passed
@teknium1
teknium1 deleted the hermes/hermes-8d2534a6 branch June 6, 2026 01:05

@tonydwb tonydwb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved. Fixes IME composition commit bug with regression test harness that mirrors real Chromium event order. Well-scoped, clear test coverage for Korean/CJK input.

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.

[Bug]: Chinese Character Send Button Disappear Bug

3 participants