Skip to content

feat(skills): paginate registry tab and preserve state across detail navigation#2097

Merged
samuv merged 4 commits intomainfrom
pagination-registry-skill
Apr 24, 2026
Merged

feat(skills): paginate registry tab and preserve state across detail navigation#2097
samuv merged 4 commits intomainfrom
pagination-registry-skill

Conversation

@samuv
Copy link
Copy Markdown
Collaborator

@samuv samuv commented Apr 23, 2026

The skills registry API exposes page / limit and a total count, but the Registry tab always asked for page 1 and client-rendered everything. This PR wires up real server-side pagination, persists page / limit in the URL so they survive navigating into a skill detail and back, and extracts the controls into a reusable component.

Kapture.2026-04-23.at.18.33.43.mp4

Summary

  • Reusable Pagination component (results counter, first / prev / next, current page, items-per-page selector). Hides itself when the total fits in the smallest page size.
  • Skills → Registry tab paginates server-side, defaulting to 12 with options [12, 24, 50, 100].
  • page and limit live in the /skills route search params, so refresh and back-navigation from the skill detail restore the exact page.
  • Back button on the skill detail now pops history (router.history.back()) instead of issuing a fresh navigation that stripped page / limit.
  • Moved the "reset to page 1 on new search" logic out of a useEffect and into the debounced event handler — per React – You Might Not Need an Effect — which also fixes a StrictMode dev bug where the double-invoked effect clobbered the URL's page on every mount.

How to validate

  1. Skills → Registry shows a pagination bar with "Showing 1–12 of N skills".
  2. Click Next / change page size / type a search — URL updates in place (replace), search resets to page 1.
  3. Open a skill card → Back. You land on the page / size you left, not page 1.
  4. Deep-link to /skills_/ns/name → Back falls through to /skills?tab=registry.
  5. Registries with ≤ 12 skills don't show the pagination bar.

Tests

  • pnpm test:nonInteractive — 1913 passing. New coverage: Pagination unit tests, SkillsPage pagination integration tests (incl. StrictMode regression + URL round-trip), SkillDetailLayout back-button tests.
  • pnpm type-check clean.

@samuv samuv self-assigned this Apr 23, 2026
Copilot AI review requested due to automatic review settings April 23, 2026 17:08
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR upgrades the Skills Registry experience to use server-side pagination, persists pagination state in the /skills route search params for better back/refresh behavior, and introduces a reusable pagination control component used by the Registry tab.

Changes:

  • Added /skills route search validation for page/limit and wired these into the registry query loader.
  • Implemented server-driven pagination + URL state synchronization in SkillsPage (including StrictMode-safe “reset to page 1 on search change”).
  • Added a reusable Pagination UI component and accompanying unit/integration tests; updated skill detail back-navigation to use history when available.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
renderer/src/routes/skills.tsx Validates tab/page/limit search params and prefetches registry data using page/limit.
renderer/src/features/skills/lib/registry-pagination.ts Centralizes registry page-size defaults/options.
renderer/src/features/skills/components/skills-page.tsx Uses URL-backed pagination state, server-side pagination query params, and renders the new Pagination control.
renderer/src/features/skills/components/skill-detail-layout.tsx Updates back navigation behavior to preserve prior location state via history.
renderer/src/features/skills/components/tests/skills-page.test.tsx Adds pagination integration tests (URL round-trip + StrictMode regression coverage).
renderer/src/features/skills/components/tests/skill-detail-layout.test.tsx Adds tests ensuring the Back button restores previous search params when possible.
renderer/src/features/registry-servers/components/registry-detail-header.tsx Adds optional historyBack behavior for restoring prior URL/search state.
renderer/src/common/mocks/fixtures/registry_registryName_v0_1_x_dev_toolhive_skills/get.ts Adds MSW AutoAPIMock fixture for the registry skills endpoint including pagination metadata.
renderer/src/common/components/ui/pagination.tsx Introduces reusable pagination UI (range label, nav buttons, page-size selector).
renderer/src/common/components/ui/tests/pagination.test.tsx Adds unit coverage for the new Pagination component.

Comment thread renderer/src/common/components/ui/pagination.tsx Outdated
Comment thread renderer/src/features/skills/lib/registry-pagination.ts Outdated
- Clamp pageSize to >= 1 in the shared Pagination component so invalid
  inputs can't produce Infinity totals or negative ranges.
- Derive REGISTRY_PAGE_SIZE_OPTIONS / DEFAULT_REGISTRY_PAGE_SIZE from the
  Pagination component's DEFAULT_PAGE_SIZE_OPTIONS to keep a single source
  of truth.
- Document why the registry skills fixture keeps V01X (uppercase) — MSW's
  auto-mocker derives the lookup name via its own toPascalCase and would
  break if aligned with the SDK's V01x casing.

Made-with: Cursor
@samuv samuv enabled auto-merge (squash) April 23, 2026 17:28
@samuv samuv merged commit 2a15616 into main Apr 24, 2026
16 checks passed
@samuv samuv deleted the pagination-registry-skill branch April 24, 2026 07:56
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.

3 participants