Improve loading speed of desktop app (#4865)

# Description of Changes
Improve loading speed of desktop app by loading a default config until
the backend has spawned.
This commit is contained in:
James Brunton
2025-11-11 11:54:43 +00:00
committed by GitHub
parent 4d349c047b
commit 044bf3c2aa
21 changed files with 622 additions and 137 deletions
@@ -1,5 +1,7 @@
import { ReactNode } from "react";
import { AppProviders as ProprietaryAppProviders } from "@proprietary/components/AppProviders";
import { DesktopConfigSync } from '@app/components/DesktopConfigSync';
import { DESKTOP_DEFAULT_APP_CONFIG } from '@app/config/defaultAppConfig';
/**
* Desktop application providers
@@ -13,7 +15,13 @@ export function AppProviders({ children }: { children: ReactNode }) {
maxRetries: 5,
initialDelay: 1000, // 1 second, with exponential backoff
}}
appConfigProviderProps={{
initialConfig: DESKTOP_DEFAULT_APP_CONFIG,
bootstrapMode: 'non-blocking',
autoFetch: false,
}}
>
<DesktopConfigSync />
{children}
</ProprietaryAppProviders>
);
@@ -0,0 +1,23 @@
import { useEffect, useRef } from 'react';
import { useBackendHealth } from '@app/hooks/useBackendHealth';
import { useAppConfig } from '@app/contexts/AppConfigContext';
/**
* Desktop-only bridge that refetches the app config once the bundled backend
* becomes healthy (and whenever it restarts). Keeps the UI responsive by using
* default config until the real config is available.
*/
export function DesktopConfigSync() {
const { status } = useBackendHealth();
const { refetch } = useAppConfig();
const previousStatus = useRef(status);
useEffect(() => {
if (status === 'healthy' && previousStatus.current !== 'healthy') {
refetch();
}
previousStatus.current = status;
}, [status, refetch]);
return null;
}