diff --git a/web/packages/teleterm/src/ui/TopBar/Connections/ConnectionsFilterableList/ConnectionItem.tsx b/web/packages/teleterm/src/ui/TopBar/Connections/ConnectionsFilterableList/ConnectionItem.tsx index 551180a129d8f..76ab29dfd42c8 100644 --- a/web/packages/teleterm/src/ui/TopBar/Connections/ConnectionsFilterableList/ConnectionItem.tsx +++ b/web/packages/teleterm/src/ui/TopBar/Connections/ConnectionsFilterableList/ConnectionItem.tsx @@ -167,12 +167,6 @@ function getKindName(connection: ExtendedTrackedConnection): string { case 'connection.kube': return 'KUBE'; default: - // The default branch is triggered when the state read from the disk - // contains a connection not supported by the given Connect version. - // - // For example, the user can open an app connection in Connect v15 - // and then downgrade to a version that doesn't support apps. - // That connection should be shown as 'UNKNOWN' in the connection list. return 'UNKNOWN'; } } diff --git a/web/packages/teleterm/src/ui/services/connectionTracker/connectionTrackerService.ts b/web/packages/teleterm/src/ui/services/connectionTracker/connectionTrackerService.ts index af1d53feca6fd..91055b8266670 100644 --- a/web/packages/teleterm/src/ui/services/connectionTracker/connectionTrackerService.ts +++ b/web/packages/teleterm/src/ui/services/connectionTracker/connectionTrackerService.ts @@ -76,15 +76,27 @@ export class ConnectionTrackerService extends ImmutableStore { - const { rootClusterUri, leafClusterUri } = - this._trackedConnectionOperationsFactory.create(connection); - const clusterUri = leafClusterUri || rootClusterUri; - const clusterName = - this._clusterService.findCluster(clusterUri)?.name || - routing.parseClusterName(clusterUri); - return { ...connection, clusterName }; - }); + return this.state.connections + .map(connection => { + const trackedConnection = + this._trackedConnectionOperationsFactory.create(connection); + // A connection is undefined when the state read from the disk + // contains a connection not supported by the given Connect version. + // + // For example, the user can open a desktop connection in Connect v18 + // and then downgrade to a version that doesn't support desktops. + // That connection shouldn't be shown on the list. + if (!trackedConnection) { + return; + } + const { rootClusterUri, leafClusterUri } = trackedConnection; + const clusterUri = leafClusterUri || rootClusterUri; + const clusterName = + this._clusterService.findCluster(clusterUri)?.name || + routing.parseClusterName(clusterUri); + return { ...connection, clusterName }; + }) + .filter(Boolean); } async activateItem(