Skip to content

test(terminal): pin IME cursor-chord relocation regressions (carries #12732) - #12872

Closed
ethznn wants to merge 2 commits into
stablyai:mainfrom
ethznn:test/ime-cursor-chord-relocation-regressions
Closed

ethznn wants to merge 2 commits into
stablyai:mainfrom
ethznn:test/ime-cursor-chord-relocation-regressions

Conversation

@ethznn

@ethznn ethznn commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Regression tests for the user-visible symptom reported in #12871: with committed text on the line and a syllable still composing, a cursor-movement chord relocated the composing character to wherever the cursor landed — Option+← turned 가나 다라 마바[사] into 가나 [사]다라 마바, Cmd+← moved the syllable to the line start, and with a Japanese preedit the relocated text also overwrote the glyph at the destination cell.

This branch carries #12732 unchanged (359fd2e09 by @kunsanglee, authorship preserved — that commit is the fix and the ordering mechanism is entirely theirs) and adds one test-only commit on top, pinning the resolver branches the existing suite does not cover:

  • Option+ArrowLeft / Option+ArrowRight word jumps (\eb / \ef) — the chord in the original report
  • Cmd+ArrowRight line-end jump (\x05)
  • a multi-character Japanese preedit (かな) committing before the chord byte — pins the overwrite variant
  • Ctrl+ArrowLeft word jump on Windows (\eb)

Not meant to supersede #12732 — if maintainers prefer to land it directly, I am happy to rebase this to a test-only follow-up (or for the tests to be cherry-picked into #12732; also fine with closing this if that is easier).

Screenshots

No visual change.

Testing

  • pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/components/terminal-pane/keyboard-handlers-ime-deferred-input.test.tsx — 10/10 pass (5 existing + 5 new)
  • Non-vacuity: with keyboard-handlers.ts reverted to its pre-fix(terminal): send a composing cursor chord once, not twice #12732 state, all five new cases fail with the chord byte recorded ahead of the commit (['pty:...', 'commit:사'] instead of ['commit:사', 'pty:...'])
  • oxlint (default + react-doctor config) and oxfmt — clean via lint-staged pre-commit
  • pnpm run typecheck:web — clean
  • pnpm test (full suite, clean shell, macOS arm64) — 46,345 passed / 83 skipped; the 5 failures are unrelated to this change and accounted for:
    • src/main/native-chat/transcript-watch.test.ts + transcript-watch-liveness.test.ts — load-dependent flakes: both pass in isolation (28/28 and 7/7), and repeated full runs fail different unrelated files each time (src/relay/agent-exec-handler.test.ts, a GitHub project-view suite) while this PR's area stays green
    • config/scripts/check-root-directory-entries.test.mjs (3 cases) — fails on stock macOS regardless of this change: the guard script uses declare -A (bash 4+) but the test spawns plain bash, which resolves to /bin/bash 3.2 on macOS, so the script exits 2 before asserting anything
    • side note for anyone running the suite from an AI-agent terminal: src/relay/agent-exec-handler.test.ts asserts spawn env against process.env, so session-injected variables make it fail there; it passes in a clean shell
  • pnpm build — not run; test-only change, no production code touched
  • Added or updated high-quality tests that would catch regressions

The new cases reuse the file's existing harness and assert relative order on the same recorded list, so they pin behavior (commit before chord byte) rather than implementation details.

AI Review Report

Reviewed for vacuity (all five new cases verified to fail against the pre-fix handler), for whether the assertions are behavioral rather than structural (they assert the recorded commit/pty order, not internals), and for platform assumptions (the Windows case forces the platform via the same userAgent stub the neighboring suites use; macOptionAsAlt stays 'false', matching the harness default, and the Alt+Arrow resolver branch does not consult it). No production code, shortcuts, labels, paths, or shell behavior are touched.

Security Audit

Test-only change. No input handling at a trust boundary, no command execution, no path handling, no auth, no secrets, no IPC, and no dependency changes.

Notes

kunsanglee and others added 2 commits August 6, 2026 00:41
Typing "가나" and pressing Cmd+Backspace leaves "나" on the line. "가" has
reached the pty while "나" is still in the preedit, so the line-kill byte goes
out synchronously, erases what the shell has, and only then does xterm flush
"나" from its timer.

xterm guards this in CompositionHelper.keydown by flushing the preedit before a
non-composition key runs, but Orca's window-level capture handler calls
stopImmediatePropagation, so xterm never sees the keydown. The compositionend
path sends the committed glyph from a timer, so it is asynchronous regardless.

keyboard-handlers already defers for this reason, but only for Enter. Widen it
to every sendInput action while a composition is pending. Enter keeps
deferredNewlineSender, which also owns the Windows redispatch ledger; other keys
call sendTerminalInputAfterComposition directly so they do not leave absorb
credits nothing will consume.

Also fixes Cmd+Delete, Cmd+Arrow, Ctrl+Backspace, and the Alt meta sequences,
which shared the same unsequenced path on all platforms.

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

With committed text on the line and a syllable still composing, a
cursor-movement chord relocated the composing character to wherever the
cursor landed: Option+Left word-jump turned "가나 다라 마바[사]" into
"가나 [사]다라 마바", and Cmd+Left moved the syllable to the line start.
With a Japanese preedit the relocated text also overwrote the glyph at
the destination cell. Reported with reproduction steps in stablyai#12871.

The ordering fix already covers these chords; this pins the previously
untested resolver branches so the symptom cannot quietly return:

- Option+ArrowLeft / ArrowRight word jumps (\eb / \ef)
- Cmd+ArrowRight line-end jump (\x05)
- a multi-character Japanese preedit committing before the chord byte
- Ctrl+ArrowLeft word jump on Windows (\eb)

Verified non-vacuous: against the pre-fix keyboard-handlers.ts all five
new cases fail with the chord byte recorded ahead of the commit.
@ethznn

ethznn commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

Closing as agreed — the fix and the tests both live in #12732 now (thanks for the independent verification and the scope notes; the ConPTY and 200 ms fallback caveats are good catches). Will follow #12890 with interest.

@ethznn ethznn closed this Aug 6, 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.

2 participants