Repository navigation
Conversation
Orca's xterm patch resolves a composition session payload as `textareaInput || endData || compositionData`, and `_lastCompositionData` is never cleared by an empty compositionupdate. When an IME empties its preedit instead of committing - macOS Zhuyin Backspace on the last symbol - every observable channel is empty, so the chain falls back to the abandoned preedit and replays it into the PTY. The keystroke deletes nothing and injects the symbol the user just removed. Confirmed against a real macOS Zhuyin session: `cat -v` on a raw tty returned bytes E3 84 91 / E3 84 98 (U+3111 U+3118) with no CR and no DEL. Pristine upstream @xterm/xterm 6.1.0-beta.287 sends nothing for the same event sequence, so this is a regression from the patch, not an upstream bug. Add a composition guard that treats a session as abandoned when compositionend carries no data and no following input event carries text. A commit always surfaces on one of those two channels, so the discriminator holds across IME dialects that differ in whether they blank the preedit with their own compositionupdate first. Wire it into both xterm surfaces: the terminal pane's composition route skips the payload, and the dashboard-popout preview terminal - which has no route and would otherwise emit through xterm's own data event - cancels the session end.
|
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 selected for processing (5)
📝 WalkthroughWalkthroughAdds an abandoned-preedit guard that tracks composition and input events, suppresses empty preedit forwarding, and supports disposal. Integrates the guard with terminal composition routing and the popout preview IME bridge. Non-macOS platforms now receive a functional bridge. Adds tests for emptying and shrinking preedit text, genuine Sogou and fcitx/IBus commits, and preview-terminal behavior. Updates reliability-gate commands, evidence, assertions, and known-gap wording. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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 |
|
Superseded by the cancelled-preedit reconciliation now on main plus #12281's explicit Sogou |
Summary
Backspace that empties an IME preedit no longer replays the abandoned preedit into the PTY.
On macOS Zhuyin, pressing Backspace on the last symbol of a preedit deleted nothing and instead typed that symbol into the terminal, so the user had to press Backspace a second time to actually remove it. Reproduced on a real macOS Zhuyin session with
stty -icanon -echo; cat -v, which returned the raw bytesE3 84 91/E3 84 98(ㄑU+3111,ㄘU+3118) — no CR and no DEL.Root cause is in our own xterm patch, not upstream.
CompositionHelper._sendPendingCompositionresolves the session payload as:and
_lastCompositionDatais deliberately not cleared by an emptycompositionupdate. When an IME empties its preedit instead of committing, all observable channels are empty, so the chain falls back tocompositionData— the preedit the user just deleted — and sends it. Pristine@xterm/[email protected]emits nothing for the same event sequence, verified by running the identical sequence against an unpatched build.The fix adds
installTerminalImeAbandonedPreeditGuard, which treats a composition as abandoned whencompositionendcarries no data and no followinginputevent carries text. A real commit always surfaces on one of those two channels, so the discriminator does not depend on thecompositionupdatesequence, which differs per IME dialect (Sogou/fcitx blank the preedit first; macOS can go straight tocompositionend).It is wired into both xterm surfaces:
terminal-ime-composition-route.ts(terminal pane) skips the payload instead of callingterminal.input.preview-terminal-ime-bridge.ts(dashboard popout preview terminal) has no composition route and would otherwise emit through xterm's own data event, so it cancels the session-end instead.Screenshots
No visual change.
Testing
pnpm lint— exit 0; oxlint, native and type-aware code-quality audits all report 0 warnings / 0 errors; reliability gate manifest check passed for 62 gatespnpm typecheck— exit 0pnpm test— 4111 files passed, 16 skipped; 44115 tests passed, 135 skipped, 0 failedpnpm build— exit 0 (desktop, CLI, web projection, native)New file
terminal-ime-abandoned-preedit.test.tsdrives realTerminalinstances with the real composition route, not mocks:compositionupdatefirstcompositionendcompositionupdate你routes exactly onceinputevent after an emptycompositionend你routes exactly onceThe last three are the important ones: they fail if the guard over-suppresses. Forcing the guard off turns the four suppression assertions red while the three commit assertions stay green, so the suite discriminates rather than passing vacuously.
Registered under the existing
terminal-input.ime-and-synthetic-forwardingreliability gate (commands, testFiles, assertionRefs, evidenceRuns), and narrowed itsknownGapsentry accordingly.AI Review Report
Review focused on the risk that a payload guard drops text the user actually committed.
Cross-platform. The guard contains no platform branch — it reads only
CompositionEvent.dataandInputEvent.data. No paths, no shell, no keyboard-accelerator or shortcut-label changes, so themetaKey/CmdOrCtrland⌘/Ctrl+rules are not touched. One behavioral note:installPreviewImeBridgepreviously returnednullon non-darwin and now always returns a bridge, because the abandoned-preedit path is not macOS-specific. Both call sites useimeBridge?.claimKeyEvent(event) ?? falseandimeBridge?.dispose(); the non-darwin bridge returnsclaimKeyEvent: () => false, so observable behavior on Linux and Windows is unchanged and cleanup is now actually performed. Windows MS-IME and Linux fcitx/IBus commits always carry text oncompositionendor the followinginputevent, which the two "must route" tests pin — but that reasoning is covered by unit tests only, not by real-OS IME automation on those platforms.SSH / remote / local. No change to transport, PTY ownership, or process assumptions. The composition route's existing captured-transport and pty-id checks are untouched; the guard only adds one more reason to skip
terminal.input, evaluated before those checks change any state.Agents / integrations / git providers. Nothing provider- or agent-specific. The change sits below every CLI agent in the renderer input path.
Performance. Three passive listeners per terminal element and two booleans. No allocation in the keystroke path, no polling, no IPC. Listeners are removed in
dispose(), which both surfaces call on teardown.UI quality. No UI surface touched.
What was flagged and changed. The first implementation keyed on
compositionupdate('')precedingcompositionend(''). That sequence was assumed, not observed, and would have silently failed on IMEs that skip the blanking update — the fix would have looked correct while doing nothing. It was replaced with the dialect-independent discriminator described above, and a second test case was added for the skipped-update dialect. The first implementation also only covered the terminal pane; the dashboard popout preview terminal was found to be independently affected and was fixed in the same change.Security Audit
No input validation, command execution, path handling, authentication, secrets, IPC, or dependency surface is touched. The change is a renderer-local DOM event state machine that can only ever suppress one already-computed string; it cannot construct, widen, or redirect a payload, and it does not alter which PTY a payload reaches. The residual risk is functional rather than security-related: an over-broad guard would drop legitimate committed text, which the three "must route" test cases exist to catch. No follow-up needed.
Notes
config/patches/@[email protected], not an upstream xterm bug, so no upstream PR is needed. The|| pending.compositionDatafallback is intentionally kept for IMEs that clear the textarea before committing; only the abandoned case is filtered out.