Skip to content

fix(terminal): return IME composition ownership to xterm - #12261

Closed
nwparker wants to merge 1 commit into
mainfrom
nwparker/ime-native-ownership-terminal
Closed

nwparker wants to merge 1 commit into
mainfrom
nwparker/ime-native-ownership-terminal

Conversation

@nwparker

@nwparker nwparker commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • restore xterm-owned composition, preedit, and commit delivery
  • refuse IME-owned events only at Orca application-action boundaries
  • prevent stale PTY generations from receiving xterm data
  • delete the parallel composition route, trackers, deferred newline state, native-text forwarding, and related platform machinery

This intentionally supersedes #12259: the held modifier set, modified-enter chord owner, and deferred newline sender no longer exist.

VS Code parity

VS Code adds no terminal IME commit route. Its attachCustomKeyEventHandler handles application shortcuts and otherwise returns true so xterm owns input.

Local reference: /Users/nwparker/projects/vscode/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts.

VS Code uses xterm 6.1.0-beta.191; Orca uses beta.287. Their stock CompositionHelper and _inputEvent composition behavior is identical apart from import-path changes. This PR now removes Orcas remaining keypress/composition xterm patch too. The only xterm patch left is the unrelated SortedList decoration cleanup.

Size

Net change: 393 insertions, 7,772 deletions. No new production IME class, tracker, buffer, adapter, registry, route, or file.

Evidence

  • stock xterm back-to-back Hangul composition emits 가나
  • settled composition followed by physical Enter emits 한\r
  • ordinary typing plus Enter remains ab\r
  • marked real Enter (key: Enter, keyCode: 13, isComposing: true) is refused before shortcut resolution
  • replacement PTY generations reject stale xterm data
  • the deterministic IBus replay now preserves the native task boundary required by xterms composition-position timer
  • the workflow runs native IBus before deterministic replay so synthetic coverage cannot mask native failure

Verification

  • pnpm install --frozen-lockfile
  • pnpm typecheck
  • pnpm lint
  • 713 affected tests passed after reinstalling the stock xterm patch

Remaining certification

Draft until the native Linux IBus workflow passes on this head. Windows, macOS, SSH, rendering-scale, and reporter evidence remain separate goalpost work; no issue should be closed from this PR alone.

@nwparker
nwparker force-pushed the nwparker/ime-native-ownership-terminal branch from 3e3c255 to e08b770 Compare August 3, 2026 09:46
@nwparker
nwparker force-pushed the nwparker/ime-native-ownership-terminal branch 3 times, most recently from eb858bc to 00eefc8 Compare August 3, 2026 10:04
@nwparker
nwparker force-pushed the nwparker/ime-native-ownership-terminal branch from 00eefc8 to 695859c Compare August 3, 2026 10:10
@nwparker
nwparker marked this pull request as ready for review August 3, 2026 10:15
@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The change removes custom terminal IME composition, candidate-key, native-text forwarding, and input-context refresh handling. Keyboard events now use shared IME ownership detection, and PTY input requires current transport ownership. Preview terminals retain direct IME event bypass behavior. Focus recovery uses guarded scheduling without IME refresh callbacks. Tests now cover stock xterm composition, PTY isolation, preview key handling, and native IBus Hangul input. The workflow uploads native evidence separately and validates test-step ordering.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the change and evidence, but it omits the required Screenshots, Testing, AI Review Report, Security Audit, and Notes sections. Add all missing template sections, including test checkboxes, AI cross-platform review details, security audit findings, screenshots status, and platform-specific notes.
Docstring Coverage ⚠️ Warning Docstring coverage is 19.05% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the primary change: returning IME composition ownership to xterm.
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.
✨ 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 730ab366-861e-420b-902f-f24466e23d29

📥 Commits

Reviewing files that changed from the base of the PR and between e08eba6 and 695859c.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (58)
  • .github/workflows/terminal-ime-e2e.yml
  • config/patches/@[email protected]
  • config/reliability-gates.jsonc
  • config/scripts/terminal-ime-e2e-workflow.test.mjs
  • src/renderer/src/components/dashboard-popout/AgentTerminalPreview.test.tsx
  • src/renderer/src/components/dashboard-popout/AgentTerminalPreview.tsx
  • src/renderer/src/components/dashboard-popout/preview-terminal-compatibility.ts
  • src/renderer/src/components/dashboard-popout/preview-terminal-ime-bridge.ts
  • src/renderer/src/components/dashboard-popout/preview-terminal-key-handler.test.ts
  • src/renderer/src/components/dashboard-popout/preview-terminal-key-handler.ts
  • src/renderer/src/components/floating-terminal/FloatingTerminalPanel.test.tsx
  • src/renderer/src/components/floating-terminal/FloatingTerminalPanel.tsx
  • src/renderer/src/components/terminal-pane/TerminalPane.tsx
  • src/renderer/src/components/terminal-pane/keyboard-handlers-ime-enter-keyup.test.tsx
  • src/renderer/src/components/terminal-pane/keyboard-handlers-ime.test.tsx
  • src/renderer/src/components/terminal-pane/keyboard-handlers.test.ts
  • src/renderer/src/components/terminal-pane/keyboard-handlers.ts
  • src/renderer/src/components/terminal-pane/pty-connection.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection.ts
  • src/renderer/src/components/terminal-pane/regular-terminal-focus-ownership.test.ts
  • src/renderer/src/components/terminal-pane/regular-terminal-focus-ownership.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-candidate-key-release-guard.test.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-candidate-key-release-guard.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-composition-route.test.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-composition-route.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-composition-tracker.test.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-composition-tracker.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-composition-transaction-ownership.test.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-deferred-newline.test.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-deferred-newline.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-hangul-syllable-flush.test.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-input-context-refresh.test.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-input-context-refresh.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-input-source.test.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-input-source.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-linux-candidate-state.test.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-linux-candidate-state.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-native-text-candidates.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-native-text-forwarder.test.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-native-text-forwarder.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-won-composition-order.test.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-xterm-adversarial.test.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-xterm-composition-cancel.test.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-xterm-composition-deduplication.test.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-xterm-transaction-events.test.ts
  • src/renderer/src/components/terminal-pane/terminal-stock-composition.test.ts
  • src/renderer/src/components/terminal-pane/use-terminal-pane-lifecycle.ts
  • src/renderer/src/components/terminal-pane/xterm-bypass-policy-non-mac.test.ts
  • src/renderer/src/components/terminal-pane/xterm-bypass-policy.test.ts
  • src/renderer/src/components/terminal-pane/xterm-bypass-policy.ts
  • src/renderer/src/lib/focus-terminal-tab-surface.test.ts
  • src/renderer/src/lib/focus-terminal-tab-surface.ts
  • src/renderer/src/lib/ime-composition-keyboard-event.test.ts
  • src/renderer/src/lib/ime-composition-keyboard-event.ts
  • src/renderer/src/lib/pane-manager/pane-lifecycle.ts
  • src/renderer/src/lib/pane-manager/terminal-ime-candidate-anchor.ts
  • tests/e2e/terminal-ibus-hangul-native.spec.ts
  • tests/e2e/terminal-ime-observed-event-sequences.ts
💤 Files with no reviewable changes (36)
  • src/renderer/src/components/terminal-pane/keyboard-handlers-ime.test.tsx
  • src/renderer/src/components/terminal-pane/terminal-ime-input-context-refresh.test.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-xterm-adversarial.test.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-won-composition-order.test.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-composition-transaction-ownership.test.ts
  • src/renderer/src/components/terminal-pane/keyboard-handlers-ime-enter-keyup.test.tsx
  • src/renderer/src/components/terminal-pane/terminal-ime-composition-tracker.test.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-linux-candidate-state.test.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-input-source.ts
  • src/renderer/src/components/dashboard-popout/preview-terminal-ime-bridge.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-composition-route.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-composition-tracker.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-xterm-composition-deduplication.test.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-deferred-newline.test.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-candidate-key-release-guard.test.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-hangul-syllable-flush.test.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-linux-candidate-state.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-input-context-refresh.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-candidate-key-release-guard.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-input-source.test.ts
  • src/renderer/src/lib/pane-manager/terminal-ime-candidate-anchor.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-composition-route.test.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-native-text-forwarder.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-native-text-candidates.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-xterm-transaction-events.test.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-deferred-newline.ts
  • src/renderer/src/lib/focus-terminal-tab-surface.ts
  • src/renderer/src/components/dashboard-popout/AgentTerminalPreview.test.tsx
  • src/renderer/src/components/terminal-pane/regular-terminal-focus-ownership.test.ts
  • src/renderer/src/lib/pane-manager/pane-lifecycle.ts
  • src/renderer/src/components/dashboard-popout/AgentTerminalPreview.tsx
  • src/renderer/src/lib/focus-terminal-tab-surface.test.ts
  • src/renderer/src/components/terminal-pane/TerminalPane.tsx
  • src/renderer/src/components/terminal-pane/use-terminal-pane-lifecycle.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-native-text-forwarder.test.ts
  • src/renderer/src/components/terminal-pane/xterm-bypass-policy.ts

"keyboard bypass",
"JIS yen"
],
"surfaces": ["IME", "paste", "keyboard bypass", "JIS yen"],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Reconcile surfaces/coveredPlatforms claims with the new scope and known gaps.

surfaces still lists paste and JIS yen, but no assertion, oracle text, or test file in this rewritten entry exercises paste or JIS-yen handling; the PR removes native-text forwarding entirely. Narrow surfaces to what the new oracle actually covers.

coveredPlatforms (unchanged by this diff) still lists linux, but the newly added knownGaps entry states the Linux E2E "must be rerun against this stock-owner head." Listing Linux as covered while acknowledging the evidence has not been rerun against this implementation is self-contradictory and can mislead promotion decisions that rely on this file.

📝 Proposed fix
-      "surfaces": ["IME", "paste", "keyboard bypass", "JIS yen"],
+      "surfaces": ["IME", "keyboard bypass"],
       "platforms": ["macos", "linux", "windows"],
       "providers": ["local", "daemon", "ssh", "remote-runtime"],
-      "coveredPlatforms": ["macos", "linux"],
+      "coveredPlatforms": ["macos"],

Also applies to: 5680-5681, 5756-5757

@nwparker

nwparker commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

Closing as superseded by the targeted IME fixes and native coverage now on main, including #12259, #12265, #12273, #12278, #12280, #12281, and #12282. The current branch also conflicts with main and does not preserve the certified native macOS 2-Set Korean leading-vowel sequence. We will continue hardening IME support incrementally from the landed, tested path.

@nwparker nwparker closed this Aug 3, 2026
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