Expand file tree Collapse file tree 3 files changed +13
-65
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ data class WorkspaceAgentListModel(
16
16
var icon : Icon ? = null ,
17
17
// The combined status of the workspace and agent to display on the row.
18
18
val status : WorkspaceAndAgentStatus = WorkspaceAndAgentStatus .from(workspace, agent),
19
- // The combined `workspace.agent` name to display on the row.
19
+ // The combined `workspace.agent` name to display on the row. Users can have workspaces with the same name, so it
20
+ // must not be used as a unique identifier.
20
21
val name : String = if (agent != null) " ${workspace.name} .${agent.name} " else workspace.name,
21
22
)
Original file line number Diff line number Diff line change @@ -989,17 +989,19 @@ class WorkspacesTable : TableView<WorkspaceAgentListModel>(WorkspacesTableModel(
989
989
}
990
990
}
991
991
992
- fun getNewSelection (oldSelection : WorkspaceAgentListModel ? ): Int {
992
+ /* *
993
+ * If a row becomes unselected because the workspace turned on, find the
994
+ * first agent row and select that.
995
+ *
996
+ * If a row becomes unselected because the workspace turned off, find the
997
+ * workspace row and select that.
998
+ */
999
+ private fun getNewSelection (oldSelection : WorkspaceAgentListModel ? ): Int {
993
1000
if (oldSelection == null ) {
994
1001
return - 1
995
1002
}
996
- val index = listTableModel.items.indexOfFirst { it.name == oldSelection.name }
997
- if (index > - 1 ) {
998
- return index
999
- }
1000
- // If there is no matching agent, try matching on just the workspace.
1001
- // It is possible it turned off so it no longer has agents displaying;
1002
- // in this case we want to keep it highlighted.
1003
- return listTableModel.items.indexOfFirst { it.workspace.name == oldSelection.workspace.name }
1003
+ // Both cases are handled by just looking for the ID, since we only ever
1004
+ // show agents or a workspace but never both.
1005
+ return listTableModel.items.indexOfFirst { it.workspace.id == oldSelection.workspace.id }
1004
1006
}
1005
1007
}
Load Diff This file was deleted.
0 commit comments