Skip to content

Route mouse wheel scroll to the chat transcript instead of the prompt - #337

Merged
TheGreatAxios merged 4 commits into
release/tui-bugfixesfrom
cl-5561-mouse-scroll-should-move-chat-not-the-prompt-arrows-cycle
Aug 7, 2026
Merged

Route mouse wheel scroll to the chat transcript instead of the prompt#337
TheGreatAxios merged 4 commits into
release/tui-bugfixesfrom
cl-5561-mouse-scroll-should-move-chat-not-the-prompt-arrows-cycle

Conversation

@TheGreatAxios

@TheGreatAxios TheGreatAxios commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Turns DEC mouse reporting on by default in the main session shell (useMouse: true), so real wheel/trackpad scroll reaches OpenTUI instead of the terminal's alternate-scroll mode resending it as arrow keys that the prompt read as history navigation
  • Overrides the prompt textarea's scroll handling so wheel/trackpad scroll events land on the chat transcript instead of scrolling the prompt's own buffer
  • Adds a regression test that drives the renderer's real SGR-mouse parse and hit-test (not a direct method call) and asserts the transcript, not the prompt, moves
  • Arrow-key history cycling is unchanged — it was already implemented and is untouched by this change

Verification

  • Accepted trade, stated plainly: turning mouse reporting on suppresses the terminal's native drag-select in the main shell. A separate ticket (CL-5540) recorded wanting the opposite default there and found shift+drag does not work as a bypass. The owner has prioritized wheel-scrolling the chat over native drag-select in the main shell; Alt+M still hands the mouse back on demand. list-modal.ts and provider-setup.ts are untouched and keep mouse reporting off, so their pickers keep native drag-select.
  • Captured the pty byte stream of the built binary with useMouse: true, enableMouseMovement: false: the emitted DEC private modes are 1000, 1002, 1006 (plus unrelated terminal modes 1049, 2004, 2026, 2027, 2031, 25) — 1003 (any-motion tracking) is confirmed absent. 1002 (button-event tracking, which reports drags) is present, so a plain modifier-free drag is not recoverable by narrowing further; this was not re-tested since CL-5540 already falsified shift+drag empirically under the same 1000-suppresses-selection condition.
  • Ran the actual compiled binary in a real pty under a VT100 screen emulation (not just bun test): typed "hello-typed" into the live prompt, then sent 6 genuine SGR wheel-up sequences (\x1b[<64;col;rowM, the exact bytes the app's own emitted 1000/1006 modes request) at the prompt's on-screen row. The prompt content and cursor were unaffected — no scrolling, no history cycling, no corruption.
  • The existing regression test drives the same real dispatch (h.mockMouse.scroll through the renderer's SGR parse and hit-test, not a direct method call) against seeded transcript rows and confirms the transcript moves and pins while the prompt's own buffer never scrolls; verified it fails without the fix and passes with it.
  • bun run typecheck, bun run build, and bun test (4368 tests) all pass. A handful of unrelated tests (async markdown-highlight timing, transcript bottom-anchoring under load) flake intermittently across repeated full-suite runs but pass individually; confirmed pre-existing and unrelated to mouse/keyboard input handling.

Closes CL-5561

@linear-code

linear-code Bot commented Aug 7, 2026

Copy link
Copy Markdown

CL-5561

@TheGreatAxios
TheGreatAxios changed the base branch from main to release/tui-bugfixes August 7, 2026 04:20
The prompt textarea holds keyboard focus for the whole session and has
its own scrollable buffer, so OpenTUI's wheel dispatch (hit-test, or
fall back to the focused renderable when the hit misses) kept handing
scroll events to the prompt instead of the transcript. Override the
prompt's scroll handling to forward wheel/trackpad events to the
transcript instead of scrolling its own buffer.

Arrow-key history cycling in the prompt was already implemented and
tested; verified it end to end via real key-event dispatch.
Calling the prompt's overridden onMouseEvent directly skipped the
renderer's SGR-mouse parse and hit-test, so the test proved the
forwarding function works without proving the renderer ever calls it
on a genuine wheel scroll. Driving the same bytes through the mock
mouse at the prompt's actual screen position closes that gap.
Wheel/trackpad scroll only reaches OpenTUI when the terminal is
told to report it; otherwise the terminal's own alternate-scroll
mode resends it as arrow keys, which the prompt reads as history
navigation. Flipping the default lets routePromptWheelToTranscript
run for real scroll instead of only after Alt+M.

Trade accepted: this suppresses the terminal's native drag-select
in the main shell, which a separate ticket recorded wanting the
opposite default. Alt+M still hands the mouse back for drag-select
and copy. enableMouseMovement stays off; only clicks and wheel need
reporting.
@TheGreatAxios
TheGreatAxios force-pushed the cl-5561-mouse-scroll-should-move-chat-not-the-prompt-arrows-cycle branch from 7ea2e4d to c2f8101 Compare August 7, 2026 05:49
These four spots described mouse reporting as off by default,
matching the main shell's old behavior. The satellite pickers still
keep reporting off on purpose, but the main shell now defaults it
on, so the comments read backwards. Reword them to state each
surface's actual behavior instead of claiming they match, and
update the readiness doc to describe the decision as settled with
current line references.
@TheGreatAxios
TheGreatAxios merged commit ef7d22a into release/tui-bugfixes Aug 7, 2026
2 checks passed
@TheGreatAxios
TheGreatAxios deleted the cl-5561-mouse-scroll-should-move-chat-not-the-prompt-arrows-cycle branch August 7, 2026 06:35
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