Skip to content

feat: add include_related option to client.Workspace in codersdk - #29284

Open
spikecurtis wants to merge 1 commit into
spikecurtis/workspace-include-relatedfrom
spikecurtis/workspace-sdk-include-related
Open

spikecurtis wants to merge 1 commit into
spikecurtis/workspace-include-relatedfrom
spikecurtis/workspace-sdk-include-related

Conversation

@spikecurtis

@spikecurtis spikecurtis commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Part of the lite codersdk.Workspace work (GRU-82, RFC). Stacked on #29233, which wired include_related into GET /api/v2/workspaces/{workspace}.

Adds include_related support to the codersdk client, expressed with the typed selection tree so only supported selections are representable:

  • Moves the wsrelated package from coderd/ to codersdk/ so both the server and the client can share wsrelated.Config. coderd already depends on codersdk, so this only changes import paths on the server side.
  • Adds Config.QueryParam, which encodes a selection into the include_related value: the dotted path of each selected node that has no selected descendants. Selecting a node implies its ancestors, so Parse round-trips the result back into an equal Config (covered by a round-trip test).
  • WorkspaceOptions gains IncludeRelated *wsrelated.Config. A nil value omits the parameter (server returns everything, unchanged); a non-nil value is encoded via QueryParam, and a zero Config loads only the workspace.
  • Client.Workspace now accepts optional WorkspaceOptions, backward compatible with existing client.Workspace(ctx, id) calls.

Testing

  • codersdk internal test asserts WorkspaceOptions.asRequestOption sets include_related from the selection, following the existing WorkspaceFilter test pattern rather than spinning up a server.
  • wsrelated tests cover QueryParam output and a Parse/QueryParam round trip.

make gen regenerated the WorkspaceOptions TypeScript type. Because the wire representation of include_related is a comma-separated string, scripts/apitypings maps wsrelated.Config to string in TypeScript, so include_related?: string rather than a nested object the frontend cannot serialize. api.getWorkspace already forwards WorkspaceOptions as query params, and a frontend test in api.test.ts confirms include_related is sent through.


Generated by Coder Agents on behalf of @spikecurtis.

@spikecurtis
spikecurtis added this pull request to stack #29285 September 14, 2026 12:29
@spikecurtis
spikecurtis requested a review from cstyan September 14, 2026 12:29
@spikecurtis
spikecurtis force-pushed the spikecurtis/workspace-sdk-include-related branch from cb631bd to 3282bbe Compare September 14, 2026 14:13
@spikecurtis
spikecurtis force-pushed the spikecurtis/workspace-sdk-include-related branch from 3282bbe to d4ec4af Compare September 14, 2026 15:33
@spikecurtis spikecurtis changed the title feat(codersdk): add include_related option to client.Workspace feat: add include_related option to client.Workspace in codersdk Sep 15, 2026
@spikecurtis
spikecurtis marked this pull request as ready for review September 15, 2026 07:24
@spikecurtis
spikecurtis requested a review from Emyrk as a code owner September 15, 2026 07:24
@spikecurtis
spikecurtis force-pushed the spikecurtis/workspace-sdk-include-related branch from d4ec4af to 144f8a9 Compare September 15, 2026 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant