Skip to content

Revert the terminal IME composition-ownership change - #13282

Merged
nwparker merged 5 commits into
mainfrom
nwparker/revert-ime-xterm-ownership
Aug 9, 2026
Merged

nwparker merged 5 commits into
mainfrom
nwparker/revert-ime-xterm-ownership

Conversation

@nwparker

@nwparker nwparker commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

Reverts the terminal IME composition-ownership change. Main is shipping two user-visible IME regressions and a release needs to go out; this restores the terminal composition layer that shipped in v1.4.177-rc.3.

The two regressions

A. Full-width CJK punctuation typed as ASCII. , (U+FF0C) arrived as ,, 。 (U+3002) as .. The forwarder that handles IME text arriving as insertText outside a composition session (terminal-ime-native-text-forwarder.ts, plus terminal-ime-native-text-candidates.ts) was deleted by #13128. xterm's own composition handling only covers text inside a composition session, so direct-punctuation commits fell through to the raw key.

B. Korean preedit invisible. 2-Set Korean showed committed syllables but not the in-progress jamo, so users typed blind until each syllable committed. The preedit anchor/overlay positioning (terminal-ime-anchor.ts, terminal-ime-candidate-anchor.ts) was deleted by the same commit.

What was reverted

What was deliberately kept

Deliberate partial revert: the macOS Backslash bypass

xterm-bypass-policy.ts is not cleanly reverted, on purpose. git log -S"event.code === 'Backslash'" returns exactly one commit — #13128 itself — which added that bypass as a partial replacement for the deleted forwarder. A clean revert would remove it.

That matters because the restored forwarder is gated on a hardcoded CJK_INPUT_SOURCE_TERMS allowlist. Third-party IMEs off that list (Qingg, com.aodaren.inputmethod.Qingg, issue #10896) never get their key claimed, so 、 would arrive as \ again. The reporter's ,/。 bug is fixed by the revert regardless — Sogou and Apple Pinyin match pinyin — but there was no reason to trade an open issue back.

So shouldBypassXtermForMacNativeText is kept, wired into shouldBypassXtermKeyboardEvent exactly as on main, with its three tests. It is deliberately narrowed to the bare backslash key. Main's version also bypassed all unmodified non-ASCII text; kept as-is that would race the restored forwarder and double-send. The Won key is unaffected — it is on Backquote, not Backslash.

Shift+Backslash (|) keeps main's existing expectation of not bypassing.

What was dropped from #13168

mobile/src/terminal/terminal-live-native-ime-accessory-order.test.ts pinned the new handleLiveInputChange signature and fails after the revert (TypeError: text.replace is not a function). It could not be kept.

Collateral

#13128 was one squashed commit of 332 files, so the revert also removes non-IME work that rode along with it — notably the mobile/packages/react-native-terminal-input Android module, SshDisconnectedDialog.tsx, cursor-agent-parked-screen.ts, macos-automatic-period-substitution.ts, and the xterm patch-regeneration tooling. None of it is depended on by any later commit on main (verified: the only later commit touching any removed file is #13168 itself). Any of it can be re-landed independently.

Preservation

The pre-revert state is parked on nwparker/ime-xterm-ownership-parked (at 17eefef5021). Re-landing is a revert-of-this-revert.

Verification

Gate Result
npx vitest run --config config/vitest.config.ts src/ 4408 files / 47683 tests pass, 0 fail
pnpm --dir mobile test 434 files / 3391 pass, 3 skipped
pnpm run typecheck (buildinfo cleared) clean
pnpm run lint clean, incl. max-lines ratchet

Regression proofs: the restored terminal-ime-native-text-forwarder.test.ts (explicit ,/。 insertText coverage) and both anchor test files pass — 57 tests. All four restored files are byte-identical to v1.4.177-rc.3.

src/relay/agent-exec-handler.test.ts fails only when the shell exports GIT_CONFIG_* vars, which the test asserts on; the revert touches no file under src/relay. With those unset the whole suite is green, as above.

For a future re-land

Root cause of A, measured rather than inferred: CoreBrowserTerminal.ts _keyDown calls triggerDataEvent(result.key, ...) and then preventDefault(), which cancels Chromium's text pipeline — the keypress and input carrying , never fire, so the character is destroyed before _inputEvent runs. macOS-only: other platforms' frameworks claim the keydown with keyCode 229, so their failure mode would be a drop, not an ASCII downgrade. Not gated on kitty, so the blast radius was all macOS users.

A re-land is not a straight re-apply of what this PR restores. The restored code violates two constraints set after the last incident:

And it must cover the two things this attempt missed:

  1. IME text arriving as insertText OUTSIDE a composition session. Direct-punctuation commits never open a composition, so composition-scoped handling cannot see them. This is regression A.
  2. Preedit VISIBILITY, not just byte correctness. Every retained test asserts bytes reaching the PTY; none asserts that composing jamo is rendered, which is why regression B shipped green.

Do not take the "obvious" fix of clearing _keyDownSeen when the custom handler bypasses: it double-sends the Korean Won key, because resolveTerminalKoreanWonInput calls terminal.input('')and returnsfalsewithoutpreventDefault, so the browser still fires inputwith₩`.

Vietnamese is not in this class — the built-in Telex path commits through a composition session and its test passes on main.

Executable checklist for the re-land: /tmp/wave47-fullwidth-punct-backup/forwarder-form-probe.test.ts drives a real Terminal with installTerminalImeNativeTextForwarder wired as the old lifecycle did. Post-revert it gives 6 pass / 4 fail, and those 4 failures are the checklist: full-width digits, Qingg backslash, Qingg comma, Vietnamese punctuation. Deliberately not included in this PR.

nwparker and others added 3 commits August 8, 2026 18:23
The recorded IBus/fcitx5 and Windows MS-Korean traces from #13168 assert PTY
byte order, not composition ownership, so they still hold once the terminal
composition layer is restored. The mobile accessory-order test pinned the new
handleLiveInputChange signature and does not.

Co-authored-by: Orca <help@stably.ai>
@nwparker
nwparker requested a review from brennanb2025 as a code owner August 9, 2026 01:34
@greptile-apps

greptile-apps Bot commented Aug 9, 2026

Copy link
Copy Markdown

Too many files changed for review (329 files, 100 file limit).

Bypass the limit by tagging @greptile-apps to review.

nwparker and others added 2 commits August 8, 2026 18:41
The restored native-text forwarder only claims keys for input sources in its
hardcoded CJK allowlist, so third-party IMEs off that list (Qingg, #10896) still
get a raw backslash. #13128 added this bypass as a partial replacement; keep it
rather than trade the open issue back.

Scoped to the bare backslash key. The rest of shouldBypassXtermForMacNativeText
bypassed all unmodified non-ASCII text, which would race the restored forwarder.

Co-authored-by: Orca <help@stably.ai>
The restored hook assigned runMirrorStepRef during render, which is not
replay-safe — React can discard render work, so the mutation can leak from UI
that never commits. Its only read is inside the held-commit timer, which fires
long after commit, and the ref has a safe default, so an effect is soon enough.

Surfaced by the changed-lines React Doctor gate: the rule postdates this code,
so restoring the file re-introduced it as a new violation.

Co-authored-by: Orca <help@stably.ai>
@nwparker
nwparker merged commit 17cfc96 into main Aug 9, 2026
92 of 95 checks passed
@nwparker

nwparker commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

Re-landing IME composition ownership — what a second attempt must do differently

Written 2026-08-09, after 17b3dff3c41 (#13128) shipped two user-visible regressions and was
reverted by #13282. The reverted work is preserved on nwparker/ime-xterm-ownership-parked
at 17eefef5021.

This is not a summary of the change. It is the list of things that were wrong about how it was
built and verified, because the architecture was defensible and the process was not.


1. What actually broke, and why neither was caught

A. Full-width CJK punctuation typed as ASCII (,→,, 。→.)

Owner: terminal-ime-native-text-forwarder.ts + terminal-ime-native-text-candidates.ts,
deleted by 17b3dff3c41. Lineage: #6147 reported it → #6575 fixed it as
terminal-ime-punctuation-forwarder.ts → #6682 renamed/expanded it to the native-text forwarder
(314 lines + 622 lines of tests) → present in v1.4.177-rc.3 → deleted by us.

Mechanism (verified in source, macOS-only): CoreBrowserTerminal.ts:933-936 in _keyDown
calls triggerDataEvent(result.key, ...) — sending the raw , — and then event.preventDefault()
two lines later cancels Chromium's text pipeline, so the keypress and input carrying , never
fire at all. The character is destroyed before the _keyDownSeen gate in _inputEvent that
looks like the obvious culprit.

NOT gated on kitty (verified with kittyKeyboardFlags: 0). Blast radius was every macOS user
with a CJK input source. Windows/Linux frameworks claim the keydown with keyCode 229, so their
failure mode for the same shape would be a drop, not an ASCII downgrade.

Why no test caught it: every IME test we kept or wrote is composition-session-shaped —
compositionstart → update → end. CJK punctuation arrives as a bare insertText with no session.
It was invisible to the suite by construction.

B. OS candidate window opens away from the cursor in Cursor Agent panes

Owner: terminal-ime-anchor.ts + terminal-ime-candidate-anchor.ts, deleted with no
replacement. No compositionstart/compositionupdate listener remains anywhere in production
code. The OS reads the focused textarea's rect; xterm positions that textarea from its own cursor;
Cursor Agent parks the public cursor on a blank row while drawing its prompt elsewhere.

C. NOT ours — invisible resumed preedit (do not attribute this to #13128)

Windows/WSL Korean resumes a composition with a bare compositionupdate and no second
compositionstart
. xterm adds .active to .composition-view only in compositionstart and
removes it in _finalizeComposition, so the resumed preedit is written into a hidden element.
Proved pre-existing by running the failing test against the pre-#13128 xterm bundle and getting an
identical result. Fix is parked (see §4); it is 8 lines in xterm's own helper.


2. The real testing failure — read this before writing another IME test

We had 20k+ lines of IME tests and ~3000 passing assertions, and both regressions walked
straight through. Two distinct blind spots, and the second is the one that matters:

(i) Byte-only assertions. terminal-ime-xterm-linux-native-trace-replay.test.ts replays real
recorded IBus/fcitx5 DOM traces and asserts only trace.onData.join(''). Correct bytes, nothing
about pixels. Real, but not the main problem.

(ii) Hand-authored happy event orderings. This is the actual failure.
terminal-ime-xterm-preedit-overlay-committed-cell.test.ts:316 asserts
expect(sample.overlayActive).toBe(true) — the exact property that broke — and still passed,
because its typeKorean helper emits compositionend immediately followed by compositionstart
at every syllable boundary. _isComposing is therefore true at every assertion and
overlayActive is true by construction. Its sibling dispatches one compositionstart then
only updates. Neither ever replays a resume-without-start.

Both fixtures were hand-authored from a Windows cursor/geometry capture, not from a DOM event
capture. happy-dom would have caught this fine — classList.contains('active') needs no
layout. The environment was never the limitation; the event corpus was.

The rule: we model the ordering we expect instead of replaying the orderings we recorded.
There are 318 recorded Hangul traces under .tmp/ime-handoff/evidence/. The bug was found by
replaying all of them and counting compositionupdates that landed while the overlay was
inactive. We had the data and pointed the tests at invented sequences.

(iii) Coverage counted files, not behaviors. #13128 deleted 23 test files. They were triaged as
"guarded deleted implementation" vs "guarded user-visible behavior"; three were restored.
terminal-ime-native-text-forwarder.test.ts — 622 lines — was classified safe to lose. It was
regression A. A 314-line module with 622 lines of tests should be the loudest possible signal.

(iv) Hardware verification had the same hole. Windows, macOS and Android runs all confirmed the
byte path and none looked at the screen. "Verified on real hardware" was narrower than it sounded.


3. Concrete testing changes, cheapest first

  1. One assertion, highest value. The trace-replay test already loads recorded DOM traces —
    assert overlay visibility at every compositionupdate inside its existing loop, not just
    onData at the end. That converts the entire recorded corpus into visibility coverage.
  2. Check in the Windows/WSL capture (.tmp/ime-handoff/evidence/11919-windows-wsl-current/)
    as a third fixture alongside the two Linux ones. It contains the resume-without-start shape.
  3. Cover insertText outside a composition session. No test did. That is regression A's shape.
  4. Ungate the real-geometry e2e. tests/e2e/terminal-macos-2set-korean-preedit-visibility.spec.ts
    asserts geometry correctly but is @headful + ORCA_E2E_NATIVE_MACOS_KOREAN=1, so it never runs
    in CI, and it is macOS-only. Driving composition with CDP Input.imeSetComposition +
    Input.dispatchKeyEvent instead of AppleScript removes the native-IME dependency; verified to
    work headless in ~8s. Keep its during.rect.width > 0 assertion — that is the one thing
    happy-dom genuinely cannot express, and it catches clipping and zero-size overlays.

4. Parked artifacts

what where
The reverted work, intact branch nwparker/ime-xterm-ownership-parked @ 17eefef5021
Punctuation reproduction (policy shape, 28 cases) swarm-scratch/wave47-fullwidth-punct/parked/terminal-ime-xterm-punctuation-substitution.test.ts
Re-land checklist, executable swarm-scratch/wave47-fullwidth-punct/parked/forwarder-form-probe.test.ts
Parked policy-level fix (data point only) swarm-scratch/wave47-fullwidth-punct/parked/xterm-bypass-policy.{ts,test.ts}
Preedit fix (8 lines) + its red-by-design test swarm-scratch/wave48-preedit-visible/parked/

forwarder-form-probe.test.ts runs 6 pass / 4 fail against the restored forwarder, and those
four failures are the remaining gaps: full-width digits, Qingg backslash, Qingg comma, Vietnamese
punctuation. Start there.


5. The restored code is NOT a good baseline — do not straight-apply it

The code the revert brings back violates both rules we adopted after the deferred-newline incident:

It also does not cover input sources outside a hardcoded 23-term allowlist
(CJK_INPUT_SOURCE_TERMS). Qingg (com.aodaren.inputmethod.Qingg) matches none of them, which is
why #10896 was open before #13128 and would reopen on a naive revert. #13282 keeps a narrowed
!kittyKeyboardActive && event.code === 'Backslash' bypass specifically to prevent that. An
allowlist of IME bundle IDs is a maintenance treadmill, not a design.

A trap to avoid: clearing _keyDownSeen when the custom key handler bypasses looks like the
clean one-line fix and closes more cases, including multi-code-unit commits (——, ……). It
double-sends the Korean Won key: resolveTerminalKoreanWonInput calls terminal.input('\')and returnsfalsewithout preventDefault, so the browser still firesinputwith₩`.


5b. State as of 2026-08-09 02:25 UTC

Main is 5a84dbb564b. Landed:

PR what
#13282 the revert. Both regressions gone; !kittyKeyboardActive && event.code === 'Backslash' deliberately kept so #10896 does not reopen; contributor's Won feature preserved
#13283 Korean probe teardown + epoch guard (independent of the revert)

Open, green, unmerged: #13284 — the resumed-preedit visibility fix. Held only on release timing,
not on doubt. It is a pre-existing upstream bug, broken in every shipped build including v1.4.177.

Two carried caveats on #13284, both disclosed in its PR body:

The two xterm bundles are not symmetric. lib/xterm.mjs (esbuild/ESM) and lib/xterm.js
(webpack/UMD) differ in variable binding, let vs const, and whether LRM marks are literal or
escaped. Never assume one edit ports to the other; assert a unique single match per bundle.

Android native module — do NOT re-land standalone

mobile/packages/react-native-terminal-input (250-line Kotlin TerminalInputPackage.kt) was
introduced by #13128, has never shipped (absent from v1.4.177-rc.3), and was dropped by the
revert. Dropping it costs users nothing. It is also orphaned without the rest of the mobile IME
work
— the mobile composition path that consumes it was reverted too. Re-land it with that piece,
not before.

5c. Which references to trust for CJK terminal input

Corrected by the user 2026-08-09. During the ₩ investigation I leaned on a large editor's
keyboard-layout table as evidence that the OS behaviour was correct and merely ergonomically
hostile. The user reports that editor does not always handle Chinese input properly, while
iTerm2 and Warp do.

That reprioritises the reference set for anything CJK and terminal-shaped:

  • Prefer iTerm2 and Warp. They are PTY-facing terminals solving the same problem — native text
    arriving outside a composition session, then having to become bytes on a pty. Both reportedly get
    Chinese input right, which makes them the highest-value references for the re-land.
  • Treat editors as weak references here. An editor owns its own text buffer and keybinding
    resolution; it never has to decide what byte reaches a shell. Its layout tables describe what the
    OS emits, not how a terminal should forward it.
  • The Zig/Swift emulator reference remains useful for the key-model question (physical vs
    translated keys, intl_yen as a distinct identity) even though it ships no CJK rewrite.

Concretely for the re-land: before designing the forwarder's successor, check how iTerm2 and Warp
handle (a) full-width punctuation substitution, (b) multi-code-unit commits like —— and ……, and
(c) input sources outside any allowlist. Our 23-term CJK_INPUT_SOURCE_TERMS allowlist is the part
most likely to have no counterpart in either.

6. Process

  • refactor(terminal): return IME composition ownership to xterm #13128 was 332 files squashed. That is why unrelated work (an Android native module, a macOS
    period-substitution fix, an RN patch, tooling) rode along and had to be dropped by the revert. It
    also made the blast radius unassessable at review time. Land the next attempt as a stack.
  • Do not merge on local green. Revert the terminal IME composition-ownership change #13282 passed 4408 files / 47683 tests locally and still failed
    CI on a changed-lines React Doctor gate. Confirm from the CI run.
  • Verify the presentation path, not just the data path, before merging anything IME-shaped.

@nwparker

nwparker commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

Update — the re-land design, researched against a mature native terminal's source. It is smaller than what was reverted.

Headline: no mature terminal enumerates IMEs. Repo-wide greps across two credible native terminals return zero IME bundle IDs between them. The only input-source literals are keyboard layouts, used as negative exceptions — never to grant ownership. Both read the current input source solely for change detection ("did an IME grab this key?"), which is identity-blind and the opposite polarity of an allowlist.

So the 23-term CJK_INPUT_SOURCE_TERMS list was the wrong design, not an incomplete one. Qingg was never a gap in the list; the list is the gap.

The rule that replaces it: a plain printable keydown never produces terminal bytes — bytes for printable characters come only from the input event. The reference terminal contains no full-width-punctuation code at all, because the ASCII , byte is never manufactured in the first place.

It ports. We cannot call interpretKeyEvents, and we do not need to: Chromium's renderer is the text-input client. input with inputType: 'insertText' is insertText:replacementRange:, and ev.data is the committed string. The commit channel already exists.

Claim on a structural predicate — keydown, no ctrl/alt/meta, key.length === 1, not composing. That reads key for length only, never identity, so it is invariant under the CJK key rewrite and sidesteps the #12171 / #13033 failure mode.

What it deletes: the input-source allowlist, the candidates module, every punctuation table, and the input-source read on the hot path. Fixed as consequences rather than special cases: full-width punctuation, #10896 (and every IME that does not exist yet — it cannot structurally reopen), and multi-code-unit commits like —— and ……, which come free because the forwarder reads ev.data wholesale.

Won/Yen should move to the input-event side rather than be special-cased. The reference does its ¥ rewrite inside insertText:, because a keydown-side implementation cannot distinguish "¥ through a pass-through IME" from "¥ routed through an IME that maps it to something else" — the latter must send what the IME committed. Moving ours is also what dissolves the Won double-send trap rather than working around it.

Two risks worth stating rather than burying. Under kitty's report_all_keys_as_escape_codes flag this path sends raw text where CSI-u is expected; the reference has the same hole deliberately, and the correct gate is that single flag, not "kitty is active". And the "IME swallowed the key and committed nothing" case has no known timer-free design — the old code used a 100 ms timer, which is exactly the pattern that caused the earlier incident. That is the open design question and it should be settled on hardware.

Full notes are in the earlier comment on this PR, now updated.

kunsanglee added a commit to kunsanglee/orca that referenced this pull request Aug 9, 2026
main reverted stablyai#13128 (`17cfc968cf`, PR stablyai#13282), which this branch was built
on. Two conflicts, both from that revert.

`terminal-pane/AGENTS.md` — took the deletion. The file was stablyai#13128's and the
revert removed it; this branch only reformatted one line of it.

`keyboard-handlers.ts` — took main's restored file and reapplied this
branch's additions on top:

- No IME gate in `resolveTerminalKeyboardShortcutAction`. This branch had
  narrowed stablyai#13128's blanket gate; with the blanket gate reverted away, adding
  the narrowed form back would newly suppress IME-owned events main routes
  through here (the Windows composing-Enter path among them).
- The keydown yield is scoped to the exempt chords. stablyai#13128 yielded on every
  IME-owned keydown; now only a chord the IME can swallow yields, and every
  other IME-owned key keeps main's restored path.
- The composing-Enter deferral moved out of `runShortcutAction` into a
  caller-supplied callback. It reads the live keydown and its
  `imeProcessEnter`; a chord recovered from a release has neither, and is
  never Enter.

KNOWN RED, and not fixable by merging: 14 cases in
`keyboard-handlers.issue-12871-recorded-chord-traces.test.ts`.

The revert changed where terminal shortcut bytes go. Before, they went
through `pane.terminal.input(...)` — xterm held them behind a live preedit and
released them at commit, which is the standing safety argument in this
branch's own comments. Now they go through `sendCapturedTerminalInput` →
`transport.sendInput(...)`, straight to the pty with nothing holding them. So
a swallowed chord recovered during a live composition lands AHEAD of the text
still being composed, and the suite's spies watch a sink the bytes no longer
reach.

The redesign rides main's own `sendTerminalInputAfterComposition`
(`terminal-ime-deferred-newline.ts`), which waits for the composition to
commit. Its open decisions are enumerated in
`.loop/spec/fix-ime-deferred-terminal-shortcut-input/` and land in a separate
commit, so this one stays what it is: taking the revert.

The other five red IME suites under `terminal-pane/` are main's own — 62
failures on `upstream/main` untouched, the same 62 here.
kunsanglee added a commit to kunsanglee/orca that referenced this pull request Aug 11, 2026
main replaced the design this branch was written against, so the conflict could
not be resolved by picking a side.

What changed underneath. The branch was based on eea0bb6, before stablyai#13128 gave
terminal composition ownership to xterm and before stablyai#13282 reverted it. Since
then stablyai#13288 made the native-text claim structural (every single printable
keydown, `key` read for length only) and stablyai#13310 encodes commits as CSI-u under
the kitty all-keys flag. terminal-ime-native-text-candidates.ts and the
getInputSourceFeatures argument the branch built on no longer exist.

Resolution, three judgments.

1. The forwarder takes main's version wholesale. The branch's punctuation
   feature-list claim is gone from main and reviving it would undo stablyai#13288.

2. The defect the branch reported is still in main, so it is reapplied on the
   new shape. claimKeyEvent bails on a chorded or composing event BEFORE the
   keyup branch that retires the claim, and every keyup inside a composition
   reports isComposing. The release is the only event that retires a claim, so
   the claim survives the composition; nothing else clears it until the next
   non-composing printable keydown or a blur. While it is stranded a keypress
   whose own keydown was refused (composition still live at keydown, ended by
   keypress) is bypassed with nothing armed to forward it, and the character is
   dropped. Fix: retire on a matching keyup first, then fold the chord and
   composition test into the return value.

   Every existing return value is preserved. Only the leaked state changes:
   a chorded or composing release returned false before and returns false now.

3. terminal-ime-native-text-claim-release.test.ts is rewritten against main's
   API. Its old body imported terminal-ime-native-text-candidates, which main
   deleted, so it could not compile. The two cases it now pins are the two the
   fix repairs; both fail against main's forwarder and pass against this one
   (verified by swapping the file back and rerunning).

Verified: terminal-ime-native-text-forwarder.test.ts 32/32 (main's own, all
still pass), the rewritten suite 2/2, use-terminal-pane-lifecycle 29/29,
dashboard-popout 220/220. tsconfig.node, tsconfig.tc.cli, tsconfig.tc.web all
0 errors. oxlint clean. max-lines ratchet OK.
kunsanglee added a commit to kunsanglee/orca that referenced this pull request Aug 15, 2026
A chord the IME swallows is recovered from its release, and until now the
bytes went out there. They no longer travel through xterm: stablyai#13282 moved
shortcut input onto the transport, which reaches the pty directly, so a
release that fires mid-preedit puts the chord ahead of the text still being
composed. With 가나 on the line and 다 in the preedit, Cmd+ArrowLeft yielded
다가나 — the cursor moved to line start and the syllable landed there.

The release now defers through sendTerminalInputAfterComposition, with no
time bound. The 200ms fallback is right for a newline, where arriving late
still means arriving; a cursor chord sent while the preedit is open is the
corruption the wait exists to prevent, and a Japanese conversion holds its
candidate window open far longer than that. An abandoned composition drops
the chord instead, which costs one keypress rather than a mangled line.

Routing the chord back through terminal.input() was the smaller change and
does not work: on the patched xterm this tree builds, a byte handed to
input() during a live composition is dropped outright rather than queued
behind the preedit. The recordings that show it queued predate that.

A chord remapped onto a pane command keeps firing immediately. Deferring it
too would let the commit land after the pane had already cleared or closed,
which loses the text rather than ordering it.

No platform check: what arms the recovery is a release that still reports
itself composing, which an input source either produces or does not. Gating
it to macOS was tried and moved nothing measurable, so it would have been an
untested claim.

The trace rig was watching terminal.input and terminal.onData, so every
chord assertion had been reading an empty channel since stablyai#13282. Both records
now follow the bytes down either route, and expectEmitted compares as a
joined stream because the captures were taken when xterm flushed the preedit
and the chord as one payload while the transport writes each on its own.

Two captures stop mid-composition, where the contract is now "held, not
sent". They assert that, then drive the commit the recording does not
contain and check that the chord lands after it. The appended commit is
marked as authored so it cannot be read as captured.

Two expectations went stale when an earlier merge changed the bundled xterm,
and both are about what xterm emits rather than what this handler sends. It
no longer commits a session it never saw start, so a capture that opens
mid-gesture flushes nothing; and it now commits a cancelled composition from
its own buffer instead of the cleared helper textarea. The cancel case stops
pinning whether that text arrives and pins that the chord is last either way.

The three macOS e2e specs this branch adds are hand-run — no workflow calls
them and they need real input sources — and now say so in a header line, so
a red local run is not read as a regression of this change.

Not touched: the two symptoms stablyai#13282 gave for the revert (full-width
punctuation arriving as ASCII, an invisible Korean preedit). Both live in
xterm's composition rendering, which nothing here goes near.

Local: src/renderer/src/components/terminal-pane is 251 files / 3230 tests,
all passing. tsc clean on all three projects, oxlint and oxfmt clean,
reliability gate manifest passes for 73 gates, max-lines ratchet OK at 352.

Measured after installing this worktree's own dependencies. Worktrees here
resolve node_modules from the enclosing checkout, which was serving an xterm
patch hash this lockfile does not ask for; the 62 failures seen before that
install were entirely that mismatch.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
nwparker pushed a commit that referenced this pull request Oct 4, 2026
Restore IME Enter protection in workspace details by reusing the existing composition tracker. Reset Notes ownership at textarea detachment and preserve sizing behavior. Repair isolated native test-window delivery without changing the production foreground policy or original native input assertions.

Fixes #24097

Related contributor history: #10711, #11067, #13128, #13282.
Original implementation and macOS recordings: @setodeve, commit b30f095.
Verified on required stock Linux X11/Wayland checks and independent frozen-source review.

Co-authored-by: setodeve <keinick11@outlook.com>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
* Revert "test(ime): restore coverage the composition-ownership change removed (stablyai#13168)"

This reverts commit d1782d4.

* Revert "refactor(terminal): return IME composition ownership to xterm (stablyai#13128)"

This reverts commit 45169f2.

* test(ime): keep the architecture-neutral Korean trace coverage

The recorded IBus/fcitx5 and Windows MS-Korean traces from stablyai#13168 assert PTY
byte order, not composition ownership, so they still hold once the terminal
composition layer is restored. The mobile accessory-order test pinned the new
handleLiveInputChange signature and does not.

Co-authored-by: Orca <help@stably.ai>

* fix(terminal): keep the macOS Backslash bypass through the revert

The restored native-text forwarder only claims keys for input sources in its
hardcoded CJK allowlist, so third-party IMEs off that list (Qingg, stablyai#10896) still
get a raw backslash. stablyai#13128 added this bypass as a partial replacement; keep it
rather than trade the open issue back.

Scoped to the bare backslash key. The rest of shouldBypassXtermForMacNativeText
bypassed all unmodified non-ASCII text, which would race the restored forwarder.

Co-authored-by: Orca <help@stably.ai>

* fix(mobile): move the mirror-step ref write out of render

The restored hook assigned runMirrorStepRef during render, which is not
replay-safe — React can discard render work, so the mutation can leak from UI
that never commits. Its only read is inside the held-commit timer, which fires
long after commit, and the ref has a safe default, so an effect is soon enough.

Surfaced by the changed-lines React Doctor gate: the rule postdates this code,
so restoring the file re-introduced it as a new violation.

Co-authored-by: Orca <help@stably.ai>

---------

Co-authored-by: Orca <help@stably.ai>
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