Skip to content

fix: stabilize Live Activity infinite scroll pagination#1056

Open
nickmopen wants to merge 2 commits into
entrius:testfrom
nickmopen:fix/live-activity-infinite-scroll-pagination
Open

fix: stabilize Live Activity infinite scroll pagination#1056
nickmopen wants to merge 2 commits into
entrius:testfrom
nickmopen:fix/live-activity-infinite-scroll-pagination

Conversation

@nickmopen
Copy link
Copy Markdown
Contributor

@nickmopen nickmopen commented May 12, 2026

Summary

Fixes the Live Activity infinite scroll on the Dashboard that would enter an endless loading loop when scrolling at a moderate pace.

Note: This PR addresses Issue 1 (infinite scroll) from #685. Issue 2 (repo table chart showing incorrect bar heights / empty bars when sorting by Weight with Log Scale enabled) was investigated but could not be reproduced — the chart behaved correctly under all tested conditions (ascending, descending, log scale on/off). No changes were made for Issue 2.

Two root causes addressed for Issue 1:

  • DashboardApi: getNextPageParam was using allPages.length + 1 to derive the next page number. During a background refetchInterval refetch, allPages is rebuilt page-by-page and can be shorter than expected when getNextPageParam is evaluated, causing a stale/incorrect page number to be requested. Changed to lastPageParam + 1 which is always the canonical value.

  • LiveCommitLog: The IntersectionObserver had isFetchingNextPage and visibleEntries.length in its dependency array. Every time a page loaded, the effect would teardown and recreate the observer — which would immediately fire if the sentinel element was still in the viewport, bypassing the in-flight guard and triggering another fetchNextPage(). This created the infinite request loop. Replaced with a debounced scroll handler (120ms) that checks a fixed pixel distance from the bottom of the container, with a fetchInFlightRef flag to prevent concurrent fetches. Removes the sentinel DOM element entirely.

Related Issues

See #685 (Issue 1 only — Issue 2 not reproducible, no changes made)

Type of Change

  • Bug fix
  • New feature
  • Refactor
  • Documentation
  • Other (describe below)

Screenshots

before

Screen.Recording.2026-05-11.at.8.30.27.PM.mov

after

Screen.Recording.2026-05-11.at.8.29.46.PM.mov

Checklist

  • New components are modularized/separated where sensible
  • Uses predefined theme (e.g. no hardcoded colors)
  • Responsive/mobile checked
  • Tested against the test API
  • npm run format and npm run lint:fix have been run
  • npm run build passes
  • Screenshots included for any UI/visual changes

- DashboardApi: use lastPageParam+1 in getNextPageParam instead of
  allPages.length+1, which could return a stale page number during
  background refetch cycles
- LiveCommitLog: replace IntersectionObserver with a debounced scroll
  handler (120ms) that checks distance from bottom in fixed pixels.
  Adds fetchInFlightRef to prevent concurrent fetches. Removes sentinel
  DOM element.
@xiao-xiao-mao xiao-xiao-mao Bot added the bug Something isn't working label May 12, 2026
Copy link
Copy Markdown
Collaborator

@anderdc anderdc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Three things to address before merge:

  • src/pages/dashboard/views/LiveCommitLog.tsx: the scrollDebounceRef timeout is never cleared on unmount. Add a cleanup effect that clears the pending timeout.
  • LiveCommitLog.tsx: the scroll handler only fires on a real scroll event, so if the first page doesn't fill the container there's nothing to trigger fetchNextPage and more pages can't load. Handle the not-scrollable case — the IntersectionObserver this replaces covered it automatically.
  • PR body: "Fixes #685" will auto-close the issue on merge while Issue 2 (repo bar chart) is still unaddressed. Reference #685 without the closing keyword so it stays open for Issue 2.

@nickmopen nickmopen requested a review from anderdc May 16, 2026 02:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants