Repository navigation
fix(mobile): show live input caret and preserve selection edits - #31477
Conversation
|
No actionable comments were generated in the recent review. ℹ️ Recent review info
Walkthrough
Priority: Merge Risk:
|
c855dd2 to
dca762a
Compare
41437c1 to
752ed93
Compare
[Medium impact] The changes since the last review appear safe to merge. SummaryThe PR makes the live terminal field visible and adds caret-aware accessory edits.
Reviews (4) · Last reviewed commit: "chore(mobile): allowlist the live input ..." · Reviewed by Greptile |
Display the existing input directly so its native caret shows. Accessory Backspace/Delete edit at the field's caret, read from the input when pressed, so edits that keep the caret (IME composition) still delete, and the caret is restored for subsequent typing. Port and adapt community PR #28294 to the current command dock. Co-authored-by: Kyino <[email protected]>
Hardware Left/Right/Home/End moved both the visible field caret and the PTY cursor, so the mirror erased at the wrong place. With field text they now move only the field caret, like Backspace and Delete; Right/End at the field end still reach the PTY so shells can accept an autosuggestion. On Android the key binding lets plain caret keys through to that decision instead of sending them to the PTY. The dictation and upload status covers the field instead of adding a row, so starting or stopping either no longer resizes the terminal.
12df646 to
ac9b36a
Compare
ELI5
Live input now shows the real text cursor. You can move into the middle of a command, delete a letter there and keep typing where the cursor is, and the terminal line stays in step with the field.
What Changed
Why
Fixes the hidden caret and end-only deletion in #27829. The session screen only renders in the web shell (RN-Web in the app's WebView), so the live input ref is the DOM input and its
selectionStart/selectionEndare the caret at the moment of the press. That replaced an earlier version of this PR that tracked selection-change events and paired them with text events, which needed extra state and guards for out-of-order reports.Linked Issue
Fixes #27829
Visual Proof
Caret (from Neil's iOS simulator run): before, no caret at offset 3; after, the caret sits between
candd.After accessory Delete and typing X:
Command dock in iOS 27 Safari (real WebKit), main vs this branch, idle and while dictating. The dock is 78 px tall in both states on this branch.
Testing
On a real target, I ran the production commit hook in a page bundle built from this branch, with an in-memory terminal sink:
abcdef, three Left presses, accessory Delete, typeX: the field and terminal both readabcXef.cX, accessory Backspace, typeY: both readabYef.a🙂b👍🏽c, then arrows and accessory keys around the surrogate pairs: each edit removes one code point and the bytes match.git chsendsESC[C. Left, Left, Right stays local.abc, tap the caret into the word, accessory Delete, typex: both readaxc.AI Disclosure
Review
Two reviewers (Codex and Claude) ran four rounds. Fixed from review:
Rejected: "accessory Delete corrupts an active Android composition". It came from a synthetic CDP composition, and Gboard on the emulator does not reproduce it (see Testing). Main's Backspace already writes the field the same way.
Known gaps, unchanged from main: the accessory-bar arrows still send to the PTY in the middle of a session. After a shell autosuggestion is accepted with Right/End, the field doesn't know about the accepted text, so a later Backspace from the field erases from the suggestion's end.
Agent skill upstream boundary
Notes
Mobile-only, client-side. No RPC, host-version or workspace-kind change, so mixed phone/desktop versions are unaffected. Ported and adapted community PR #28294 by @Kyino-Pan; the commit includes
Co-authored-by: Kyino <[email protected]>.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)