Skip to content

fix(native-chat): preserve IME deletions at composition end - #12281

Merged
OrcaWin merged 1 commit into
mainfrom
OrcaWin/ime-native-composition-followups
Aug 3, 2026
Merged

OrcaWin merged 1 commit into
mainfrom
OrcaWin/ime-native-composition-followups

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • resynchronize the native chat draft from the live textarea on compositionend when Sogou/WeChat deletes a preedit without firing a final input event
  • reuse the normal draft-change path so caret, history, picker state, and the persisted draft remain consistent
  • pin the exact macOS 2-Set r k s k e k (가나다) terminal contract: two committed syllables plus the visible active third syllable before blur
  • pin the Sogou terminal cancellation shape nihao → niha → nih → ni → n → empty with no trailing input event

Current main already fixes the terminal-layer behavior through #12278 and the cancelled-preedit reconciliation, and #12276 directly exercises the native Microsoft Pinyin Shift-toggle trace on Windows. This PR closes the remaining adjacent native-chat gap from #12230 and makes all three reported reproductions explicit regression contracts.

The native-chat fix follows the diagnosis contributed by @fengxinzi1814 in #12230, credited as co-author. #12274 by @kcfang independently provides real-macOS Zhuyin evidence for the same empty-preedit terminal shape; current xterm reconciliation already resolves it without adding another terminal listener state machine. #12043 independently identified the Hangul finalizer cause later landed through #12278.

Fixes #12230
Fixes #11914
Fixes #12063

Screenshots

No visual design change. The visible changes are restored IME text: 가나다 remains present during the active final composition, and a deleted Sogou n stays deleted.

Testing

  • 126 focused native-chat and terminal IME unit tests across 9 files
  • Electron E2E: Microsoft Pinyin Shift commits its active preedit exactly once
  • Electron E2E: Sogou-style candidate selection commits Chinese text without leaking selector keys
  • oxfmt and oxlint
  • Node typecheck
  • max-lines ratchet
  • git diff --check

AI Review Report

The change was checked against the three native event contracts separately rather than treating CJK IMEs as one path.

  • macOS Hangul: no production timing is changed here; the test proves fix(terminal): stop Hangul composition lagging one syllable #12278 leaves 가나 emitted while xterm's active composition view contains 다, matching the pre-click state of the physical-key repro.
  • Windows Pinyin: the existing native Electron trace remains green and proves Shift commits nihao without clearing it or sending a newline.
  • macOS Sogou: terminal cancellation remains data-free even without a trailing input event. Native chat now adopts the DOM's authoritative empty value at composition end; ordinary compositions already adopted through onChange do not cause a second write.
  • Cross-platform/SSH/folder workspaces: the only production change is renderer-local controlled-textarea state reconciliation. Terminal transport, PTY routing, paths, worktree assumptions, and platform shortcut behavior are unchanged.

Security Audit

No IPC, transport, command execution, authentication, secrets, path handling, or dependency behavior changes. The native chat handler only copies the current textarea value into its existing draft state through the same path used by onChange.

Notes

Synthetic macOS event coverage is based on the repository's recorded 2-Set and empty-composition shapes. A final physical IME pass on macOS is still worthwhile because CI cannot install and drive Sogou itself; the code no longer depends on a Sogou-specific event ordering beyond compositionend exposing the live DOM value.

@OrcaWin
OrcaWin merged commit 40d5f36 into main Aug 3, 2026
43 checks passed
@OrcaWin
OrcaWin deleted the OrcaWin/ime-native-composition-followups branch August 3, 2026 09:56
@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 5ab416f1-ea8b-4abd-94e6-397b54fc05e5

📥 Commits

Reviewing files that changed from the base of the PR and between 035d8c2 and 782738e.

📒 Files selected for processing (4)
  • src/renderer/src/components/native-chat/NativeChatComposer.test.tsx
  • src/renderer/src/components/native-chat/NativeChatComposer.tsx
  • src/renderer/src/components/terminal-pane/terminal-ime-hangul-syllable-flush.test.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-xterm-composition-cancel.test.ts

📝 Walkthrough

Walkthrough

Native chat composition-end handling now reprocesses textarea values that differ from the stored draft. Shared draft handling updates history, caret position, autocomplete, and suggestions. Tests cover empty composition values and duplicate prevention. Terminal tests validate incremental macOS Hangul commits, active composition display, and Sogou preedit cancellation without input events.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the native-chat IME deletion fix performed by the pull request.
Description check ✅ Passed The description includes all required sections and documents the change, testing, review, security, and platform considerations.
Linked Issues check ✅ Passed The changes fix the native-chat deletion issue and add regression coverage for the linked Hangul terminal issues.
Out of Scope Changes check ✅ Passed All production and test changes support the linked IME fixes and their regression coverage; no unrelated changes are evident.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant