Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@DanielleMaywood
Copy link
Contributor

This PR replaces the use of the container ID with the devcontainer ID. This is a breaking change. This allows rebuilding a devcontainer when there is no valid container ID.

This PR replaces the use of the **container** ID with the
**devcontainer** ID. This is a breaking change. This allows rebuilding a
devcontainer when there is no valid container ID.
@DanielleMaywood DanielleMaywood marked this pull request as ready for review June 26, 2025 09:59
@DanielleMaywood DanielleMaywood requested a review from Copilot June 26, 2025 09:59
@github-actions github-actions bot added the release/breaking This label is applied to PRs to detect breaking changes as part of the release process label Jun 26, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR changes API endpoints and internal references to use the devcontainer ID rather than the container ID. Key changes include updating URL paths, parameter names, and related error messages in both the API and its documentation.

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
site/src/modules/resources/AgentDevcontainerCard.tsx Updated the endpoint URL to use devcontainer.id
docs/reference/api/agents.md Updated the API documentation and parameter names
codersdk/workspacesdk/agentconn.go Changed function signature and URL path for recreating devcontainers
codersdk/workspaceagents.go Refactored the workspace agent recreate method to use devcontainerID
coderd/workspaceagents_test.go Updated tests to align with the new devcontainer ID usage
coderd/workspaceagents.go, coderd/coderd.go, coderd/apidoc/swagger.json, coderd/apidoc/docs.go Modified routing, error messages, and API docs for consistency
agent/agentcontainers/api_test.go, agent/agentcontainers/api.go Adjusted API routes and tests to reflect the devcontainer changes

return
var workspaceFolder string
for _, dc := range api.knownDevcontainers {
if dc.ID.String() == devcontainerID {
Copy link

Copilot AI Jun 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider refactoring the 'knownDevcontainers' map to be keyed by the devcontainer ID instead of the workspaceFolder. This change can improve lookup clarity and avoid potential key collisions when multiple devcontainers share the same workspace folder.

Copilot uses AI. Check for mistakes.
@DanielleMaywood DanielleMaywood requested review from johnstcn and mafredri and removed request for mafredri June 26, 2025 10:02
@johnstcn johnstcn requested a review from mafredri June 26, 2025 10:12
Copy link
Member

@mafredri mafredri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Except for the minor nit, this looks good to me. A bit more invasive than I imagined but we should be OK and good to get this changed before GA 👍🏻

if dc.ID.String() == devcontainerID {
workspaceFolder = dc.WorkspaceFolder
break
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: This could be simplified by storing dc from the for-loop rather than doing two lookups first ID then workspace folder (which we already know).

// /-route was dropped. We can drop the /devcontainers prefix here too.
r.Route("/devcontainers", func(r chi.Router) {
r.Post("/container/{container}/recreate", api.handleDevcontainerRecreate)
r.Route("/devcontainers/{devcontainer}", func(r chi.Router) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This dawned on me just now, but we could take workspaceFolder here instead, which will allow starting any non-started devcontainer even if it doesn't exist. 😅 We can table this for now though as implementing it would be preemptive and more thought behind it would be good.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oooh that could be good to add in the future.

for i := range tt.wantStatus {
// Simulate HTTP request to the recreate endpoint.
req := httptest.NewRequest(http.MethodPost, "/devcontainers/container/"+tt.containerID+"/recreate", nil).
req := httptest.NewRequest(http.MethodPost, "/devcontainers/"+tt.devcontainerID+"/recreate", nil).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a much more sensible URL 😍

@DanielleMaywood DanielleMaywood merged commit f2d229e into main Jun 26, 2025
34 checks passed
@DanielleMaywood DanielleMaywood deleted the danielle/container-rebuild branch June 26, 2025 10:42
@github-actions github-actions bot locked and limited conversation to collaborators Jun 26, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release/breaking This label is applied to PRs to detect breaking changes as part of the release process

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants