You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(api): add pagination to listRepositories, listUsers, and workspace.list #5969
packages/trpc/src/router/integration/github/github.ts:99-117 — returns all repos
packages/trpc/src/router/admin/admin.ts:11-14 — returns all users
packages/host-service/src/trpc/router/workspace/workspace.ts:40-62 — returns all workspaces
No limit(), no cursor, no pagination. Large organizations get massive single responses.
Proposed solution
Add cursor-based pagination with a default limit of 50 items. Return { items, nextCursor, totalCount }.
Workarounds you've tried
Implemented a local prototype of cursor-based pagination using limit + 1 queries and a cursor based on the last item's ID. This reduces payload size and avoids fetching entire datasets at once. However, the current API contracts don't expose pagination parameters or return pagination metadata, so the implementation can't be used consistently across listRepositories, listUsers, and workspace.list without changing the API.
I did not open a reproduction PR: there's no defective behavior to pin down with a failing test. These endpoints return everything because nothing ever asked them not to, so a test asserting "returns all rows" would encode today's intended behavior rather than prove a bug. What follows is the design input I'd want settled before someone implements this.
There's already a pagination convention in the repo — reuse it
packages/host-service/src/trpc/router/workspace-creation/procedures/search-branches.ts:35,169 establishes the house pattern: input.limit ?? 50, an opaque offset cursor via decodeCursor/encodeNextCursor, returning { items, nextCursor }. acp-sessions uses the same shape. Worth matching that instead of introducing a new one.
One deviation to flag: the proposal's totalCount isn't part of the existing convention, and it costs a second COUNT(*) on every page. Suggest omitting it unless a specific UI needs a total.
Also note listPullRequests already hard-caps at limit: 100 (github.ts:179) — precedent for a cap even without a cursor.
The three endpoints are not equal risk — I'd split this issue
Safe to paginate as proposed (1 consumer each, both plain render-the-array UIs):
workspace.list is the problem. It has ~10 consumers spanning desktop, mobile, CLI, SDK, and MCP, and it's part of the public SDK/CLI surface. A default limit of 50 would silently truncate:
packages/sdk/src/resources/workspaces.ts:43 fetches the full array and then filters by search / projectIdclient-side. With a default page of 50, those filters would only ever see page 1 — superset workspaces list --search foo would return wrong results with no error.
apps/desktop/src/renderer/lib/v1-migration/runV1Migration.ts:250,530 builds a complete workspaceId → projectId map from the full list. Truncation means workspaces past Ship deep links #50 are silently skipped during migration.
packages/mcp-v2/src/tools/workspaces/list.ts:28 and packages/cli/src/lib/host-workspaces/workspacesOnHost.ts:28 pass the raw array through to callers.
Separately, the motivation in the issue ("large organizations get massive single responses") doesn't really apply here: workspace.list reads from the local host SQLite db — it's bounded by workspaces on one machine, typically tens, and it's a synchronous local read, not a network-scale query.
Suggested scoping
Do: paginate listUsers and listRepositories using the search-branches convention (limit default 50, opaque cursor, { items, nextCursor }), updating their single consumers to useInfiniteQuery.
For workspace.list: either leave it alone, or add opt-inlimit/cursor that default to unlimited, so the SDK/CLI/MCP/migration contract is preserved. If it must become paginated by default, the SDK's client-side search/projectId filtering has to be pushed server-side first, and runV1Migration needs an explicit paginate-to-exhaustion loop — that's the real work in this issue, and it deserves its own ticket.
Happy to implement the two low-risk ones if a maintainer confirms that scoping.
Activity
github-actions commentedon Jul 26, 2026
Triage: claims verified, but this is a feature request — no reproduction PR
I verified the three call-sites. All three are genuinely unbounded — no
limit(), no cursor:packages/trpc/src/router/integration/github/github.ts:113-116—findManyovergithubRepositories, ordered only.packages/trpc/src/router/admin/admin.ts:12-14—findManyover allusers.packages/host-service/src/trpc/router/workspace/workspace.ts:41—ctx.db.select().from(workspaces).all().I did not open a reproduction PR: there's no defective behavior to pin down with a failing test. These endpoints return everything because nothing ever asked them not to, so a test asserting "returns all rows" would encode today's intended behavior rather than prove a bug. What follows is the design input I'd want settled before someone implements this.
There's already a pagination convention in the repo — reuse it
packages/host-service/src/trpc/router/workspace-creation/procedures/search-branches.ts:35,169establishes the house pattern:input.limit ?? 50, an opaque offset cursor viadecodeCursor/encodeNextCursor, returning{ items, nextCursor }.acp-sessionsuses the same shape. Worth matching that instead of introducing a new one.One deviation to flag: the proposal's
totalCountisn't part of the existing convention, and it costs a secondCOUNT(*)on every page. Suggest omitting it unless a specific UI needs a total.Also note
listPullRequestsalready hard-caps atlimit: 100(github.ts:179) — precedent for a cap even without a cursor.The three endpoints are not equal risk — I'd split this issue
Safe to paginate as proposed (1 consumer each, both plain render-the-array UIs):
admin.listUsers→apps/admin/src/app/(dashboard)/users/components/UsersTable/UsersTable.tsx:49integration.github.listRepositories→apps/web/src/app/(dashboard-legacy)/integrations/github/components/RepositoryList/RepositoryList.tsx:23workspace.listis the problem. It has ~10 consumers spanning desktop, mobile, CLI, SDK, and MCP, and it's part of the public SDK/CLI surface. A default limit of 50 would silently truncate:packages/sdk/src/resources/workspaces.ts:43fetches the full array and then filters bysearch/projectIdclient-side. With a default page of 50, those filters would only ever see page 1 —superset workspaces list --search foowould return wrong results with no error.apps/desktop/src/renderer/lib/v1-migration/runV1Migration.ts:250,530builds a completeworkspaceId → projectIdmap from the full list. Truncation means workspaces past Ship deep links #50 are silently skipped during migration.packages/mcp-v2/src/tools/workspaces/list.ts:28andpackages/cli/src/lib/host-workspaces/workspacesOnHost.ts:28pass the raw array through to callers.Separately, the motivation in the issue ("large organizations get massive single responses") doesn't really apply here:
workspace.listreads from the local host SQLite db — it's bounded by workspaces on one machine, typically tens, and it's a synchronous local read, not a network-scale query.Suggested scoping
listUsersandlistRepositoriesusing thesearch-branchesconvention (limitdefault 50, opaque cursor,{ items, nextCursor }), updating their single consumers touseInfiniteQuery.workspace.list: either leave it alone, or add opt-inlimit/cursorthat default to unlimited, so the SDK/CLI/MCP/migration contract is preserved. If it must become paginated by default, the SDK's client-sidesearch/projectIdfiltering has to be pushed server-side first, andrunV1Migrationneeds an explicit paginate-to-exhaustion loop — that's the real work in this issue, and it deserves its own ticket.Happy to implement the two low-risk ones if a maintainer confirms that scoping.