Skip to content

Fix duplicate and lost IME terminal commits - #9235

Merged
Jinwoo-H merged 1 commit into
mainfrom
Jinwoo-H/repro-8861-linux-korean-ime
Jul 18, 2026
Merged

Jinwoo-H merged 1 commit into
mainfrom
Jinwoo-H/repro-8861-linux-korean-ime

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • ELI5: Linux IME could expose one completed character through two browser event paths, and the terminal could send both copies to the shell.
  • Reconcile legacy keypress text with the final composition candidate inside the xterm composition state machine.
  • Keep PTY, SSH, relay, rendering, and platform-specific code unchanged.

Fixes #8861

Deterministic reproduction

Environment: Ubuntu 22.04 ARM64, headful X11 at 1600x1000, Openbox, IBus 1.5.26, ibus-hangul 1.5.4, Electron 43.1.0 / Chrome 150, and a real Orca PTY.

xdotool type --delay 1 --clearmodifiers gks
xdotool key Hangul
xdotool type --delay 1 abc
xdotool key Hangul
xdotool type --delay 1 rmf
xdotool key Return

Expected visible input and exact PTY bytes:

한abc글\n
ed959c616263eab8800a
  • Baseline: 12 failures in 30 trials.
  • Patched build: 30 exact-byte passes in 30 trials.
  • The retained trials did not add focus changes or clicks.

Patched Orca terminal showing repeated exact visible text and UTF-8 bytes

Implementation

  • Offer legacy keypress text to the existing composition helper before sending terminal data.
  • Buffer it only while the existing zero-delay composition finalizer is pending.
  • Reconcile containment and boundary overlap against the final textarea candidate, then emit the logical commit once.
  • Add six installed-package regression cases covering duplicate, contained, unmatched, partial-overlap, multi-keypress, and immediate-keydown finalization paths.

Risk and performance

The residual correctness risk is a narrow ambiguity when an intentional repeated string is identical to the duplicate observation during the pending-finalizer window. Gating reconciliation to that existing window limits the surface.

The ordinary keypress path adds one function call and a boolean check. Reconciliation runs only when composition finalization is already pending. This adds no timer, render, IPC, PTY, SSH, or relay work, so a measurable throughput or latency regression is not expected.

This logic belongs in the terminal input state machine. We should upstream it and remove the package patch after the corresponding dependency release is adopted.

Validation

  • Faithful headful Linux run: 30/30 exact PTY-byte passes after 12/30 baseline failures
  • Installed-package regression: 6/6 passing
  • Upstream-focused composition suite: 167 passing
  • Full TypeScript check: passing
  • oxlint: passing
  • oxfmt check: passing
  • max-lines ratchet: passing
  • Fresh offline install and patch application: passing
  • Git diff whitespace check: passing

Made with Orca 🐋

@coderabbitai

coderabbitai Bot commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

Failed to post review comments.

We encountered an issue with GitHub. Use @coderabbitai full review to retry the review.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: b0ceb29e-5fe2-4e93-9079-71b9de4e4060

📥 Commits

Reviewing files that changed from the base of the PR and between 2f5fc65 and 0d834ca.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (3)
  • config/patches/@[email protected]
  • package.json
  • src/renderer/src/components/terminal-pane/terminal-ime-xterm-composition-deduplication.test.ts
⏰ Context from checks skipped due to timeout. (4)
  • GitHub Check: golden e2e linux experiment
  • GitHub Check: golden e2e mac experiment
  • GitHub Check: verify
  • GitHub Check: Windows terminal restart regressions
🧰 Additional context used
📓 Path-based instructions (4)
src/renderer/src/**/*.{tsx,ts,css}

📄 CodeRabbit inference engine (AGENTS.md)

All UI work must follow docs/STYLEGUIDE.md, use tokens from src/renderer/src/assets/main.css, and use shadcn primitives from src/renderer/src/components/ui/.

Files:

  • src/renderer/src/components/terminal-pane/terminal-ime-xterm-composition-deduplication.test.ts
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{js,jsx,ts,tsx}: Never disable max-lines via ESLint or oxlint, including line-specific variants.
Use path.join or Electron/Node path utilities for file paths; never assume / or \.

Files:

  • src/renderer/src/components/terminal-pane/terminal-ime-xterm-composition-deduplication.test.ts
src/renderer/src/**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

src/renderer/src/**/*.{js,jsx,ts,tsx}: For keyboard shortcuts, use a Mac platform check to select metaKey and use ctrlKey on Linux and Windows; Electron accelerators must use CmdOrCtrl.
Shortcut labels must display ⌘/⇧ on Mac and Ctrl+/Shift+ on other platforms.

Files:

  • src/renderer/src/components/terminal-pane/terminal-ime-xterm-composition-deduplication.test.ts
**/*.{js,jsx,ts,tsx,sh,ps1}

📄 CodeRabbit inference engine (AGENTS.md)

Batch gh CLI requests where possible, avoid unnecessary API calls, and keep code, commands, and scripts compatible with macOS, Linux, and Windows.

Files:

  • src/renderer/src/components/terminal-pane/terminal-ime-xterm-composition-deduplication.test.ts
🧠 Learnings (3)
📚 Learning: 2026-06-16T15:35:16.815Z
Learnt from: gsxdsm
Repo: stablyai/orca PR: 5501
File: src/renderer/src/components/right-sidebar/checks-panel-content.tsx:1504-1504
Timestamp: 2026-06-16T15:35:16.815Z
Learning: In the stablyai/orca renderer codebase, Tailwind classes using the custom variant `can-hover` (e.g., `can-hover:opacity-0`) are intentionally treated as self-documenting, with the hover/pointer-only rationale defined once at `src/renderer/src/assets/main.css` via `custom-variant can-hover (media (hover: hover))`. When reviewing `.ts/.tsx` files, do not flag usage sites for missing inline “why” comments or duplicated rationale—assume the variant name and its central definition provide sufficient context.

Applied to files:

  • src/renderer/src/components/terminal-pane/terminal-ime-xterm-composition-deduplication.test.ts
📚 Learning: 2026-06-24T11:33:31.894Z
Learnt from: gatsby74
Repo: stablyai/orca PR: 6256
File: src/renderer/src/components/terminal-pane/terminal-agent-session-fork.test.ts:83-84
Timestamp: 2026-06-24T11:33:31.894Z
Learning: When reviewing *.test.ts files, treat hardcoded OS-specific path literals used as mock fixture inputs (e.g., Windows `C:\...`, UNC paths like `\\wsl.localhost\Ubuntu\...`, and POSIX `/repo/...`) as intentional if they exist to simulate real platform path formats for path/launch-platform detection logic. Do not replace these static fixture strings with `path.join` or other runtime path construction utilities—doing so can make assertions OS-dependent and break test determinism. Reserve `path.join` guidance for production/runtime path construction, not for static test fixture strings used to exercise detection/parsing logic.

Applied to files:

  • src/renderer/src/components/terminal-pane/terminal-ime-xterm-composition-deduplication.test.ts
📚 Learning: 2026-07-08T00:01:30.534Z
Learnt from: wquintal
Repo: stablyai/orca PR: 7734
File: src/renderer/src/components/right-sidebar/gitlab-check-details-loader.ts:29-41
Timestamp: 2026-07-08T00:01:30.534Z
Learning: In the stablyai/orca Electron renderer, avoid unbounded/bare GitLab IPC calls (e.g., `window.api.gl.jobTrace`, `workItemDetails`, `resolveMRDiscussion`, `updateMR`, and the job-trace call used in GitLab item dialogs/components). Add/use a shared renderer-side timeout wrapper/utility (since there is no shared `withTimeout` currently, create one or reuse the existing implementation pattern from `useCreateProjectDefaults.ts`) and apply it consistently to all such `window.api.gl.*` calls, rather than fixing a single call site in isolation. The goal is to ensure each IPC request has an explicit timeout so hangs can’t block the UI indefinitely.

Applied to files:

  • src/renderer/src/components/terminal-pane/terminal-ime-xterm-composition-deduplication.test.ts
🪛 Betterleaks (1.6.1)
config/patches/@[email protected]

[high] 6-6: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


[high] 7-7: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

📝 Walkthrough

Walkthrough

Adds a patched dependency entry for @xterm/[email protected]. Adds a Vitest suite that opens an xterm terminal, simulates IME composition and keyboard events, captures onData output, and verifies composition ordering, duplicate suppression, deferred keypress merging, and keydown reconciliation.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description has a good summary and validation, but it misses several required template sections, including AI Review Report and Security Audit. Add the missing Screenshots, Testing checklist, AI Review Report, Security Audit, and Notes sections per the repository template.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% 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 summarizes the main change: fixing duplicated or dropped IME commits in the terminal.
Linked Issues check ✅ Passed The patch and regression tests directly target the Linux IBus IME duplication/loss bug described in #8861.
Out of Scope Changes check ✅ Passed The diff is limited to the xterm patch entry and focused IME regression tests, with no clear unrelated changes.
✨ Finishing Touches
📝 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.

@Jinwoo-H
Jinwoo-H force-pushed the Jinwoo-H/repro-8861-linux-korean-ime branch from ea55499 to 0d834ca Compare July 18, 2026 01:10
@Jinwoo-H
Jinwoo-H merged commit 360b242 into main Jul 18, 2026
4 checks passed
@Jinwoo-H
Jinwoo-H deleted the Jinwoo-H/repro-8861-linux-korean-ime branch July 18, 2026 01:29
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 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.

[Bug]: Korean (CJK/IME) input intermittently duplicated or dropped in the integrated terminal (Linux/IBus)

1 participant