@@ -171,12 +171,16 @@ class CoderGatewayRecentWorkspaceConnectionsView(private val setContentCallback:
171171 } else {
172172 false
173173 }
174- val workspaceWithAgent = deployment?.items?.firstOrNull { it.workspace.name == workspaceName }
174+ val me = deployment?.client?.me?.username
175+ val workspaceWithAgent = deployment?.items?.firstOrNull {
176+ it.workspace.ownerName + " /" + it.workspace.name == workspaceName ||
177+ (it.workspace.ownerName == me && it.workspace.name == workspaceName)
178+ }
175179 val status =
176180 if (deploymentError != null ) {
177181 Triple (UIUtil .getErrorForeground(), deploymentError, UIUtil .getBalloonErrorIcon())
178182 } else if (workspaceWithAgent != null ) {
179- val inLoadingState = listOf (WorkspaceStatus .STARTING , WorkspaceStatus .CANCELING , WorkspaceStatus .DELETING , WorkspaceStatus .STOPPING ).contains(workspaceWithAgent? .workspace? .latestBuild? .status)
183+ val inLoadingState = listOf (WorkspaceStatus .STARTING , WorkspaceStatus .CANCELING , WorkspaceStatus .DELETING , WorkspaceStatus .STOPPING ).contains(workspaceWithAgent.workspace.latestBuild.status)
180184
181185 Triple (
182186 workspaceWithAgent.status.statusColor(),
@@ -244,7 +248,7 @@ class CoderGatewayRecentWorkspaceConnectionsView(private val setContentCallback:
244248 foreground = Color .GRAY
245249 }
246250 }
247- label(workspaceProjectIDE.name.replace(workspaceName + " ." , " " )).resizableColumn()
251+ label(workspaceProjectIDE.name.replace(" $workspaceName ." , " " )).resizableColumn()
248252 label(workspaceProjectIDE.ideName).applyToComponent {
249253 foreground = JBUI .CurrentTheme .ContextHelp .FOREGROUND
250254 font = ComponentPanelBuilder .getCommentFont(font)
@@ -276,7 +280,10 @@ class CoderGatewayRecentWorkspaceConnectionsView(private val setContentCallback:
276280 }
277281
278282 /* *
279- * Get valid connections grouped by deployment and workspace.
283+ * Get valid connections grouped by deployment and workspace name. The
284+ * workspace name will be in the form `owner/workspace.agent`, without the agent
285+ * name, or just `workspace`, if the connection predates when we added owner
286+ * information, in which case it belongs to the current user.
280287 */
281288 private fun getConnectionsByDeployment (filter : Boolean ): Map <String , Map <String , List <WorkspaceProjectIDE >>> = recentConnectionsService.getAllRecentConnections()
282289 // Validate and parse connections.
@@ -351,10 +358,20 @@ class CoderGatewayRecentWorkspaceConnectionsView(private val setContentCallback:
351358 throw Exception (" Unable to make request; token was not found in CLI config." )
352359 }
353360
361+ // This is purely to populate the current user, which is
362+ // used to match workspaces that were not recorded with owner
363+ // information.
364+ val me = client.authenticate().username
365+
354366 // Delete connections that have no workspace.
367+ // TODO: Deletion without confirmation seems sketchy.
355368 val items = client.workspaces().flatMap { it.toAgentList() }
356369 connectionsByWorkspace.forEach { (name, connections) ->
357- if (items.firstOrNull { it.workspace.name == name } == null ) {
370+ if (items.firstOrNull {
371+ it.workspace.ownerName + " /" + it.workspace.name == name ||
372+ (it.workspace.ownerName == me && it.workspace.name == name)
373+ } == null
374+ ) {
358375 logger.info(" Removing recent connections for deleted workspace $name (found ${connections.size} )" )
359376 connections.forEach { recentConnectionsService.removeConnection(it.toRecentWorkspaceConnection()) }
360377 }
0 commit comments