fix(tui): drop ESC-stripped SGR mouse reports instead of inserting them#872
Merged
Conversation
ConPTY occasionally strips the leading ESC off CSI sequences. Mouse reports — `\x1b[<btn;col;rowM/m` — then arrive in the byte stream as `[<btn;col;rowM/m`, slip past the escapeless-CSI lookahead (which only knows arrow / page tails), and fall into the printable accumulator. The composer receives the literal SGR text and the user has to backspace through every wheel nudge. Add `tryEscapelessSgrMouse` alongside the existing escapeless-paste and escapeless-arrow guards. Recognised reports dispatch the same mouseScroll/Click/Drag/Release events the with-ESC path already emits; unmapped buttons are consumed and dropped. Share `decodeSgrMouseBody` with `dispatchCsi` so both paths surface the same shape. Closes #867
ChasLui
pushed a commit
to ChasLui/DeepSeek-Reasonix
that referenced
this pull request
May 23, 2026
…em (esengine#872) ConPTY occasionally strips the leading ESC off CSI sequences. Mouse reports — `\x1b[<btn;col;rowM/m` — then arrive in the byte stream as `[<btn;col;rowM/m`, slip past the escapeless-CSI lookahead (which only knows arrow / page tails), and fall into the printable accumulator. The composer receives the literal SGR text and the user has to backspace through every wheel nudge. Add `tryEscapelessSgrMouse` alongside the existing escapeless-paste and escapeless-arrow guards. Recognised reports dispatch the same mouseScroll/Click/Drag/Release events the with-ESC path already emits; unmapped buttons are consumed and dropped. Share `decodeSgrMouseBody` with `dispatchCsi` so both paths surface the same shape. Closes esengine#867
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.
Summary
\x1b[<btn;col;rowM/m— then arrive in the byte stream as[<btn;col;rowM/m, slip past the escapeless-CSI lookahead (which only knows arrow / page tails), and fall into the printable accumulator. The composer ends up with the literal SGR text on every wheel nudge.tryEscapelessSgrMousealongside the existing escapeless-paste / escapeless-arrow guards. Recognised reports dispatch the samemouseScroll*/mouseClick/mouseDrag/mouseReleaseevents the with-ESC path already emits; unmapped buttons are consumed and dropped silently.decodeSgrMouseBodysodispatchCsiand the new escapeless path share the button-decoding table.This is the cheap step described in the issue — no DECSET state changes, no terminal-mode requests, just stop the garbage at the parser. Mouse-tracking enablement (DECSET 1000 + 1006) stays a separate, larger change.
Test plan
tests/stdin-reader.test.ts: with-ESC wheel up/down, click press+release, unmapped-button drop, ESC-stripped wheel, burst of ESC-stripped reports, printable text adjacent to a report, ESC-stripped unmapped button, and a literal[<not-a-mouse-reportthat must arrive intact as text.tests/comment-policy.test.tsclean.tsc --noEmitclean.Closes #867