fix: improve startup readiness performance
This commit is contained in:
+10
-2
@@ -56,6 +56,7 @@ import { SyncAppEffects } from '@/apps/AppEffects';
|
||||
import { useAppFontEffects } from '@/apps/useAppFontEffects';
|
||||
import { resetStreamingState } from '@/sync/streaming';
|
||||
import { OpenCodeUpdateToast } from '@/components/update/OpenCodeUpdateToast';
|
||||
import { markStartupTrace, startupTraceEnabled } from '@/lib/startupTrace';
|
||||
|
||||
// Lazy-loaded heavy views — loaded on demand to reduce initial bundle size.
|
||||
const OnboardingScreen = lazyWithChunkRecovery(() =>
|
||||
@@ -201,6 +202,13 @@ const EmbeddedSessionChatContent: React.FC<{
|
||||
};
|
||||
|
||||
function App({ apis }: AppProps) {
|
||||
React.useEffect(() => {
|
||||
markStartupTrace('App:mounted');
|
||||
if (startupTraceEnabled()) {
|
||||
console.info('[startup-trace] enabled. Run console.table(window.__OPENCHAMBER_STARTUP_TRACE__) after startup.');
|
||||
}
|
||||
}, []);
|
||||
|
||||
const initializeApp = useConfigStore((s) => s.initializeApp);
|
||||
const isInitialized = useConfigStore((s) => s.isInitialized);
|
||||
const isConnected = useConfigStore((s) => s.isConnected);
|
||||
@@ -470,8 +478,8 @@ function App({ apis }: AppProps) {
|
||||
const state = useConfigStore.getState();
|
||||
if (state.providers.length > 0 && state.agents.length > 0) return;
|
||||
try {
|
||||
if (state.providers.length === 0) await loadProviders();
|
||||
if (useConfigStore.getState().agents.length === 0) await loadAgents();
|
||||
if (state.providers.length === 0) await loadProviders({ source: 'startupRecovery' });
|
||||
if (useConfigStore.getState().agents.length === 0) await loadAgents({ source: 'startupRecovery' });
|
||||
} catch { /* retry next interval */ }
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user