Problem
Pagination on the workspace command activity/history page is unstable: navigating between pages can jump or reset back to page 1, especially while data is refetching.
Root cause
The page query key includes page. When the page changes, React Query temporarily has no data for the new key. The UI derives totalPages as 1 from missing data, and the effect if (page > totalPages) setPage(totalPages) immediately clamps the requested page back to 1 before the fetch completes.
Live invalidation/refetch can make the behavior appear even more erratic.
Fix
- Keep previous command-history data while a pagination request is in flight.
- Do not clamp
page using placeholder data; only clamp once real data for the current request arrives.
- Add regression coverage for navigating to another page during loading/refetch.
This should keep pagination stable while preserving the existing correction when a real response reports fewer pages.
Problem
Pagination on the workspace command activity/history page is unstable: navigating between pages can jump or reset back to page 1, especially while data is refetching.
Root cause
The page query key includes
page. When the page changes, React Query temporarily has no data for the new key. The UI derivestotalPagesas 1 from missing data, and the effectif (page > totalPages) setPage(totalPages)immediately clamps the requested page back to 1 before the fetch completes.Live invalidation/refetch can make the behavior appear even more erratic.
Fix
pageusing placeholder data; only clamp once real data for the current request arrives.This should keep pagination stable while preserving the existing correction when a real response reports fewer pages.