Files
coder/coderd/x
Ethan 2d725a1ced refactor(coderd): move the chat start decision into the start tool (#32433)
Closes CODAGT-292
Relates to CODAGT-1607

`coderd/export_test.go` re-exported `chatCreateWorkspace`,
`chatStartWorkspace`, `chatStopWorkspace` and
`chatRenderTemplateParameters`, just so four tests could call them
directly. This PR removes those tests and their aliases, and the last
alias in that file goes in the next PR in the stack.

The start and stop tests only checked which template version the build
ends up on. That decision lived in `coderd`, behind the function the
tool calls, so the only way to test it was to call that function
directly. Now `start_workspace` makes the decision itself, much like
`coder start` does: it checks whether the template requires its active
version, sends that version with the build request, and tells the model
how to retry when the update needs parameters. All of that is covered by
the tool's own tests. With the decision gone, the start and stop
functions were identical, so both tools now share `chatBuildWorkspace`,
which just creates a build as the workspace owner.

Two small behaviour changes. `start_workspace` now returns `template_id`
whenever it asks the model to retry with parameters. Previously it was
missing for templates on the classic parameter flow, even though the
message says to use it. The tool also reads the template's setting
directly, like `coder start`, so chat updates on start too when the
setting is still on after a licence lapses.

`TestStartWorkspaceTool_EndToEnd` now starts a workspace whose active
version needs a new parameter, so we still know the whole flow works
against a real `coderd`.

`chatRenderTemplateParameters` keeps a direct test, it's just an
internal one now, against a database instead of a whole `coderd`. It no
longer checks the owner default, as that's already tested in the
renderer and in the tool. The bind failure test needs a real
transaction, so it moves to `chatd` and runs through the
`create_workspace` tool.
2026-12-01 00:17:20 +11:00
..