@@ -87,11 +87,11 @@ import { getPairingTokenFromUrl, setPairingTokenOnUrl } from "../../pairingUrl";
8787import { readHostedPairingRequest } from "../../hostedPairing" ;
8888import {
8989 createServerPairingCredential ,
90- fetchSessionState ,
9190 revokeOtherServerClientSessions ,
9291 revokeServerClientSession ,
9392 revokeServerPairingLink ,
9493 isLoopbackHostname ,
94+ usePrimarySessionState ,
9595 type ServerClientSessionRecord ,
9696 type ServerPairingLinkRecord ,
9797} from "~/environments/primary" ;
@@ -1584,13 +1584,13 @@ const DesktopSshHostRow = memo(function DesktopSshHostRow({
15841584
15851585export function ConnectionsSettings ( ) {
15861586 const desktopBridge = window . desktopBridge ;
1587- const [ currentSessionScopes , setCurrentSessionScopes ] =
1588- useState < ReadonlyArray < AuthEnvironmentScope > | null > (
1589- desktopBridge ? AuthAdministrativeScopes : null ,
1590- ) ;
1591- const [ currentAuthPolicy , setCurrentAuthPolicy ] = useState <
1592- "desktop-managed-local" | "loopback-browser" | "remote-reachable" | "unsafe-no-auth" | null
1593- > ( desktopBridge ? null : null ) ;
1587+ const primarySessionState = usePrimarySessionState ( ) ;
1588+ const currentSessionScopes = desktopBridge
1589+ ? AuthAdministrativeScopes
1590+ : primarySessionState . data ?. authenticated
1591+ ? ( primarySessionState . data . scopes ?? null )
1592+ : null ;
1593+ const currentAuthPolicy = desktopBridge ? null : ( primarySessionState . data ?. auth . policy ?? null ) ;
15941594 const savedEnvironmentsById = useSavedEnvironmentRegistryStore ( ( state ) => state . byId ) ;
15951595 const savedEnvironmentIds = useMemo (
15961596 ( ) =>
@@ -2113,30 +2113,6 @@ export function ConnectionsSettings() {
21132113 savedBackendMode ,
21142114 ] ) ;
21152115
2116- useEffect ( ( ) => {
2117- if ( desktopBridge ) {
2118- setCurrentSessionScopes ( AuthAdministrativeScopes ) ;
2119- return ;
2120- }
2121-
2122- let cancelled = false ;
2123- void fetchSessionState ( )
2124- . then ( ( session ) => {
2125- if ( cancelled ) return ;
2126- setCurrentSessionScopes ( session . authenticated ? ( session . scopes ?? null ) : null ) ;
2127- setCurrentAuthPolicy ( session . auth . policy ) ;
2128- } )
2129- . catch ( ( ) => {
2130- if ( cancelled ) return ;
2131- setCurrentSessionScopes ( null ) ;
2132- setCurrentAuthPolicy ( null ) ;
2133- } ) ;
2134-
2135- return ( ) => {
2136- cancelled = true ;
2137- } ;
2138- } , [ desktopBridge ] ) ;
2139-
21402116 useEffect ( ( ) => {
21412117 if ( ! canManageLocalBackend ) return ;
21422118
0 commit comments