feat(site): allow recreating devcontainers and showing dirty status (#18049)

This change allows showing the devcontainer dirty status in the UI as
well as a recreate button to update the devcontainer.

Closes #16424
This commit is contained in:
Mathias Fredriksson
2025-05-27 19:42:24 +03:00
committed by GitHub
parent 23d14233bf
commit a18eb9d08f
14 changed files with 275 additions and 46 deletions
+23
View File
@@ -17201,6 +17201,14 @@ const docTemplate = `{
"description": "DevcontainerDirty is true if the devcontainer configuration has changed\nsince the container was created. This is used to determine if the\ncontainer needs to be rebuilt.",
"type": "boolean"
},
"devcontainer_status": {
"description": "DevcontainerStatus is the status of the devcontainer, if this\ncontainer is a devcontainer. This is used to determine if the\ndevcontainer is running, stopped, starting, or in an error state.",
"allOf": [
{
"$ref": "#/definitions/codersdk.WorkspaceAgentDevcontainerStatus"
}
]
},
"id": {
"description": "ID is the unique identifier of the container.",
"type": "string"
@@ -17265,6 +17273,21 @@ const docTemplate = `{
}
}
},
"codersdk.WorkspaceAgentDevcontainerStatus": {
"type": "string",
"enum": [
"running",
"stopped",
"starting",
"error"
],
"x-enum-varnames": [
"WorkspaceAgentDevcontainerStatusRunning",
"WorkspaceAgentDevcontainerStatusStopped",
"WorkspaceAgentDevcontainerStatusStarting",
"WorkspaceAgentDevcontainerStatusError"
]
},
"codersdk.WorkspaceAgentHealth": {
"type": "object",
"properties": {
+18
View File
@@ -15706,6 +15706,14 @@
"description": "DevcontainerDirty is true if the devcontainer configuration has changed\nsince the container was created. This is used to determine if the\ncontainer needs to be rebuilt.",
"type": "boolean"
},
"devcontainer_status": {
"description": "DevcontainerStatus is the status of the devcontainer, if this\ncontainer is a devcontainer. This is used to determine if the\ndevcontainer is running, stopped, starting, or in an error state.",
"allOf": [
{
"$ref": "#/definitions/codersdk.WorkspaceAgentDevcontainerStatus"
}
]
},
"id": {
"description": "ID is the unique identifier of the container.",
"type": "string"
@@ -15770,6 +15778,16 @@
}
}
},
"codersdk.WorkspaceAgentDevcontainerStatus": {
"type": "string",
"enum": ["running", "stopped", "starting", "error"],
"x-enum-varnames": [
"WorkspaceAgentDevcontainerStatusRunning",
"WorkspaceAgentDevcontainerStatusStopped",
"WorkspaceAgentDevcontainerStatusStarting",
"WorkspaceAgentDevcontainerStatusError"
]
},
"codersdk.WorkspaceAgentHealth": {
"type": "object",
"properties": {
+2 -2
View File
@@ -956,7 +956,7 @@ func (api *API) workspaceAgentRecreateDevcontainer(rw http.ResponseWriter, r *ht
}
defer release()
err = agentConn.RecreateDevcontainer(ctx, container)
m, err := agentConn.RecreateDevcontainer(ctx, container)
if err != nil {
if errors.Is(err, context.Canceled) {
httpapi.Write(ctx, rw, http.StatusRequestTimeout, codersdk.Response{
@@ -977,7 +977,7 @@ func (api *API) workspaceAgentRecreateDevcontainer(rw http.ResponseWriter, r *ht
return
}
httpapi.Write(ctx, rw, http.StatusNoContent, nil)
httpapi.Write(ctx, rw, http.StatusAccepted, m)
}
// @Summary Get connection info for workspace agent
+1 -1
View File
@@ -1483,7 +1483,7 @@ func TestWorkspaceAgentRecreateDevcontainer(t *testing.T) {
ctx := testutil.Context(t, testutil.WaitLong)
err := client.WorkspaceAgentRecreateDevcontainer(ctx, agentID, devContainer.ID)
_, err := client.WorkspaceAgentRecreateDevcontainer(ctx, agentID, devContainer.ID)
if wantStatus > 0 {
cerr, ok := codersdk.AsError(err)
require.True(t, ok, "expected error to be a coder error")