Skip to content

mecatui: coalesce smooth wheel input and avoid Agents scroll backlog #1790

Open

Description

@jbeda

Problem

Smooth trackpad scrolling on macOS produces a burst of tea.MouseWheelMsg events. Mecatui currently maps each event to one physical-line move and performs layout/render work serially. If input arrives faster than processing, events queue and the list keeps scrolling after the gesture stops.

The existing renderInterval coalescer applies only to streamed assistant deltas, not wheel input.

Agents is especially costly: onAgentsWheel rebuilds overlay geometry, probes normal-body fit, configures/replaces list items, computes indicator-adjusted layout, scrolls one line, then computes indicator-adjusted layout again for every raw event.

Scope

  • Add a shared owner-aware wheel-burst policy at the root dispatch layer: modal -> Agents -> conversation.
  • Coalesce same-direction wheel bursts into bounded net physical-line movement per frame; cancel opposing movement; prevent delayed catch-up after the gesture ends.
  • Preserve visible-owner isolation: wheel events cannot leak into the conversation viewport.
  • Make modal surfaces and the future Agents-surface migration use the same policy.
  • Migrate the /sessions inventory once its bounded.List adoption in mecatui: migrate sessions inventory to bounded.List #1895 lands: wheel over a visible normal Sessions inventory must use this shared policy to move only its physical viewport, never its selected session, and must not leak to the conversation. The short-geometry Close-only fallback remains static and consumes the wheel.
  • In the same follow-on (not mecatui: migrate sessions inventory to bounded.List #1895), add frame-scoped click-to-select for the normal Sessions inventory: clicking any visible physical line of a session row changes the selected session and minimally reveals it, but never continues, inspects, copies, forks, renames, or deletes it. Clicks on chrome, overflow indicators, blank trailing space, compact fallback, stale frames, or closed surfaces are ignored.
  • Reduce Agents work so a burst requires one geometry/layout reconciliation around the net move rather than repeated ViewWithIndicators passes per raw event.
  • Keep keyboard paging and one-event mouse-wheel semantics testable; do not change selection while physically scrolling.

Proof

Add reducer-level coverage for a burst of wheel messages that demonstrates bounded rendering/application, no post-gesture catch-up, correct net direction, and owner isolation. Include representative multiline Agents and Sessions rosters with overflow indicators. Sessions coverage must prove the selected session is unchanged, the physical viewport moves only on the normal inventory surface, and compact/fallback Sessions wheel input neither changes hidden selection nor leaks to the conversation. It must also prove that a current-frame click on each visible physical line selects only that row without activation, while chrome, indicators, blank space, fallback, stale-frame, and closed-surface clicks are inert.

Relates to #555, #1589, #1895, and #1273. The same queueing/render-cost patterns may overlap with #1273's long-transcript viewport profiling work; compare measurements and share any applicable coalescing or render-budget mechanisms rather than introducing two independent schedulers.

Activity

  1. self-assigned this
    on Sep 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions