@@ -661,13 +661,17 @@ func (api *API) getContainers() (codersdk.WorkspaceAgentListContainersResponse,
661
661
if len (api .knownDevcontainers )> 0 {
662
662
devcontainers = make ([]codersdk.WorkspaceAgentDevcontainer ,0 ,len (api .knownDevcontainers ))
663
663
for _ ,dc := range api .knownDevcontainers {
664
- // Include the agent if it's been created (we're iterating
665
- // over copies, so mutating is fine).
666
- if agent := api .injectedSubAgentProcs [dc .WorkspaceFolder ].agent ;agent .ID != uuid .Nil {
664
+ // Include the agent if it's been created (we're iterating over
665
+ // copies, so mutating is fine).
666
+ //
667
+ // NOTE(mafredri): We could filter on "proc.containerID == dc.Container.ID"
668
+ // here but not doing so allows us to do some tricks in the UI to
669
+ // make the experience more responsive for now.
670
+ if proc := api .injectedSubAgentProcs [dc .WorkspaceFolder ];proc .agent .ID != uuid .Nil {
667
671
dc .Agent = & codersdk.WorkspaceAgentDevcontainerAgent {
668
- ID :agent .ID ,
669
- Name :agent .Name ,
670
- Directory :agent .Directory ,
672
+ ID :proc . agent .ID ,
673
+ Name :proc . agent .Name ,
674
+ Directory :proc . agent .Directory ,
671
675
}
672
676
}
673
677