Skip to content

test(ime): restore coverage the composition-ownership change removed - #13168

Merged
nwparker merged 4 commits into
mainfrom
nwparker/ime-coverage-restore
Aug 8, 2026
Merged

nwparker merged 4 commits into
mainfrom
nwparker/ime-coverage-restore

Conversation

@nwparker

@nwparker nwparker commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

Returning IME composition ownership to xterm (17b3dff) deleted 23 test files. Most went correctly — they specified the deleted implementation, and the behavior they protected is re-expressed by the 23 IME test files main now carries. Three did not, and this restores those.

Each one passes on main, so none of these was a live regression. But none was guarded either, and all three protect behavior a user would notice.

Hangul back-to-back flush. #12278 fixed a syllable that was not flushed before the next composition began — the force-end path, the one that leaves stale glyphs behind. Both that patch and its test went away. Replays the recorded back-to-back arms (25/60/120 ms, read as 가\r나 at the PTY) against a real xterm Terminal. It passes: stock xterm flushes natively, so the removal was safe rather than a silent regression.

Korean commit before newline. Recorded first-party on Windows 11 + Microsoft Korean (HKL 0412), bytes read on the far side of the PTY: ea b0 80 0d, the syllable strictly before the CR. Two facts here would have been wrong in a synthesized trace — the physical Enter arrives after compositionend with isComposing false, and there are three compositionupdates for two jamo keys.

IBus and fcitx5 Linux traces. Commits interleaved with ASCII (한abc글) is the Linux IME gesture users report on, and its failure modes are a lost syllable and a doubled one. It was covered only by an e2e spec needing a Linux host with a live input framework. Fixtures are the recorded captures from the sealed linux-final evidence run — 280 DOM events, verified normalized-identical to source — asserted three ways: exact onData, exactly-once counts across five repetitions, and the PTY bytes the recorded run actually received.

Mobile accessory ordering. An accessory-bar keystroke must not overtake the syllable being committed, and must be suppressed when that commit fails. Drives the current hook with an Android composing-region trace rather than reconstructing the deleted coordinator.

Tests only — no production code changes.

Verified with the project's own config (--config config/vitest.config.ts; auto-discovery silently loads a different one): terminal-pane 239 files / 2829 tests, mobile 434 files / 3385 tests.

Made with Orca 🐋

nwparker and others added 4 commits August 8, 2026 02:10
…STA-3132)

Recorded first-party on Windows 11 + Microsoft Korean (HKL 0412) against the
defect-era v1.4.164 build, with bytes read on the far side of the PTY: the
terminal received ea b0 80 0d, the syllable strictly before the CR.

The capture did not reproduce the suspected deferred-newline inversion. That
route needed a session end carrying dataPendingReconciliation, which plain
compose-then-Enter cannot produce because the IME finalizes first and the
newline is never held; back-to-back arms at 25/60/120 ms did not reach it
either. The test therefore pins the ordering rather than discriminating a fix.

Co-authored-by: Orca <[email protected]>
…th the composition layer

#12278 fixed a Hangul syllable that was not flushed before the next
composition began — the force-end path, and the one that leaves stale glyphs
behind. Returning composition ownership to xterm deleted both that patch and
its test, so nothing guarded the behavior any more.

Replays the recorded back-to-back arms (25/60/120 ms, read as 가\r나 at the
PTY) against a real xterm Terminal. It passes on main: stock xterm flushes the
committed syllable natively, so the removal was safe rather than a silent
regression.

Co-authored-by: Orca <[email protected]>
Returning composition ownership to xterm deleted the accessory-input commit
tests along with the hook they targeted, but the guarantee they protected is
user-visible and still applies: an accessory-bar keystroke must not overtake
the syllable being committed, and must be suppressed when that commit fails.

Drives the current hook with an Android composing-region trace rather than
reconstructing the deleted coordinator.

Co-authored-by: Orca <[email protected]>
Commits interleaved with ASCII (한abc글) are the Linux IME gesture users report
on, and its failure modes are a lost syllable and a doubled one. That gesture
was only covered by tests/e2e/terminal-linux-ime-native.spec.ts, which needs a
Linux host running a real input framework.

Fixtures are the recorded captures from the sealed linux-final evidence run,
replayed against a real xterm Terminal: exact onData, exactly-once counts across
five repetitions, and the PTY bytes the recorded run actually received.

Co-authored-by: Orca <[email protected]>
@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Added native IME regression coverage across mobile and renderer terminal paths. Mobile tests verify Hangul commit handling and accessory-byte ordering for successful and failed sends. Linux fixtures and replay tests cover IBus and fcitx5 event traces, terminal output, delivery counts, and PTY bytes. Windows tests cover Korean composition commits, Enter ordering, ordinary typing, and consecutive compositions.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the restored IME tests and verification but omits the required Screenshots, AI Review Report, Security Audit, and Notes sections. Add all required template sections, state "No visual change," document AI review and macOS/Linux/Windows checks, provide the security audit, and record platform risks or follow-up work.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies restored IME test coverage and matches the primary changes in the pull request.
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.
✨ 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.

@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 (3)
src/renderer/src/components/terminal-pane/terminal-ime-xterm-linux-native-trace-replay.test.ts (1)

119-122: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Replace the as RecordedTrace assertions with a checked assignment.

The assertion silences structural mismatches. If a fixture key is renamed or removed, the test still compiles and fails later with an unclear error. A satisfies-style binding keeps the same runtime behavior and reports fixture drift at type-check time.

♻️ Proposed refactor
-import fcitx5Trace from './__fixtures__/fcitx5-hangul-mixed-ascii-terminal-trace.json'
-import ibusTrace from './__fixtures__/ibus-hangul-mixed-ascii-terminal-trace.json'
+import fcitx5TraceJson from './__fixtures__/fcitx5-hangul-mixed-ascii-terminal-trace.json'
+import ibusTraceJson from './__fixtures__/ibus-hangul-mixed-ascii-terminal-trace.json'
+const ibusTrace: RecordedTrace = ibusTraceJson
+const fcitx5Trace: RecordedTrace = fcitx5TraceJson
+
 describe.each([
-  ['IBus', ibusTrace as RecordedTrace],
-  ['fcitx5', fcitx5Trace as RecordedTrace]
+  ['IBus', ibusTrace],
+  ['fcitx5', fcitx5Trace]
 ])('%s Hangul commits interleaved with ASCII', (_framework, trace) => {
src/renderer/src/components/terminal-pane/terminal-ime-xterm-korean-enter-commit-order.test.ts (1)

96-132: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Parameterize the vowel key and the commit data.

composeSyllable accepts leadCode, but line 109 hardcodes code: 'KeyK'. finalizeThenEnter hardcodes the commit data '가' at line 127. Both values are correct for the current callers, because 가 and 나 share the ㅏ vowel key and only composeGa precedes finalizeThenEnter. A future syllable with a different vowel or a different preceding compose would produce a silently wrong trace. Pass both values as arguments.

♻️ Proposed refactor
 async function composeSyllable(
   textarea: HTMLTextAreaElement,
   leadCode: string,
+  vowelCode: string,
   jamo: string,
   syllable: string
 ): Promise<void> {
@@
-  dispatchKeydown(textarea, { key: 'Process', code: 'KeyK', keyCode: 229, isComposing: true })
+  dispatchKeydown(textarea, { key: 'Process', code: vowelCode, keyCode: 229, isComposing: true })
@@
 function composeGa(textarea: HTMLTextAreaElement): Promise<void> {
-  return composeSyllable(textarea, 'KeyR', 'ㄱ', '가')
+  return composeSyllable(textarea, 'KeyR', 'KeyK', 'ㄱ', '가')
 }
@@
-async function finalizeThenEnter(textarea: HTMLTextAreaElement): Promise<void> {
-  dispatchCompositionEvent(textarea, 'compositionend', '가')
+async function finalizeThenEnter(textarea: HTMLTextAreaElement, syllable: string): Promise<void> {
+  dispatchCompositionEvent(textarea, 'compositionend', syllable)
mobile/src/terminal/terminal-live-native-ime-accessory-order.test.ts (1)

61-72: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Unmount the test renderer after the harness returns.

Line 63 discards the value from create(...), so no test can unmount the root. The Harness component and its effects stay mounted for the whole file. Return the renderer and unmount it at the end of each test.

♻️ Proposed refactor
-function createHarness(sender: TerminalLiveInputSender): Handlers {
+function createHarness(sender: TerminalLiveInputSender): {
+  handlers: Handlers
+  unmount: () => void
+} {
@@
+  let renderer: ReturnType<typeof create> | null = null
   try {
     act(() => {
-      create(createElement(Harness))
+      renderer = create(createElement(Harness))
     })
   } finally {
     consoleError.mockRestore()
   }
-  if (!handlers) {
+  if (!handlers || !renderer) {
     throw new Error('terminal live input hook did not render')
   }
-  return handlers
+  const root = renderer
+  return { handlers, unmount: () => act(() => root.unmount()) }
 }

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3af6e90a-3c9a-4d84-a214-390c458f9d91

📥 Commits

Reviewing files that changed from the base of the PR and between 9825706 and f7719ad.

📒 Files selected for processing (5)
  • mobile/src/terminal/terminal-live-native-ime-accessory-order.test.ts
  • src/renderer/src/components/terminal-pane/__fixtures__/fcitx5-hangul-mixed-ascii-terminal-trace.json
  • src/renderer/src/components/terminal-pane/__fixtures__/ibus-hangul-mixed-ascii-terminal-trace.json
  • src/renderer/src/components/terminal-pane/terminal-ime-xterm-korean-enter-commit-order.test.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-xterm-linux-native-trace-replay.test.ts

Comment on lines +146 to +193
it('emits the committed syllable before the carriage return', async () => {
const { emitted, textarea } = openTerminal()
await composeGa(textarea)
await finalizeThenEnter(textarea)

const stream = emitted.join('')
expect(stream).toContain('가')
expect(stream).toContain('\r')
// The recorded PTY bytes were `ea b0 80 0d`. Anything that releases the newline first
// submits a line whose last syllable has not been written yet.
expect(stream.indexOf('가')).toBeLessThan(stream.indexOf('\r'))
expect(stream).toBe('가\r')
})

it('leaves ordinary non-IME typing followed by Enter unchanged', async () => {
const { emitted, textarea } = openTerminal()
for (const key of ['a', 'b', 'c']) {
dispatchKeydown(textarea, {
key,
code: `Key${key.toUpperCase()}`,
keyCode: key.toUpperCase().charCodeAt(0),
isComposing: false
})
await nextEventLoop()
}
dispatchKeydown(textarea, { key: 'Enter', code: 'Enter', keyCode: 13, isComposing: false })
await nextEventLoop()

// The paired latin arm of the same capture session read `61 62 63 0d` at the PTY.
expect(emitted.join('')).toBe('abc\r')
})

// Restores coverage deleted with terminal-ime-hangul-syllable-flush.test.ts: #12278 fixed a
// syllable that was not flushed before the next composition began, which is the force-end path
// and the one that leaves stale glyphs behind. Recorded b2b arms read `가\r나` at 25/60/120 ms.
it('keeps the first syllable when the next composition starts immediately', async () => {
const { emitted, textarea } = openTerminal()
await composeGa(textarea)
await finalizeThenEnter(textarea)
await composeSyllable(textarea, 'KeyS', 'ㄴ', '나')
dispatchCompositionEvent(textarea, 'compositionend', '나')
await nextEventLoop()

const stream = emitted.join('')
expect(stream).toBe('가\r나')
// A dropped flush loses the leading syllable; a double flush repeats it.
expect(stream.match(/가/g)).toHaveLength(1)
})

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.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Dispose each Terminal after the test.

openTerminal returns terminal, but none of the three tests destructure or dispose it. afterEach only removes the DOM nodes. xterm keeps timers, observers, and document-level listeners until dispose() runs, so each test leaves a live renderer behind. The sibling file terminal-ime-xterm-linux-native-trace-replay.test.ts calls terminal.dispose() after each replay. Apply the same cleanup here.

🧹 Proposed cleanup
   it('emits the committed syllable before the carriage return', async () => {
-    const { emitted, textarea } = openTerminal()
+    const { emitted, terminal, textarea } = openTerminal()
     await composeGa(textarea)
     await finalizeThenEnter(textarea)
+    terminal.dispose()

Apply the same change to the tests at Line 160 and Line 181.

📝 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
it('emits the committed syllable before the carriage return', async () => {
const { emitted, textarea } = openTerminal()
await composeGa(textarea)
await finalizeThenEnter(textarea)
const stream = emitted.join('')
expect(stream).toContain('가')
expect(stream).toContain('\r')
// The recorded PTY bytes were `ea b0 80 0d`. Anything that releases the newline first
// submits a line whose last syllable has not been written yet.
expect(stream.indexOf('가')).toBeLessThan(stream.indexOf('\r'))
expect(stream).toBe('가\r')
})
it('leaves ordinary non-IME typing followed by Enter unchanged', async () => {
const { emitted, textarea } = openTerminal()
for (const key of ['a', 'b', 'c']) {
dispatchKeydown(textarea, {
key,
code: `Key${key.toUpperCase()}`,
keyCode: key.toUpperCase().charCodeAt(0),
isComposing: false
})
await nextEventLoop()
}
dispatchKeydown(textarea, { key: 'Enter', code: 'Enter', keyCode: 13, isComposing: false })
await nextEventLoop()
// The paired latin arm of the same capture session read `61 62 63 0d` at the PTY.
expect(emitted.join('')).toBe('abc\r')
})
// Restores coverage deleted with terminal-ime-hangul-syllable-flush.test.ts: #12278 fixed a
// syllable that was not flushed before the next composition began, which is the force-end path
// and the one that leaves stale glyphs behind. Recorded b2b arms read `가\r나` at 25/60/120 ms.
it('keeps the first syllable when the next composition starts immediately', async () => {
const { emitted, textarea } = openTerminal()
await composeGa(textarea)
await finalizeThenEnter(textarea)
await composeSyllable(textarea, 'KeyS', 'ㄴ', '나')
dispatchCompositionEvent(textarea, 'compositionend', '나')
await nextEventLoop()
const stream = emitted.join('')
expect(stream).toBe('가\r나')
// A dropped flush loses the leading syllable; a double flush repeats it.
expect(stream.match(/가/g)).toHaveLength(1)
})
it('emits the committed syllable before the carriage return', async () => {
const { emitted, terminal, textarea } = openTerminal()
await composeGa(textarea)
await finalizeThenEnter(textarea)
terminal.dispose()
const stream = emitted.join('')
expect(stream).toContain('가')
expect(stream).toContain('\r')
// The recorded PTY bytes were `ea b0 80 0d`. Anything that releases the newline first
// submits a line whose last syllable has not been written yet.
expect(stream.indexOf('가')).toBeLessThan(stream.indexOf('\r'))
expect(stream).toBe('가\r')
})
it('leaves ordinary non-IME typing followed by Enter unchanged', async () => {
const { emitted, terminal, textarea } = openTerminal()
for (const key of ['a', 'b', 'c']) {
dispatchKeydown(textarea, {
key,
code: `Key${key.toUpperCase()}`,
keyCode: key.toUpperCase().charCodeAt(0),
isComposing: false
})
await nextEventLoop()
}
dispatchKeydown(textarea, { key: 'Enter', code: 'Enter', keyCode: 13, isComposing: false })
await nextEventLoop()
terminal.dispose()
// The paired latin arm of the same capture session read `61 62 63 0d` at the PTY.
expect(emitted.join('')).toBe('abc\r')
})
// Restores coverage deleted with terminal-ime-hangul-syllable-flush.test.ts: `#12278` fixed a
// syllable that was not flushed before the next composition began, which is the force-end path
// and the one that leaves stale glyphs behind. Recorded b2b arms read `가\r나` at 25/60/120 ms.
it('keeps the first syllable when the next composition starts immediately', async () => {
const { emitted, terminal, textarea } = openTerminal()
await composeGa(textarea)
await finalizeThenEnter(textarea)
await composeSyllable(textarea, 'KeyS', 'ㄴ', '나')
dispatchCompositionEvent(textarea, 'compositionend', '나')
await nextEventLoop()
terminal.dispose()
const stream = emitted.join('')
expect(stream).toBe('가\r나')
// A dropped flush loses the leading syllable; a double flush repeats it.
expect(stream.match(/가/g)).toHaveLength(1)
})

@nwparker
nwparker merged commit 25a8c51 into main Aug 8, 2026
47 checks passed
@nwparker
nwparker deleted the nwparker/ime-coverage-restore branch August 8, 2026 09:29
nwparker added a commit that referenced this pull request Aug 9, 2026
* Revert "test(ime): restore coverage the composition-ownership change removed (#13168)"

This reverts commit 25a8c51.

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

This reverts commit 17b3dff.

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

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

Co-authored-by: Orca <[email protected]>

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

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

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

Co-authored-by: Orca <[email protected]>

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

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

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

Co-authored-by: Orca <[email protected]>

---------

Co-authored-by: Orca <[email protected]>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…tablyai#13168)

* test(terminal): pin the recorded Korean commit-before-newline order (STA-3132)

Recorded first-party on Windows 11 + Microsoft Korean (HKL 0412) against the
defect-era v1.4.164 build, with bytes read on the far side of the PTY: the
terminal received ea b0 80 0d, the syllable strictly before the CR.

The capture did not reproduce the suspected deferred-newline inversion. That
route needed a session end carrying dataPendingReconciliation, which plain
compose-then-Enter cannot produce because the IME finalizes first and the
newline is never held; back-to-back arms at 25/60/120 ms did not reach it
either. The test therefore pins the ordering rather than discriminating a fix.

Co-authored-by: Orca <[email protected]>

* test(terminal): restore Hangul back-to-back flush coverage deleted with the composition layer

stablyai#12278 fixed a Hangul syllable that was not flushed before the next
composition began — the force-end path, and the one that leaves stale glyphs
behind. Returning composition ownership to xterm deleted both that patch and
its test, so nothing guarded the behavior any more.

Replays the recorded back-to-back arms (25/60/120 ms, read as 가\r나 at the
PTY) against a real xterm Terminal. It passes on main: stock xterm flushes the
committed syllable natively, so the removal was safe rather than a silent
regression.

Co-authored-by: Orca <[email protected]>

* test(mobile): pin accessory-byte ordering behind a Hangul commit

Returning composition ownership to xterm deleted the accessory-input commit
tests along with the hook they targeted, but the guarantee they protected is
user-visible and still applies: an accessory-bar keystroke must not overtake
the syllable being committed, and must be suppressed when that commit fails.

Drives the current hook with an Android composing-region trace rather than
reconstructing the deleted coordinator.

Co-authored-by: Orca <[email protected]>

* test(terminal): replay recorded IBus and fcitx5 Hangul traces offline

Commits interleaved with ASCII (한abc글) are the Linux IME gesture users report
on, and its failure modes are a lost syllable and a doubled one. That gesture
was only covered by tests/e2e/terminal-linux-ime-native.spec.ts, which needs a
Linux host running a real input framework.

Fixtures are the recorded captures from the sealed linux-final evidence run,
replayed against a real xterm Terminal: exact onData, exactly-once counts across
five repetitions, and the PTY bytes the recorded run actually received.

Co-authored-by: Orca <[email protected]>

---------

Co-authored-by: Orca <[email protected]>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
* Revert "test(ime): restore coverage the composition-ownership change removed (stablyai#13168)"

This reverts commit d1782d4.

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

This reverts commit 45169f2.

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

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

Co-authored-by: Orca <[email protected]>

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

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

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

Co-authored-by: Orca <[email protected]>

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

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

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

Co-authored-by: Orca <[email protected]>

---------

Co-authored-by: Orca <[email protected]>
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