fix(terminal): restore the mouse format with mouse tracking, so phone swipes don't type into Codex (#23946)

* fix(terminal): restore the mouse encoding with mouse tracking in every snapshot

Swiping to scroll Codex from the phone on a Windows host typed legacy
`ESC [ M` mouse reports into the Codex composer (#23818). SerializeAddon
re-arms mouse tracking (?1000h/?1002h/?1003h) but never the SGR encoding
(?1006h/?1016h). Any snapshot taken from a desktop pane's xterm (the
runtime seeds its headless model from it after a reattach, and serves it
to remote viewers when no model exists) therefore restored "tracking on,
legacy encoding", and the phone encoded wheel events as X10 bytes, which
ConPTY hands to Codex as keystrokes.

serializeWithAbsoluteCursor, the one wrapper every Orca snapshot producer
uses, now appends the encoding xterm itself parsed, read from xterm's
mouse state service. The daemon/runtime headless model reads tracking and
encoding from xterm too, so its regex mirror of the DECSET stream is
deleted (one source of truth; one less regex pass per PTY chunk).

Mixed versions: no wire field changes. A new host's snapshot carries an
extra DECSET that old desktop and phone clients already parse; an old
host's snapshot restores exactly as before. With tracking off the encoding
alone sends no reports, so the wheel still scrolls scrollback.

* test(terminal): pin the mouse-encoding read against the renderer xterm build

* fix(terminal): type the xterm mouse-state read behind named shapes
This commit is contained in:
Brennan Benson
2026-09-29 19:23:25 -07:00
committed by GitHub
parent 6b36a2c3fb
commit ad2e1b5efa
15 changed files with 274 additions and 190 deletions
-1
View File
@@ -1608,7 +1608,6 @@
"src/main/daemon/terminal-host-teardown-recreate.test.ts": 484,
"src/main/daemon/terminal-host-wsl-context.test.ts": 249,
"src/main/daemon/terminal-host.test.ts": 691,
"src/main/daemon/terminal-mouse-tail-retention.test.ts": 171,
"src/main/daemon/terminal-session-teardown.test.ts": 95,
"src/main/daemon/terminal-shell-armed-input-mode-recovery.test.ts": 215,
"src/main/daemon/terminal-shell-lifecycle-scanner.test.ts": 56,
@@ -5,7 +5,7 @@
// CSI strip against the shipped shape (256KB tail + shared CSI_SEQUENCE_PATTERN). Every
// variant is asserted to agree with the baseline before it is timed.
// 2. TerminalKittyKeyboardModeTracker.scanReplay — measured to justify leaving it alone, and
// to record that porting the daemon mouse mirror's includes() pre-filter makes it slower.
// to record that an includes() introducer pre-filter makes it slower.
//
// Payloads are generated deterministically (LCG, no Math.random) so runs compare.
//
@@ -214,7 +214,7 @@ const kittyScan = (data) => {
tracker.scanReplay(data)
return tracker.flags
}
// Mirrors src/main/daemon/terminal-mouse-mode-mirror.ts:41-47.
// The includes() introducer pre-filter a daemon-side mode scan would use.
const kittyGated = (data) => {
if (!data.includes('\x1b[?') && !data.includes('\x1bc') && !data.includes('\x9b')) {
return 0