Skip to content

feat(cli): replace open vscode container with devcontainer subagent #18765

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 8, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
docs
  • Loading branch information
mafredri committed Jul 7, 2025
commit a9c6794eedf117ca3a5dee3a274d71ee9eba56a4
11 changes: 10 additions & 1 deletion cli/open.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,15 @@ func (r *RootCmd) openVSCode() *serpent.Command {
workspaceName := workspace.Name + "." + workspaceAgent.Name
insideThisWorkspace := insideAWorkspace && inWorkspaceName == workspaceName

// To properly work with devcontainers, VS Code has to connect to
// parent workspace agent. It will then proceed to enter the
// container given the correct parameters. There is inherently no
// dependency on the devcontainer agent in this scenario, but
// relying on it simplifies the logic and ensures the devcontainer
// is ready. To eliminate the dependency we would need to know that
// a sub-agent that hasn't been created yet may be a devcontainer,
// and thus will be created at a later time as well as expose the
// container folder on the API response.
var parentWorkspaceAgent codersdk.WorkspaceAgent
var devcontainer codersdk.WorkspaceAgentDevcontainer
if workspaceAgent.ParentID.Valid {
Expand Down Expand Up @@ -109,7 +118,7 @@ func (r *RootCmd) openVSCode() *serpent.Command {
}
}
if devcontainer.ID == uuid.Nil {
cliui.Warnf(inv.Stderr, "Devcontainer for agent %q not found, opening as a regular workspace", workspaceAgent.Name)
cliui.Warnf(inv.Stderr, "Devcontainer %q not found, opening as a regular workspace...", workspaceAgent.Name)
parentWorkspaceAgent = codersdk.WorkspaceAgent{} // Reset to empty, so we don't use it later.
break
}
Expand Down
Loading