Symptom
Scrolling the mouse wheel anywhere in the TUI dumps raw escape sequences into the composer line. Even a small wheel nudge produces a long run of \x1b[<...M / \x1b[<...m characters that the user then has to delete by hand.
Reported in #20 by @kaerstphone (comment).
Cause
We never call DECSET to enable mouse tracking, so the terminal stays in "report mouse events as stdin bytes" mode. Wheel events come in as SGR mouse reports (CSI < b ; x ; y M/m) and our line editor treats every byte as a keystroke.
Fix
Two layers, ship the cheap one first.
Step 1 (this patch). Recognize the SGR mouse-report prefix in the input pipeline and drop the whole sequence instead of inserting it. Same shape as the bracketed-paste guard we already have — short regex, no terminal-state changes. Stops the garbage cold and is safe on every host because we're not asking the terminal to do anything new.
Step 2 (later). Enable mouse tracking ourselves (DECSET 1000 + 1006) and route wheel events to scroll the card history. Nice for portrait layouts (#122's sidebar) but bigger scope — different terminals deliver different report formats, and we'd need to disable + restore the mode on suspend / exit. Track separately once step 1 is in.
Step 1 is half a day. Owner: me.
Symptom
Scrolling the mouse wheel anywhere in the TUI dumps raw escape sequences into the composer line. Even a small wheel nudge produces a long run of
\x1b[<...M/\x1b[<...mcharacters that the user then has to delete by hand.Reported in #20 by @kaerstphone (comment).
Cause
We never call DECSET to enable mouse tracking, so the terminal stays in "report mouse events as stdin bytes" mode. Wheel events come in as SGR mouse reports (
CSI < b ; x ; y M/m) and our line editor treats every byte as a keystroke.Fix
Two layers, ship the cheap one first.
Step 1 (this patch). Recognize the SGR mouse-report prefix in the input pipeline and drop the whole sequence instead of inserting it. Same shape as the bracketed-paste guard we already have — short regex, no terminal-state changes. Stops the garbage cold and is safe on every host because we're not asking the terminal to do anything new.
Step 2 (later). Enable mouse tracking ourselves (
DECSET 1000 + 1006) and route wheel events to scroll the card history. Nice for portrait layouts (#122's sidebar) but bigger scope — different terminals deliver different report formats, and we'd need to disable + restore the mode on suspend / exit. Track separately once step 1 is in.Step 1 is half a day. Owner: me.