Skip to content

perf(list): virtualize the results list #98

Closed

Description

@Ardnived

Summary

The release-readiness review (.claude/reports/RELEASE_READINESS.md §1.3, Appendix A — local, gitignored) found the results list unvirtualized: every revealed row is a live DOM subtree, and the only bound is the hard ceiling of MAX_REVEAL = 1,000 rows — which the list auto-pages toward on scroll. At the ceiling that is 1,000 mounted card subtrees, each with EventFacts/EventChips and their hooks. The existing mitigations are real but not a fix: EventListItem is the repo's only React.memo (EventListItem.tsx:123) and reveals run inside useTransition. This ticket adds windowed rendering — or, as the honest documented fallback, lowers MAX_REVEAL.

Scope flag, stated up front: this is the largest of the perf tickets. The list lives inside a vaul drawer whose scroll container the virtualizer must measure against; if the virtualizer fights vaul's scroll container, the sanctioned fallback is a lower MAX_REVEAL plus a written decision in the implementation report — not a half-working virtualizer.

Current behavior

  • MAX_REVEAL = PAGE_SIZE * 40 = 1,000 (src/lib/shape/reveal.ts:38,59); revealRows slices the sorted set to it (reveal.ts:180). All revealed rows render as real DOM.
  • Auto-paging: an IntersectionObserver in LoadMore (src/components/organisms/EventsList/LoadMore.tsx:92-101) advances the reveal as the control scrolls into view — armed only while more === 'more' && !showAll; the distant segment is always an explicit press.
  • Mitigations in place: EventListItem memoized (src/components/molecules/EventListItem/EventListItem.tsx:123), reveal advances in useTransition, aria-busy (never disabled) on the control plus a polite live region (LoadMore.tsx, covered by LoadMore.test.tsx).

Proposed changes

Windowed rendering for the results list (EventsList / DynamicEventsList):

  • Evaluate @tanstack/react-virtual — small, headless, fits the existing DOM structure (ul > li rows inside the drawer's scroll container) — vs. simply lowering MAX_REVEAL as the documented fallback decision. The implementer owns this call; record it either way.
  • Standard virtualizer hygiene: overscan, and focus handling so the focused row is never unmounted under the user.

MUST preserve, whichever path is taken:

  1. Reveal/position-restore semantics: useReveal is store-keyed by revealKey so the paging position survives drawer remounts (open an event, come back, still deep in the list) and resets by construction on a new search/filter/sort key — see .claude/rules/i18n-and-state.md §useResultsReveal. Virtualization changes what's mounted, not what's revealed; don't collapse the two.
  2. The LoadMore boundary behavior: auto-page within the nearby segment; reaching the distant segment is always an explicit "Show distant events" press; the label keeps saying "distant" for every page after it.
  3. aria-busy semantics and the polite live region (keyboard users keep focus on the control; LoadMore.test.tsx covers this — keep it green).
  4. Hover prefetch + pin-highlight handlers per row (activate/highlightEvent on the card).
  5. Keyboard focus across virtualization: the focused row must not be unmounted under the user (overscan/focus-retention), and the data-event-row focus move onto the first newly revealed card after a reveal press must still work.

Acceptance criteria

  • With the list revealed to a large count (e.g. ≥ 500 rows), the mounted DOM row count is bounded by viewport + overscan, not by the reveal count — or the fallback decision (lower MAX_REVEAL) is taken and documented with reasoning in the implementation report.
  • Position restore preserved: open an event from deep in the list, navigate back, the list is still revealed to the same depth (store-keyed by revealKey; no reset call added to filters/sort — the reset stays by-construction).
  • Auto-page + explicit-press boundary preserved: nearby segment auto-pages via the observer; the distant segment requires the explicit press; labels unchanged.
  • aria-busy + live-region semantics preserved; existing LoadMore.test.tsx passes unmodified or with edits justified in the report.
  • Hover prefetch and pin-highlight still fire for every visible row.
  • Keyboard: a focused row is never unmounted while focused; post-reveal focus move (data-event-row) still lands on the first new card.
  • If a new dependency is added, it's justified in the report (size, maintenance) and pnpm-lock.yaml is regenerated via pnpm install.
  • pnpm lint && pnpm typecheck && pnpm test:run pass.
  • Write an implementation report to .claude/reports/<issue-number>-virtualize-list.md — in the MAIN checkout at /Users/devindra/Documents/Projects/SahajAtlasWeb even when implementing from a worktree (the folder is gitignored) — covering what changed, what was deliberately NOT changed, and which readiness-report findings are resolved.

Files affected

  • src/components/organisms/EventsList/ — EventsList.tsx, DynamicEventsList.tsx, LoadMore.tsx (+ co-located stories/tests)
  • src/lib/shape/reveal.ts
  • pnpm-lock.yaml — shared file; conflicts with sibling tickets are resolved by re-running pnpm install

Parallel implementation: this ticket OWNS the files above; sibling release-hardening tickets run concurrently. Avoid edits outside owned files except strictly additive ones. Note EventListItem.tsx is cited as evidence but is owned by the sibling caching/prefetch ticket — its handlers must keep working from this list, but edits to it belong there.

References

  • .claude/reports/RELEASE_READINESS.md §1.3, §1.6 (recommendation 5), Appendix A (local, gitignored)
  • Reveal semantics: .claude/rules/i18n-and-state.md §useResultsReveal (why paging position survives drawer remounts, why reset is by-construction)
  • src/lib/shape/reveal.ts:38,59,180 (PAGE_SIZE, MAX_REVEAL, the slice); LoadMore.tsx:92-101 (observer); EventListItem.tsx:123 (the repo's one React.memo)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Hold Until

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions