Skip to content

fix: disable mouse reporting so wheel sequences can't leak into search#18

Merged
brtkwr merged 1 commit into
mainfrom
fix/mouse-report-leak
Jun 30, 2026
Merged

fix: disable mouse reporting so wheel sequences can't leak into search#18
brtkwr merged 1 commit into
mainfrom
fix/mouse-report-leak

Conversation

@brtkwr

@brtkwr brtkwr commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Problem

Typing a query and scrolling the mouse wheel over the results inserted escape sequences like [<65;36;40M straight into the search box. It only happened with results on screen, because the heavier frame (results + preview) lets the terminal emit SGR mouse-wheel reports faster than bubbletea reads them - batched reads parse the first as a MouseMsg and leak the fragmented trailing reports through as typed runes (e.g. a ;36;40M tail plus repeated [<65;36;40M).

A content filter on the input was tried first but can't reliably catch these - they arrive split across reads, so partial fragments slip past any pattern match.

Fix

Disable mouse reporting entirely (drop tea.WithMouseCellMotion). The terminal then never sends mouse sequences, so there's nothing to leak - a certain fix rather than a best-effort filter.

Scrolling is keyboard-only now, which already covered everything:

  • list: ↑/↓ or Ctrl+P/N
  • preview: Ctrl+J/K or PgUp/PgDn

Removes the now-dead MouseMsg handler, mouseInPreview state, its test, and the mouse-wheel mentions in --help / README. Net -84 lines.

Trade-off

Loses mouse-wheel scrolling. Given it was actively corrupting the search input and keyboard scrolling fully covers the use case, that's the right call. If wheel scroll is wanted back later, it'd need a bubbletea version/input-handling that doesn't fragment mouse reports under load.

Verify

go build, go test, go vet all pass; coverage 62.7%.

Scrolling the mouse wheel over results could insert escape sequences
like "[<65;36;40M" into the search box. With mouse reporting enabled, a
heavy frame (results + preview) lets the terminal emit SGR mouse reports
faster than bubbletea reads them; batched reads leak the fragmented
trailing reports through as typed runes. A content filter can't reliably
catch them because they arrive split across reads.

Disable mouse reporting entirely (drop tea.WithMouseCellMotion) so the
terminal never sends mouse sequences - nothing to leak. Scrolling is
keyboard-only now (arrows / Ctrl+P/N for the list, Ctrl+J/K or
PgUp/PgDn for the preview), which already covered every action. Removes
the now-dead MouseMsg handler, mouseInPreview state, its test, and the
mouse-wheel mentions in help/README.
@brtkwr brtkwr merged commit 1155348 into main Jun 30, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant