Skip to content

fix(terminal): stop Hangul composition lagging one syllable - #12278

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

OrcaWin merged 1 commit into
mainfrom
OrcaWin/korean-ime-composition

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • let the pending xterm composition finalizer survive the next compositionstart, so committed Hangul syllable N reaches the PTY before syllable N+1 is drawn
  • retain the deferred task boundary required for IBus final-consonant transfer (아아, never 앙아)
  • add CJS and ESM regressions for prompt syllable flush, exact-once delivery, IBus reconciliation, and cancel-to-empty isolation
  • regenerate the pinned xterm CJS/ESM bundles and source maps from upstream commit 53a98a720ae4a973e384fa2440880d09537132f3

PR #11293 introduced this regression in v1.4.163: its new compositionstart path cancelled and settled the preceding composition without emitting its pending bytes. The next opaque composition overlay therefore painted over the cell whose prior syllable had never reached the PTY.

This adopts the narrow mechanism identified by @leon1114 in #12158 and credits Hyunggyun Lyou as co-author. Unlike #12158's submitted artifacts, these bundles and maps were rebuilt from the pinned xterm source.

Community fix comparison

#11550 covers different native Windows event shapes. Its relevant fixes are already on main through the physical-Enter guard, cancelled-preedit reconciliation, and #12276's native Microsoft Pinyin Shift-commit E2E. This PR does not duplicate its broader keyboard state machine; the new composition timing remains compatible with those fixes.

Together with current main, this covers all three symptoms reported in #12262:

  1. Shift-modified IME keys do not synthesize Enter.
  2. Deleting a preedit to empty does not replay stale text.
  3. A committed Hangul syllable is no longer stranded behind the next composition overlay.

Fixes #12262
Fixes #12132
Fixes #11855

Testing

  • 103 focused IME tests across 6 files
  • native Microsoft Pinyin Shift-commit Electron E2E
  • oxfmt and oxlint
  • Node typecheck
  • max-lines ratchet
  • installed CJS/ESM bundles and maps byte-match the rebuilt patch artifacts
  • pristine upstream rebuild reproduced all four published xterm artifacts byte-for-byte before applying Orca's patch

@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: 14f2e257-3886-4b50-be90-22f95504c412

📥 Commits

Reviewing files that changed from the base of the PR and between 6f7a30a and f596fa4.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (2)
  • config/patches/@[email protected]
  • src/renderer/src/components/terminal-pane/terminal-ime-hangul-syllable-flush.test.ts

📝 Walkthrough

Walkthrough

Added a parameterized happy-dom Vitest suite for Hangul IME behavior in ESM and CJS xterm builds. The suite simulates composition, input, and keyboard events. It verifies syllable flushing, final-consonant transfer, exact output, IBus commit deduplication, empty-composition deletion, and subsequent composition recovery. Shared setup mocks canvas measurement, tracks and disposes terminals, and restores timers and mocks after each test.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description has detailed summary and testing evidence but omits the required Screenshots, AI Review Report, Security Audit, and Notes sections. Add the missing template sections, state whether there is visual change, and document cross-platform review and security audit results.
Linked Issues check ❓ Inconclusive The summary confirms focused IME regression tests, but it does not show the implementation or rebuilt artifacts needed to verify the linked fixes. Provide reviewable evidence for the source fix and regenerated CJS/ESM artifacts, or include their changes in the review summary.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the terminal Hangul composition lag fix, which is the primary change.
Out of Scope Changes check ✅ Passed The documented changes target Hangul IME flushing, PTY synchronization, and regression coverage for the linked issues.
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.

@OrcaWin
OrcaWin merged commit f82d410 into main Aug 3, 2026
43 checks passed
@OrcaWin
OrcaWin deleted the OrcaWin/korean-ime-composition branch August 3, 2026 09:45
nwparker added a commit that referenced this pull request Aug 8, 2026
…13168)

* test(terminal): pin the recorded Korean commit-before-newline order (STA-3132)

Recorded first-party on Windows 11 + Microsoft Korean (HKL 0412) against the
defect-era v1.4.164 build, with bytes read on the far side of the PTY: the
terminal received ea b0 80 0d, the syllable strictly before the CR.

The capture did not reproduce the suspected deferred-newline inversion. That
route needed a session end carrying dataPendingReconciliation, which plain
compose-then-Enter cannot produce because the IME finalizes first and the
newline is never held; back-to-back arms at 25/60/120 ms did not reach it
either. The test therefore pins the ordering rather than discriminating a fix.

Co-authored-by: Orca <[email protected]>

* test(terminal): restore Hangul back-to-back flush coverage deleted with the composition layer

#12278 fixed a Hangul syllable that was not flushed before the next
composition began — the force-end path, and the one that leaves stale glyphs
behind. Returning composition ownership to xterm deleted both that patch and
its test, so nothing guarded the behavior any more.

Replays the recorded back-to-back arms (25/60/120 ms, read as 가\r나 at the
PTY) against a real xterm Terminal. It passes on main: stock xterm flushes the
committed syllable natively, so the removal was safe rather than a silent
regression.

Co-authored-by: Orca <[email protected]>

* test(mobile): pin accessory-byte ordering behind a Hangul commit

Returning composition ownership to xterm deleted the accessory-input commit
tests along with the hook they targeted, but the guarantee they protected is
user-visible and still applies: an accessory-bar keystroke must not overtake
the syllable being committed, and must be suppressed when that commit fails.

Drives the current hook with an Android composing-region trace rather than
reconstructing the deleted coordinator.

Co-authored-by: Orca <[email protected]>

* test(terminal): replay recorded IBus and fcitx5 Hangul traces offline

Commits interleaved with ASCII (한abc글) are the Linux IME gesture users report
on, and its failure modes are a lost syllable and a doubled one. That gesture
was only covered by tests/e2e/terminal-linux-ime-native.spec.ts, which needs a
Linux host running a real input framework.

Fixtures are the recorded captures from the sealed linux-final evidence run,
replayed against a real xterm Terminal: exact onData, exactly-once counts across
five repetitions, and the PTY bytes the recorded run actually received.

Co-authored-by: Orca <[email protected]>

---------

Co-authored-by: Orca <[email protected]>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…tablyai#13168)

* test(terminal): pin the recorded Korean commit-before-newline order (STA-3132)

Recorded first-party on Windows 11 + Microsoft Korean (HKL 0412) against the
defect-era v1.4.164 build, with bytes read on the far side of the PTY: the
terminal received ea b0 80 0d, the syllable strictly before the CR.

The capture did not reproduce the suspected deferred-newline inversion. That
route needed a session end carrying dataPendingReconciliation, which plain
compose-then-Enter cannot produce because the IME finalizes first and the
newline is never held; back-to-back arms at 25/60/120 ms did not reach it
either. The test therefore pins the ordering rather than discriminating a fix.

Co-authored-by: Orca <[email protected]>

* test(terminal): restore Hangul back-to-back flush coverage deleted with the composition layer

stablyai#12278 fixed a Hangul syllable that was not flushed before the next
composition began — the force-end path, and the one that leaves stale glyphs
behind. Returning composition ownership to xterm deleted both that patch and
its test, so nothing guarded the behavior any more.

Replays the recorded back-to-back arms (25/60/120 ms, read as 가\r나 at the
PTY) against a real xterm Terminal. It passes on main: stock xterm flushes the
committed syllable natively, so the removal was safe rather than a silent
regression.

Co-authored-by: Orca <[email protected]>

* test(mobile): pin accessory-byte ordering behind a Hangul commit

Returning composition ownership to xterm deleted the accessory-input commit
tests along with the hook they targeted, but the guarantee they protected is
user-visible and still applies: an accessory-bar keystroke must not overtake
the syllable being committed, and must be suppressed when that commit fails.

Drives the current hook with an Android composing-region trace rather than
reconstructing the deleted coordinator.

Co-authored-by: Orca <[email protected]>

* test(terminal): replay recorded IBus and fcitx5 Hangul traces offline

Commits interleaved with ASCII (한abc글) are the Linux IME gesture users report
on, and its failure modes are a lost syllable and a doubled one. That gesture
was only covered by tests/e2e/terminal-linux-ime-native.spec.ts, which needs a
Linux host running a real input framework.

Fixtures are the recorded captures from the sealed linux-final evidence run,
replayed against a real xterm Terminal: exact onData, exactly-once counts across
five repetitions, and the PTY bytes the recorded run actually received.

Co-authored-by: Orca <[email protected]>

---------

Co-authored-by: Orca <[email protected]>
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