Repository navigation
fix(terminal): compose iPadOS Hangul by holding the syllable in the renderer (#13345) - #15480
Conversation
…enderer (#13345) Korean typed on an iPad with a hardware keyboard reached the PTY as separate jamo: `한글깨짐` arrived as `ㅎㅏㄴㄱㅡㄹ...`. iPadOS fires no composition events for it — each jamo is a plain keydown while the IME rewrites the syllable in place in the helper textarea — so xterm consumes the keydown, sends the raw jamo from `_keyPress`, and drops the composed `insertText` because `_inputEvent` admits a composed insert only when no key is down. The jamo keydown is handed to the system by a new bypass rule, and the syllable it builds is held in the renderer until the IME proves it final. The PTY sees one write per syllable and nothing is ever sent then retracted, so raw-mode TUIs never receive DEL bytes they need not read as "erase one cell" and SSH and relay sessions pay no round trip for them. `한글깨짐` is four writes and zero DELs. Sitting upstream of `xterm-bypass-policy.ts` rather than inside xterm is what makes this work for Shift-typed double consonants: Orca's own Shift rule already hides `ㄲ ㄸ ㅃ ㅆ ㅉ` keydowns from xterm, so a fix living in CompositionHelper never sees them and every syllable starting with one — 깨 꿈 딸 빵 쓰다 짜다 — stays broken. That placement call is dvpaa's, from #13346. Composition sessions are left alone entirely, so Chinese pinyin on the same device keeps working; that state is derived from the existing composition tracker rather than latched, so a session that never ends cannot disable the pane. The bypass claims jamo only — a Cyrillic or kana key would lose its keydown, keypress and `input` alike and reach the PTY as nothing. Co-authored-by: dvpaa <[email protected]>
|
Warning Review limit reachedNext included review available in 2 minutes. View limit detailsLimit details: You’ve used all 10 included reviews currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (14)
💤 Files with no reviewable changes (1)
🚧 Files skipped from review as they are similar to previous changes (9)
Included review availability: Your plan provides up to 10 included reviews per hour; 0 remain after this review. 📝 WalkthroughWalkthroughAdds iOS WebKit and iPadOS desktop-mode detection. Adds Hangul jamo event bypassing for xterm. Adds Hangul preedit tracking, commit, cancellation, deletion handling, and overlay rendering. Wires the feature into terminal lifecycle management. Adds fixtures and tests for Hangul composition, Chinese pinyin coexistence, device traces, platform gating, and other scripts. Removes the previous touch-based iOS helper and its tests. Merge Risk: 🔵 Low · up to The PR adds narrowly gated iPadOS Hangul preedit handling and is mergeable with explicit owner awareness: tearing down a pane while a syllable is still held may discard typed input, and one test is coupled to source text and process.cwd(), so unrelated refactors or configuration changes could break the suite. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 55.88% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 34 functions across 12 files. (1 skipped: 1 unsupported.) Full details: Description checkExplanation The description provides detailed problem, cause, fix, linked issue, testing, and device-verification information. However, it omits several required template sections, including ELI5, Visual Proof or an explicit N/A explanation, checklist items, and review notes. It also conflicts with the provided PR objectives, which describe workspace layout duplication rather than iPadOS Hangul input. Resolution Update the description to follow the repository template. Add ELI5, What Changed, Why, Visual Proof or an explicit N/A explanation, Testing checklist status, AI Disclosure if applicable, Review, Notes, and Checklist sections. Resolve the conflict with the PR objectives by aligning the objectives with the iPadOS Hangul changes or correcting the changeset and description. ✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (3)
src/renderer/src/components/terminal-pane/terminal-ios-hangul-preedit-overlay.ts (1)
49-51: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valuePrefer theme tokens over raw hex fallbacks.
#000and#FFFare hardcoded colors. The renderer style guide requires colors from the tokens insrc/renderer/src/assets/main.css. The primary values come fromterminal.options.theme, so the fallback is rarely used, but a token keeps the overlay consistent with the pane when the theme is unset.As per path instructions: "All renderer UI work must follow
docs/STYLEGUIDE.md, use tokens fromsrc/renderer/src/assets/main.css... do not invent documented colors, font sizes, or shadow tiers."Source: Path instructions
src/renderer/src/components/terminal-pane/terminal-ios-hangul-preedit-fixture.ts (1)
32-51: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winGlobal navigator overrides have no paired restore.
pretendIosWebreplacesnavigator.userAgentandnavigator.maxTouchPointsand leaves the restore to each caller. Two suites implement it by hand and one does not, so the override can outlive its file.
src/renderer/src/components/terminal-pane/terminal-ios-hangul-preedit-fixture.ts#L32-L51: save the original property descriptors insidepretendIosWeband restore them indisposeOpenTerminals; also track and remove the appended containers there.src/renderer/src/components/terminal-pane/terminal-ios-hangul-preedit-device-trace.test.ts#L51-L62: once the fixture restores the descriptors, drop the need for a local restore; until then, save and restorenavigator.userAgentandnavigator.maxTouchPointsas the other two suites do.src/renderer/src/components/terminal-pane/terminal-ios-hangul-preedit-coexistence.test.ts (1)
161-175: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winReplace the source-text assertion with a behavior assertion.
This test reads
use-terminal-pane-lifecycle.tsas text and matches regexes against it. Three problems follow:
- A harmless edit breaks it. Renaming
isIosWeb, wrapping the ternary across lines, or extracting the install into a helper all fail the test without changing behavior.process.cwd()must equal the repository root. If the renderer ever gets its own Vitestroot,resolveproduces a wrong path and the test fails on an unrelated config change.- The property it checks — a single platform gate — is already covered behaviorally by the desktop-inertness tests above (lines 130-159), which prove the controller does not run off iOS web.
Remove this test, or assert the same property through the rig instead of the file contents.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: d6a9594a-3d08-43de-8074-769d68c0ec59
📒 Files selected for processing (13)
src/renderer/src/components/terminal-pane/hangul-jamo-key.tssrc/renderer/src/components/terminal-pane/terminal-ios-hangul-preedit-coexistence.test.tssrc/renderer/src/components/terminal-pane/terminal-ios-hangul-preedit-device-trace.test.tssrc/renderer/src/components/terminal-pane/terminal-ios-hangul-preedit-fixture.tssrc/renderer/src/components/terminal-pane/terminal-ios-hangul-preedit-overlay.tssrc/renderer/src/components/terminal-pane/terminal-ios-hangul-preedit.test.tssrc/renderer/src/components/terminal-pane/terminal-ios-hangul-preedit.tssrc/renderer/src/components/terminal-pane/use-terminal-pane-lifecycle.test.tssrc/renderer/src/components/terminal-pane/use-terminal-pane-lifecycle.tssrc/renderer/src/components/terminal-pane/xterm-bypass-policy-ios.test.tssrc/renderer/src/components/terminal-pane/xterm-bypass-policy.tssrc/renderer/src/lib/ios-web-platform.test.tssrc/renderer/src/lib/ios-web-platform.ts
💤 Files with no reviewable changes (1)
- src/renderer/src/components/terminal-pane/use-terminal-pane-lifecycle.test.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.
| return { | ||
| heldText: () => preedit?.heldText ?? '', | ||
| dispose: () => { | ||
| root.removeEventListener('keydown', handleKeyDown, true) | ||
| root.removeEventListener('input', handleInput, true) | ||
| root.removeEventListener('compositionstart', handleCompositionStart, true) | ||
| root.removeEventListener('blur', handleBlur, true) | ||
| close() | ||
| } | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Description: Check whether the preedit dispose can run while a hold is open, and in what order relative to terminal disposal.
set -euo pipefail
fd -t f 'use-terminal-pane-lifecycle.ts' -x rg -n -C 6 'imeCompositionDisposablesRef|iosHangulPreedit|manager.destroy\(\)|terminal.dispose\(\)' {}
fd -t f 'pane-manager*.ts' -x rg -n -C 6 'dispose\(\)|destroy\(\)|blur\(' {}Repository: stablyai/orca
Length of output: 5901
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- preedit implementation ---'
fd -t f 'terminal-ios-hangul-preedit.ts' -x cat -n {} | sed -n '1,290p'
printf '%s\n' '--- lifecycle cleanup and pane disposal ---'
fd -t f 'use-terminal-pane-lifecycle.ts' -x sed -n '1330,1410p' {}
fd -t f 'use-terminal-pane-lifecycle.ts' -x sed -n '1870,1945p' {}
printf '%s\n' '--- PaneManager.destroy and pane disposal ---'
fd -t f 'pane-manager*.ts' -x sed -n '320,390p' {}
fd -t f 'pane-manager*.ts' -x rg -n -C 12 'dispose\(\)|destroy\(\)|terminal\.dispose|panes\.clear' {}
printf '%s\n' '--- all preedit disposal call sites ---'
rg -n -C 5 'installTerminalIosHangulPreedit|iosHangulPreedit|terminal-ios-hangul-preedit|imeCompositionDisposablesRef' .Repository: stablyai/orca
Length of output: 42012
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- pane disposable definition and close callback context ---'
fd -t f 'use-terminal-pane-lifecycle.ts' -x rg -n -C 18 'const disposable|disposable =|onPaneClosed|disposePane' {}
printf '%s\n' '--- disposePane implementation ---'
rg -n -C 20 'function disposePane|const disposePane|export .*disposePane' src/renderer/src
printf '%s\n' '--- focused source invariant check ---'
python3 - <<'PY'
from pathlib import Path
preedit = Path('src/renderer/src/components/terminal-pane/terminal-ios-hangul-preedit.ts').read_text()
lifecycle = Path('src/renderer/src/components/terminal-pane/use-terminal-pane-lifecycle.ts').read_text()
assert 'const close = (): void' in preedit
close_start = preedit.index('const close = (): void')
close_end = preedit.index('const commit = (): void', close_start)
close_body = preedit[close_start:close_end]
assert 'preedit = null' in close_body
assert 'sendInput' not in close_body
dispose_start = preedit.index('dispose: () => {')
dispose_end = preedit.index('\n }\n }', dispose_start)
dispose_body = preedit[dispose_start:dispose_end]
assert 'close()' in dispose_body
assert 'commit()' not in dispose_body
pane_close = lifecycle.index('const imeCompositionDisposable = imeCompositionDisposablesRef.current.get(paneId)')
pane_close_end = lifecycle.index('const imeNativeTextForwarderDisposable', pane_close)
pane_close_body = lifecycle[pane_close:pane_close_end]
assert pane_close_body.index('imeCompositionDisposable.dispose()') < pane_close_body.index('disposable.dispose()') if 'disposable.dispose()' in pane_close_body else True
unmount = lifecycle.index('for (const disposable of imeCompositionDisposables.values())')
manager_destroy = lifecycle.index('manager.destroy()', unmount)
assert unmount < manager_destroy
print('dispose() clears the held preedit without sending it.')
print('Unmount cleanup disposes IME handlers before manager.destroy().')
print('The remaining question is whether pane-close disposable.dispose() destroys the terminal; inspect its implementation.')
PYRepository: stablyai/orca
Length of output: 14766
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- pane disposable definition and close callback context ---'
fd -t f 'use-terminal-pane-lifecycle.ts' -x rg -n -C 18 'const disposable|disposable =|onPaneClosed|disposePane' {}
printf '%s\n' '--- disposePane implementation ---'
rg -n -C 20 'function disposePane|const disposePane|export .*disposePane' src/renderer/src
printf '%s\n' '--- focused source invariant check ---'
python3 - <<'PY'
from pathlib import Path
preedit = Path('src/renderer/src/components/terminal-pane/terminal-ios-hangul-preedit.ts').read_text()
lifecycle = Path('src/renderer/src/components/terminal-pane/use-terminal-pane-lifecycle.ts').read_text()
close_start = preedit.index('const close = (): void')
close_end = preedit.index('const commit = (): void', close_start)
assert 'preedit = null' in preedit[close_start:close_end]
assert 'sendInput' not in preedit[close_start:close_end]
dispose_start = preedit.index('dispose: () => {')
dispose_end = preedit.index('\n }\n }', dispose_start)
dispose_body = preedit[dispose_start:dispose_end]
assert 'close()' in dispose_body
assert 'commit()' not in dispose_body
unmount = lifecycle.index('for (const disposable of imeCompositionDisposables.values())')
manager_destroy = lifecycle.index('manager.destroy()', unmount)
assert unmount < manager_destroy
print('dispose() clears the held preedit without sending it.')
print('Unmount cleanup disposes IME handlers before manager.destroy().')
PYRepository: stablyai/orca
Length of output: 14649
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- closePane call and implementation ---'
rg -n -C 30 'closePane\(' src/renderer/src/lib/pane-manager src/renderer/src/components/terminal-pane
printf '%s\n' '--- complete disposePane body ---'
fd -t f 'pane-lifecycle.ts' -x sed -n '169,260p' {}
printf '%s\n' '--- pane-manager callback ordering ---'
rg -n -C 25 'onPaneClosed|disposePane\(' src/renderer/src/lib/pane-managerRepository: stablyai/orca
Length of output: 50370
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- delegated close implementation ---'
rg -n -C 35 'closePaneOnManager|function closePane|const closePane' src/renderer/src/lib
printf '%s\n' '--- terminal disposal in pane lifecycle ---'
fd -t f 'pane-lifecycle.ts' -x rg -n -C 12 'terminal\.dispose|onPaneClosed|panes\.delete|return' {}
printf '%s\n' '--- callback ordering assertions ---'
python3 - <<'PY'
from pathlib import Path
root = Path('src/renderer/src/lib')
matches = []
for path in root.rglob('*.ts'):
text = path.read_text()
if 'closePaneOnManager' in text or 'function closePane' in text or 'const closePane' in text:
matches.append(path)
for path in matches:
print(path)
for i, line in enumerate(path.read_text().splitlines(), 1):
if 'closePaneOnManager' in line or 'function closePane' in line or 'const closePane' in line:
print(f'{i}: {line.strip()}')
PYRepository: stablyai/orca
Length of output: 50369
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- delegated close implementation ---'
rg -n -C 35 'closePaneOnManager|function closePane|const closePane' src/renderer/src/lib
printf '%s\n' '--- terminal disposal in pane lifecycle ---'
fd -t f 'pane-lifecycle.ts' -x rg -n -C 12 'terminal\.dispose|onPaneClosed|panes\.delete|return' {}
printf '%s\n' '--- callback ordering assertions ---'
python3 - <<'PY'
from pathlib import Path
root = Path('src/renderer/src/lib')
for path in root.rglob('*.ts'):
text = path.read_text()
if 'closePaneOnManager' in text or 'function closePane' in text or 'const closePane' in text:
print(path)
for i, line in enumerate(text.splitlines(), 1):
if 'closePaneOnManager' in line or 'function closePane' in line or 'const closePane' in line:
print(f'{i}: {line.strip()}')
PYRepository: stablyai/orca
Length of output: 50369
🏁 Script executed:
#!/bin/bash
set -euo pipefail
files=$(rg -l 'closeManagedPane' src/renderer/src)
printf '%s\n' '--- files defining or calling closeManagedPane ---'
printf '%s\n' "$files"
while IFS= read -r file; do
printf '\n--- %s ---\n' "$file"
rg -n -C 25 'closeManagedPane|onPaneClosed|disposePane|terminal\.dispose' "$file"
done <<< "$files"Repository: stablyai/orca
Length of output: 8262
Commit the held preedit before pane teardown.
dispose() currently drops a held syllable without calling sendInput(). Make it commit pending text, and invoke it before closeManagedPane() disposes the terminal; onPaneClosed runs too late.
…input guard `isCompositionOwnedInput(event) || options.isCompositionActive()` could never take its second branch. The composition tracker's own `input` listener runs first on the same element and clears its active flag for every input except `insertCompositionText` — which is exactly the first disjunct. Verified by construction: instrumented to throw on the combination, nothing in the renderer suite (24k tests) reached it, and five deliberate attempts to build one, via a resumed preedit and a post-compositionend insert, all failed to. Reading composition ownership off the event alone also makes the decision independent of listener registration order, which the previous comment at the call site claimed to depend on. It does not: swapping the tracker and the preedit controller leaves every test passing. The comment now states the one coupling that is real — the controller stops propagation on `input` while a syllable is held — without asserting a behavioral dependency that does not exist. `isCompositionActive` remains the gate on opening a hold, where it is pinned.
Device test on real hardware — works, with one bug foundTested on a physical iPad (iPadOS 26, hardware Korean 2-set keyboard) against the real production module through xterm's actual helper textarea. Two runs, byte-identical results. What works, confirmed on device:
The bug: syllables stop committing after a batchim migration.
The IME reaches back and rewrites a syllable that looked finished.
User-visible effect: correct text delivered late. In a terminal, nothing reaches the shell after the first batchim migration until space, Enter, or focus loss. Holding is still the right behaviour — committing The 34-event recording is being added as a replay fixture. The previous round of this work passed on a hand-built shape the device never produces, which is how the Shift-jamo ( |
…it grows The hold released a syllable only when the textarea tail grew past it and still started with it. Korean batchim migration breaks that: a device capture on iPadOS 26 shows `깨` + `ㅈ` rewritten to `깾` — a different codepoint, not an extension — and only becoming `깨주` once the next vowel decides where the `ㅈ` belongs. The prefix check failed there, the hold stopped advancing, and `깨쥠` reached the PTY as one chunk on blur. Locate the IME's edit with a prefix diff of the two field states instead. Everything before where it began rewriting is settled: the batchim question for those syllables is already answered. Still hold-and-commit, so no DEL ever reaches the pty. The capture is now the fixture, replayed both verbatim and as keystrokes.
Device-verified on a physical iPad — passesSame hardware and harness as the failure recorded above (iPadOS 26, hardware Korean 2-set keyboard, real production module through xterm's actual helper textarea). All four syllables, correct codepoints, committed one at a time as the user types. Compare the pre-fix run on the same device: Observed behaviour is that three syllables appear while typing and the fourth appears on focus loss. That is correct — the final syllable is legitimately still an open preedit, and it commits on space, Enter, or blur like any other IME. In a terminal the user never sees it held, because the command ends with one of those. Both device-found defects are now fixed and pinned to the recording:
Reverting the diff to the previous growth assumption fails 4 tests, emitting |
…rewrite Backspace can decompose a held syllable as deleteContentBackward then a replacing insertText, the same shape the IME uses to grow one. The hold closed on the emptied half, so the replacement landed with nothing held: typing 한, Backspace, ㄹ put a bare `ㄹ` on the wire and dropped 하. The empty field now collapses the hold instead of closing it, and the Backspace that finds nothing held is the one that reaches the PTY. An `imeWrote` flag keeps an erased hold from resurrecting its opening jamo. Also diff the field as NFC. Decomposed Hangul grows by appending jamo, which the common-prefix diff reads as the previous syllable settling, so an NFD source emitted one bare jamo per keystroke. The recorded device trace is NFC, where normalization is a no-op.
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
The coexistence suite proved pinyin and a short list of non-Hangul keys. Widen it: a kana-to-kanji session, a Hanja lookup over a live preedit, a digit that ends a held syllable as literal text, and Greek, halfwidth kana and accented Latin among the keys the bypass must not claim.
…enderer (stablyai#13345) (stablyai#15480) * fix(terminal): compose iPadOS Hangul by holding the syllable in the renderer (stablyai#13345) Korean typed on an iPad with a hardware keyboard reached the PTY as separate jamo: `한글깨짐` arrived as `ㅎㅏㄴㄱㅡㄹ...`. iPadOS fires no composition events for it — each jamo is a plain keydown while the IME rewrites the syllable in place in the helper textarea — so xterm consumes the keydown, sends the raw jamo from `_keyPress`, and drops the composed `insertText` because `_inputEvent` admits a composed insert only when no key is down. The jamo keydown is handed to the system by a new bypass rule, and the syllable it builds is held in the renderer until the IME proves it final. The PTY sees one write per syllable and nothing is ever sent then retracted, so raw-mode TUIs never receive DEL bytes they need not read as "erase one cell" and SSH and relay sessions pay no round trip for them. `한글깨짐` is four writes and zero DELs. Sitting upstream of `xterm-bypass-policy.ts` rather than inside xterm is what makes this work for Shift-typed double consonants: Orca's own Shift rule already hides `ㄲ ㄸ ㅃ ㅆ ㅉ` keydowns from xterm, so a fix living in CompositionHelper never sees them and every syllable starting with one — 깨 꿈 딸 빵 쓰다 짜다 — stays broken. That placement call is dvpaa's, from stablyai#13346. Composition sessions are left alone entirely, so Chinese pinyin on the same device keeps working; that state is derived from the existing composition tracker rather than latched, so a session that never ends cannot disable the pane. The bypass claims jamo only — a Cyrillic or kana key would lose its keydown, keypress and `input` alike and reach the PTY as nothing. Co-authored-by: dvpaa <[email protected]> * refactor(terminal): drop the dead session check from the iOS preedit input guard `isCompositionOwnedInput(event) || options.isCompositionActive()` could never take its second branch. The composition tracker's own `input` listener runs first on the same element and clears its active flag for every input except `insertCompositionText` — which is exactly the first disjunct. Verified by construction: instrumented to throw on the combination, nothing in the renderer suite (24k tests) reached it, and five deliberate attempts to build one, via a resumed preedit and a post-compositionend insert, all failed to. Reading composition ownership off the event alone also makes the decision independent of listener registration order, which the previous comment at the call site claimed to depend on. It does not: swapping the tracker and the preedit controller leaves every test passing. The comment now states the one coupling that is real — the controller stops propagation on `input` while a syllable is held — without asserting a behavioral dependency that does not exist. `isCompositionActive` remains the gate on opening a hold, where it is pinned. * fix(terminal): settle iPad Hangul by diffing the field, not assuming it grows The hold released a syllable only when the textarea tail grew past it and still started with it. Korean batchim migration breaks that: a device capture on iPadOS 26 shows `깨` + `ㅈ` rewritten to `깾` — a different codepoint, not an extension — and only becoming `깨주` once the next vowel decides where the `ㅈ` belongs. The prefix check failed there, the hold stopped advancing, and `깨쥠` reached the PTY as one chunk on blur. Locate the IME's edit with a prefix diff of the two field states instead. Everything before where it began rewriting is settled: the batchim question for those syllables is already answered. Still hold-and-commit, so no DEL ever reaches the pty. The capture is now the fixture, replayed both verbatim and as keystrokes. * fix(terminal): keep the iPad Hangul hold open across the IME's erase rewrite Backspace can decompose a held syllable as deleteContentBackward then a replacing insertText, the same shape the IME uses to grow one. The hold closed on the emptied half, so the replacement landed with nothing held: typing 한, Backspace, ㄹ put a bare `ㄹ` on the wire and dropped 하. The empty field now collapses the hold instead of closing it, and the Backspace that finds nothing held is the one that reaches the PTY. An `imeWrote` flag keeps an erased hold from resurrecting its opening jamo. Also diff the field as NFC. Decomposed Hangul grows by appending jamo, which the common-prefix diff reads as the previous syllable settling, so an NFD source emitted one bare jamo per keystroke. The recorded device trace is NFC, where normalization is a no-op. * test(terminal): cover Japanese, Hanja and Greek on the iPad Hangul path The coexistence suite proved pinyin and a short list of non-Hangul keys. Widen it: a kana-to-kanji session, a Hanja lookup over a live preedit, a digit that ends a held syllable as literal text, and Greek, halfwidth kana and accented Latin among the keys the bypass must not claim. --------- Co-authored-by: dvpaa <[email protected]> (cherry picked from commit 0743394)
…enderer (stablyai#13345) (stablyai#15480) * fix(terminal): compose iPadOS Hangul by holding the syllable in the renderer (stablyai#13345) Korean typed on an iPad with a hardware keyboard reached the PTY as separate jamo: `한글깨짐` arrived as `ㅎㅏㄴㄱㅡㄹ...`. iPadOS fires no composition events for it — each jamo is a plain keydown while the IME rewrites the syllable in place in the helper textarea — so xterm consumes the keydown, sends the raw jamo from `_keyPress`, and drops the composed `insertText` because `_inputEvent` admits a composed insert only when no key is down. The jamo keydown is handed to the system by a new bypass rule, and the syllable it builds is held in the renderer until the IME proves it final. The PTY sees one write per syllable and nothing is ever sent then retracted, so raw-mode TUIs never receive DEL bytes they need not read as "erase one cell" and SSH and relay sessions pay no round trip for them. `한글깨짐` is four writes and zero DELs. Sitting upstream of `xterm-bypass-policy.ts` rather than inside xterm is what makes this work for Shift-typed double consonants: Orca's own Shift rule already hides `ㄲ ㄸ ㅃ ㅆ ㅉ` keydowns from xterm, so a fix living in CompositionHelper never sees them and every syllable starting with one — 깨 꿈 딸 빵 쓰다 짜다 — stays broken. That placement call is dvpaa's, from stablyai#13346. Composition sessions are left alone entirely, so Chinese pinyin on the same device keeps working; that state is derived from the existing composition tracker rather than latched, so a session that never ends cannot disable the pane. The bypass claims jamo only — a Cyrillic or kana key would lose its keydown, keypress and `input` alike and reach the PTY as nothing. Co-authored-by: dvpaa <[email protected]> * refactor(terminal): drop the dead session check from the iOS preedit input guard `isCompositionOwnedInput(event) || options.isCompositionActive()` could never take its second branch. The composition tracker's own `input` listener runs first on the same element and clears its active flag for every input except `insertCompositionText` — which is exactly the first disjunct. Verified by construction: instrumented to throw on the combination, nothing in the renderer suite (24k tests) reached it, and five deliberate attempts to build one, via a resumed preedit and a post-compositionend insert, all failed to. Reading composition ownership off the event alone also makes the decision independent of listener registration order, which the previous comment at the call site claimed to depend on. It does not: swapping the tracker and the preedit controller leaves every test passing. The comment now states the one coupling that is real — the controller stops propagation on `input` while a syllable is held — without asserting a behavioral dependency that does not exist. `isCompositionActive` remains the gate on opening a hold, where it is pinned. * fix(terminal): settle iPad Hangul by diffing the field, not assuming it grows The hold released a syllable only when the textarea tail grew past it and still started with it. Korean batchim migration breaks that: a device capture on iPadOS 26 shows `깨` + `ㅈ` rewritten to `깾` — a different codepoint, not an extension — and only becoming `깨주` once the next vowel decides where the `ㅈ` belongs. The prefix check failed there, the hold stopped advancing, and `깨쥠` reached the PTY as one chunk on blur. Locate the IME's edit with a prefix diff of the two field states instead. Everything before where it began rewriting is settled: the batchim question for those syllables is already answered. Still hold-and-commit, so no DEL ever reaches the pty. The capture is now the fixture, replayed both verbatim and as keystrokes. * fix(terminal): keep the iPad Hangul hold open across the IME's erase rewrite Backspace can decompose a held syllable as deleteContentBackward then a replacing insertText, the same shape the IME uses to grow one. The hold closed on the emptied half, so the replacement landed with nothing held: typing 한, Backspace, ㄹ put a bare `ㄹ` on the wire and dropped 하. The empty field now collapses the hold instead of closing it, and the Backspace that finds nothing held is the one that reaches the PTY. An `imeWrote` flag keeps an erased hold from resurrecting its opening jamo. Also diff the field as NFC. Decomposed Hangul grows by appending jamo, which the common-prefix diff reads as the previous syllable settling, so an NFD source emitted one bare jamo per keystroke. The recorded device trace is NFC, where normalization is a no-op. * test(terminal): cover Japanese, Hanja and Greek on the iPad Hangul path The coexistence suite proved pinyin and a short list of non-Hangul keys. Widen it: a kana-to-kanji session, a Hanja lookup over a live preedit, a digit that ends a held syllable as literal text, and Greek, halfwidth kana and accented Latin among the keys the bypass must not claim. --------- Co-authored-by: dvpaa <[email protected]>
Problem
Fixes #13345 — Korean typed on an iPad reaches the terminal as separate jamo instead of composed syllables.
Cause
iPadOS Korean fires zero composition events. No
compositionstart,compositionupdateorcompositionend— just plain keydowns, while the IME rewrites xterm's hidden helper textarea in place (adeleteContentBackwardfollowed by a replacinginsertText). xterm'sCompositionHelperis built entirely around composition events, so it never sees a composition and forwards each jamo as it arrives.Confirmed on the reporter's hardware rather than inferred: Chinese pinyin on the same device fires composition events normally, so this is specific to the Korean input mode.
Fix
Entirely in Orca's renderer. No xterm patch —
config/patches/is untouched.xterm-bypass-policy.ts—shouldBypassXtermForIosTextEditkeeps xterm out of the way for jamo keys. Without it xtermpreventDefaults the printable keydown and the IME never writes to the field at all. Deliberately narrowed to jamo only: xterm sets_keyDownSeenbefore consulting the custom handler, and_inputEventadmits a composedinsertTextonly when no key is down — so a bypassed non-jamo key loses its keydown, its keypress and itsinput. A broader predicate makes Cyrillic, Greek and kana reach the PTY as nothing.terminal-ios-hangul-preedit.ts— holds the syllable and commits only what a common-prefix diff proves settled. Never sends then retracts, so zero DEL bytes ever reach the PTY.ios-web-platform.ts—userAgent.includes('Mac') && maxTouchPoints > 1. Every iOS user agent contains "Mac";> 0is too loose because a Mac with a touch peripheral reports 1..composition-viewso the syllable visibly builds (하 → 한).Why a diff and not a prefix test. The first version assumed the field only grows. It does not: after a batchim migration the IME reaches back and rewrites a syllable that looked finished —
깨+ㅈbecomes깾, thenㅜturns it into깨주as the consonant migrates forward. A syllable is not final until the following syllable's vowel decides. Committing깨early would be wrong, so the diff commits only up to the point the IME's own edit has moved past.Device verification
Recorded on a physical iPad (iPadOS 26, hardware Korean 2-set keyboard) through the real production module and xterm's actual helper textarea. The 34-event capture is committed as
__fixtures__/ipados-hardware-2set-hangul-batchim-migration-trace.jsonand drives the suite.Per-syllable commits as the user types, with the final syllable correctly still held as an open preedit until space, Enter or blur.
Before the diff, the same device produced
['한','글','깨쥠']— everything after the first batchim migration accumulated and arrived in one chunk on blur. Reverting to the growth assumption fails 27 tests, emitting that string verbatim.Verification
dispose()'s overlay cleanup) got a test; a second survivor appeared because of a fix (collapsing instead of closing made the compose-deletion skip unobservable in emitted data) and got a test asserting the overlay mid-rewrite.maxTouchPoints0 and 1, plus Windows and Linux user agents, driving a realTerminal.src/renderer.tsc,oxlint,oxfmt, max-lines ratchet all clean. No dependency or lockfile change.Not verified — read before merging
.xterm-screena zero-sized rect, so the geometry branch short-circuits; only text content and theactiveclass are ever exercised. Worth a device pass before release.Supersedes #15456, which patched the vendored xterm and — being downstream of the bypass policy — never fixed Shift-typed jamo, so every syllable starting with a double consonant broke.
Co-authored-by: dvpaa — the decision to fix this above the terminal rather than inside it is theirs, from #13346.