You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(ime): keep plain-committed Hangul so macOS 2-Set can rebuild it in place - #41884
On macOS, the Korean keyboard sometimes types a consonant as finished text and then tries to turn it into a full syllable when the vowel comes (ㅇ + ㅏ → 아). Orca had already sent the consonant and wiped its hidden typing box, so there was nothing to turn into a syllable and the vowel disappeared. Now Orca leaves Korean text in the box and, when the keyboard swaps it, sends backspaces for the part it already sent.
What Changed
Before: right after switching to Korean 2-Set, 안녕 could arrive as ㅇㄴㅕㅇ (the reporter's exact output). The native text forwarder sent the plain-committed ㅇ and then cleared xterm's helper textarea (the [Bug]: macOS automatic period substitution injects ". " into the terminal with a CJK input source #11504 double-space protection). The input method then tried to replace that ㅇ with 아 by its position in the field, found nothing there, and the vowel was lost. Later keys drifted the same way.
After: when a forwarded plain commit contains Hangul, the forwarder keeps it in the field instead of clearing it. If the input method then replaces that kept range, either by committing over a selection or by starting a composition over it, Orca first sends one backspace per replaced character, then the replacement. Under the Kitty protocol's report-all-keys mode the backspace is CSI 127u, plus a release report when event types are negotiated.
Kept text is dropped, and removed from the field, as soon as anything could make it stale: keys the input method never sees (Backspace, Enter, arrows, Ctrl/Alt/Cmd chords, including macOS Ctrl+C that the pane handles before the forwarder), blur, or the start of any ordinary composition.
Backspaces are sent only for an insertText or composition that replaces the tail of the kept range at the end of the field. Those are the only edits xterm or the forwarder then forwards, and the only ones where a backspace from the PTY cursor deletes the right characters. Any other edit erases nothing.
New module: terminal-ime-retained-hangul-commit.ts. The forwarder gains about 12 lines.
CI routing fix (commit 3)
#39113 moved the terminal IME and keyboard-policy files under terminal-pane/input/, but pr-e2e-source-routing.mjs still matched the old paths. Since then, IME changes have selected neither the real-IBus lane nor the synthetic IME e2e specs. This updates both routes to the current paths. With it, this PR now runs real IME (X11 and Wayland) plus 7 IME e2e specs, and all pass.
Why
A plain Chromium textarea under the same input method handles this correctly, because the committed ㅇ is still there to replace. Turning off "Correct spelling automatically" avoids it, which is what the reporter did, but that is not a fix. Dropping the field-clearing entirely would bring back #11504. Keeping only Hangul commits leaves the input method a valid field and still protects the Latin double-space case.
Linked Issue
Fixes#9738 (macOS report). The separate Windows TSF report in that thread is not addressed here, because this forwarder only runs on macOS and Linux.
Visual Proof
The changed behavior is the bytes sent to the shell, not anything drawn. Captured on an M4 MacBook Air (macOS 27.2, Korean 2-Set, autocorrect at default), with the bytes the PTY actually received:
Sequence (Chromium IME entry points)
main
this PR
ㅇ plain-committed → replaced by 아 → composition replaces with 안
ㅇ아안
ㅇ⌫아⌫안 → shows 안
The same emulation in a live Claude Code prompt shows ❯ 안.
Testing
On the M4 Air, using a dev build of this branch with real hardware keystrokes:
Korean 2-Set: the reporter's flow (type English, Ctrl+Space, type Korean immediately) and fast typing all produce the expected text, e.g. 안녕 이로인한 한글 and 안녕하세요 한글이 좋네요. Typing into a Claude Code prompt is correct too.
Other input sources: Japanese Romaji (かんじ → 漢字/感じ commits), Chinese Pinyin (你好) and Vietnamese Telex (việt) are unchanged.
The bad state itself: the real input method entered it once, captured in the trace above. About ten later trigger attempts did not reproduce it, so this path is covered by CDP emulation through Blink's IME commit and imeSetComposition replacement paths, not by a repeatable hardware repro. It would be worth asking the reporter to retest.
Automated:pnpm check:changed passes all 30 checks, and all 124 terminal-input tests pass.
Native macOS spec on the M4 Air (terminal-macos-2set-korean-native.spec.ts, real keystrokes):
PR: 5 runs, 15 tests.
main: 2 runs, 6 tests, all passed. They never entered the bad state.
The bad state, on the PR: the first PR run hit it naturally, on the first Korean typing after the machine was unlocked. The input method plain-committed ㅎ and then rebuilt it in place as 하. With this PR the PTY received ㅎ⌫하, so the vowel survived; on main the field is empty and the rebuild is lost, as the earlier ㅇㄴㅕㅇ trace shows.
Still split in that state: the input method then began a fresh ㄴ composition instead of extending 하 to 한, so the spec saw 하ㄴ글 rather than 한글. That split comes from the input method's own composition choice, not from Orca dropping input. The other 4 PR runs passed 3/3.
Linux, real fcitx5 on omarchy (Arch): I used an isolated Xvfb with a private D-Bus and fcitx5 (Hangul, Pinyin, Mozc), and checked the exact bytes the PTY received.
GTK fcitx module: Hangul always arrives as a composition, so the new path is not used. 안녕 이로인한, fast 안녕하세요 한글이 좋네요, Backspace mid-syllable, a terminating digit and an Enter commit were all exact. Pinyin 你好 and Mozc 感じ were also exact.
GTK XIM module: fcitx5 commits every syllable as plain text through the forwarder, so the new path is used on every keystroke. The same Korean, Pinyin and Mozc cases came out byte-exact, with no stray backspaces.
CI real IME: native IBus Hangul passes on both Linux X11 and Wayland. Commit 3 fixes the CI routing so these jobs run at all (see below).
Independent review: an adversarial review found four ways the first commit could erase or keep the wrong text. Commit 2 fixes them: the macOS Ctrl+C path that skips the forwarder, edits that are never forwarded, a replacement that isn't the last text sent, and stale ranges after blur or a composition. Every m4air run above was repeated on the final code with the same results.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
The five new tests replay the trace and the review's edge cases; each fails on the code it guards against.
Risk
Level: Low–Medium
The riskiest part is sending a backspace that deletes a character the user wanted. The backspace is sent only when the selection being replaced lies entirely inside text this forwarder itself committed, and that text is still intact in the field. Normal Korean composition never goes through the forwarder, so it is untouched. It does not affect Windows, which doesn't use the forwarder, or iOS. A plain revert backs this out completely; no stored state or settings are involved.
…n place
Right after an input-source switch, macOS 2-Set can commit a lone jamo as
plain text and then rebuild it (ㅇ + ㅏ → 아) by replacing that committed
range. The native text forwarder emptied the field after every commit, so
the replacement had nothing to land on and the vowel was dropped (#9738).
Keep Hangul commits in the field (Latin commits still clear for #11504),
and erase replaced text from the PTY before the replacement is sent.
…d and still at the PTY cursor
Drop retention on blur, on any composition start, and on chord/named keydowns
the pane handles before the forwarder (macOS Ctrl+C, non-Latin control chords).
Erase only for insertText/composition replacements that end at the field tail.
The change adds a retained-Hangul commit handler and connects it to the native text forwarder. The handler tracks matching committed Hangul text in the textarea. When an eligible replacement selection covers retained text, it sends encoded Backspaces to the PTY. The forwarder preserves retained textarea content and disposes the handler. Tests cover replacement commits, composition, and pane-handled Ctrl+C. Source-routing patterns now match relocated IME, lifecycle, and keyboard-policy paths.
Severity of issue fixed: Low
Merge Risk: Moderate · up to 806d2
Korean 2-Set input can lose a character if a replacement composition is cancelled after the existing character has been erased. This is a narrow edge case. It should be resolved or consciously accepted before merging.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: plain-committed Hangul is kept so macOS 2-Set can rebuild it in place. The raw summary shows the forwarder now retains Hangul commits and the new retained-commit modul…
Linked Issues check
Directly linked issue #9738 requires that Korean 2-set input in a Claude Code chat on macOS compose and commit every keystroke without dropped syllables. The reviewed head changes the failure path. te…
Out of Scope Changes check
The forwarder hook (about 11 added lines, 1 deleted) and the new retained-Hangul commit module (about 138 lines) implement the #9738 objective. Their test file (about 127 lines) supports that objectiv…
Description check
The PR description is thorough and covers every required template section: ELI5, What Changed, Why, Linked Issue (Fixes #9738), Visual Proof (a before/after byte table plus a note that the change is b…
Full details: Title check
Explanation
The title names the main change: plain-committed Hangul is kept so macOS 2-Set can rebuild it in place. The raw summary shows the forwarder now retains Hangul commits and the new retained-commit module sends backspaces before a replacement, which matches the title. The title follows the conventional commit style and is specific to the IME fix.
Full details: Linked Issues check
Explanation
Directly linked issue #9738 requires that Korean 2-set input in a Claude Code chat on macOS compose and commit every keystroke without dropped syllables. The reviewed head changes the failure path. terminal-ime-native-text-forwarder.ts keeps forwarded plain Hangul commits in the helper textarea instead of clearing them. The new module terminal-ime-retained-hangul-commit.ts sends one Backspace per replaced character when the input method replaces retained text, then sends the replacement. This gives the input method the committed text it needs for in-place replacement, which the PR identifies as the cause of the lost vowel. Five new Vitest tests replay the commit and replacement sequences and edge cases. The PR reports hardware testing on macOS with the expected output. The original hardware failure did not recur in about ten later attempts, so the evidence for the fix is CDP emulation plus manual testing, not a repeatable hardware repro. The Windows TSF report in the issue thread is not part of the linked issue body and is not a requirement here. The change since the previous review adds a CI source-routing update (config/scripts/workflow/source-routing/pr-e2e-source-routing.mjs). It does not change the runtime behavior required by #9738. The assessment relies on the PR summary and raw change summary; no full diff was read, and no repository inspection was made.
Full details: Out of Scope Changes check
Explanation
The forwarder hook (about 11 added lines, 1 deleted) and the new retained-Hangul commit module (about 138 lines) implement the #9738 objective. Their test file (about 127 lines) supports that objective. The forwarder keeps Latin field-clearing, so the #11504 double-space protection is preserved. The Kitty CSI 127u backspace encoding and the Ctrl+C and non-text key handling keep retained text correct. The new change since the previous review updates pr-e2e-source-routing.mjs (+3/-2). It re-points the terminal IME and keyboard path patterns to their current input/ime and input/keyboard locations, so the IME test lanes select the changed files. The PR objectives describe this routing change in the commit message summary. It is test-routing support for the IME change and is not unrelated work. No unrelated files or features appear in the summary. The assessment relies on the PR summary and raw change summary; no full diff was read.
Full details: Description check
Explanation
The PR description is thorough and covers every required template section: ELI5, What Changed, Why, Linked Issue (Fixes #9738), Visual Proof (a before/after byte table plus a note that the change is byte-level), Testing with checklist items, and Risk with a level and a revert path. The AI Disclosure section is absent, but the template marks it as optional for StablyAI team members, and the author's identity is not stated. The Review, Agent skill upstream boundary, and Checklist sections are also absent. These gaps are non-critical. The description is mostly complete, so the check passes.
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Major · Functional Correctness · Heavy lift
Cancelling a rebuilt composition drops the erased character.
The erase runs at compositionstart and sends Backspace before any replacement commits. An Escape while the replacement is composing reaches _cancelComposition(). That method sends an empty input and rebuilds the field from the composition start and suffix. Nothing sends the erased character back to the PTY, so the character is lost.
The correction must keep the erase tied to an accepted replacement, or re-send the retained text when the composition is cancelled. The inspected code does not establish a safe localized edit, so no patch is proposed.
…t/ owner move
#39113 moved IME and keyboard policy files under terminal-pane/input/, but the
native IBus and synthetic IME routes still matched the old paths, so IME changes
selected neither lane.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Functional Correctness · Quick win
Update the Unicode provider path in the native IME matcher.
The first alternative in NATIVE_IME_PRODUCT_SOURCE still points to src/shared/terminal-unicode-provider.ts. The provider is now at src/shared/terminal/appearance/terminal-unicode-provider.ts. Changes to that file therefore do not select the native IBus Hangul spec through this matcher. This PR updates the other alternatives on this line but leaves this one on the old path.
Suggested fix
--- "a/config/scripts/workflow/source-routing/pr-e2e-source-routing.mjs"+++ "b/config/scripts/workflow/source-routing/pr-e2e-source-routing.mjs"@@ -21,7 +21,7 @@
// Paths follow the input/ime and input/keyboard owners (#39113); the pre-move paths matched nothing.
const NATIVE_IME_PRODUCT_SOURCE =
- /^(?:src\/shared\/terminal-unicode-provider\.ts$|src\/renderer\/src\/lib\/pane-manager\/terminal-input\/terminal-ime-|src\/renderer\/src\/components\/terminal-pane\/input\/(?:ime\/|keyboard\/xterm-bypass-policy|terminal-pane-pane-input\.ts$))/+ /^(?:src\/shared\/terminal\/appearance\/terminal-unicode-provider\.ts$|src\/renderer\/src\/lib\/pane-manager\/terminal-input\/terminal-ime-|src\/renderer\/src\/components\/terminal-pane\/input\/(?:ime\/|keyboard\/xterm-bypass-policy|terminal-pane-pane-input\.ts$))/
/** The harness itself: the session runner, the boundary probes, and the native specs. */
const NATIVE_IME_HARNESS =
Committable suggestion
IMPORTANT
Review the replacement and indentation, then test before committing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
On macOS, the Korean keyboard sometimes types a consonant as finished text and then tries to turn it into a full syllable when the vowel comes (ㅇ + ㅏ → 아). Orca had already sent the consonant and wiped its hidden typing box, so there was nothing to turn into a syllable and the vowel disappeared. Now Orca leaves Korean text in the box and, when the keyboard swaps it, sends backspaces for the part it already sent.
What Changed
ㅇㄴㅕㅇ(the reporter's exact output). The native text forwarder sent the plain-committedㅇand then cleared xterm's helper textarea (the [Bug]: macOS automatic period substitution injects ". " into the terminal with a CJK input source #11504 double-space protection). The input method then tried to replace thatㅇwith아by its position in the field, found nothing there, and the vowel was lost. Later keys drifted the same way.CSI 127u, plus a release report when event types are negotiated.insertTextor composition that replaces the tail of the kept range at the end of the field. Those are the only edits xterm or the forwarder then forwards, and the only ones where a backspace from the PTY cursor deletes the right characters. Any other edit erases nothing.New module:
terminal-ime-retained-hangul-commit.ts. The forwarder gains about 12 lines.CI routing fix (commit 3)
#39113 moved the terminal IME and keyboard-policy files under
terminal-pane/input/, butpr-e2e-source-routing.mjsstill matched the old paths. Since then, IME changes have selected neither the real-IBus lane nor the synthetic IME e2e specs. This updates both routes to the current paths. With it, this PR now runs real IME (X11 and Wayland) plus 7 IME e2e specs, and all pass.Why
A plain Chromium textarea under the same input method handles this correctly, because the committed
ㅇis still there to replace. Turning off "Correct spelling automatically" avoids it, which is what the reporter did, but that is not a fix. Dropping the field-clearing entirely would bring back #11504. Keeping only Hangul commits leaves the input method a valid field and still protects the Latin double-space case.Linked Issue
Fixes #9738 (macOS report). The separate Windows TSF report in that thread is not addressed here, because this forwarder only runs on macOS and Linux.
Visual Proof
The changed behavior is the bytes sent to the shell, not anything drawn. Captured on an M4 MacBook Air (macOS 27.2, Korean 2-Set, autocorrect at default), with the bytes the PTY actually received:
mainㅇ아안ㅇ⌫아⌫안→ shows안The same emulation in a live Claude Code prompt shows
❯ 안.Testing
On the M4 Air, using a dev build of this branch with real hardware keystrokes:
Korean 2-Set: the reporter's flow (type English, Ctrl+Space, type Korean immediately) and fast typing all produce the expected text, e.g.
안녕 이로인한 한글and안녕하세요 한글이 좋네요. Typing into a Claude Code prompt is correct too.Other input sources: Japanese Romaji (
かんじ→漢字/感じcommits), Chinese Pinyin (你好) and Vietnamese Telex (việt) are unchanged.[Bug]: macOS automatic period substitution injects ". " into the terminal with a CJK input source #11504: a double space under Korean gives
아, with no period.The bad state itself: the real input method entered it once, captured in the trace above. About ten later trigger attempts did not reproduce it, so this path is covered by CDP emulation through Blink's IME commit and
imeSetCompositionreplacement paths, not by a repeatable hardware repro. It would be worth asking the reporter to retest.Automated:
pnpm check:changedpasses all 30 checks, and all 124 terminal-input tests pass.Native macOS spec on the M4 Air (
terminal-macos-2set-korean-native.spec.ts, real keystrokes):ㅎand then rebuilt it in place as하. With this PR the PTY receivedㅎ⌫하, so the vowel survived; on main the field is empty and the rebuild is lost, as the earlierㅇㄴㅕㅇtrace shows.ㄴcomposition instead of extending하to한, so the spec saw하ㄴ글rather than한글. That split comes from the input method's own composition choice, not from Orca dropping input. The other 4 PR runs passed 3/3.Linux, real fcitx5 on omarchy (Arch): I used an isolated Xvfb with a private D-Bus and fcitx5 (Hangul, Pinyin, Mozc), and checked the exact bytes the PTY received.
안녕 이로인한, fast안녕하세요 한글이 좋네요, Backspace mid-syllable, a terminating digit and an Enter commit were all exact. Pinyin你好and Mozc感じwere also exact.CI real IME: native IBus Hangul passes on both Linux X11 and Wayland. Commit 3 fixes the CI routing so these jobs run at all (see below).
Independent review: an adversarial review found four ways the first commit could erase or keep the wrong text. Commit 2 fixes them: the macOS Ctrl+C path that skips the forwarder, edits that are never forwarded, a replacement that isn't the last text sent, and stale ranges after blur or a composition. Every m4air run above was repeated on the final code with the same results.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
The five new tests replay the trace and the review's edge cases; each fails on the code it guards against.
Risk
Level: Low–Medium
The riskiest part is sending a backspace that deletes a character the user wanted. The backspace is sent only when the selection being replaced lies entirely inside text this forwarder itself committed, and that text is still intact in the field. Normal Korean composition never goes through the forwarder, so it is untouched. It does not affect Windows, which doesn't use the forwarder, or iOS. A plain revert backs this out completely; no stored state or settings are involved.