Skip to content

fix(terminal): stop the macOS IME forwarder from running on iPadOS - #15218

Merged
nwparker merged 2 commits into
mainfrom
nwparker/ime-ipad-forwarder-gate
Aug 18, 2026
Merged

nwparker merged 2 commits into
mainfrom
nwparker/ime-ipad-forwarder-gate

Conversation

@nwparker

@nwparker nwparker commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​37 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​37
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​23 $\color{#cf222e}{\Huge{\mathbf{−}}}$​12 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​11

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

installTerminalImeNativeTextForwarder is a macOS workaround. It is installed from a check that reduces to:

const isMac = navigator.userAgent.includes('Mac')

Every iOS and iPadOS user agent contains Mac — Macintosh in iPad desktop mode, which has been the default since iPadOS 13, and like Mac OS X in mobile mode. So a macOS-only workaround installs on every iPad and iPhone web client. navigator.maxTouchPoints is 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 input event 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 checking isComposing and compositionActive in isNativeTextKeydown.

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 sets compositionActive, 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. isMac itself is untouched, and its other five consumers keep current behaviour deliberately:

consumer why it should still treat an iPad like a Mac
xterm-bypass-policy.ts:127 standalone 229 keydown this is the path that must remain open for xterm's own composition handling to work
xterm-bypass-policy.ts:214 Ctrl+C interrupt matches iPadOS keyboard conventions
xterm-bypass-policy.ts:248-280 Mod+C / Mod+V clipboard bypass an iPad hardware keyboard uses Cmd, like a Mac
terminal-jis-yen-input.ts:38 JIS yen input unrelated to touch

Redefining isMac would have changed all of them. A narrow isTouchIOSUserAgent predicate 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 Macintosh UA with touch points, iPhone like Mac OS X UA with touch points, and non-Mac UAs regardless of touch points.

use-terminal-pane-lifecycle.test.ts + terminal-ime-native-text-forwarder.test.ts
Test Files  2 passed (2)
     Tests  84 passed (84)

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.ts gates 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.

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
@coderabbitai

coderabbitai Bot commented Aug 18, 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: 6c7591d5-146f-4a6a-bb39-8841a241a1e3

📥 Commits

Reviewing files that changed from the base of the PR and between b9e59c8 and 2ae1e05.

📒 Files selected for processing (2)
  • src/renderer/src/components/terminal-pane/use-terminal-pane-lifecycle.test.ts
  • src/renderer/src/components/terminal-pane/use-terminal-pane-lifecycle.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/renderer/src/components/terminal-pane/use-terminal-pane-lifecycle.test.ts
  • src/renderer/src/components/terminal-pane/use-terminal-pane-lifecycle.ts

Included review availability: Your plan includes up to 10 reviews per rolling hour; 6 remain after this review.


📝 Walkthrough

Walkthrough

The change adds isTouchIOSUserAgent to identify iOS/iPadOS devices that report Mac-like user agents. Tests cover Mac, iPadOS desktop mode, iPhone, Linux, and Windows with varied touch-point counts. Terminal keyboard setup now enables native IME text forwarding only for desktop macOS and uses a no-op forwarder on touch iOS/iPadOS.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely identifies the main fix: preventing the macOS IME forwarder from running on iPadOS.
Description check ✅ Passed The description explains the issue, scope, rationale, linked issue, testing, limitations, and follow-up, but omits several template headings and visual proof.
✨ Finishing Touches 💡 1
📝 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.

@nwparker

Copy link
Copy Markdown
Contributor Author

Confirmed on hardware — and it sharpens the mechanism

I 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 insertText — C being a deliberate model of this forwarder.

The user agent is byte-identical to a desktop Mac:

Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 … Version/26.3 Safari/605.1.15
navigator.platform        = "MacIntel"
navigator.maxTouchPoints  = 5

platform is MacIntel too. maxTouchPoints really is the only separator — the premise of this PR, now measured rather than argued.

Results: A = 한글 ✅ · B = ✗ · C = ✗

Korean on iPadOS fires no composition events at all

This is the part I had wrong. I wrote that composition events are unreliable here. Measured, for Korean they are entirely absent — 0 compositionstart / compositionupdate / compositionend across the whole Korean portion, in every field. (Composition events do fire on the same device for Chinese pinyin, which is what made this ambiguous.)

Instead, Korean uses a stateful in-place rewrite of the field. Box A, working:

keydown ㅎ → textInput 'ㅎ'  → insertText 'ㅎ'  value='ㅎ'
keydown ㅏ → deleteContentBackward value=''
           → textInput '하'  → insertText '하'  value='하'
keydown ㄴ → deleteContentBackward value='하'
           → …                                  value='한'

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 destroys

Box C, same keystrokes, blanked after each insertText — this is #13345, reproduced in ~40 lines of standalone HTML:

keydown ㅎ → insertText 'ㅎ' → (blanked)
keydown ㅏ → keypress → keyup          ← no input event at all; dropped
keydown ㄴ → insertText 'ㄴ' → (blanked)
keydown ㄱ → insertText 'ㄱ' → (blanked)
keydown ㅡ → insertText 'ㅡ' → (blanked)
keydown ㄹ → insertText 'ㄹ' → (blanked)

Loose jamo, and note ㅏ is dropped outright — this is data loss, not merely decomposition.

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 terminal-ime-native-text-forwarder.ts do it:

  1. event.target.value = '' after handling destroys the syllable-so-far that the next deleteContentBackward needs.
  2. forwardCommittedText consumes the pending commit on any non-insertText inputType, so deleteContentBackward settles it and the replacing insertText then finds no pending commit and returns.

The header comment's stated assumption — one keydown, one insertText, one commit, helper textarea as scratch — is simply not how iPadOS Korean behaves.

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 verified

Box 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.

@nwparker

Copy link
Copy Markdown
Contributor Author

Reproduced in a real terminal, not just a test page

Confirmed 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 — ㅎㅏㄴㄱㅡㄹ — instead of the two composed syllables 한글.

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:

user report six jamo instead of two syllables
standalone capture, field blanked after each insertText six jamo, one dropped
released Orca on the same device six jamo
standalone capture, plain field 한글 ✅

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.
@nwparker
nwparker merged commit 598ba5d into main Aug 18, 2026
45 checks passed
paidaxingyo666 pushed a commit to paidaxingyo666/Manta that referenced this pull request Aug 21, 2026
…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.
dallascrilley pushed a commit to dallascrilley/orca that referenced this pull request Aug 27, 2026
…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.
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant