Repository navigation
fix(terminal): empty the IME textarea when a key moves the shell cursor - #2900
Conversation
The keyCode 229 fallback in the patched xterm CompositionHelper sends an IME replacement as one DEL per removed character plus the inserted text, assuming the shell cursor sits at the end of the hidden textarea's text. A key that moves that cursor without touching the textarea broke that: after an arrow, Home, Tab, Esc or Ctrl key (hardware, or the key bar through Terminal.input), a Gboard rewrite of the last word sent its DELs at the moved cursor and deleted text the user never edited. _keyDown now empties the textarea after any control key, not only Backspace, with the same guards (outside composition, not in screen reader mode). Terminal.input() calls the new CompositionHelper.clearTextarea(), which finishes a pending replacement, sends a just finished composition first, then empties the textarea; a composition still in progress keeps its text. Fixes #2836 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
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 19 minutes. View limit details
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. |
… commit Terminal.input() drained a just finished composition's deferred send before the embedder's own data. Ovis labels the next data event as the key bar key or the Stop (useTerminalMount's onData), so that commit took the label and the Escape went out as plain input; the early send could also read the textarea before the IME's final edit landed. clearTextarea() now sends nothing itself: a composition in progress, or one whose deferred send has not yet read the textarea, keeps its text, as before this branch. Found in review. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Deploying ovis with
|
| Latest commit: |
04ba1dc
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://022fee66.ovis.pages.dev |
| Branch Preview URL: | https://lane-issue-2836.ovis.pages.dev |
Review: Codex (gpt-6.1-terra, xhigh, adversarial) on 96ad617, and how each finding was resolvedOne fix round, a5fa0f5. CodeRabbit skipped this PR, so this review stands in for it. 1. Embedder input's label taken by a pending commit (reported HIGH): fixed. In 96ad617, 2. The early send could read the textarea before the IME's final edit (reported MEDIUM): fixed by the same change. Nothing is sent ahead of its deferred send any more. 3. A cursor key during an active composition does not clear (reported HIGH): no change, kept on purpose. The new rule keeps the guards Backspace already had: only outside a composition, and not in screen reader mode. An open IME composition is the browser's to finish, and clearing under it is what the Backspace guard avoids. I found no input path that reaches this. Desktop IMEs report a key pressed during a composition as keyCode 229, which never gets here. Gboard commits the composition before it forwards a hardware arrow, so the composition has already ended at the keydown. The key bar and sticky chords wait for a direct-typing composition ( 4. iOS: the key bar leaves the helper textarea without its one-space placeholder (#862) until the next focus, key or input (reported MEDIUM): no change, not verified on a device. Ovis's simulator notes (docs/terminal-input.md, "Native iOS keyboard check") say the keyboard repeats ⌫ "only while the focused field has text, cancelled keydowns included". The first ⌫ keydown puts the space back ( 5. A mouse-driven cursor move (a click in a mouse-reporting app, or xterm's Alt+click) still keeps the textarea (reported MEDIUM): not in this PR. Mouse reports reach the pane through xterm's mouse service, not Validation after the fix round: |
Second Codex pass after the fix round (aa7cc3e), and the main mergeorigin/main (15e4344) is merged on top of aa7cc3e, without conflicts: ef1aafa. Codex (gpt-6.1-terra, xhigh, adversarial) reviewed the PR again after the fix round. It found no HIGH issues and two MEDIUM ones:
Validation at ef1aafa: |
Merge of origin/main and a review at the new head (04ba1dc)origin/main (b2aadc4) is merged into this branch as one merge commit, 04ba1dc, without conflicts. main's changes since the last merge touch none of this PR's files. Codex (gpt-6.1-terra, xhigh, adversarial) reviewed the PR again at the merge of 0c41431 (6ca8265a; the PR's own diff is the same at 04ba1dc). It found no HIGH issues and one MEDIUM:
The screen reader follow-up from the earlier comment still stands. Earlier unresolved review threads: none. Validation at 04ba1dc: |
# Conflicts: # patches/@XTerm%[email protected]
A second merge of origin/main (fae565e)#2962 changed the same Validation at fae565e: |
|
Local merge gate (owner-approved): adopted and re-driven on old-desktop: origin/main merged, |
Change
Fixes #2836.
The keyCode 229 fallback in the patched xterm
CompositionHelper(patches/@xterm%[email protected]) sends an IME replacement as one DEL per removed character plus the inserted text. It assumes the shell cursor sits at the end of the hidden textarea's text. xterm only emptied the textarea on Enter, Ctrl+C, Backspace, paste and blur, so after a key that moves the shell cursor without touching the textarea, that assumption no longer held. The keys were an arrow, Home, Tab, Esc or a Ctrl/Alt key, from a hardware keyboard or from the key bar throughTerminal.input(). A Gboard rewrite of the last word then sent its DELs at the moved cursor and deleted text the user never edited.CoreBrowserTerminal._keyDownnow empties the textarea after any control key it sends (first character below 0x20, or DEL), not only Backspace. It keeps the same guards: only outside a composition, and not in screen reader mode, where the uncancelled key moves the textarea's caret along with the shell cursor. Enter and Ctrl+C still clear unconditionally, as before.Terminal.input()(key bar keys, sticky-modifier chords, Cmd+arrows on a Mac) calls the newCompositionHelper.clearTextarea(). It finishes a pending Safari replacement as before, then empties the textarea. A composition still in progress, or one whose deferred send has not run yet, keeps its text. So nothing new is sent ahead of the embedder's own data, which Ovis labels as the key bar key or the Stop.Reproduction
Real Chromium (playwright-core) with the patched xterm built by
scripts/build-xterm.ts. No server, no herdr session. The script typedabcdefthrough the 229 path, moved the cursor, then had the IME rewrite the word it sees before its caret intoX:abcdef, then 6×DELXabcdef, thenESC[D, 6×DELXESC[D,Xabcdef, thenESC[H, 6×DELXESC[H,Xabcdef, then\t, 6×DELX\t,Xterm.input("\x1b[D")abcdef, thenESC[D, 6×DELXESC[D,XTests
scripts/xterm-composition.test.tsnow also builds the patchedCoreBrowserTerminal. It drives a real, unopened terminal (fake textarea, real key evaluation, realonData), alongside the existing helper-only cases:With
origin/main's patch the 7 rewrite cases fail: the rewrite sends 6×DELX. The last case guards the review fix: it fails with the first commit's patch, which sent the commit first. With this branch, 18/18 pass.Not changed
The issue's lower-impact case, an edit before the end of the textarea, still forwards only a plain insertion. That happens when the textarea's caret was moved inside it, for example by Gboard's space-bar swipe, which moves the caret without a key. Fixing it changes what the pane receives for caret moves inside the field and needs a device check, so it is left out of this PR.
Validation
bun run check fastat aa7cc3e (mainmerged in, including fix(i18n): keep settings part files under the line cap #2886): workflow syntax, generated types and themes, typecheck, build and unit tests pass (11665 pass, 0 fail, 46 skip). Earlier runs on this branch before that merge failed onlysrc/lib/i18n.test.ts's 400-line cap, which was red onmainuntil fix(i18n): keep settings part files under the line cap #2886.bun test scripts/xterm-composition.test.ts: 18 pass. Before the patch change: 10 pass, 8 fail.bun test scripts/changelog-fold.test.ts scripts/conventions.test.ts scripts/build-xterm.test.ts scripts/xterm-parser-state.test.ts: 45 pass.bun install --frozen-lockfileapplies the regenerated patch.bun.lockis unchanged.Not run:
bun run check fullor the browser lane, and a check on a physical Android device with Gboard or on iOS. One thing for an iPhone check: the key bar now leaves the helper textarea empty until the next key, focus or input event puts back its one-space placeholder (#862). The first ⌫ keydown puts it back, as it does after Enter.🤖 Generated with Claude Code