Repository navigation
fix(terminal): clear the preedit overlay when an IME cancels a composition - #14758
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: Your plan includes up to 10 reviews per rolling hour; 6 remain after this review. 📝 WalkthroughWalkthroughAdded a Vitest/happy-dom regression test for xterm IME preedit visibility. The test simulates empty-update cancellation, input-only cancellation, and deletion from a multi-character preedit. It checks overlay visibility, displayed text, covered cells, and emitted data. Test setup configures canvas measurements, waits for deferred updates, disposes terminals, restores mocks, and clears the document. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/renderer/src/components/terminal-pane/terminal-ime-xterm-cancelled-preedit-visibility.test.ts (1)
2-19: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winReduce the file-level comment.
The comment documents the full event flow and test implementation. The fixtures and test names already provide that detail. Keep only the issue reference and the required visible behavior.
As per coding guidelines: “Comments must be concise, non-obvious, and brief—prefer one line; do not explain obvious behavior or walk through code.”
Proposed reduction
-/** - * Cancelling a composition must also take the preedit overlay off the screen. - * - * Reported for macOS Cangjie (`#11951`): compose until the preedit shows 尸, press Backspace before - * committing a candidate, and 尸 stays painted over the terminal. Backspacing the last radical - * makes the IME's marked text empty, which Chromium reports either as a `compositionupdate` with - * empty data or — when the composition never produced a candidate — as nothing more than the - * deleting `input` event. Neither path reaches `compositionend`, and xterm only ever dropped the - * overlay's `active` class there, so the box kept whatever glyph it was last given. - * - * The assertions are on what the user sees: the `active` class CSS keys `display: block` off, the - * text inside the box, and the cells it therefore covers. `onData` is asserted too, but only as a - * guard — it is already empty on the broken build, which is why the existing cancellation coverage - * in `terminal-ime-xterm-composition-cancel.test.ts` cannot catch this. - * - * happy-dom performs no layout, so the cell size is supplied and the covered footprint is derived - * from the overlay's own display state rather than measured. - */ +/** Covers `#11951`: cancelling Cangjie preedit must clear and hide the composition overlay. */Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: d89a6a08-4d94-42be-8664-ed09066daca6
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (2)
config/patches/@[email protected]src/renderer/src/components/terminal-pane/terminal-ime-xterm-cancelled-preedit-visibility.test.ts
…ition Backspacing over the last radical of a Cangjie composition empties the IME's marked text without reaching compositionend, and the vendored xterm CompositionHelper only dropped the overlay's `active` class there. The box stayed painted with whatever glyph it last held (#11951). Clear on the state rather than on the key, as native terminals do: an empty `compositionupdate` now hides the overlay instead of only ever showing it, and a key the IME swallows re-derives the preedit from the textarea once it settles so a composition emptied with no composition event at all is cancelled too.
45d58d5 to
9935101
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
…ition (#14758) Backspacing over the last radical of a Cangjie composition empties the IME's marked text without reaching compositionend, and the vendored xterm CompositionHelper only dropped the overlay's `active` class there. The box stayed painted with whatever glyph it last held (#11951). Clear on the state rather than on the key, as native terminals do: an empty `compositionupdate` now hides the overlay instead of only ever showing it, and a key the IME swallows re-derives the preedit from the textarea once it settles so a composition emptied with no composition event at all is cancelled too.
Second readiness pass, checking each of the first pass's ten fixes rather than taking them on trust. Nine held. This is the one that did not, plus three fail-open shapes in the site-config scanner that a live OpenSSH disproved. P1 — the store. loadTrustedHostKeys returns [] for ANY read failure, and trustHostKey then wrote [...that empty list, newRecord]: one transient EMFILE followed by one first-contact accept replaced the file with a single record. Every other host re-TOFUs, and one whose key genuinely changed in between is accepted as first contact rather than refused — the exact outcome pinning exists to prevent. It also contradicted the doctrine this PR applies to known_hosts two files away, where a file that exists and refuses to open is evidence withheld. Fixed by classifying one read instead of guessing twice: readStore returns ok/absent/withheld, the read path flattens withheld to 'nothing trusted' so it still fails closed, and the write path declines. That subsumes the separate newer-version probe, so trustHostKey now reads the file once inside the queue rather than twice. The 'Trusted host key' log moved inside the branch that actually writes — it was already claiming success on the newer-version path. P2 — the site-config scanner documents 'doubt wins on every path' and had three where it did not, each the same shape: a path resolved WRONG still resolves to something, and a nonexistent Include reads as 'nothing there', which is indistinguishable from 'no policy'. Verified against OpenSSH 10.2p1: relative Includes resolve against a fixed dir, not the including file's, so a directive two deep was missed; ? and [...] are globs it honours; ~ and %-tokens expand before use. All three now answer doubt. P2 — credential prompts are gated on the attempt generation in one place rather than per rung. A superseded attempt is denied without a recorded decision, so isHostKeyVerificationError reads false and the ladder ran on to prompt for a passphrase nobody was waiting on. P2 — resolveKnownHostsFiles is async. Its rejoin existsSync-scans the very paths the 5s bound protects, and sat outside it as an eagerly-evaluated argument, so a stalled NFS/SMB mount blocked the whole main process. Tests fail against the pre-fix code: 2 for the store wipe, 3 for the scanner. Also: the 4 IME failures I previously reported as pre-existing main breakage were a stale node_modules — the xterm patch from #14758 was not applied here (402,643 bytes installed vs 403,181 expected). pnpm install applies it and all 4 pass. The OSC8 and SFTP failures were the same cause.
…ition (stablyai#14758) Backspacing over the last radical of a Cangjie composition empties the IME's marked text without reaching compositionend, and the vendored xterm CompositionHelper only dropped the overlay's `active` class there. The box stayed painted with whatever glyph it last held (stablyai#11951). Clear on the state rather than on the key, as native terminals do: an empty `compositionupdate` now hides the overlay instead of only ever showing it, and a key the IME swallows re-derives the preedit from the textarea once it settles so a composition emptied with no composition event at all is cancelled too.


ELI5
When Cangjie composition was cancelled before committing a character, xterm could leave the last preedit glyph painted over the terminal. The overlay now follows whether marked text actually exists, so cancellation clears and hides it without sending text to the shell.
What Changed
CompositionHelperproduction patch inconfig/patches/@[email protected].compositionupdatedata now removes the overlay'sactiveclass.inputevent and no composition event.Why
The fix is state-driven rather than key-driven. Backspace is not special-cased: after the IME settles, an empty marked-text region means the composition is gone. This covers both event sequences that can leave stale UI while preserving normal edits that merely shorten a composition.
The existing cancellation test checked only that
onDataemitted nothing. It could pass while the stale overlay remained visible, so the new test asserts the rendered overlay state and text directly.Linked Issue
Fixes #11951
#14902 is adjacent IME work but not the same defect: it concerns Cursor Agent candidate-window positioning. It should remain separate.
Visual Proof
Exact head
99351010135f078e82980840672bd3762b340dbe, rendered in Orca on an M4 Air running macOS 26.5.2:The before state rendered
尸in.composition-view.active. Clearing the composition removedactive, emptied the glyph content, hid the overlay, and left the PTY cursor unchanged with zero new lines.Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
M4 Air / macOS 26.5.2: exact-head dev app attached through Electron CDP; visible preedit and cancelled state captured at 1710×1073.
M4 Air backing state: target PTY stayed at cursor
706with zero new lines before/after cancellation.Focused IME suite: 18 files / 54 tests passed.
pnpm typecheckpassed.pnpm lintpassed.Focused oxlint and formatting passed.
PR CI covers the full cross-platform suite and packaging.
AI Disclosure
Review
Self-reviewed the xterm patch and regression coverage for correctness, cleanup, stale overlay state, emitted terminal data, and the non-cancelling shortening case. CodeRabbit's latest review generated no actionable comments.
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
loginwindow, so a physical/System Events Cangjie keystroke could not target the app. The built-in Cangjie source was present and selected, while Chromium's nativeInput.imeSetCompositioncommand drove the real terminal text client. This proves rendered cancellation and PTY isolation on macOS, but not the reporter's exact hardware event trace.Backspace/keyCode 8 can finalize text into the PTY. It is pre-existing, was unchanged here, and needs its own evidence and issue before broadening this fix.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)Author