feat: paginate /models in UI + "Fetch All Pages" option - #20
Open
dawidope wants to merge 1 commit into
Open
Conversation
deAPI paginates /models and caps `limit` at 50 server-side (`limit=100` still returns per_page=50, and `per_page` is accepted but silently ignored), so more than 50 models can only be read by walking pages. The registry entry for "List Models" had `params: []`, so the tester could only ever issue a bare GET /models — 25 models, page 1, with no way to request the next page. - add `page` + `limit` fields to the List Models endpoint - add a `_fetchAll` checkbox that walks every page and merges the result; `page`/`limit` hide via visibleWhen while it is on - extract the page walker to lib/pagination.ts and reuse it in /api/models, which already paginated with its own inline copy - handle `_fetchAll` generically in the proxy (any GET endpoint), not as a special case for /models The merged response carries a `_tester.merged_pages` marker so it is not mistaken for a verbatim API response — its `meta` comes from the last page, and `truncated` flags a stop at MAX_PAGES rather than silently dropping items. Verified against the live API with PAGE_LIMIT temporarily lowered to 5 to force a real multi-page walk: 6 pages merged to 27 unique models, no duplicates or gaps. The single-page path is unchanged. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
GET /modelsis paginated, and the tester had no way to reach past the first page.The registry entry for List Models had
params: [], so the form offered no fields at all — every call was a bareGET /models, which returns 25 models, page 1. There was no way to ask for page 2.Raising the limit alone does not fix this. Verified against the live API:
per_page=100per_page: 25limit=100per_page: 50limit=50page=2So 50 is a server-side cap, and reading more than 50 models always requires walking pages.
Changes
List Modelsendpoint — addedpageandlimitfields, plus a_fetchAll("Fetch All Pages") checkbox that walks every page and merges the results.page/limithide viavisibleWhenwhile it is on, since the walker owns them in that mode.src/lib/pagination.ts(new) — extracted the page walker so it is not duplicated./api/modelsalready paginated with its own inline copy; it now uses the shared helper. The deAPI quirks above are documented there./api/proxy— handles_fetchAllgenerically (anyGETendpoint, never a price-calc), not as a hardcoded special case for/models. If deAPI adds another paginated GET, it only needs a registry field. The flag is stripped from params so it is never forwarded as a query param.Note on the merged response
It carries a marker so it is not mistaken for a verbatim API response:
This matters because
metain a merged response comes from the last page (socurrent_page === last_page), which would otherwise look like a bug.truncatedflags a stop atMAX_PAGES(20 × 50 = 1000 items) rather than silently dropping items.Scope note
The model dropdowns were never affected —
/api/modelshas walked all pages since 97ed2c4. This PR fixes the manual tester endpoint, and de-duplicates the walker along the way.Testing
At 27 models everything fits in one page of 50, so the multi-page path had never actually executed. I temporarily lowered
PAGE_LIMITto 5 to force a real 6-page walk, then restored it:_fetchAll=true,PAGE_LIMIT=5pages_fetched=6,truncated=false✅_fetchAll=true,PAGE_LIMIT=50pages_fetched=1✅_fetchAll=false,page=2&limit=10meta.current_page=2, no_tester— old path untouched ✅_endpointId+_fetchAll/api/models(cache)tsc --noEmitclean,npm run lintreports no warnings or errors.🤖 Generated with Claude Code