Repository navigation
Conversation
lmdc45
force-pushed
the
fix/serialize-mouse-modes
branch
from
November 16, 2026 06:16
63d8f70 to
2b4b7cb
Compare
SerializeAddon re-emitted mouse tracking (?9/?1000/?1002/?1003) but never the encoding (?1006 SGR / ?1016 SGR-pixels), so a serialized+replayed terminal reported mouse in the legacy single-byte encoding. Expose modes.mouseEncodingMode (browser + headless) and serialize it when non-default; consumers that must drop mouse modes can append DECRSTs after the replay since modes serialize last. Tests: unit (SGR, SGR-pixels, default-omitted, reset-noop, both round-trips), integration exact-string cases, headless getter + defaults, browser Playwright defaults key + per-mode h/l toggles. Mode tests sit in IModes-alphabetical order in every suite.
lmdc45
force-pushed
the
fix/serialize-mouse-modes
branch
from
November 16, 2026 09:03
2b4b7cb to
ea59ce9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
SerializeAddonserializes the mouse tracking mode (?1000/?1002/?1003) but not the mouse encoding (?1006SGR /?1016SGR-Pixels). Replaying a serialized terminal that used SGR mouse reporting therefore re-enables tracking with the default single-byte encoding: the application receives X10-style bytes instead of SGR sequences, and mouse input breaks until the application re-asserts?1006itself.This is observable in VS Code's persistent terminal replay (window reload): the replayed TUI gets
?1002hback but never?1006h. From the review of microsoft/vscode#326121:Change
IModes.mouseEncodingMode('default' | 'sgr' | 'sgr-pixels') — new readonly field on the publicmodesAPI, mirroring the existingmouseTrackingModeshape, wired through both the browser and headlessTerminalimplementations fromMouseStateService.activeEncoding, and declared intypings/xterm.d.tsandtypings/xterm-headless.d.ts.?1006h/?1016h), after the tracking mode — the same skip-when-default convention every other mode in_serializeModesfollows.The three-value union is complete:
?1005/?1015(UTF-8/urxvt encodings) are unimplemented inInputHandler(only debug-logged; DECRQM reports them as permanently reset), soactiveEncodingcan only ever beDEFAULT/SGR/SGR_PIXELS.Consumers that replay into a context where the process owning the mouse modes is gone (e.g. VS Code replays a persistent terminal after a full-screen TUI child exited without resetting modes) can strip the mouse modes by appending the DECRSTs themselves — modes are serialized at the end of the output, so a trailing
\x1b[?1000l\x1b[?1006l…reliably lands after them. No new option is needed for that.Tests
addons/addon-serialize/src/SerializeAddon.test.ts): SGR and SGR-pixels emitted; default encoding omitted; nothing emitted after the encoding is reset (?1006hthen?1006l); round-trip replay restoresmouseTrackingMode: 'drag'+mouseEncodingMode: 'sgr', and a SGR-pixels round-trip restoressgr-pixels.addons/addon-serialize/test/SerializeAddon.test.ts): same coverage through the browser terminal.src/headless/public/Terminal.test.ts):modes.mouseEncodingModeset/reset by?1006h/?1016h/DECRST, and thedefaultsdeep-equal updated.Gates:
npm run test-unit(2452 passing),npm run lint,npm run lint-api— all clean.