Skip to content

feat: templates list pagination#352

Open
drankou wants to merge 11 commits into
mainfrom
template-list-pagination-eng-4207
Open

feat: templates list pagination#352
drankou wants to merge 11 commits into
mainfrom
template-list-pagination-eng-4207

Conversation

@drankou

@drankou drankou commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Replaces the full-list getTemplates query with a cursor-paginated endpoint and rewires the templates list UI around useSuspenseInfiniteQuery + a Load More button. Sorting, filtering, and search are now executed server-side, so the page no longer needs to download every template up front and the table is a pure renderer over the rows returned by the paginated query.

Changes

Backend (tRPC + repository)

  • New listTeamTemplates repo method accepting cursor, limit, cpuCount, memoryMB, public, search, and a single sort token; returns { data, nextCursor }.
  • templates.getTemplates router input now validates the same params (limit ≤ 100, default 50; sort defaults to updated_at_desc).
  • Full-list getTeamTemplates is kept untouched — still used by the terminal page.

Sort token

The active react-table column + direction is mapped to one of the server enum values:

Column Asc Desc
name name_asc name_desc
cpuCount cpu_count_asc cpu_count_desc
memoryMB memory_mb_asc memory_mb_desc
createdAt created_at_asc created_at_desc
updatedAt updated_at_asc updated_at_desc

@linear-code

linear-code Bot commented Jun 2, 2026

Copy link
Copy Markdown

ENG-4207

@cla-bot cla-bot Bot added the cla-signed label Jun 2, 2026
@vercel

vercel Bot commented Jun 2, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
web Ready Ready Preview, Comment Jun 9, 2026 2:53pm
web-juliett Ready Ready Preview, Comment Jun 9, 2026 2:53pm

Request Review

@drankou drankou marked this pull request as ready for review June 2, 2026 21:00
@drankou drankou requested a review from ben-fornefeld as a code owner June 2, 2026 21:00

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0fde47cc58

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/features/dashboard/templates/list/table-body.tsx
Comment thread src/features/dashboard/templates/list/table.tsx
drankou and others added 10 commits June 8, 2026 16:59
…i spec

Regenerates the dashboard-api client types for the cursor-paginated
GET /templates (single `sort` enum) and GET /templates/{templateID}.
…nput

getTemplates accepts cursor/limit/filter/search and a single `sort` token
and returns a paginated page via the dashboard-api endpoint. The full-list
getTeamTemplates (used by the terminal page) is kept unchanged.
…/filter

Switches the list to useSuspenseInfiniteQuery, flattens pages, auto-loads
the next page on scroll, and maps the active column+direction to the single
server `sort` token (react-table runs in manual mode).
…y change

Replaces the optimistic setQueryData (incompatible with the infinite query
cache) with a pathKey invalidation matching every filter/sort variant.
Template IDs are random nanoid strings — sorting alphabetically by them
gives no meaningful order. The server-side sort enum has no templateID
variant (clicks would silently fall back to updated_at_desc on the
server), so this just removes the misleading sort affordance from the
column header to match the other unsortable columns
(Visibility, ENVD Ver., Actions).

@huv1k huv1k left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Few nit picks, what do you think?

import type { SortingState } from '@tanstack/react-table'
import type { TemplatesSort } from '@/core/modules/templates/models'

export const TEMPLATES_PAGE_SIZE = 50

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we have some default page size for everything instead of having it specific to templates?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I would keep it as-is for now since page size could depend on row item size and API performance

Comment thread src/core/modules/templates/repository.server.ts Outdated
Comment thread src/core/modules/templates/repository.server.ts Outdated
Comment thread src/core/modules/templates/repository.server.ts Outdated
- pass options directly as query
- early return on empty data
- single-literal mapping with conditional spread for default templates
@drankou

drankou commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

@huv1k addressed all three:

  • Collapsed the query to query: options — type-checks since ListTeamTemplatesOptions and the OpenAPI query are field-identical.
  • Replaced base + spread with a single object literal using a conditional spread for the DefaultTemplate discriminator (one allocation per item instead of two on the default path).
  • Added an explicit early return for the empty-data case so the mapping path only runs when there's something to map.

Skipping the page-size constant nit for now — happy to lift it to a shared constant in a follow-up if other paginated lists land that'd reuse it.

Pushed in fa088ab.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants