@@ -30,6 +30,7 @@ import {
3030 dispatchCommandAtom ,
3131 isWriterAtom ,
3232 lastReconnectAttemptAtom ,
33+ providerListAtom ,
3334 reconnectAttemptCountAtom ,
3435 serverInfoAtom ,
3536 sessionsAtom ,
@@ -88,6 +89,7 @@ import {
8889} from "../features/workspace/atoms" ;
8990import { useActivation } from "../hooks/use-activation" ;
9091import { getThemeById , resolveStoredThemeId } from "../theme" ;
92+ import { useSyncTerminalThemeBackground } from "../theme/use-sync-terminal-theme-background" ;
9193import type { ConnectionStatus , EventListener } from "../ws" ;
9294import { resolveWsUrl , WsClient } from "../ws" ;
9395
@@ -221,6 +223,34 @@ function resetServerProjectedState(store: Store): void {
221223 }
222224}
223225
226+ function ProviderListBootstrapper ( ) {
227+ const connectionStatus = useAtomValue ( connectionStatusAtom ) ;
228+ const dispatch = useAtomValue ( dispatchCommandAtom ) ;
229+ const providerList = useAtomValue ( providerListAtom ) ;
230+ const setProviderList = useSetAtom ( providerListAtom ) ;
231+
232+ useEffect ( ( ) => {
233+ if ( connectionStatus !== "connected" || providerList . length > 0 ) {
234+ return ;
235+ }
236+
237+ let cancelled = false ;
238+
239+ void dispatch ( "provider.list" , { } ) . then ( ( result ) => {
240+ if ( cancelled || ! result . ok || ! Array . isArray ( result . data ) ) {
241+ return ;
242+ }
243+ setProviderList ( result . data ) ;
244+ } ) ;
245+
246+ return ( ) => {
247+ cancelled = true ;
248+ } ;
249+ } , [ connectionStatus , dispatch , providerList . length , setProviderList ] ) ;
250+
251+ return null ;
252+ }
253+
224254function parseWorkspaceRefreshHint (
225255 topic : string ,
226256 payload : unknown
@@ -302,6 +332,7 @@ export function AppProviders({ children }: AppProvidersProps) {
302332 const { claim } = useActivation ( ) ;
303333
304334 useSessionNotifications ( ) ;
335+ useSyncTerminalThemeBackground ( dispatch , activeWorkspaceId , connectionStatus ) ;
305336
306337 // Use refs to avoid stale closures in event handlers
307338 const wsClientRef = useRef < WsClient | null > ( null ) ;
@@ -1186,7 +1217,12 @@ export function AppProviders({ children }: AppProvidersProps) {
11861217 . catch ( ( ) => { } ) ;
11871218 } , [ activeWorkspaceId , activationStatus , authEnabled , authenticated , connectionStatus ] ) ;
11881219
1189- return < > { children } </ > ;
1220+ return (
1221+ < >
1222+ < ProviderListBootstrapper />
1223+ { children }
1224+ </ >
1225+ ) ;
11901226}
11911227
11921228function storeServerMetadata (
0 commit comments