@@ -99,57 +99,68 @@ export const getWindowFullscreenState = DesktopIpc.makeSyncIpcMethod({
9999 } ) ,
100100} ) ;
101101
102- export const getLocalEnvironmentBootstraps = DesktopIpc . makeSyncIpcMethod ( {
103- channel : IpcChannels . GET_LOCAL_ENVIRONMENT_BOOTSTRAPS_CHANNEL ,
104- result : Schema . Array ( DesktopEnvironmentBootstrapSchema ) ,
105- handler : Effect . fn ( "desktop.ipc.window.getLocalEnvironmentBootstraps" ) ( function * ( ) {
106- const pool = yield * DesktopBackendPool . DesktopBackendPool ;
107- const configuration = yield * DesktopBackendConfiguration . DesktopBackendConfiguration ;
108- const instances = yield * pool . list ;
109- const bootstraps : DesktopEnvironmentBootstrap [ ] = [ ] ;
110- for ( const instance of instances ) {
111- const isPrimary = instance . id === PRIMARY_LOCAL_ENVIRONMENT_ID ;
112- const config = yield * instance . currentConfig ;
113- const snapshot = yield * instance . snapshot ;
114- if ( Option . isNone ( config ) || Option . isSome ( config . value . preflightFailure ) ) {
115- const fatalPreflight =
116- Option . isSome ( config ) &&
117- Option . isSome ( config . value . preflightFailure ) &&
118- config . value . preflightFailure . value . fatal ;
119- const stoppedPreflight =
120- Option . isSome ( config ) &&
121- Option . isSome ( config . value . preflightFailure ) &&
122- ( ! snapshot . desiredRunning || ! snapshot . restartScheduled ) ;
123- if ( isPrimary || fatalPreflight || stoppedPreflight ) continue ;
124- bootstraps . push ( {
125- id : instance . id ,
126- label : yield * instance . label ,
127- runningDistro : null ,
128- httpBaseUrl : null ,
129- wsBaseUrl : null ,
130- } ) ;
131- continue ;
132- }
133- const { bootstrap, httpBaseUrl } = config . value ;
134- const runningDistro = config . value . runningDistro ?? null ;
102+ const readLocalEnvironmentBootstrapSnapshot = Effect . fn (
103+ "desktop.ipc.window.getLocalEnvironmentBootstraps" ,
104+ ) ( function * ( ) {
105+ const pool = yield * DesktopBackendPool . DesktopBackendPool ;
106+ const configuration = yield * DesktopBackendConfiguration . DesktopBackendConfiguration ;
107+ const instances = yield * pool . list ;
108+ const bootstraps : DesktopEnvironmentBootstrap [ ] = [ ] ;
109+ for ( const instance of instances ) {
110+ const isPrimary = instance . id === PRIMARY_LOCAL_ENVIRONMENT_ID ;
111+ const config = yield * instance . currentConfig ;
112+ const snapshot = yield * instance . snapshot ;
113+ if ( Option . isNone ( config ) || Option . isSome ( config . value . preflightFailure ) ) {
114+ const fatalPreflight =
115+ Option . isSome ( config ) &&
116+ Option . isSome ( config . value . preflightFailure ) &&
117+ config . value . preflightFailure . value . fatal ;
118+ const stoppedPreflight =
119+ Option . isSome ( config ) &&
120+ Option . isSome ( config . value . preflightFailure ) &&
121+ ( ! snapshot . desiredRunning || ! snapshot . restartScheduled ) ;
122+ if ( isPrimary || fatalPreflight || stoppedPreflight ) continue ;
135123 bootstraps . push ( {
136124 id : instance . id ,
137- label : runningDistro === null ? yield * instance . label : `WSL (${ runningDistro } )` ,
138- runningDistro,
139- httpBaseUrl : httpBaseUrl . href ,
140- wsBaseUrl : toWebSocketBaseUrl ( httpBaseUrl ) ,
141- // A backend launched with the desktop secret accepts whichever token the secret derives
142- // for the current window, so hand out that one rather than the token frozen into its
143- // launch config.
144- ...( bootstrap . desktopBootstrapSecret
145- ? { bootstrapToken : yield * configuration . currentBootstrapToken }
146- : bootstrap . desktopBootstrapToken
147- ? { bootstrapToken : bootstrap . desktopBootstrapToken }
148- : { } ) ,
125+ label : yield * instance . label ,
126+ runningDistro : null ,
127+ httpBaseUrl : null ,
128+ wsBaseUrl : null ,
149129 } ) ;
130+ continue ;
150131 }
151- return bootstraps ;
152- } ) ,
132+ const { bootstrap, httpBaseUrl } = config . value ;
133+ const runningDistro = config . value . runningDistro ?? null ;
134+ bootstraps . push ( {
135+ id : instance . id ,
136+ label : runningDistro === null ? yield * instance . label : `WSL (${ runningDistro } )` ,
137+ runningDistro,
138+ httpBaseUrl : httpBaseUrl . href ,
139+ wsBaseUrl : toWebSocketBaseUrl ( httpBaseUrl ) ,
140+ // A backend launched with the desktop secret accepts whichever token the secret derives
141+ // for the current window, so hand out that one rather than the token frozen into its
142+ // launch config.
143+ ...( bootstrap . desktopBootstrapSecret
144+ ? { bootstrapToken : yield * configuration . currentBootstrapToken }
145+ : bootstrap . desktopBootstrapToken
146+ ? { bootstrapToken : bootstrap . desktopBootstrapToken }
147+ : { } ) ,
148+ } ) ;
149+ }
150+ return bootstraps ;
151+ } ) ;
152+
153+ export const getLocalEnvironmentBootstraps = DesktopIpc . makeSyncIpcMethod ( {
154+ channel : IpcChannels . GET_LOCAL_ENVIRONMENT_BOOTSTRAPS_CHANNEL ,
155+ result : Schema . Array ( DesktopEnvironmentBootstrapSchema ) ,
156+ handler : readLocalEnvironmentBootstrapSnapshot ,
157+ } ) ;
158+
159+ export const readLocalEnvironmentBootstraps = DesktopIpc . makeIpcMethod ( {
160+ channel : IpcChannels . GET_LOCAL_ENVIRONMENT_BOOTSTRAPS_CHANNEL ,
161+ payload : Schema . Void ,
162+ result : Schema . Array ( DesktopEnvironmentBootstrapSchema ) ,
163+ handler : readLocalEnvironmentBootstrapSnapshot ,
153164} ) ;
154165
155166function extractWslDistroFromEnvironmentId ( envId : string ) : string | null {
0 commit comments