Skip to content

fix(terminal): stop Hangul input lagging a syllable behind the IME - #12158

Closed
leon1114 wants to merge 2 commits into
stablyai:mainfrom
leon1114:fix/terminal-hangul-composition-lag
Closed

leon1114 wants to merge 2 commits into
stablyai:mainfrom
leon1114:fix/terminal-hangul-composition-lag

Conversation

@leon1114

@leon1114 leon1114 commented Aug 3, 2026 •

Copy link
Copy Markdown

Summary

Korean input in the terminal lags one syllable behind the IME.

Typing 한글 after a space renders 한, then the next composition (ㄱ, ㅡ) appears to overwrite it, and the display only settles once 글 commits and both syllables appear. Reported after updating to v1.4.163.

The committed syllable was never sent. #11293 made compositionstart cancel the pending finalizer and route the just-committed syllable through _endPendingCompositionSession, which announces the commit with dataPendingReconciliation: true but never emits the bytes — and terminal-ime-composition-route.ts:92-101 drops exactly that event. The macOS Hangul IME commits syllable N at syllable N+1's compositionstart and sends no intervening insertText, so syllable N stayed stranded until the next compositionend. With no bytes on the wire the buffer cursor never advanced, so xterm drew the next composition's opaque .composition-view overlay on the previous syllable's cell.

This drops that block from compositionstart so the already-armed finalizer survives. It fires on the next task, which is:

One mechanism covers both platforms. This is effectively upstream xterm's original flush timing restored, while every piece of transaction bookkeeping #11293 added — transaction ids, the pending record, tracked timers, stale-end rejection, accepted/settled balance — is left intact.

Note the deleted block's own _cancelPendingFinalizer is not lost: _sendPendingComposition cancels the finalizer as its first action.

Screenshots

orca-korean-ime.mov

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test — see the note below about 5 pre-existing macOS-only failures
  • pnpm build
  • Added or updated high-quality tests that would catch regressions

New file src/renderer/src/components/terminal-pane/terminal-ime-hangul-syllable-flush.test.ts — 4 cases against both the CJS and ESM terminal builds (8 tests):

  1. flushes syllable N before syllable N+1 finishes composing — the regression gate. Asserts emitted is already 한 right after the second compositionstart, before any second compositionend.
  2. preserves Korean final-consonant transfer — 아아, never 앙.
  3. emits 한글 exactly once — no duplication at the syllable boundary.
  4. does not double-send when an insertText input event follows compositionend — the IBus shape.

Why the existing suites missed this. terminal-ime-xterm-adversarial.test.ts:114-126 already replays this exact sequence, but asserts only the joined string after the second compositionend, so a withheld-then-late-flushed syllable passes identically to a promptly-flushed one. Every new assertion here is on intermediate state.

Red control. With the fix reverted in the installed bundle, cases 1 and 2 fail on both builds with expected '' to be '한' and expected '' to be '아' — i.e. nothing has reached the terminal at the moment the next syllable starts composing, which is the bug.

Regression runs. Full IME suite 244/244; whole terminal-pane unit suite 2894/2894 across 219 files, including terminal-ime-xterm-composition-deduplication.test.ts (the #11293 아아/앙아 and duplicate-commit guarantees) and terminal-ime-xterm-transaction-events.test.ts (the strict accepted, settled, accepted, settled ordering).

An earlier, larger version of this fix was rejected by your own tests. Flushing eagerly inside compositionstart (right after nextCompositionStart is set) fixes macOS but breaks IBus: preserves a Korean final-consonant transfer across compositions fails with expected '앙아' to be '아아', because IBus rewrites the textarea in the compositionupdate that follows compositionstart, so a synchronous read there sees the pre-transfer 앙. Deferring by one task is what makes a single fix correct on both platforms.

AI Review Report

Reviewed with Claude (Opus 5). Risks checked and findings:

Cross-platform (macOS / Linux / Windows). The change is in shared CompositionHelper code with no platform guard, so all three were considered explicitly. macOS is the reported break. Linux/IBus is the constraint that shaped the fix — an earlier variant regressed it and was discarded on that evidence (above). Windows IME ownership tests are part of the 244-test IME suite and pass. No keyboard shortcut, shortcut label, filesystem path, or shell invocation is touched, so the metaKey/CmdOrCtrl, ⌘/Ctrl+, and path.join rules do not apply here. The one Electron-specific surface nearby — xterm-bypass-policy.ts:127 suppressing isComposing keydowns, which is why the keydown flush path is unavailable during Hangul composition — was read but not modified.

SSH / remote / local. Composition bytes now reach the pty through terminal-ime-composition-route.ts → terminal.input() → xterm's existing ordered onData transport, the same path all other input uses. No host-local assumption is introduced and no transport code changed, so local ptys, SSH/relay runtimes, git worktrees, and folder workspaces are all unaffected structurally.

Agent / integration / git provider. None touched.

Performance. Net removal of work on a hot input path: three calls per compositionstart are gone and nothing is added. No new timer is created — the fix reuses the finalizer that was already armed, and the tracked-timer set bookkeeping is unchanged, so the bounded-timer guarantee from #11293 holds. terminal-ime-xterm-adversarial.test.ts's 256-transaction same-task burst still passes.

UI quality. No component, token, or style changed; docs/STYLEGUIDE.md is not engaged. The visible effect is that the terminal now renders what the user typed.

Security. See below.

What the review flagged and what I did. It flagged that the originally-drafted eager flush was unsafe on IBus; I dropped it and shipped the smaller variant, then confirmed the difference with a red control rather than reasoning alone. It also flagged the two dead surfaces listed under Notes, which I deliberately left in place to keep the diff minimal rather than expanding scope.

Security Audit

No new input sanitization, command execution, path handling, auth, secrets, or IPC surface. Concretely:

  • Input handling — improved. Previously the stranded syllable was eventually emitted by xterm's bare _coreService.triggerDataEvent, bypassing Orca's route because dispatchSessionEnd was false once _endPendingCompositionSession had set sessionEnded. With that call gone, pending.sessionEnded stays false, so the flush dispatches a normal session-end that terminal-ime-composition-route.ts handles — meaning the bytes are now validated against the captured pty id and the current transport (:96-100) before being written, instead of going out unchecked.
  • Command execution / path handling / auth / secrets: untouched.
  • IPC: untouched. The composition events are DOM CustomEvents on the xterm textarea, entirely renderer-local.
  • Dependencies: no version changed. pnpm-lock.yaml's only diff is the @xterm/xterm patch content hash and its 24 dependent patch_hash= references, which necessarily follow any edit to the vendored patch.

No follow-up security work identified.

Notes

Vendored artifacts — needs a maintainer decision. config/patches/@[email protected] carries both the TypeScript source and the prebuilt lib/xterm.js / lib/xterm.mjs bundles, and the runtime loads lib/. I applied the same semantic change to all three by exact anchored string replacement (asserted to match exactly once per bundle), but I did not regenerate the bundles from upstream xterm source the way PR #11293 did. Consequently:

  • lib/xterm.js.map / lib/xterm.mjs.map were left untouched, so their mappings offsets are now stale relative to the edited bundles.
  • The patch's index <sha>..<sha> blob lines for the two bundles still name the pre-edit b-side blobs. pnpm install applies the patch cleanly regardless.

If you would rather land this with properly regenerated artifacts, say so and I will redo it against a clean upstream checkout — or feel free to regenerate on your side, since the semantic change is five deleted lines.

Two surfaces are now unreachable. _endPendingCompositionSession has zero call sites, and with nothing dispatching dataPendingReconciliation the guard at terminal-ime-composition-route.ts:94 is a defensive no-op. Both were left in place deliberately to keep the reviewable diff to the semantic change and to keep the patch's TypeScript source and minified bundles mirrored. Happy to remove them in this PR or a follow-up, whichever you prefer.

Local pnpm test had 5 failures, all pre-existing and macOS-specific. Neither file is touched by this PR and both reproduce on a clean tree:

  • config/scripts/check-root-directory-entries.test.mjs (3) — .github/scripts/check-root-directory-entries.sh:14 uses declare -A, which macOS's system /bin/bash 3.2.57 does not support, so the script exits 2 instead of 1. The test spawns bare bash, so it can only pass where bash is 4+. Worth a separate fix (#!/usr/bin/env bash plus a bash-4 lookup, or an explicit skip on macOS).
  • src/relay/agent-exec-handler.test.ts (2) — asserts on the spawned process environment and picks up GIT_CONFIG_COUNT/GIT_CONFIG_KEY_* injected by my shell session.

Testing notes. Manually verified on macOS with the built-in Korean (2-Set) input source, running the branch through pnpm dev: typing 한글 into a terminal pane now renders correctly, where before the second syllable's preview covered the first. The 아아/앙아 final-consonant case is covered by automated tests rather than that manual pass.

Playwright e2e was not run locally (needs a GUI/Electron runtime); the nightly terminal-ime-e2e.yml ibus-hangul job should exercise the Linux path. A manual pass on a real Windows IME would be welcome from anyone set up for it.

X handle: I don't have an X account, so there's no handle to credit — noting it explicitly rather than leaving the field blank.

Typing a Korean word into a terminal showed the previous syllable being
overwritten by the one being composed: "한글" rendered "한", then "그" on
top of it, and only settled once "글" committed.

stablyai#11293 made compositionstart cancel the pending finalizer and route the
just-committed syllable through _endPendingCompositionSession, which
announces the commit with dataPendingReconciliation but never sends the
bytes; terminal-ime-composition-route.ts drops exactly that event. macOS
Hangul commits syllable N at syllable N+1's compositionstart and emits no
intervening insertText, so syllable N stayed stranded until the next
compositionend. The buffer cursor never advanced, so xterm drew the next
composition's opaque overlay on the previous syllable's cell.

Drop that block so the already-armed finalizer survives. It fires on the
next task, which is after IBus rewrites the textarea (preserving the
final-consonant transfer "아아", not "앙아") and still long before the next
compositionend, so macOS flushes immediately. One mechanism covers both
platforms, and the transaction bookkeeping stablyai#11293 added is untouched.

Adds terminal-ime-hangul-syllable-flush.test.ts, which asserts the
intermediate state the existing suites miss: they only compare the final
joined string, so a withheld-then-late-flushed syllable passed.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: bc004844-396d-4a5a-ae67-3e01a7be8ca6

📥 Commits

Reviewing files that changed from the base of the PR and between 94d88db and fed2ba2.

📒 Files selected for processing (1)
  • src/renderer/src/components/terminal-pane/terminal-ime-hangul-syllable-flush.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/renderer/src/components/terminal-pane/terminal-ime-hangul-syllable-flush.test.ts

📝 Walkthrough

Walkthrough

Added a happy-dom Vitest suite for Hangul IME behavior in ESM and CJS xterm builds. The suite simulates composition, input, and keyboard events. It verifies syllable-boundary flushing, Korean final-consonant transfer, exact-once emission for 한글, and prevention of duplicate sends after insertText. Test setup mocks canvas measurement and cleans up terminals, timers, mocks, and DOM state.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the terminal Hangul IME lag fix and matches the primary change.
Description check ✅ Passed The description covers every template section, explains the fix, documents tests and known failures, and records AI review and security findings.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

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

🧹 Nitpick comments (1)
src/renderer/src/components/terminal-pane/terminal-ime-hangul-syllable-flush.test.ts (1)

15-30: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Dispose the terminal unconditionally, not only on the success path.

Each test calls terminal.dispose() itself at the end (Line 96, 120, 133, 162). If an expect assertion throws earlier in the test body, dispose() is skipped. afterEach (Lines 78-82) clears mocks, real timers, and DOM children, but never calls dispose() on the terminal created in openTerminal. A failed assertion can leave an xterm instance with active timers/RAF loops running into later tests in the same file, risking cross-test pollution or flakiness.

Track the current terminal and dispose it unconditionally in afterEach.

♻️ Proposed fix for guaranteed terminal disposal
+let currentTerminal: EsmTerminal | null = null
+
 function openTerminal(TerminalType: typeof EsmTerminal): {
   emitted: string[]
   terminal: EsmTerminal
   textarea: HTMLTextAreaElement
 } {
   const container = document.createElement('div')
   document.body.appendChild(container)
   const terminal = new TerminalType()
   terminal.open(container)
   if (!terminal.textarea) {
     throw new Error('xterm textarea was not created')
   }
   const emitted: string[] = []
   terminal.onData((data) => emitted.push(data))
+  currentTerminal = terminal
   return { emitted, terminal, textarea: terminal.textarea }
 }
   afterEach(() => {
+    currentTerminal?.dispose()
+    currentTerminal = null
     vi.useRealTimers()
     vi.restoreAllMocks()
     document.body.replaceChildren()
   })

Also applies to: 78-82


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 842b6e63-28e6-4fc9-9f64-0de9b5a1b7a8

📥 Commits

Reviewing files that changed from the base of the PR and between 8c5371e and 94d88db.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (2)
  • config/patches/@[email protected]
  • src/renderer/src/components/terminal-pane/terminal-ime-hangul-syllable-flush.test.ts

Comment on lines +140 to +143
textarea.setSelectionRange(0, 0)
composition(textarea, 'compositionstart')
keydown(textarea, 'Process', 'KeyG', 229)
composition(textarea, 'compositionupdate', '한')

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

Chromium keydown compositionstart event order for first IME character IBus Linux

💡 Result:

In Chromium on Linux, when using an IBus-based IME, the keydown event precedes the compositionstart event [1][2]. The standard event sequence for the initiation of an IME composition in Chromium is keydown followed by compositionstart [1][3]. This order is consistent with the UI Events specification, which lists keydown as the event that triggers the composition system [1][4]. When a user types a character that initiates an IME session, the browser first dispatches the keydown event for that keystroke before the compositionstart event fires to indicate the beginning of the composition process [1][2]. It is important to note that developers should rely on composition-specific events (such as compositionupdate, beforeinput, and input) for handling text changes, rather than keydown, due to variations in how IMEs and different operating systems handle key events during composition [5][6]. For example, even when a key event is part of a composition, the keydown event is still dispatched, often with a keyCode of 229 (the "IME processed" code) [5]. While Chromium aims for consistency, historically there have been noted complexities regarding Linux IBus behavior, where key events may sometimes contain character values that differ from other platforms [7][6].

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Locate and inspect the relevant test and nearby composition helper behavior.
if [ -f "src/renderer/src/components/terminal-pane/terminal-ime-hangul-syllable-flush.test.ts" ]; then
  echo "== file lines =="
  nl -ba src/renderer/src/components/terminal-pane/terminal-ime-hangul-syllable-flush.test.ts | sed -n '1,180p'
else
  echo "Target file not found"
  fd -a terminal-ime-hangul-syllable-flush.test.ts .
fi

echo "== references to compositionstart/keydown handling =="
rg -n "compositionstart|keydown|keyCode === 229|isComposing|keyCode" src/renderer src -g '*.{ts,tsx,js,jsx}' | sed -n '1,220p'

Repository: stablyai/orca

Length of output: 208


🏁 Script executed:

#!/bin/bash
set -euo pipefail

TARGET="src/renderer/src/components/terminal-pane/terminal-ime-hangul-syllable-flush.test.ts"

echo "== target file excerpt =="
if [ -f "$TARGET" ]; then
  wc -l "$TARGET"
  cat -n "$TARGET" | sed -n '1,180p'
else
  echo "Target file not found"
  fd -a terminal-ime-hangul-syllable-flush.test.ts . || true
fi

echo "== references to compositionstart/keydown handling =="
rg -n "compositionstart|compositionupdate|keydown|keyCode === 229|isComposing|keyCode" src/renderer src -g '*.{ts,tsx,js,jsx}' 2>/dev/null | sed -n '1,240p' || true

Repository: stablyai/orca

Length of output: 42105


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== locate xterm source or references =="
git ls-files | rg '(`@xterm/xterm`|node_modules/@xterm/xterm|terminal.*\.ts|compositionstart|textarea)' | sed -n '1,120p'

echo "== package manifests mentioning `@xterm/xterm` =="
fd -a 'package.json' . -d 4 | while read -r f; do
  if rg -q '"`@xterm/xterm`"' "$f" 2>/dev/null; then
    echo "--- $f"
    rg '"`@xterm/xterm`"' "$f"
  fi
done

echo "== read-only probe: current test event sequence effects vs Chromium-compliant sequence =="
python3 - <<'PY'
from pathlib import Path
p = Path('src/renderer/src/components/terminal-pane/terminal-ime-hangul-syllable-flush.test.ts')
text = p.read_text()
seq_start = text.find("it('does not double-send", text.find('terminal-ime-hangul-syllable-flush.test.ts'))
end = text.find("\n  })", seq_start)
case = text[max(0, seq_start-text.find('  it(')-40):end]
print(case)
print("case_contains_first_compositionstart_before_keydown:", "composition(textarea, 'compositionstart')" in case and case.index("composition(textarea, 'compositionstart'") < case.find("keydown(textarea, 'Process'"))
print("case_contains_insertText_after_insertCompositionText:", "input(textarea, 'insertCompositionText', '한')" in case and "input(textarea, 'insertText', '한')" in case)
PY

Repository: stablyai/orca

Length of output: 13109


Emulate Chromium/IBus event order for the first composing key.

Chromium dispatches keydown before compositionstart for the first IME character, so this test should fire the keyCode === 229/isComposing: true keydown first and keep the later compositionstart. The IBus behavior described here is a commit-reinsert sequence, and the subsequent insertText/second compositionstart order in this flow is correct.

@greptile-apps

greptile-apps Bot commented Aug 3, 2026 •

Copy link
Copy Markdown

Greptile Summary

This PR fixes Korean Hangul input lagging one syllable behind the IME in the terminal. The root cause was that the compositionstart handler cancelled the pending finalizer for syllable N when syllable N+1 began, and the fallback path dispatched a dataPendingReconciliation event that terminal-ime-composition-route.ts explicitly drops — leaving the committed syllable's bytes undelivered until the next compositionend.

  • The fix removes the three-call block (_cancelPendingFinalizer + _endPendingCompositionSession) from compositionstart and replaces it with a single line that records nextCompositionStart on the pending composition. The already-armed finalizer fires on the next task, reads the textarea up to nextCompositionStart, and routes the bytes through the normal session-end path — after IBus has had a chance to rewrite the textarea, preserving the final-consonant transfer (아아 not 앙아).
  • The same semantic change is applied by exact anchored string replacement to the minified CJS and ESM bundles vendored in the patch. Source maps are acknowledged-stale (explicitly noted by the author as a trade-off).
  • Four new test cases (×2 builds = 8 tests) gate the regression, the consonant-transfer constraint, duplication at syllable boundaries, and the IBus double-send path.

Confidence Score: 5/5

Safe to merge. The change is a minimal deletion in the compositionstart handler; the transaction bookkeeping and IBus-protection logic from #11293 are entirely preserved.

The fix is a targeted removal of three calls in compositionstart — no new logic added, no new timers created, no new IPC or transport surface touched. The regression is covered by four new test cases that assert on intermediate state, and the IBus constraint is validated by an automated red-control run.

Files Needing Attention: No files require special attention. The stale source maps in the patch are an acknowledged maintenance item with no runtime impact.

Important Files Changed

Filename Overview
config/patches/@[email protected] Core fix: removes the compositionstart block that cancelled the pending finalizer; replaces it with just setting nextCompositionStart on the pending composition, letting the deferred flush survive to the next task. The same semantic change is applied to the minified CJS (xterm.js) and ESM (xterm.mjs) bundles by exact string replacement. Source maps are acknowledged-stale (noted by author).
src/renderer/src/components/terminal-pane/terminal-ime-hangul-syllable-flush.test.ts New test file with 4 scenarios (×2 for CJS/ESM = 8 tests): regression gate (syllable N flush before syllable N+1 completes), Korean final-consonant transfer (아아 not 앙아), no-duplication at syllable boundary, and no double-send on IBus insertText path. Timing assertions target intermediate state, closing the gap in the existing adversarial suite.
pnpm-lock.yaml Only change is the @xterm/xterm patch content hash and 24 dependent patch_hash= references that necessarily follow any edit to the vendored patch — no dependency version changes.

Reviews (2): Last reviewed commit: "test(terminal): dispose Hangul flush ter..." | Re-trigger Greptile

Comment on lines +27 to +29
const emitted: string[] = []
terminal.onData((data) => emitted.push(data))
return { emitted, terminal, textarea: terminal.textarea }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Tests observe triggerDataEvent, not the production terminal.input() path

In the test there is no installTerminalImeCompositionRoute call, so XTERM_COMPOSITION_SESSION_END_EVENT is never prevented. This means _sendCompositionInput falls through to _coreService.triggerDataEvent, which triggers terminal.onData → emitted.push. In production the route's onSessionEnd calls event.preventDefault() and routes through terminal.input() after validating the pty ID and transport.

The timing assertions (the actual regression gates) are unaffected by this difference, but a future test author might be surprised to find the route's pty-validation logic untested here. Consider adding a companion test or a comment noting that pty/transport validation is covered by the existing route tests.

A failed assertion skipped the inline dispose and leaked xterm timers into
the next test in the file.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@leon1114

leon1114 commented Aug 3, 2026 •

Copy link
Copy Markdown
Author

Addressed the review feedback in fed2ba2:

  • CodeRabbit nitpick (unconditional dispose): terminals opened by openTerminal are now tracked and disposed in afterEach, so a failed assertion can no longer leak xterm timers into the next test in the file. The inline terminal.dispose() calls are gone.
  • "Out of Scope Changes" inconclusive check: confirming the vendored bundle edits are in this PR. GitHub reports three changed files:
File +/-
config/patches/@[email protected] +7 / -10
pnpm-lock.yaml +24 / -24
src/renderer/src/components/terminal-pane/terminal-ime-hangul-syllable-flush.test.ts +164 / -0

The patch hunk carries the same semantic change in all three places it has to: the TypeScript source (src/browser/input/CompositionHelper.ts), the CJS bundle (lib/xterm.js), and the ESM bundle (lib/xterm.mjs). The summarizer likely skipped that file because its bundle hunks are single lines of a few hundred KB. The pnpm-lock.yaml diff is only the patch content hash and its dependent patch_hash= references.

Re-ran after the change: the new file is 8/8, and the full terminal-pane unit suite is 2894/2894 across 219 files.

@Daworks

Daworks commented Aug 3, 2026

Copy link
Copy Markdown

Verified this fix on macOS. Summary: still reproduces on current main, and applying only
your patch file fixes it.

Since this branch is 80 commits behind main (merge-base c5c10e1), I didn't test the branch
as-is — a pass there wouldn't distinguish your patch from the 80 intervening commits. Instead I
built current main and then applied only config/patches/@[email protected]
from this PR (byte-identical to yours), so the two builds differ by nothing else.

Environment

Item Value
Control main @ 18dbcf0, pnpm dev
Fix same tree + this PR's patch file only (+7/-10)
macOS 26.5.2 (25F84), Apple Silicon
Input source System 2-Set Korean (com.apple.inputmethod.Korean.2SetKorean)
Also reproduces on released 1.4.164

The two builds resolve different patched packages, so the patch definitely took effect:

control  node_modules/@xterm/xterm -> ...patch_hash=082a4e71...  lib/xterm.js sha256 605f406c...
fix      node_modules/@xterm/xterm -> ...patch_hash=a08b04de...  lib/xterm.js sha256 47886efd...

Result

Typing 가나다 at a bare zsh prompt. Measured the .composition-view anchor x-coordinate
via CDP on each composition event. Dev builds already expose CDP on --remote-debugging-port=9379
(the dev runner sets it), so this is reproducible in about a minute without patching anything in.

Anchor x after each syllable commits, starting from the same baseline column (301):

After committing Control With this patch
가 301 (no advance) 317 (+16)
나 301 (no advance) 333 (+16)

Control: the anchor never advances across three syllables, so each new composition is painted
over the previous syllable's cell — matching your description. With the patch the anchor
advances exactly one syllable width per commit, and the composing jamo render normally
(confirmed visually as well as by measurement).

(The fix build's probe was installed mid-word, so the first syllable's compositionstart was
not captured there; both runs are compared from the 301 baseline the first composition occupies.)

Measurement caveat

The probe listens on document in the capture phase, which runs before xterm's own handler,
so a snapshot taken there reflects the previous event's state and shows a spurious one-event
lag. The numbers above are from a second snapshot taken on the next macrotask
(setTimeout(…, 0)), after xterm has processed the event. An earlier run of mine that showed
301 → 301 → 317 was contaminated by this artifact — disregard that shape if it matters.

Also worth noting: the xterm-helper-textarea value accumulates to 가나다 in both
builds, so that is not a signal for this bug — the anchor position is the only discriminator I
found.

Not covered

I did not verify Orca's own chat composer (native-chat/). It's a separate path that this PR
doesn't touch, and #11332 describes that one as intermittent, so a single passing sample
wouldn't mean anything. Treating it as out of scope here.

@OrcaWin

OrcaWin commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Superseded by #12278, which adopts this fix, rebuilds the pinned xterm CJS/ESM bundles and source maps reproducibly, and credits Hyunggyun Lyou as co-author. Thank you @leon1114 for isolating the one-syllable-behind finalizer regression and validating the IBus constraint.

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

3 participants