Repository navigation
fix(terminal): keep the text of an IME key pressed before a commit finalizes - #28441
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 4 minutes. View limit details
📝 Walkthrough
Priority: ➖ Normal Merge Risk: 🟡 Moderate · up to
|
There was a problem hiding this comment.
Actionable comments posted: 3
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
ea840c1f-73cc-4279-b9a2-2c8694a690c2
⛔ Files ignored due to path filters: 1
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing: 3
config/patches/@[email protected]config/patches/xterm-src/@[email protected]src/renderer/src/components/terminal-pane/terminal-ime-xterm-consumed-key-commit.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
ce94861 to
b1aba4a
Compare
…nalizes A Process (229) keydown that lands after compositionend but before xterm's deferred finalizer runs took the composing early return and never recorded that it owed its own commit. When the finalizer ran first, the key's insertText found no pending transaction and no owed commit, so xterm dropped it: `你` then `,` reached the PTY as `你`. Record the debt for such a keydown when the ended session's commit is already in the textarea, and clear it when the pending transaction settles the text itself. Sessions still waiting for their post-composition echo keep their old path, so the echo cannot be sent twice. Fixes the intermittent terminal-linux-direct-ime-commit e2e failure.
…itionend A plain Escape after compositionend cancelled the accepted commit, dropping both the text and the Escape; it now settles the commit and then sends Escape. The Escape that itself ends a session (still composing, reported after compositionend) still cancels. A keypress for the Process key that owes a commit now clears that debt, so a later input cannot send the key's text a second time.
1b0d0f7 to
0d3222e
Compare
Resolve the xterm patch conflicts left by the beta.303 -> beta.304 bump (stablyai#27935) and the consumed-key commit fix (stablyai#28441): the clause-selection change is carried onto the beta.304 source patch, and the dist patch and pnpm-lock.yaml patch hash are regenerated with config/scripts/regenerate-xterm-patches.mjs (--check in sync). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01ULRg9j8BYaqbuCeANNH1AQ
ELI5
If you finish a Chinese or Japanese word and quickly type punctuation right after it, the terminal sometimes dropped the punctuation. Now it always arrives.
What Changed
Before: a full-width comma or period typed straight after a commit could vanish:
你then,reached the shell as你. It only happened when the punctuation key landed in a few-millisecond window, so it showed up as an intermittent failure interminal-linux-direct-ime-commit.spec.ts. That test failed 4 to 7 times in 40 runs, onmaintoo.After: the punctuation always reaches the shell. 200 stress runs since the fix have passed.
The mechanism. Orca's patched xterm finishes a composition commit on a deferred timer. I added timestamps to a failing run and got this order:
Three things combine to lose the comma:
,arrived, there was no pending transaction and no owed text, so xterm dropped it.The test passed whenever the timer fired before the key press or after the text.
The fix is in
config/patches/xterm-src/…src.patch(CompositionHelper.ts). The shipped patch and lockfile hash were regenerated withregenerate-xterm-patches.mjs --write.Why
The bug was a missing "this key still owes text" record, so the fix restores that record. The alternatives either guess or hide the problem:
Linked Issue
None. This was found while validating #28275, where it showed up as a flaky test that fails at the same rate on
main.Visual Proof
N/A. This changes terminal input bytes, not the UI. The before and after are the PTY bytes in the e2e spec (
,。你。before,,。你,。after).Testing
New regression test:
terminal-ime-xterm-consumed-key-commit.test.tsuses a real xtermTerminal. It runs compositionend你, a Process key press, theninsertText ',', both with the finalizer firing between the key press and the text and without.expected '你' to be '你,'). Both cases pass now.Results:
terminal-linux-direct-ime-commit.spec.tswith--repeat-each=40 --workers=4: 4 of 40 failed before the fix. After, it passed 80/80 in one set of runs and 120/120 in another.terminal-pane,dashboard-popoutandlib: 12,324 passed.pnpm tc:webis clean,regenerate-xterm-patches.mjs --checkreports the patches in sync, andcheck:code-quality:changedpasses.Review
The change is narrow: it only applies when the composition has ended and its finalizer is still pending, and the commit is already in the textarea. The case where it stays on the old behaviour is a 229 key press landing between compositionend and an expected IBus/fcitx5 echo. No recorded trace has that order.
Agent skill upstream boundary
Notes
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)