fix(tui): add mouse scroll support to pager overlay#1716
Conversation
PagerView previously ignored mouse scroll events entirely. Terminals with mouse capture now get scroll-up/scroll-down (3 lines per tick) inside the pager, matching the transcript scroll granularity.
There was a problem hiding this comment.
Code Review
This pull request introduces mouse scroll support to the TUI pager, allowing users to navigate content using the mouse wheel. It also includes unit tests to verify the scrolling logic. Feedback was provided regarding a discrepancy between the scrolling logic and the rendering constraints; specifically, the ScrollDown implementation allows the scroll position to exceed the visual limit, creating a 'dead zone' that makes scrolling back up feel unresponsive.
| MouseEventKind::ScrollDown => { | ||
| let max_scroll = self.max_scroll(); | ||
| self.scroll_down(3, max_scroll); | ||
| self.pending_g = false; | ||
| ViewAction::None | ||
| } |
There was a problem hiding this comment.
The ScrollDown logic uses self.max_scroll(), which allows scrolling until only the last line is at the top of the view. However, the render function (line 399) clamps the scroll position to lines.len() - visible_height to ensure the screen remains full. This discrepancy creates a 'dead zone' at the bottom where the mouse wheel continues to increment self.scroll without visual feedback, making subsequent scrolling up feel unresponsive for several ticks. While this matches the existing keyboard behavior, it is particularly noticeable with mouse wheel scrolling. Consider calculating the visual limit using self.last_visible_height to avoid this discrepancy.
Make scroll a Cell<usize> so render() can clamp it back to the visual max on every frame. Previously scroll could overshoot the render limit, creating a dead zone where scrolling up from the bottom required multiple wheel ticks before content moved.
Bump workspace, inter-crate, and npm package versions 0.8.38 -> 0.8.39. Roll CHANGELOG [Unreleased] into [0.8.39] with all fixes: - Revert v0.8.38 /model picker rework (back to instant curated picker) - Restore approval grouping (lossy v0.8.37 logic for approvals, exact key for denials) - Thinking-only turn surface fix (#1727) - ACP server JSON-RPC id stringification (#1696) - Chat client: reasoning_content for generic providers (#1673) - Compaction: user text query preservation (#1704) - Engine: system prompt override survival (#1688) - Pager: G/End overshoot fix (#1706), mouse scroll (#1716) - Composer: scroll with text (#1677), multiline arrows (#1721) - macOS system theme detection (#1670) - rlm_open blank source fields (#1712) - Terminal resize paging fix (#1724) - Docker first-run permission (#1684) - README Rust 1.88+ requirement note (#1718) Tests: 3149 passed, 0 failed (deepseek-tui crate) clippy: clean on --all-targets --all-features
|
Thanks for the pager mouse-scroll patch. The useful slice was harvested into v0.8.39 via #1734 and credited in the changelog, so I am closing this PR to keep the queue clean. If latest still misses pager wheel events, please reopen with terminal details. |
Summary
Problem
The pager overlay ignored all mouse events. Users could only navigate with keyboard (j/k, PgUp/PgDn, Ctrl+D/U). This was inconvenient for users who prefer mouse-based scrolling.
Fix
Added
handle_mouseimplementation toPagerViewthat handlesScrollUpandScrollDownevents.Test plan
mouse_scroll_up_scrolls_contenttestmouse_scroll_down_scrolls_contenttest