@@ -7,7 +7,6 @@ import com.coder.gateway.models.TokenSource
7
7
import com.coder.gateway.models.WorkspaceAgentModel
8
8
import com.coder.gateway.models.WorkspaceAndAgentStatus
9
9
import com.coder.gateway.models.WorkspaceVersionStatus
10
- import com.coder.gateway.sdk.Arch
11
10
import com.coder.gateway.sdk.CoderCLIManager
12
11
import com.coder.gateway.sdk.CoderRestClientService
13
12
import com.coder.gateway.sdk.CoderSemVer
@@ -20,8 +19,8 @@ import com.coder.gateway.sdk.ex.AuthenticationResponseException
20
19
import com.coder.gateway.sdk.ex.TemplateResponseException
21
20
import com.coder.gateway.sdk.ex.WorkspaceResponseException
22
21
import com.coder.gateway.sdk.toURL
23
- import com.coder.gateway.sdk.v2.models.Workspace
24
22
import com.coder.gateway.sdk.v2.models.WorkspaceStatus
23
+ import com.coder.gateway.sdk.v2.models.toAgentModels
25
24
import com.coder.gateway.sdk.withPath
26
25
import com.coder.gateway.services.CoderSettingsState
27
26
import com.intellij.ide.ActivityTracker
@@ -659,7 +658,15 @@ class CoderWorkspacesStepView(val setNextButtonEnabled: (Boolean) -> Unit) : Cod
659
658
val timeBeforeRequestingWorkspaces = System .currentTimeMillis()
660
659
try {
661
660
val ws = clientService.client.workspaces()
662
- val ams = ws.flatMap { it.toAgentModels() }.toSet()
661
+ val ams = ws.flatMap { it.toAgentModels() }
662
+ ams.forEach {
663
+ cs.launch(Dispatchers .IO ) {
664
+ it.templateIcon = iconDownloader.load(it.templateIconPath, it.name)
665
+ withContext(Dispatchers .Main ) {
666
+ tableOfWorkspaces.updateUI()
667
+ }
668
+ }
669
+ }
663
670
val timeAfterRequestingWorkspaces = System .currentTimeMillis()
664
671
logger.info(" Retrieving the workspaces took: ${timeAfterRequestingWorkspaces - timeBeforeRequestingWorkspaces} millis" )
665
672
return @withContext ams
@@ -675,62 +682,6 @@ class CoderWorkspacesStepView(val setNextButtonEnabled: (Boolean) -> Unit) : Cod
675
682
}
676
683
}
677
684
678
- private fun Workspace.toAgentModels (): Set <WorkspaceAgentModel > {
679
- val wam = this .latestBuild.resources.filter { it.agents != null }.flatMap { it.agents!! }.map { agent ->
680
- val workspaceWithAgentName = " ${this .name} .${agent.name} "
681
- val wm = WorkspaceAgentModel (
682
- this .id,
683
- this .name,
684
- workspaceWithAgentName,
685
- this .templateID,
686
- this .templateName,
687
- this .templateIcon,
688
- null ,
689
- WorkspaceVersionStatus .from(this ),
690
- this .latestBuild.status,
691
- WorkspaceAndAgentStatus .from(this , agent),
692
- this .latestBuild.transition,
693
- OS .from(agent.operatingSystem),
694
- Arch .from(agent.architecture),
695
- agent.expandedDirectory ? : agent.directory,
696
- )
697
- cs.launch(Dispatchers .IO ) {
698
- wm.templateIcon = iconDownloader.load(wm.templateIconPath, wm.name)
699
- withContext(Dispatchers .Main ) {
700
- tableOfWorkspaces.updateUI()
701
- }
702
- }
703
- wm
704
- }.toSet()
705
-
706
- if (wam.isNullOrEmpty()) {
707
- val wm = WorkspaceAgentModel (
708
- this .id,
709
- this .name,
710
- this .name,
711
- this .templateID,
712
- this .templateName,
713
- this .templateIcon,
714
- null ,
715
- WorkspaceVersionStatus .from(this ),
716
- this .latestBuild.status,
717
- WorkspaceAndAgentStatus .from(this ),
718
- this .latestBuild.transition,
719
- null ,
720
- null ,
721
- null
722
- )
723
- cs.launch(Dispatchers .IO ) {
724
- wm.templateIcon = iconDownloader.load(wm.templateIconPath, wm.name)
725
- withContext(Dispatchers .Main ) {
726
- tableOfWorkspaces.updateUI()
727
- }
728
- }
729
- return setOf (wm)
730
- }
731
- return wam
732
- }
733
-
734
685
override fun onPrevious () {
735
686
super .onPrevious()
736
687
logger.info(" Going back to the main view" )
0 commit comments