Skip to content

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

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

  • delete Orca's parallel terminal composition trackers, routes, forwarding, and deferred-input state
  • retain a small xterm CompositionHelper seam because stock beta.287 and beta.292 fail the recorded rapid Korean and empty-end IBus traces
  • route application-generated terminal bytes through existing Terminal.input() so xterm orders them behind its active composition
  • keep IME-owned key events above Orca shortcut dispatch
  • preserve the unrelated existing SortedList search-decoration repair

This supersedes the IME architecture introduced by #12259 and the follow-up hotfixes without reverting unrelated terminal behavior.

Design

VS Code and Hyper use unpatched xterm, but they mostly avoid injecting application-owned terminal bytes during composition. Wave injects Shift+Enter directly and has the same race shape as Orca; it is not evidence that stock xterm solves the ordering problem.

The retained patch stays inside xterm's existing composition owner. It derives Korean commits from saved ranges, accepts exact InputEvent.data for empty-end IBus commits, and queues Terminal.input() data only while xterm already owns a composition. Its internal hook is optional for stock/test composition helpers. It adds no public IME API, Orca callback, session ID, custom DOM event, application tracker, PTY map, class, or production file. Ordinary non-composition Terminal.input() remains immediate.

Deletion

The final application-keyboard adjustment is 12 additions and 80 deletions. It removes the dedicated captured-input dispatcher and its 104-line test file. The xterm IME source delta is 40 added lines including blanks and 48 removed; its unrelated SortedList hunk is unchanged.

Native evidence

  • Physical macOS Korean 2-Set: leading vowels, multi-syllable live preedit, exact PTY bytes, physical Shift+Enter ordering, and ordinary controls.
  • Folder workspace and Docker SSH: identical Hangul/ordinary bytes with local/remote PTY isolation.
  • Physical macOS Pinyin and Cangjie: Backspace cancellation produces no stale input; ordinary ABC controls pass.
  • Physical macOS Simple Telex: exact tiếng việt commit/PTY bytes without commit-time normalization.
  • Signed macOS app: reporter DefaultKeyBinding.dict remap reaches the PTY as backtick; ordinary ABC control passes.
  • Linux X11 IBus/Fcitx5 and Wayland Fcitx5: repeated Korean and Pinyin number-candidate exact-byte traces with process cleanup.

Regression and mutation evidence

  • Before application bytes used Terminal.input(), the committing-Enter E2E expected 하 하 하\x1b\r but received 하 하 \x1b\r하.
  • With the seam, the deterministic composition emits 하\x1b\r; ordinary non-composition input emits \x1b\r immediately.
  • Pre-fix X11/IBus emits 한ab한c글; removing the mutable textarea-diff fallback emits exact 한abc글 while ordinary controls remain green.
  • Reintroducing the stale cancelled-preedit fallback leaks Pinyin c; the valid empty-end commit control remains green.

Verification

  • pnpm install --frozen-lockfile
  • pnpm run typecheck:web
  • targeted oxlint and git diff --check
  • 3 focused Vitest files: 33/33 passing
  • Electron/PTTY ordering E2E: 4/4 passing
    • Shift+Enter, redispatch before keyup
    • Shift+Enter, keyup before redispatch
    • Ctrl+Enter, redispatch before keyup
    • Ctrl+Enter, keyup before redispatch
  • dedicated native Linux X11 IBus/Fcitx5 and Wayland Fcitx5 workflows

Scope

This PR does not claim the full IME goalpost is complete. Windows Microsoft Korean native traces, ConPTY/WSL/SSH, Windows rendering at 100/125/150%, Qingg Wubi, and mobile device evidence remain separate acceptance work. Synthetic modifier-loss cases were removed because no recorded native trace contains modifier loss; the Windows Shift-release issues remain uncertified pending native evidence.

@nwparker
nwparker force-pushed the nwparker/ime-native-ownership-terminal branch from de47aec to 1ecf549 Compare August 3, 2026 10:54
@coderabbitai

coderabbitai Bot commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The change removes custom IME composition, native-text forwarding, candidate-key, and input-context refresh paths. Keyboard routing now filters IME-owned events through shared detection and retains macOS initial-jamo bypass handling. Terminal lifecycle code enforces active PTY transport ownership. New tests cover stock composition, Enter ordering, preview keyboard behavior, transport replacement, and native macOS input. CI separates native IBus tests from deterministic tests and updates reliability-gate coverage.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 23.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description provides detailed design, scope, native evidence, regression evidence, and verification, but omits several required template sections. Add explicit Screenshots, Testing, AI Review Report, Security Audit, and Notes sections, including the required cross-platform review confirmation and test checklist.
✅ Passed checks (3 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 identifies the main change: returning IME composition ownership to xterm.
✨ 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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/renderer/src/components/terminal-pane/regular-terminal-focus-ownership.ts (1)

75-89: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Remove the now-dead isMac parameter, or update its stale documentation.

args.isMac is declared on resyncTerminalFocusForWindowFocus and documented as overriding "the macOS check," but the function body no longer reads args.isMac anywhere. The macOS-specific IME refresh flow that used to consume this flag is gone. A caller or test that still passes isMac to change behavior gets no effect, and the JSDoc now describes behavior that does not exist.

Remove the parameter and its JSDoc if no caller depends on it, or update the comment if it is intentionally kept for a near-term reintroduction.

Run the following script to check whether any caller or test still passes isMac:

#!/bin/bash
# Description: Check for remaining `isMac` usage tied to resyncTerminalFocusForWindowFocus.
rg -n -C4 'resyncTerminalFocusForWindowFocus' -g '*.ts' -g '*.tsx' src/renderer
rg -n 'isMac' src/renderer/src/components/terminal-pane/regular-terminal-focus-ownership.test.ts 2>/dev/null
♻️ Proposed fix (if no caller depends on it)
   releasedHelper?: HTMLElement | null
-  /** Override the macOS check (tests). Defaults to the navigator user agent. */
-  isMac?: boolean
   /** Override the refocus scheduler (tests). Defaults to requestAnimationFrame. */
   scheduleRefocus?: RefocusScheduler

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1bf871b9-535c-4bf9-9610-33e4118a6494

📥 Commits

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

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (60)
  • .github/workflows/pr.yml
  • .github/workflows/terminal-ime-e2e.yml
  • config/patches/@[email protected]
  • config/reliability-gates.jsonc
  • config/scripts/pr-e2e-gate-contract.test.mjs
  • 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 (35)
  • src/renderer/src/components/dashboard-popout/preview-terminal-ime-bridge.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-deferred-newline.test.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-xterm-adversarial.test.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-composition-route.test.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-input-source.test.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-composition-tracker.ts
  • src/renderer/src/components/terminal-pane/regular-terminal-focus-ownership.test.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-composition-route.ts
  • src/renderer/src/lib/pane-manager/pane-lifecycle.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-candidate-key-release-guard.test.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-composition-transaction-ownership.test.ts
  • src/renderer/src/lib/pane-manager/terminal-ime-candidate-anchor.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-linux-candidate-state.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-xterm-transaction-events.test.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-native-text-forwarder.test.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-input-context-refresh.test.ts
  • src/renderer/src/components/dashboard-popout/AgentTerminalPreview.test.tsx
  • src/renderer/src/components/terminal-pane/terminal-ime-candidate-key-release-guard.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-linux-candidate-state.test.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-native-text-candidates.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-input-source.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-hangul-syllable-flush.test.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-native-text-forwarder.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-composition-tracker.test.ts
  • src/renderer/src/components/terminal-pane/TerminalPane.tsx
  • src/renderer/src/components/terminal-pane/keyboard-handlers-ime.test.tsx
  • src/renderer/src/components/terminal-pane/terminal-ime-deferred-newline.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-xterm-composition-deduplication.test.ts
  • src/renderer/src/components/dashboard-popout/AgentTerminalPreview.tsx
  • src/renderer/src/lib/focus-terminal-tab-surface.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-input-context-refresh.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-won-composition-order.test.ts
  • src/renderer/src/components/terminal-pane/keyboard-handlers-ime-enter-keyup.test.tsx
  • src/renderer/src/lib/focus-terminal-tab-surface.test.ts
  • src/renderer/src/components/terminal-pane/use-terminal-pane-lifecycle.ts

"keyboard bypass",
"JIS yen"
],
"surfaces": ["IME", "paste", "keyboard bypass", "JIS yen"],
"platforms": ["macos", "linux", "windows"],

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 stale surfaces and missing assertionRefs in this gate.

surfaces at Line 5677 lists "paste" and "JIS yen", but neither the invariant, the oracle, nor any assertionRefs entry addresses paste handling or a JIS Yen key case. Remove these two surfaces, or add corresponding oracle coverage and assertionRefs.

testFiles at Lines 5693-5699 lists 5 files, but assertionRefs at Lines 5700-5722 documents only 3 of them. keyboard-handlers.test.ts and ime-composition-keyboard-event.test.ts have no assertionRefs entries, unlike every other gate in this file, which pairs each testFiles entry with a matching assertionRefs entry. Add the missing entries so this gate's evidence trail stays traceable.

Also applies to: 5693-5722

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

🧹 Nitpick comments (1)
tests/e2e/terminal-ibus-hangul-native.spec.ts (1)

92-93: 🚀 Performance & Scalability | 🔵 Trivial | 🏗️ Heavy lift

Reduce per-character process churn if the native suite is slow.

typeSentenceSequence now invokes xdotool type and xdotool sleep for every character. The 38-character sentence creates about 380 synchronous child-process launches at the default of five repetitions and about 2,280 at the maximum of 30. This can increase test duration and failure points. If character-level segmentation is required for IBus, preserve the event boundaries but use a lower-process delay strategy. Verify that the replacement preserves separate key events and the required composition delay.

Based on the supplied line-range change details and static-analysis context, the previous implementation used one delayed xdotool type call and this path uses execFileSync.

Also applies to: 95-97

Source: Linters/SAST tools


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 48acd5a6-487f-4bc1-b9fc-bbb1bbf85cb6

📥 Commits

Reviewing files that changed from the base of the PR and between de47aecdfa1a14f136a5b3eae565c9b20aea2195 and 1ecf549.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (60)
  • .github/workflows/pr.yml
  • .github/workflows/terminal-ime-e2e.yml
  • config/patches/@[email protected]
  • config/reliability-gates.jsonc
  • config/scripts/pr-e2e-gate-contract.test.mjs
  • 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 (35)
  • src/renderer/src/lib/focus-terminal-tab-surface.test.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-candidate-key-release-guard.test.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-composition-tracker.test.ts
  • src/renderer/src/components/terminal-pane/regular-terminal-focus-ownership.test.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-xterm-adversarial.test.ts
  • src/renderer/src/components/dashboard-popout/preview-terminal-ime-bridge.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-hangul-syllable-flush.test.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-won-composition-order.test.ts
  • src/renderer/src/components/terminal-pane/keyboard-handlers-ime.test.tsx
  • src/renderer/src/components/terminal-pane/terminal-ime-input-source.test.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-xterm-composition-deduplication.test.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-linux-candidate-state.test.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-candidate-key-release-guard.ts
  • src/renderer/src/components/terminal-pane/TerminalPane.tsx
  • src/renderer/src/components/terminal-pane/terminal-ime-input-source.ts
  • src/renderer/src/components/dashboard-popout/AgentTerminalPreview.test.tsx
  • src/renderer/src/components/terminal-pane/terminal-ime-input-context-refresh.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-linux-candidate-state.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-input-context-refresh.test.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-deferred-newline.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-deferred-newline.test.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-xterm-transaction-events.test.ts
  • src/renderer/src/components/terminal-pane/keyboard-handlers-ime-enter-keyup.test.tsx
  • src/renderer/src/components/terminal-pane/terminal-ime-native-text-candidates.ts
  • src/renderer/src/lib/pane-manager/terminal-ime-candidate-anchor.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-composition-tracker.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-native-text-forwarder.ts
  • src/renderer/src/components/dashboard-popout/AgentTerminalPreview.tsx
  • src/renderer/src/lib/focus-terminal-tab-surface.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-composition-transaction-ownership.test.ts
  • src/renderer/src/components/terminal-pane/use-terminal-pane-lifecycle.ts
  • src/renderer/src/lib/pane-manager/pane-lifecycle.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-composition-route.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-native-text-forwarder.test.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-composition-route.test.ts
🚧 Files skipped from review as they are similar to previous changes (22)
  • src/renderer/src/components/terminal-pane/pty-connection.test.ts
  • src/renderer/src/components/terminal-pane/keyboard-handlers.test.ts
  • src/renderer/src/lib/ime-composition-keyboard-event.test.ts
  • src/renderer/src/components/dashboard-popout/preview-terminal-key-handler.test.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-xterm-composition-cancel.test.ts
  • src/renderer/src/lib/ime-composition-keyboard-event.ts
  • src/renderer/src/components/dashboard-popout/preview-terminal-compatibility.ts
  • src/renderer/src/components/floating-terminal/FloatingTerminalPanel.test.tsx
  • config/scripts/pr-e2e-gate-contract.test.mjs
  • src/renderer/src/components/terminal-pane/xterm-bypass-policy.test.ts
  • src/renderer/src/components/terminal-pane/xterm-bypass-policy-non-mac.test.ts
  • .github/workflows/pr.yml
  • src/renderer/src/components/dashboard-popout/preview-terminal-key-handler.ts
  • tests/e2e/terminal-ime-observed-event-sequences.ts
  • src/renderer/src/components/terminal-pane/regular-terminal-focus-ownership.ts
  • src/renderer/src/components/terminal-pane/pty-connection.ts
  • config/scripts/terminal-ime-e2e-workflow.test.mjs
  • src/renderer/src/components/floating-terminal/FloatingTerminalPanel.tsx
  • .github/workflows/terminal-ime-e2e.yml
  • config/reliability-gates.jsonc
  • src/renderer/src/components/terminal-pane/keyboard-handlers.ts
  • src/renderer/src/components/terminal-pane/xterm-bypass-policy.ts

@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: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a65ae7be-7dc8-45ad-af39-9584fa9bb067

📥 Commits

Reviewing files that changed from the base of the PR and between 1ecf549 and 3c5f7d9.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (5)
  • config/patches/@[email protected]
  • 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/terminal-stock-composition.test.ts
  • tests/e2e/terminal-macos-2set-korean-native.spec.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/renderer/src/components/terminal-pane/keyboard-handlers.test.ts

@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: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 4ce82d37-ec8a-4719-b4f0-3cdd47c8d7a2

📥 Commits

Reviewing files that changed from the base of the PR and between 3c5f7d9 and 756f931.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (2)

Comment on lines +61 to +63
function selectInputSource(inputSourceId: string): void {
execFileSync('swift', ['.tmp/select-input-source.swift', inputSourceId])
}

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Find the Swift input-source helper and any code that generates it.
fd -H -t f 'select-input-source' .
rg -n --hidden -g '!node_modules' 'select-input-source'
rg -n --hidden -g '!node_modules' 'ORCA_E2E_NATIVE_MACOS_PINYIN'

Repository: stablyai/orca

Length of output: 151


🏁 Script executed:

#!/bin/bash
set -u

echo "Tracked files matching select-input-source:"
git ls-files -- '*select-input-source*'

echo
echo "Tracked files under tests/e2e matching terminal:"
git ls-files | grep -E '(^|/)terminal[^/]*|tests/e2e/terminal' || true

echo
echo "Repository file list for .tmp (limited):"
git ls-files -- | grep '^\./?\.tmp/' || true
git ls-files -- | grep '^\./?\.tmp' || true

echo
echo "Search text patterns with status-safe rg:"
rg -n --hidden -g '!node_modules' 'select-input-source|ORCA_E2E_NATIVE_MACOS_PINYIN|execFileSync\(\x27swift\x27|swift.*select-input-source' . || true

echo
echo "Candidate e2e files:"
git ls-files tests/e2e | sort | sed -n '1,120p'

Repository: stablyai/orca

Length of output: 50369


Ensure .tmp/select-input-source.swift is available before selectInputSource runs.

selectInputSource resolves ./\.tmp/select-input-source.swift relative to the current working directory. If this generated helper is missing, the E2E gate fails with an opaque swift error instead of explaining the missing input-source script. Add script generation/availability handling for ORCA_E2E_NATIVE_MACOS_PINYIN=1, or resolve the path from a known repository baseline.

🧰 Tools
🪛 ast-grep (0.45.0)

[warning] Importing child_process exposes a command-execution surface; ensure any command/argument built from input is validated, and prefer execFile/spawn with an argument array over exec.
Context: import { execFileSync } from 'node:child_process'
Note: [CWE-78] Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection').

(detect-child-process-typescript)

Comment on lines +126 to +136
} finally {
await attachTerminalImeBoundaryEvidence(orcaPage, testInfo, 'native-macos-pinyin').catch(
() => undefined
)
await disposeTerminalImeBoundaryProbe(orcaPage).catch(() => undefined)
if (!completed) {
await sendToTerminal(orcaPage, ptyId, '\x03').catch(() => undefined)
}
removeTerminalImeByteReader(reader)
selectInputSource(ABC_ID)
}

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

Guard the input-source restore in finally.

selectInputSource(ABC_ID) at Line 135 is synchronous and unguarded. If swift exits non-zero, execFileSync throws inside finally and replaces the original test failure. The reported error then hides the real assertion failure.

🛡️ Proposed fix
       removeTerminalImeByteReader(reader)
-      selectInputSource(ABC_ID)
+      try {
+        selectInputSource(ABC_ID)
+      } catch {
+        // Keep the original failure visible if the input-source reset fails.
+      }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
} finally {
await attachTerminalImeBoundaryEvidence(orcaPage, testInfo, 'native-macos-pinyin').catch(
() => undefined
)
await disposeTerminalImeBoundaryProbe(orcaPage).catch(() => undefined)
if (!completed) {
await sendToTerminal(orcaPage, ptyId, '\x03').catch(() => undefined)
}
removeTerminalImeByteReader(reader)
selectInputSource(ABC_ID)
}
} finally {
await attachTerminalImeBoundaryEvidence(orcaPage, testInfo, 'native-macos-pinyin').catch(
() => undefined
)
await disposeTerminalImeBoundaryProbe(orcaPage).catch(() => undefined)
if (!completed) {
await sendToTerminal(orcaPage, ptyId, '\x03').catch(() => undefined)
}
removeTerminalImeByteReader(reader)
try {
selectInputSource(ABC_ID)
} catch {
// Keep the original failure visible if the input-source reset fails.
}
}
🧰 Tools
🪛 ast-grep (0.45.0)

[warning] Importing child_process exposes a command-execution surface; ensure any command/argument built from input is validated, and prefer execFile/spawn with an argument array over exec.
Context: import { execFileSync } from 'node:child_process'
Note: [CWE-78] Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection').

(detect-child-process-typescript)

@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: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1da88e93-f182-4817-b1d6-4cfd6645dcdc

📥 Commits

Reviewing files that changed from the base of the PR and between 756f931 and e466cc2.

📒 Files selected for processing (1)
  • tests/e2e/terminal-macos-vietnamese-native.spec.ts

Comment on lines +49 to +51
function selectInputSource(inputSourceId: string): void {
execFileSync('swift', ['.tmp/select-input-source.swift', inputSourceId])
}

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Locate the input-source helper script and any step that generates it.
fd -H -t f 'select-input-source' || echo 'no select-input-source file found'
rg -n --hidden -g '!node_modules' 'select-input-source'
rg -n --hidden -g '!node_modules' 'ORCA_E2E_NATIVE_MACOS_VIETNAMESE'

Repository: stablyai/orca

Length of output: 151


🏁 Script executed:

#!/bin/bash
set -u

echo "Repository top-level files/directories relevant to tmp/scripts:"
git ls-files | sed -n '1,200p' | rg '(^|/)(\.tmp|tmp|scripts|test|e2e|setup|package\.json|Makefile|justfile|.*\.sh|.*\.swift|.*\.ts)$' || true

echo
echo "Find all script files:"
git ls-files | rg '\.(swift|sh|ts|tsx|js|jsx|json|toml|yaml|yml|md)$' | sed -n '1,240p' || true

echo
echo "Search select-input-source with all tracked files (hidden disabled by default in git ls-files):"
python3 - <<'PY'
import subprocess, os
files = subprocess.check_output(['git','ls-files'], text=True).splitlines()
try:
    for f in files:
        if 'select-input-source' in f:
            print(f)
except Exception as e:
    print(f"no match in tracked files: {e}")
PY

echo
echo "Search ORCA_E2E_NATIVE_MACOS_VIETNAMESE in tracked files:"
python3 - <<'PY'
import subprocess
files = subprocess.check_output(['git','ls-files'], text=True).splitlines()
for f in files:
    try:
        data = subprocess.check_output(['git','show',f], text=True, stderr=subprocess.DEVNULL)
    except Exception:
        continue
    if 'ORCA_E2E_NATIVE_MACOS_VIETNAMESE' in data:
        print(f)
PY

echo
echo "Inspect target file outline/size if present:"
if [ -f tests/e2e/terminal-macos-vietnamese-native.spec.ts ]; then
  wc -l tests/e2e/terminal-macos-vietnamese-native.spec.ts
  sed -n '1,140p' tests/e2e/terminal-macos-vietnamese-native.spec.ts
else
  echo "target file not tracked"
fi

Repository: stablyai/orca

Length of output: 15135


Add selectInputSource and its setup before running this test.

selectInputSource() calls .tmp/select-input-source.swift, but this repo contains no select-input-source.swift generator/setup step. Add the Swift helper or create it before the test runs, and document the ORCA_E2E_NATIVE_MACOS_VIETNAMESE requirements with an explicit file existence check.

🧰 Tools
🪛 ast-grep (0.45.0)

[warning] Importing child_process exposes a command-execution surface; ensure any command/argument built from input is validated, and prefer execFile/spawn with an argument array over exec.
Context: import { execFileSync } from 'node:child_process'
Note: [CWE-78] Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection').

(detect-child-process-typescript)

@nwparker

nwparker commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

Native macOS Korean/Codex mutation evidence is now in 90a3ef6.

  • retained xterm patch: five continuous 14-syllable runs reached the real Codex prompt exactly
  • stock beta.287 mutation: duplicated committed syllables (가가, 바바, 아자아자, 마마, and 자차자차 across clean runs)
  • paired negative: ordinary abc remained exact before the Korean assertion failed
  • observed real xterm preedit transitions, including 팧 -> 하

This adds test evidence only—no production class, tracker, buffer, or Orca-specific composition protocol. The unrelated xterm SortedList hunk remains out of this IME slimming scope.

@nwparker

nwparker commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

IME evidence update at d6b711c:

  • Physical built-in macOS Cangjie cancellation passes on the retained patch: preedit 尸 is removed by Backspace with no xterm onData or PTY bytes.
  • The paired ABC control runs before the positive assertion and produces exactly ordinary\r at xterm and ordinary\n at the PTY.
  • Applying the historical fe6f929 xterm bundle mutation leaks 尸, while that same ordinary control still passes. This supplies the issue-specific mutation for [Bug]: Cangjie preedit text remains visible after Backspace cancels composition #11951; reporter confirmation is the remaining item.
  • Current VS Code a5944fe94ff pins unpatched xterm 6.1.0-beta.291 and adds no terminal composition adapter. Its wrapper only routes commands/chords; xterm still owns composition. Beta.291 retains the mutable-textarea diff timer and delayed commit path that fail our recorded Korean and IBus traces. Hyper and WaveTerm follow the same architecture and add no alternate commit owner.

Conclusion: the OSS references support the slim ownership boundary, not stock-xterm correctness. Orca keeps composition delivery in the 40-added-line xterm seam and does not add an app-specific IME class/protocol.

@nwparker

nwparker commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #13128, which landed the same change under the same title and merged as 17b3dff. Closing this predecessor — main now has composition ownership back in xterm, plus the CI wiring this PR was carrying (terminal-ime-e2e.yml, the IBus/Hangul e2e runner, and the reliability gate entry).

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