@@ -171,12 +171,16 @@ class CoderGatewayRecentWorkspaceConnectionsView(private val setContentCallback:
171
171
}else {
172
172
false
173
173
}
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
+ }
175
179
val status=
176
180
if (deploymentError!= null ) {
177
181
Triple (UIUtil .getErrorForeground(), deploymentError,UIUtil .getBalloonErrorIcon())
178
182
}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)
180
184
181
185
Triple (
182
186
workspaceWithAgent.status.statusColor(),
@@ -244,7 +248,7 @@ class CoderGatewayRecentWorkspaceConnectionsView(private val setContentCallback:
244
248
foreground= Color .GRAY
245
249
}
246
250
}
247
- label(workspaceProjectIDE.name.replace(workspaceName + " ." ," " )).resizableColumn()
251
+ label(workspaceProjectIDE.name.replace(" $workspaceName ." ," " )).resizableColumn()
248
252
label(workspaceProjectIDE.ideName).applyToComponent {
249
253
foreground= JBUI .CurrentTheme .ContextHelp .FOREGROUND
250
254
font= ComponentPanelBuilder .getCommentFont(font)
@@ -276,7 +280,10 @@ class CoderGatewayRecentWorkspaceConnectionsView(private val setContentCallback:
276
280
}
277
281
278
282
/* *
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.
280
287
*/
281
288
private fun getConnectionsByDeployment (filter : Boolean ):Map <String ,Map <String ,List <WorkspaceProjectIDE >>>= recentConnectionsService.getAllRecentConnections()
282
289
// Validate and parse connections.
@@ -351,10 +358,20 @@ class CoderGatewayRecentWorkspaceConnectionsView(private val setContentCallback:
351
358
throw Exception (" Unable to make request; token was not found in CLI config." )
352
359
}
353
360
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
+
354
366
// Delete connections that have no workspace.
367
+ // TODO: Deletion without confirmation seems sketchy.
355
368
val items= client.workspaces().flatMap { it.toAgentList() }
356
369
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
+ ) {
358
375
logger.info(" Removing recent connections for deleted workspace$name (found${connections.size} )" )
359
376
connections.forEach { recentConnectionsService.removeConnection(it.toRecentWorkspaceConnection()) }
360
377
}