Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(agent/agentcontainers): support displayApps from devcontainer config#18342

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
DanielleMaywood merged 4 commits intomainfromdm-sub-agent-apps-configuration
Jun 12, 2025
Merged
Show file tree
Hide file tree
Changes from1 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
PrevPrevious commit
chore: include merged, com.coder to coder, UnmarshallJSON
  • Loading branch information
@DanielleMaywood
DanielleMaywood committedJun 12, 2025
commitaa77e9ee82f48b45870138d0278ab2c2a1447e78
2 changes: 1 addition & 1 deletionagent/agentcontainers/api.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1104,7 +1104,7 @@ func (api *API) injectSubAgentIntoContainerLocked(ctx context.Context, dc coders
if config, err := api.dccli.ReadConfig(ctx, dc.WorkspaceFolder, dc.ConfigPath); err != nil {
api.logger.Error(ctx, "unable to read devcontainer config", slog.Error(err))
} else {
coderCustomization := config.Configuration.Customizations.Coder
coderCustomization := config.MergedConfiguration.Customizations.Coder
if coderCustomization != nil {
displayApps = coderCustomization.DisplayApps
}
Expand Down
2 changes: 1 addition & 1 deletionagent/agentcontainers/api_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1487,7 +1487,7 @@ func TestAPI(t *testing.T) {
fSAC = &fakeSubAgentClient{createErrC: make(chan error, 1)}
fDCCLI = &fakeDevcontainerCLI{
readConfig: agentcontainers.DevcontainerConfig{
Configuration: agentcontainers.DevcontainerConfiguration{
MergedConfiguration: agentcontainers.DevcontainerConfiguration{
Customizations: agentcontainers.DevcontainerCustomizations{
Coder: tt.customization,
},
Expand Down
26 changes: 16 additions & 10 deletionsagent/agentcontainers/devcontainercli.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -19,15 +19,15 @@ import (
// Unfortunately we cannot make use of `dcspec` as the output doesn't appear to
// match.
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 unfortunate. Any particular thing it choked on?

Btw, I notice there's no "merged" configuration. I suppose we won't get customizations added by features etc here?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

They aren't 1:1 on schema.

{  "configuration": {    "name": "Development environments on your infrastructure",    "image": "codercom/oss-dogfood:latest",    "features": {      "ghcr.io/devcontainers/features/docker-in-docker:2": {        "moby": "false"      }    },    "runArgs": [      "--cap-add=SYS_PTRACE"    ],    "customizations": {      "vscode": {        "extensions": [          "biomejs.biome"        ]      }    },    "configFilePath": {      "$mid": 1,      "fsPath": "/home/coder/coder/.devcontainer/devcontainer.json",      "path": "/home/coder/coder/.devcontainer/devcontainer.json",      "scheme": "vscode-fileHost"    }  },  "workspace": {    "workspaceFolder": "/workspaces/coder",    "workspaceMount": "type=bind,source=/home/coder/coder,target=/workspaces/coder"  }}

If I runcat agent/agentcontainers/dcspec/devContainer.base.schema.json | rg 'configFilePath', it shows no results. Maybe it is just that field but it is definitely a little unfortunate.

Copy link
Member

Choose a reason for hiding this comment

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

I don't see thatconfigFilePath is needed for anything since we already know it, or am I missing something?

type DevcontainerConfig struct {
Configuration DevcontainerConfiguration `json:"configuration"`
MergedConfiguration DevcontainerConfiguration `json:"mergedConfiguration"`
}

type DevcontainerConfiguration struct {
Customizations DevcontainerCustomizations `json:"customizations,omitempty"`
}

type DevcontainerCustomizations struct {
Coder *CoderCustomization `json:"com.coder,omitempty"`
Coder *CoderCustomization `json:"coder,omitempty"`
}

type CoderCustomization struct {
Expand DownExpand Up@@ -196,23 +196,17 @@ func (d *devcontainerCLI) Up(ctx context.Context, workspaceFolder, configPath st
cmd.Stderr = io.MultiWriter(stderrWriters...)

if err := cmd.Run(); err != nil {
result, err2 := parseDevcontainerCLILastLine[devcontainerCLIResult](ctx, logger, stdoutBuf.Bytes())
_, err2 := parseDevcontainerCLILastLine[devcontainerCLIResult](ctx, logger, stdoutBuf.Bytes())
if err2 != nil {
err = errors.Join(err, err2)
}
if err2 := result.Err(); err2 != nil {
err = errors.Join(err, err2)
}
return "", err
}

result, err := parseDevcontainerCLILastLine[devcontainerCLIResult](ctx, logger, stdoutBuf.Bytes())
if err != nil {
return "", err
}
if err := result.Err(); err != nil {
return "", err
}

return result.ContainerID, nil
}
Expand DownExpand Up@@ -260,7 +254,7 @@ func (d *devcontainerCLI) ReadConfig(ctx context.Context, workspaceFolder, confi
conf := applyDevcontainerCLIReadConfigOptions(opts)
logger := d.logger.With(slog.F("workspace_folder", workspaceFolder), slog.F("config_path", configPath))

args := []string{"read-configuration"}
args := []string{"read-configuration", "--include-merged-configuration"}
if workspaceFolder != "" {
args = append(args, "--workspace-folder", workspaceFolder)
}
Expand DownExpand Up@@ -339,6 +333,18 @@ type devcontainerCLIResult struct {
Description string `json:"description"`
}

func (r *devcontainerCLIResult) UnmarshalJSON(data []byte) error {
type wrapperResult devcontainerCLIResult

var wrappedResult wrapperResult
if err := json.Unmarshal(data, &wrappedResult); err != nil {
return err
}

*r = devcontainerCLIResult(wrappedResult)
return r.Err()
}

func (r devcontainerCLIResult) Err() error {
if r.Outcome == "success" {
return nil
Expand Down
10 changes: 5 additions & 5 deletionsagent/agentcontainers/devcontainercli_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -253,10 +253,10 @@ func TestDevcontainerCLI_ArgsAndParsing(t *testing.T) {
logFile: "read-config-with-coder-customization.log",
workspaceFolder: "/test/workspace",
configPath: "",
wantArgs: "read-configuration --workspace-folder /test/workspace",
wantArgs: "read-configuration --include-merged-configuration --workspace-folder /test/workspace",
wantError: false,
wantConfig: agentcontainers.DevcontainerConfig{
Configuration: agentcontainers.DevcontainerConfiguration{
MergedConfiguration: agentcontainers.DevcontainerConfiguration{
Customizations: agentcontainers.DevcontainerCustomizations{
Coder: &agentcontainers.CoderCustomization{
DisplayApps: []codersdk.DisplayApp{
Expand All@@ -273,10 +273,10 @@ func TestDevcontainerCLI_ArgsAndParsing(t *testing.T) {
logFile: "read-config-without-coder-customization.log",
workspaceFolder: "/test/workspace",
configPath: "/test/config.json",
wantArgs: "read-configuration --workspace-folder /test/workspace --config /test/config.json",
wantArgs: "read-configuration --include-merged-configuration --workspace-folder /test/workspace --config /test/config.json",
wantError: false,
wantConfig: agentcontainers.DevcontainerConfig{
Configuration: agentcontainers.DevcontainerConfiguration{
MergedConfiguration: agentcontainers.DevcontainerConfiguration{
Customizations: agentcontainers.DevcontainerCustomizations{
Coder: nil,
},
Expand All@@ -288,7 +288,7 @@ func TestDevcontainerCLI_ArgsAndParsing(t *testing.T) {
logFile: "read-config-error-not-found.log",
workspaceFolder: "/nonexistent/workspace",
configPath: "",
wantArgs: "read-configuration --workspace-folder /nonexistent/workspace",
wantArgs: "read-configuration --include-merged-configuration --workspace-folder /nonexistent/workspace",
wantError: true,
wantConfig: agentcontainers.DevcontainerConfig{},
},
Expand Down

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

Loading

[8]ページ先頭

©2009-2025 Movatter.jp