Relates to CODAGT-1330 When a workspace rebuild gives a chat a new agent, chatd saves the new agent binding and then re-pins the chat's context to that agent. These committed separately, and a failed re-pin was just logged. The next turn would see the new agent already bound, so it never re-pinned, and the chat kept injecting the old agent's context. `create_workspace` had a similar problem. It bound the chat to the workspace after the workspace was committed, and if that failed it logged an error and still reported success. The workspace was left orphaned, and the next call would just create another one. To fix, we'll commit the binding and the re-pin in one transaction. `create_workspace` now binds the chat inside the workspace create transaction. I've done this with the unused `postCreateInTX` hook in `createWorkspace`, which I've renamed to `postBuildInTX` and moved after the build insert so it has the build ID.
24 lines
1021 B
Go
24 lines
1021 B
Go
package coderd
|
|
|
|
// ChatStartWorkspace exposes chatStartWorkspace for external tests.
|
|
//
|
|
// chatStartWorkspace is intentionally unexported to keep symmetry with
|
|
// its sister chatCreateWorkspace. The alias lets external tests drive
|
|
// the RequireActiveVersion auto-update path end-to-end without
|
|
// stubbing the entire DB layer. The proper fix is to extract a pure
|
|
// request builder; tracked in CODAGT-292.
|
|
var ChatStartWorkspace = (*API).chatStartWorkspace
|
|
|
|
// ChatCreateWorkspace exposes chatCreateWorkspace for external tests.
|
|
var ChatCreateWorkspace = (*API).chatCreateWorkspace
|
|
|
|
// ChatStopWorkspace exposes chatStopWorkspace for external tests.
|
|
var ChatStopWorkspace = (*API).chatStopWorkspace
|
|
|
|
// ChatRenderTemplateParameters exposes chatRenderTemplateParameters for
|
|
// external tests.
|
|
var ChatRenderTemplateParameters = (*API).chatRenderTemplateParameters
|
|
|
|
// NormalizeWorkspaceFileReference exposes normalizeWorkspaceFileReference for tests.
|
|
var NormalizeWorkspaceFileReference = normalizeWorkspaceFileReference
|