Skip to content

Persist xDS list pagination in the URL so it survives navigation - #1348

Draft
minwoox wants to merge 1 commit into
line:mainfrom
minwoox:fix_page
Draft

Persist xDS list pagination in the URL so it survives navigation#1348
minwoox wants to merge 1 commit into
line:mainfrom
minwoox:fix_page

Conversation

@minwoox

@minwoox minwoox commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Motivation:

The xDS group list (and the per-group resource and history lists) kept their pagination only in TanStack Table's in-memory state.

Modifications:

  • Add a reusable useUrlPagination hook (webapp/src/dogma/common/components/table/useUrlPagination.ts) that mirrors pageIndex/pageSize into the URL query (page, 1-indexed, and pageSize) with shallow routing, omits both params while at their defaults, and reads them back through a router.isReady-gated effect so the state is restored on mount and on Back/Forward. The valid page sizes are held in a ref so an inline pageSizes array cannot turn the sync effect into a render loop.

Result:

  • xDS list pagination now survives navigation.

Motivation:

The xDS group list (and the per-group resource and history lists) kept
their pagination only in TanStack Table's in-memory state.

Modifications:

- Add a reusable useUrlPagination hook
  (webapp/src/dogma/common/components/table/useUrlPagination.ts) that
  mirrors pageIndex/pageSize into the URL query (`page`, 1-indexed, and
  `pageSize`) with shallow routing, omits both params while at their
  defaults, and reads them back through a router.isReady-gated effect so
  the state is restored on mount and on Back/Forward. The valid page
  sizes are held in a ref so an inline `pageSizes` array cannot turn the
  sync effect into a render loop.

Result:

- xDS list pagination now survives navigation.
@minwoox minwoox added this to the 0.86.0 milestone Aug 3, 2026
@minwoox minwoox added the defect label Aug 3, 2026
@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The PR adds shared URL-backed pagination hooks, applies controlled pagination to the shared table and XDS views, defines common XDS page sizes, and adds tests for URL synchronization, restoration, filtering, and page-index clamping.

Changes

URL-backed pagination

Layer / File(s) Summary
Shared pagination hook
webapp/src/dogma/common/components/table/useUrlPagination.ts, webapp/tests/dogma/common/components/table/useUrlPagination.test.tsx
The new hooks parse validated query parameters, synchronize controlled pagination with shallow routing, omit default values, restore state after route changes, and clamp invalid page indexes.
Table and XDS integration
webapp/src/dogma/common/components/table/DataTableClientPagination.tsx, webapp/src/dogma/features/xds/*.tsx, webapp/src/dogma/features/xds/XdsTypes.ts
The shared table and XDS views use controlled URL pagination, shared page-size options, filter resets, and page-index clamping.
Pagination behavior tests
webapp/tests/dogma/features/xds/*.test.tsx
Tests cover pagination restoration, shallow URL updates, query preservation, filter resets, page-size changes, and clamping after data shrinks.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

Suggested reviewers: ikhoon, jrhee17

Sequence Diagram(s)

sequenceDiagram
  participant XDSView
  participant useUrlPagination
  participant NextRouter
  participant DataTable
  XDSView->>useUrlPagination: provide page sizes
  useUrlPagination->>NextRouter: read page and pageSize
  useUrlPagination->>DataTable: return controlled pagination
  DataTable->>useUrlPagination: report pagination changes
  useUrlPagination->>NextRouter: shallow-update query parameters
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: persisting xDS list pagination in the URL across navigation.
Description check ✅ Passed The description explains the motivation, implementation, and result of URL-backed pagination for xDS lists.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
webapp/src/dogma/common/components/table/DataTableClientPagination.tsx (1)

15-51: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Add useClampPageIndex to prevent a stranded empty page after filtering.

autoResetPageIndex is false and pagination is now controlled through useUrlPagination. When a column filter narrows the row set, pageCount can drop below the current pageIndex. Nothing in this file corrects that, so the table can render an empty page.

useUrlPagination.ts's own documentation states that autoResetPageIndex: false must be paired with useClampPageIndex. GroupList.tsx, ResourceHistory.tsx, and ResourceList.tsx all call it. This file does not.

🐛 Proposed fix
-import { useUrlPagination } from 'dogma/common/components/table/useUrlPagination';
+import { useClampPageIndex, useUrlPagination } from 'dogma/common/components/table/useUrlPagination';
 import { useState } from 'react';
     state: {
       sorting,
       columnFilters,
       pagination,
     },
   });
+  // Auto-reset is off, so keep the page index within bounds when a filter narrows the list to fewer pages.
+  useClampPageIndex(table);

   if (!router.isReady) {
     return null;
   }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@webapp/src/dogma/common/components/table/DataTableClientPagination.tsx`
around lines 15 - 51, Add and invoke useClampPageIndex in
DataTableClientPagination alongside the controlled pagination returned by
useUrlPagination, passing the table’s filtered row/page-count context as
required by the hook. Ensure it runs with the existing table instance and
preserves the current pagination state while clamping pageIndex after column
filtering.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@webapp/src/dogma/common/components/table/DataTableClientPagination.tsx`:
- Around line 15-51: Add and invoke useClampPageIndex in
DataTableClientPagination alongside the controlled pagination returned by
useUrlPagination, passing the table’s filtered row/page-count context as
required by the hook. Ensure it runs with the existing table instance and
preserves the current pagination state while clamping pageIndex after column
filtering.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: d9fc06ec-2077-4805-9549-46b4c80bf5b5

📥 Commits

Reviewing files that changed from the base of the PR and between 5afa110 and 312e9d7.

📒 Files selected for processing (10)
  • webapp/src/dogma/common/components/table/DataTableClientPagination.tsx
  • webapp/src/dogma/common/components/table/useUrlPagination.ts
  • webapp/src/dogma/features/xds/GroupList.tsx
  • webapp/src/dogma/features/xds/ResourceHistory.tsx
  • webapp/src/dogma/features/xds/ResourceList.tsx
  • webapp/src/dogma/features/xds/XdsTypes.ts
  • webapp/tests/dogma/common/components/table/useUrlPagination.test.tsx
  • webapp/tests/dogma/features/xds/GroupList.test.tsx
  • webapp/tests/dogma/features/xds/ResourceHistory.test.tsx
  • webapp/tests/dogma/features/xds/ResourceList.test.tsx

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant