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

Commit7387905

Browse files
authored
fix(agent/agentcontainers): refresh containers before status change (#18620)
The previous method of refreshing after we change the devcontainerstatus introduced an intermediary state where the devcontainer might notyet have been assigned a container and will flicker as stopped beforegoing into running.
1 parent7a3a6d4 commit7387905

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

‎agent/agentcontainers/api.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,6 +1002,15 @@ func (api *API) CreateDevcontainer(workspaceFolder, configPath string, opts ...D
10021002

10031003
logger.Info(ctx,"devcontainer created successfully")
10041004

1005+
// Ensure the container list is updated immediately after creation.
1006+
// This makes sure that dc.Container is populated before we acquire
1007+
// the lock avoiding a temporary inconsistency in the API state
1008+
// where status is running, but the container is nil.
1009+
iferr:=api.RefreshContainers(ctx);err!=nil {
1010+
logger.Error(ctx,"failed to trigger immediate refresh after devcontainer creation",slog.Error(err))
1011+
returnxerrors.Errorf("refresh containers: %w",err)
1012+
}
1013+
10051014
api.mu.Lock()
10061015
dc=api.knownDevcontainers[dc.WorkspaceFolder]
10071016
// Update the devcontainer status to Running or Stopped based on the
@@ -1020,13 +1029,6 @@ func (api *API) CreateDevcontainer(workspaceFolder, configPath string, opts ...D
10201029
api.knownDevcontainers[dc.WorkspaceFolder]=dc
10211030
api.mu.Unlock()
10221031

1023-
// Ensure an immediate refresh to accurately reflect the
1024-
// devcontainer state after recreation.
1025-
iferr:=api.RefreshContainers(ctx);err!=nil {
1026-
logger.Error(ctx,"failed to trigger immediate refresh after devcontainer creation",slog.Error(err))
1027-
returnxerrors.Errorf("refresh containers: %w",err)
1028-
}
1029-
10301032
returnnil
10311033
}
10321034

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp