diff --git a/apps/desktop/electron/active-ssh-route.ts b/apps/desktop/electron/active-ssh-route.ts new file mode 100644 index 0000000000..2351a959f1 --- /dev/null +++ b/apps/desktop/electron/active-ssh-route.ts @@ -0,0 +1,19 @@ +import { backendScopeKey, type ConnectionRegistry } from './connection-registry' + +/** + * Return the live SSH pool scope for the registry connection currently used by + * the Sessions workspace. Non-SSH sources deliberately return null so callers + * can preserve the legacy v1 routing fallback. + */ +export function activeRegistrySshScope( + registry: ConnectionRegistry, + profile: null | string | undefined +): null | string { + const connection = registry.connections.find(candidate => candidate.id === registry.lastUsed) + + if (!connection || connection.kind !== 'ssh') { + return null + } + + return backendScopeKey(connection.id, profile) +}