Skip to content

refactor(gui): replace GridRevealState with visibility-aware reveal#110

Merged
StudentWeis merged 3 commits into
mainfrom
refactor/remove-grid-reveal-state
May 9, 2026
Merged

refactor(gui): replace GridRevealState with visibility-aware reveal#110
StudentWeis merged 3 commits into
mainfrom
refactor/remove-grid-reveal-state

Conversation

@StudentWeis
Copy link
Copy Markdown
Owner

Summary

Removes GridRevealState and the force_reveal_* / suppress_grid_auto_reveal plumbing in favor of a single, idempotent reveal_selected_record() that mirrors the "skip if already visible" semantics list mode already gets from ListState::scroll_to_reveal_item. Eliminates a cross-event mutation (every wheel tick used to write to board state) and shrinks RopyBoard's state surface.

Linked Issue

Closes #109

Changes

  • Add masonry::board_selected_card_is_visible() plus a pure helper masonry_selected_card_fully_visible(..) driven by a MasonryColumnSpec, with unit tests covering visible / scrolled-away / scrolled-to-match / out-of-range cases.
  • Make RopyBoard::reveal_selected_record() consult that helper in grid mode and only call grid_scroll_handle.scroll_to_item when the selection is actually off-screen.
  • Drop GridRevealState, UiState::grid_reveal, UiState::grid_auto_reveal_enabled(), force_reveal_selected_record(), and suppress_grid_auto_reveal(). All seven previous force_reveal_* call sites now invoke reveal_selected_record() directly.
  • Remove the on_scroll_wheel handler on the masonry scroll container — wheel scrolling no longer mutates board state.
  • Add docs/SELECTION_REVEAL_ANALYSIS.md, the first-principles analysis that motivates this refactor.

Testing

  • scripts/precheck.sh passes locally (clippy, 428 unit tests, machete, i18n / icons / themes).
  • New / updated tests cover the change (test_selected_card_visible_when_inside_viewport, test_selected_card_not_visible_when_user_scrolled_away, test_selected_card_visible_after_user_scrolled_to_match_selection, test_selected_card_visibility_handles_empty_or_out_of_range).

Self-Check

  • PR title follows Conventional Commits
  • No hardcoded user-facing strings — i18n keys added to all locale files (no UI strings touched)
  • New UI components use gpui-component (no new UI components)
  • Errors defined with thiserror (no new error types)
  • No unrelated changes mixed in

Drop GridRevealState, force_reveal_selected_record, and
suppress_grid_auto_reveal in favor of an idempotent reveal_selected_record
that consults the new masonry::board_selected_card_is_visible helper.
Mirrors the skip-if-already-visible semantics ListState already provides
for list mode, so background re-renders no longer yank the viewport away
from where the user is looking.

Refs #109
gpui's ScrollHandle::scroll_to_item already implements 'skip if already
visible' via ScrollStrategy::FirstVisible (see gpui-0.2.2 div.rs
scroll_to_active_item). The board_selected_card_is_visible helper added
in the previous commit was a less precise reimplementation built on
estimated card heights, so it could disagree with the framework at the
pixel level.

Inline the grid arm of reveal_selected_record() to a direct
scroll_to_item call and remove the helper, MasonryColumnSpec, the pure
masonry_selected_card_fully_visible function, and the four supporting
unit tests. Documents the discovery in SELECTION_REVEAL_ANALYSIS.md as a
postscript so the reasoning is recoverable.

Refs #109
@StudentWeis StudentWeis merged commit bc8c0ae into main May 9, 2026
8 checks passed
@StudentWeis StudentWeis deleted the refactor/remove-grid-reveal-state branch May 9, 2026 07:40
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.

refactor: remove GridRevealState in favor of visibility-aware reveal

1 participant