Skip to content

fix(tui): preserve fragmented terminal mouse reports - #457

Merged
gaobrian merged 3 commits into
mainfrom
fix/tui-fragmented-terminal-input
Dec 1, 2026
Merged

gaobrian merged 3 commits into
mainfrom
fix/tui-fragmented-terminal-input

Conversation

@gaobrian

@gaobrian gaobrian commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Problem

On macOS terminal sessions, rapid two-finger trackpad scrolling can leak SGR mouse-report tails such as [<65;100;24M into the composer. The previous TUI wheel batching change (#456) cannot fix this parser-level failure.

Root cause

BSH currently resolves Crossterm 0.29.0 from crates.io through Ratatui. On Unix, a short terminal read can end immediately after the ESC byte of an SGR mouse sequence. The old reader treated that short read as the end of available input, emitted ESC as a standalone key, and subsequently exposed the remainder of the mouse report as text.

This matches the observed symptom and is independently reproduced in the Crossterm regression report/fix. The pinned revision below changes both Unix readers to retain the ambiguous ESC briefly and adds split-report and ESC-followed-by-mouse regression tests.

Change

  • Pin Crossterm to reviewed commit 37ca4a27a9424ec5dbe6451f48c339d7b45f8d63 through workspace [patch.crates-io].
  • Update Cargo.lock to the exact git revision.
  • No BSH Runtime, GUI, TUI UX, or protocol behavior changes.

Validation

  • Dependency revision contains deterministic Unix event-source regression tests for split SGR mouse reports and ESC followed by a mouse report.
  • Repository CI and the macOS Ghostty two-finger trackpad reproduction are still required before merge.
  • This PR is intentionally draft; it addresses the confirmed input-parser defect, not a claim that the entire TUI has been proven bug-free.

Acceptance

  • Fragmented SGR wheel reports are delivered only as mouse events, never composer characters or standalone Escape events.
  • Existing keyboard, paste, terminal restore, and cross-platform TUI checks remain green.
  • Manual macOS verification: rapid two-finger scroll, immediate direction reversal, top/bottom boundaries, and active streaming.

@gaobrian
gaobrian marked this pull request as ready for review December 1, 2026 03:53
@gaobrian
gaobrian merged commit 9d9dc34 into main Dec 1, 2026
2 of 6 checks passed
@gaobrian
gaobrian deleted the fix/tui-fragmented-terminal-input branch December 1, 2026 03:53
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