Skip to content

refactor(codersdk,cli,scaletest,site): add a shared workspace paging helper - #28028

Closed
jscottmiller wants to merge 1 commit into
scott/plat-386-workspace-pagination-correctnessfrom
scott/plat-386-workspace-pagination
Closed

refactor(codersdk,cli,scaletest,site): add a shared workspace paging helper#28028
jscottmiller wants to merge 1 commit into
scott/plat-386-workspace-pagination-correctnessfrom
scott/plat-386-workspace-pagination

Conversation

@jscottmiller

Copy link
Copy Markdown
Contributor

Summary

Stacked on #28027.

Every caller that needed the full workspace list carried its own paging loop,
each with its own page size and termination rule. codersdk.AllWorkspaces now
owns that logic: it advances the offset by the requested page size and stops
once it reaches the total the response reports.

Callers routed through it: cli/list.go (QueryConvertWorkspaces),
cli/ssh.go (shell completion), cli/configssh.go, both cli/exp_scaletest.go
helpers, and all four sites in scaletest/prebuilds/run.go, including the two
poll loops that were not paginated at all. allWorkspacesForTemplate is
deleted.

The frontend gains the equivalent helper as API.getAllWorkspaces, exposed as
the allWorkspaces query and used by the agents pages. Its key carries an all
marker so it stays distinct from the single-page key while remaining matched by
workspace list invalidation.

support/support.go keeps its own loop: it needs the server-reported count for
the bundle and must stop early at --workspaces-total-cap.

Testing

  • go test ./codersdk/ -run TestAllWorkspaces (new: single page, offset
    progression, short page continues, empty result, caller pagination overridden)
  • go test ./cli/ -run 'TestList|TestConfigSSH'
  • pnpm vitest run src/api/api.test.ts

Follow-ups

  • support/support.go: request min(cap, pageSize) rather than a full page
    when --workspaces-total-cap is small; that also removes the
    all[:capTotal] trim.
  • support/support.go: Run overwrites Count with the truncated length,
    contradicting the comment that says the server total is preserved.
  • support/support.go: a 403 mid-loop yields a partial list alongside a
    full count, with only a warning log.
  • The agents pages fetch every page on load and filter client side. A
    server-side organization: filter would avoid the fan-out.

This pull request was created by Coder Agents on behalf of @jscottmiller.

…helper

Every caller that needed the full workspace list carried its own paging loop,
each with its own page size and termination rule. codersdk.AllWorkspaces now
owns that logic: it advances the offset by the requested page size and stops
once it reaches the total the response reports.

The frontend gains the equivalent helper as API.getAllWorkspaces, exposed as
the allWorkspaces query. Its key carries an "all" marker so it stays distinct
from the single-page key while remaining matched by workspace list
invalidation.
@linear-code

linear-code Bot commented Aug 11, 2026

Copy link
Copy Markdown

PLAT-386

@jscottmiller jscottmiller added the experimental Changes that might not necessarily be merged, until its approved to proceed with. label Aug 11, 2026
@jscottmiller
jscottmiller marked this pull request as draft August 11, 2026 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

experimental Changes that might not necessarily be merged, until its approved to proceed with.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant