Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix unstable pagination in workspace command history #52

Description

@nilsavenholt

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.

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions