Repository navigation
fix(mobile): use desktop's terminal paste, key and query-reply rules - #33957
Conversation
|
No actionable comments were generated in the recent review.
|
There was a problem hiding this comment.
Actionable comments posted: 1

Review info
-
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
e380ea00-ff07-4802-9658-a86a9378a6ce
Files selected for processing: 38-
mobile/src/session/mobile-image-live-input-order.test.tsxmobile/src/session/mobile-worker-takeover-send-sites.test.tsmobile/src/session/terminal-field-submit-binding-send.test.tsxmobile/src/session/use-mobile-session-tab-reconciliation.tsmobile/src/session/use-mobile-session-terminal-input.tsmobile/src/session/use-mobile-session-terminal-send-actions.tsmobile/src/session/use-mobile-session-terminal-subscription.tsmobile/src/session/use-mobile-terminal-paste.test.tsmobile/src/session/use-mobile-terminal-paste.tsmobile/src/terminal/document/document-scope.tsmobile/src/terminal/document/document-terminal-shape.tsmobile/src/terminal/document/host-message-router.tsmobile/src/terminal/document/mode-mirroring.tsmobile/src/terminal/document/query-reply.tsmobile/src/terminal/document/terminal-init.tsmobile/src/terminal/mobile-terminal-query-reply.test.tsmobile/src/terminal/mobile-terminal-query-reply.tsmobile/src/terminal/terminal-accessory-keys.test.tsmobile/src/terminal/terminal-accessory-keys.tsmobile/src/terminal/terminal-key-mode-encoding.test.tsmobile/src/terminal/terminal-key-mode-encoding.tsmobile/src/terminal/terminal-webview-contract.tsmobile/src/terminal/terminal-webview-messages.tsmobile/src/terminal/terminal-webview-notification-dispatch.tsmobile/src/terminal/use-terminal-webview-controller.tsmobile/src/test-support/rpc-recording/adapters/session-terminal-gesture-mount-adapters.tsmobile/src/test-support/rpc-recording/adapters/session-terminal-input-mount-adapters.tsmobile/src/test-support/rpc-recording/adapters/terminal-mount-adapters.tssrc/main/runtime/rpc/methods/terminal/terminal-send-method.tssrc/main/runtime/rpc/terminal-send.test.tssrc/main/runtime/terminal/output/headless-terminal-state.tssrc/renderer/src/components/terminal-pane/pty-connection/apply-reattach-payload.tssrc/renderer/src/components/terminal-pane/pty-connection/hidden-output-seq-and-skip.tssrc/renderer/src/components/terminal-pane/pty-connection/reattach-payload-context.test.tssrc/renderer/src/components/terminal-pane/terminal-keyboard-runtime.tssrc/renderer/src/components/terminal-pane/terminal-shortcut-policy.tssrc/shared/terminal-kitty-keyboard-mode-tracker.tssrc/shared/terminal-modified-enter-encoding.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
-
3fddecf to
67f4ed6
Compare
The phone's xterm now tracks Kitty flags and modifyOtherKeys with desktop's tracker, seeded from the host snapshot.
26a1e12 to
bbd1b79
Compare
ELI5
When you paste into a terminal or press keys like Shift+Enter or the arrow keys on the phone, the phone now sends the same bytes the desktop app sends. Before, it had its own simpler rules, so a pasted prompt could submit early, Shift+Enter submitted instead of adding a newline, and arrow keys did nothing in some full-screen programs.
What Changed
wrapTerminalBracketedPasteText/normalizeTerminalPasteLineEndings(src/shared/terminal-bracketed-paste-text.ts), the same framing xterm'spaste()does on desktop.ESC[200~/ESC[201~markers stripped. A multi-line paste into OpenCode, vim insert mode or another full-screen app arrived as separate lines, so each newline acted as Enter.␛.terminal-shortcut-policy.tsintosrc/shared/terminal-modified-enter-encoding.ts; desktop calls it from the same place.\x17(delete word), not\b.CSI 27;2;13~when it armed modifyOtherKeys (Pi), elseESC CR. Before, it sent\r, which submits.TerminalKittyKeyboardModeTrackerover its output. It is seeded from the host snapshot'skittyKeyboardFlagswith the same rule desktop uses, now one sharedadoptSnapshotmethod that both call. The phone reports the result in its existingmodesmessage.modesmessage now carriesapplicationCursorKeysMode. Accessory keys, custom keys and hardware arrows sendESC O Aetc. while it is set, as xterm does, and keep CSI when Kitty flags are active, as xterm's Kitty encoder does. Before, they always sentESC [ A, whichless,mcand keypad-mode curses apps ignore.terminal.program-status.v1, as desktop gates it.shouldForwardHeadlessTerminalQueryReply: no OSC color replies for jcode, no XTVERSION for grok) to replies from the phone. Before, the phone answered jcode's color queries, which jcode can render as input ([Bug]: Raw OSC 10/11 color-query replies leak as text in Linux agent pane (opencode) #12112).Why
The audit found the phone re-implementing these rules and drifting from desktop. Each rule now has one copy in
src/shared(or on the host), and the phone calls it.Linked Issue
Part of the mobile/desktop parity audit
Visual Proof
N/A: this adopts desktop's existing behavior. The rules are
src/shared/terminal-bracketed-paste-text.ts,src/shared/terminal-modified-enter-encoding.ts, xterm's DECCKM key encoding,src/shared/program-status/query-responder.tsandsrc/main/runtime/headless-terminal-query-reply-policy.ts.Testing
Focused tests: mobile
src/session+src/terminal(377 files), desktopterminal-pane+terminal-send+ kitty tracker. New tests cover the paste frame in an alt-screen app, Shift+Enter/Ctrl+Backspace bytes, DECCKM/Kitty cursor encoding, and the program-status capability gate. No device run for this fleet.AI Disclosure
Review
Agent skill upstream boundary
Notes
Mobile behaviors removed:
\bfor Ctrl+Backspace and\rfor Shift+Enter in custom keys. Custom keys saved before this change keep their old bytes until re-created.Not done, and why:
CSI 13;5uexcept on local Windows ConPTY panes without evidence. A custom key is saved with no pane, and CSI-u would print as text in a Windows shell, so the phone keeps\r.Mixed versions:
kittyKeyboardFlags, and the tracker keeps what it saw live.modesfields stay inside the app.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)