Repository navigation
fix(terminal): stop the macOS IME forwarder from running on iPadOS - #15218
Conversation
Korean typed into a terminal from an iPad web client arrives as loose jamo instead of composed syllables. The native-text forwarder is a macOS workaround: it claims a printable keydown and delivers the input method's substituted text from the input event alone. It stands aside for IME composition by checking isComposing and compositionstart. Touch iOS/iPadOS is unreliable about firing those for hardware-keyboard CJK input, so each jamo keydown is claimed as its own one-shot substitution rather than deferred to xterm's composition handling. It runs there at all because every iOS user agent contains "Mac" - "Macintosh" in iPad desktop mode, the default since iPadOS 13, and "like Mac OS X" in mobile mode. maxTouchPoints is the only signal a real Mac never sets. The Linux branch immediately below already makes the mirror-image exclusion for Android and CrOS; the Mac branch never got the same treatment. Gate the forwarder install only. isMac keeps its other five consumers - the Ctrl+C interrupt, clipboard bypass, JIS yen input and the standalone 229 keydown policy - which intentionally still treat an iPad with a hardware keyboard like macOS, matching iPadOS shortcut conventions. Without the forwarder, xterm's own composition path plus the deferred textarea diff is the sole delivery mechanism, which is already the arrangement on Linux. Not verified on hardware: the claim that composition events are absent on iPadOS is the mechanism the code supports and the only one matching the reported symptom, but no on-device capture confirms it. The platform detection stands on its own regardless. terminal-ime-input-context-refresh.ts has the same user-agent collision for its NSTextInputContext refresh. Narrower trigger surface, left for a follow-up. Refs #13345
|
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 (2)
🚧 Files skipped from review as they are similar to previous changes (2)
Included review availability: Your plan includes up to 10 reviews per rolling hour; 6 remain after this review. 📝 WalkthroughWalkthroughThe change adds 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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 |
Confirmed on hardware — and it sharpens the mechanismI captured a real iPad (iPadOS 26.3, Magic-Keyboard-class Bluetooth keyboard, Korean 2-Set) against a standalone page with three fields: A plain, B keydown default-prevented, C blanked after every The user agent is byte-identical to a desktop Mac:
Results: A = Korean on iPadOS fires no composition events at allThis is the part I had wrong. I wrote that composition events are unreliable here. Measured, for Korean they are entirely absent — 0 Instead, Korean uses a stateful in-place rewrite of the field. Box A, working: Each keystroke deletes the syllable-so-far and re-inserts a fuller one. The field is not a scratch buffer — it is the IME's working state. Which is exactly what this forwarder destroysBox C, same keystrokes, blanked after each Loose jamo, and note So the causality is the reverse of what I wrote. The forwarder is not a victim of missing composition events; blanking the field is what prevents the rewrite from ever working. Two independent mechanisms in
The header comment's stated assumption — one keydown, one The fix in this PR is unchanged and is the right one. Not installing a forwarder built on that assumption is what lets the field keep the state the IME needs. Still not verifiedBox B is not a fair model of xterm — it default-prevents every printable keydown unconditionally, which is cruder than what xterm does. So B coming out empty is not evidence that xterm's own path fails on iPadOS, but this capture also does not positively confirm that it succeeds. That claim still rests on the Linux precedent, where no forwarder exists and CJK input works. Confirming it properly means running a real terminal on the iPad against a paired host. Worth doing before this is called closed. |
Reproduced in a real terminal, not just a test pageConfirmed on device just now. Released Orca (no fix), iPad paired as a web client, Bluetooth hardware keyboard, Korean 2-Set, typing the six keys for Result: six separate characters — This is the piece that was missing. Until now #13345 was a user report plus a mechanism I had reproduced only in a standalone HTML page. The symptom now reproduces end to end in the shipped product, and it matches the capture's box C — the field-blanking model of this forwarder — character for character. So the chain is closed on the "before" side:
The plain-field control composing correctly on the same device, same keyboard, same keystrokes is what rules out the iPad, the keyboard layout and iPadOS itself as the cause. The difference is entirely what the page does to the field between keystrokes — which is what this forwarder does. Still outstanding: the after run. I am building a renderer with this fix so the same device can be tested against it, and I will post that result here. That is what actually proves the fix rather than only proving the diagnosis, and it is also the one thing the capture could not settle — whether xterm's own composition path handles iPadOS Korean once the forwarder stops interfering. |
…forwarder The gate used maxTouchPoints > 0, which is looser than the idiom already in this repo. isIOSWebView in mobile/src/terminal/terminal-webview-html.ts requires more than one, because a Mac with a touch-capable peripheral can report exactly one, and such a Mac must keep the forwarder: it is a real Mac running the input method this workaround exists for. Under the old threshold that Mac silently lost native text substitution - a macOS regression introduced by a fix aimed at iPadOS. A captured iPad reports five, so the stricter bound costs nothing on the device this targets. The check stays user-agent based rather than adopting that helper's platform check, because an iPhone reports platform "iPhone" rather than "MacIntel" and would slip through.
…tablyai#15218) * fix(terminal): stop the macOS IME forwarder from running on iPadOS Korean typed into a terminal from an iPad web client arrives as loose jamo instead of composed syllables. The native-text forwarder is a macOS workaround: it claims a printable keydown and delivers the input method's substituted text from the input event alone. It stands aside for IME composition by checking isComposing and compositionstart. Touch iOS/iPadOS is unreliable about firing those for hardware-keyboard CJK input, so each jamo keydown is claimed as its own one-shot substitution rather than deferred to xterm's composition handling. It runs there at all because every iOS user agent contains "Mac" - "Macintosh" in iPad desktop mode, the default since iPadOS 13, and "like Mac OS X" in mobile mode. maxTouchPoints is the only signal a real Mac never sets. The Linux branch immediately below already makes the mirror-image exclusion for Android and CrOS; the Mac branch never got the same treatment. Gate the forwarder install only. isMac keeps its other five consumers - the Ctrl+C interrupt, clipboard bypass, JIS yen input and the standalone 229 keydown policy - which intentionally still treat an iPad with a hardware keyboard like macOS, matching iPadOS shortcut conventions. Without the forwarder, xterm's own composition path plus the deferred textarea diff is the sole delivery mechanism, which is already the arrangement on Linux. Not verified on hardware: the claim that composition events are absent on iPadOS is the mechanism the code supports and the only one matching the reported symptom, but no on-device capture confirms it. The platform detection stands on its own regardless. terminal-ime-input-context-refresh.ts has the same user-agent collision for its NSTextInputContext refresh. Narrower trigger surface, left for a follow-up. Refs stablyai#13345 * fix(terminal): require more than one touch point before skipping the forwarder The gate used maxTouchPoints > 0, which is looser than the idiom already in this repo. isIOSWebView in mobile/src/terminal/terminal-webview-html.ts requires more than one, because a Mac with a touch-capable peripheral can report exactly one, and such a Mac must keep the forwarder: it is a real Mac running the input method this workaround exists for. Under the old threshold that Mac silently lost native text substitution - a macOS regression introduced by a fix aimed at iPadOS. A captured iPad reports five, so the stricter bound costs nothing on the device this targets. The check stays user-agent based rather than adopting that helper's platform check, because an iPhone reports platform "iPhone" rather than "MacIntel" and would slip through.
…tablyai#15218) * fix(terminal): stop the macOS IME forwarder from running on iPadOS Korean typed into a terminal from an iPad web client arrives as loose jamo instead of composed syllables. The native-text forwarder is a macOS workaround: it claims a printable keydown and delivers the input method's substituted text from the input event alone. It stands aside for IME composition by checking isComposing and compositionstart. Touch iOS/iPadOS is unreliable about firing those for hardware-keyboard CJK input, so each jamo keydown is claimed as its own one-shot substitution rather than deferred to xterm's composition handling. It runs there at all because every iOS user agent contains "Mac" - "Macintosh" in iPad desktop mode, the default since iPadOS 13, and "like Mac OS X" in mobile mode. maxTouchPoints is the only signal a real Mac never sets. The Linux branch immediately below already makes the mirror-image exclusion for Android and CrOS; the Mac branch never got the same treatment. Gate the forwarder install only. isMac keeps its other five consumers - the Ctrl+C interrupt, clipboard bypass, JIS yen input and the standalone 229 keydown policy - which intentionally still treat an iPad with a hardware keyboard like macOS, matching iPadOS shortcut conventions. Without the forwarder, xterm's own composition path plus the deferred textarea diff is the sole delivery mechanism, which is already the arrangement on Linux. Not verified on hardware: the claim that composition events are absent on iPadOS is the mechanism the code supports and the only one matching the reported symptom, but no on-device capture confirms it. The platform detection stands on its own regardless. terminal-ime-input-context-refresh.ts has the same user-agent collision for its NSTextInputContext refresh. Narrower trigger surface, left for a follow-up. Refs stablyai#13345 * fix(terminal): require more than one touch point before skipping the forwarder The gate used maxTouchPoints > 0, which is looser than the idiom already in this repo. isIOSWebView in mobile/src/terminal/terminal-webview-html.ts requires more than one, because a Mac with a touch-capable peripheral can report exactly one, and such a Mac must keep the forwarder: it is a real Mac running the input method this workaround exists for. Under the old threshold that Mac silently lost native text substitution - a macOS regression introduced by a fix aimed at iPadOS. A captured iPad reports five, so the stricter bound costs nothing on the device this targets. The check stays user-agent based rather than adopting that helper's platform check, because an iPhone reports platform "iPhone" rather than "MacIntel" and would slip through.
…tablyai#15218) * fix(terminal): stop the macOS IME forwarder from running on iPadOS Korean typed into a terminal from an iPad web client arrives as loose jamo instead of composed syllables. The native-text forwarder is a macOS workaround: it claims a printable keydown and delivers the input method's substituted text from the input event alone. It stands aside for IME composition by checking isComposing and compositionstart. Touch iOS/iPadOS is unreliable about firing those for hardware-keyboard CJK input, so each jamo keydown is claimed as its own one-shot substitution rather than deferred to xterm's composition handling. It runs there at all because every iOS user agent contains "Mac" - "Macintosh" in iPad desktop mode, the default since iPadOS 13, and "like Mac OS X" in mobile mode. maxTouchPoints is the only signal a real Mac never sets. The Linux branch immediately below already makes the mirror-image exclusion for Android and CrOS; the Mac branch never got the same treatment. Gate the forwarder install only. isMac keeps its other five consumers - the Ctrl+C interrupt, clipboard bypass, JIS yen input and the standalone 229 keydown policy - which intentionally still treat an iPad with a hardware keyboard like macOS, matching iPadOS shortcut conventions. Without the forwarder, xterm's own composition path plus the deferred textarea diff is the sole delivery mechanism, which is already the arrangement on Linux. Not verified on hardware: the claim that composition events are absent on iPadOS is the mechanism the code supports and the only one matching the reported symptom, but no on-device capture confirms it. The platform detection stands on its own regardless. terminal-ime-input-context-refresh.ts has the same user-agent collision for its NSTextInputContext refresh. Narrower trigger surface, left for a follow-up. Refs stablyai#13345 * fix(terminal): require more than one touch point before skipping the forwarder The gate used maxTouchPoints > 0, which is looser than the idiom already in this repo. isIOSWebView in mobile/src/terminal/terminal-webview-html.ts requires more than one, because a Mac with a touch-capable peripheral can report exactly one, and such a Mac must keep the forwarder: it is a real Mac running the input method this workaround exists for. Under the old threshold that Mac silently lost native text substitution - a macOS regression introduced by a fix aimed at iPadOS. A captured iPad reports five, so the stricter bound costs nothing on the device this targets. The check stays user-agent based rather than adopting that helper's platform check, because an iPhone reports platform "iPhone" rather than "MacIntel" and would slip through.
Refs #13345 — Korean typed into a terminal from an iPad web client arrives as loose jamo (ㅎㅏㄴㄱㅡㄹ) instead of composed syllables (한글).
Why the forwarder runs on an iPad at all
installTerminalImeNativeTextForwarderis a macOS workaround. It is installed from a check that reduces to:Every iOS and iPadOS user agent contains
Mac—Macintoshin iPad desktop mode, which has been the default since iPadOS 13, andlike Mac OS Xin mobile mode. So a macOS-only workaround installs on every iPad and iPhone web client.navigator.maxTouchPointsis the only signal a real Mac never sets.The Linux branch immediately below already makes the mirror-image exclusion, ruling out Android and CrOS whose user agents both contain
Linux. The idiom was already in the file; the Mac branch never got the same treatment.Why that breaks Hangul
The forwarder claims a printable keydown and delivers the input method's substituted text from the
inputevent alone. It is built for one-shot native-text substitution — dead keys, smart punctuation — not for multi-keystroke composition, and it stands aside for composition by checkingisComposingandcompositionActiveinisNativeTextKeydown.On desktop macOS a genuine CJK composition session fires
compositionstart, so the forwarder correctly steps aside. If those events do not fire on touch iOS/iPadOS for hardware-keyboard input, nothing ever setscompositionActive, so every jamo keydown is independently claimed and forwarded as its own commit — which is exactly six separate jamo for한글, matching the report.Scope of the change
The gate applies to the forwarder install only.
isMacitself is untouched, and its other five consumers keep current behaviour deliberately:xterm-bypass-policy.ts:127standalone 229 keydownxterm-bypass-policy.ts:214Ctrl+C interruptxterm-bypass-policy.ts:248-280Mod+C / Mod+V clipboard bypassterminal-jis-yen-input.ts:38JIS yen inputRedefining
isMacwould have changed all of them. A narrowisTouchIOSUserAgentpredicate does not.Without the forwarder, xterm's own composition path plus the deferred textarea diff becomes the sole delivery mechanism — which is already the arrangement on Linux, where no forwarder exists and CJK input works. That is the precedent for believing the native path suffices.
Remote / SSH
The check reads the renderer's own
navigator, so it describes the client doing the typing, not the PTY host. Correct identically for local, SSH and paired-web sessions — the iPad reaches Orca as a paired web client, and it is the iPad's WebKit being detected.Tests
Four cases on the extracted predicate: real Mac UA with 0 touch points, iPad desktop-mode
MacintoshUA with touch points, iPhonelike Mac OS XUA with touch points, and non-Mac UAs regardless of touch points.oxlint and oxfmt clean.
Not verified
No hardware capture. The claim that composition events are absent on iPadOS is the mechanism the code supports and the only one that matches the reported symptom, but no on-device trace confirms it. I have an iPad capture pending; if it shows composition events firing normally, the mechanism above is wrong and this explanation needs revisiting.
The platform detection stands on its own regardless. A macOS-specific workaround installing on every iPad and iPhone is a defect whatever the Hangul mechanism turns out to be, and that half is not in doubt.
Follow-up, not fixed here
terminal-ime-input-context-refresh.tsgates a separate macOS NSTextInputContext blur/refocus behind the same user-agent check, so it has the identical collision. Narrower trigger surface — split-pane focus handoff and app reactivation rather than every keystroke — so it is left for a follow-up rather than folded in.