refactor(codersdk,cli,scaletest,site): add a shared workspace paging helper - #28028
Closed
jscottmiller wants to merge 1 commit into
Closed
Conversation
…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.
14 tasks
jscottmiller
marked this pull request as draft
August 11, 2026 15:26
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.
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.AllWorkspacesnowowns 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, bothcli/exp_scaletest.gohelpers, and all four sites in
scaletest/prebuilds/run.go, including the twopoll loops that were not paginated at all.
allWorkspacesForTemplateisdeleted.
The frontend gains the equivalent helper as
API.getAllWorkspaces, exposed asthe
allWorkspacesquery and used by the agents pages. Its key carries anallmarker so it stays distinct from the single-page key while remaining matched by
workspace list invalidation.
support/support.gokeeps its own loop: it needs the server-reported count forthe bundle and must stop early at
--workspaces-total-cap.Testing
go test ./codersdk/ -run TestAllWorkspaces(new: single page, offsetprogression, short page continues, empty result, caller pagination overridden)
go test ./cli/ -run 'TestList|TestConfigSSH'pnpm vitest run src/api/api.test.tsFollow-ups
support/support.go: requestmin(cap, pageSize)rather than a full pagewhen
--workspaces-total-capis small; that also removes theall[:capTotal]trim.support/support.go:RunoverwritesCountwith 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 afull count, with only a warning log.
server-side
organization:filter would avoid the fan-out.This pull request was created by Coder Agents on behalf of @jscottmiller.