Batch mouse wheel scrolling in the TUI (#62146)

## Why

Rapid wheel input can trigger a synchronous transcript redraw for each tick, even when the current layout can still be used.

## What changed

Accumulate wheel movement in the main transcript and side panes until the next frame when the rendered layout is safe to reuse. Refresh first when the transcript has changed, cached content can change height, or the side pane has buffered reply text. Refresh immediately when toggling side-pane zoom so subsequent mouse events use the new layout.

Start composer scrolling from the caret-adjusted viewport after an edit so wheel ticks can accumulate before the next frame.

## Testing

Cover wheel bursts while the plan menu is open, composer scrolling after edits, refresh requirements for mutable history and buffered side replies, and immediate layout updates when toggling side-pane zoom.

GitOrigin-RevId: 342d4d4c014d8a41b2e690b91622197ee97fc059
This commit is contained in:
Benjamin Carlsson
2026-11-18 00:58:27 +00:00
committed by copyberry
parent 67d8266e06
commit 2f5c413e19
12 changed files with 157 additions and 19 deletions
+12 -2
View File
@@ -179,6 +179,17 @@ impl Default for TranscriptView {
}
impl TranscriptView {
pub(crate) fn can_scroll_without_refresh(
&self,
cells: &[Arc<dyn HistoryCell>],
live_key: Option<ActiveCellTranscriptKey>,
) -> bool {
!self.area.is_empty()
&& !self.cache.has_mutable_source()
&& self.last_tail == cells.last().map(EntryKey::cell)
&& self.live_key.map(|(_, key)| key) == live_key
}
/// Rows left after the last render, including all startup notices and live entries.
/// Callers can paint temporary UI here without changing selection or saved history.
pub(crate) fn remaining_area(&self) -> Rect {
@@ -688,8 +699,7 @@ impl TranscriptView {
}
// Anchor visible content, not a hidden header that stays ahead of every older page.
let index = self.next_nonempty(cells, index).unwrap_or(index);
let bottom = self.bottom_start(cells);
if rows > 0 && (index, row) >= bottom {
if rows > 0 && (index, row) >= self.bottom_start(cells) {
if self.selection.is_none() && !self.search.is_active() {
self.jump_to_latest();
} else {