fix: improve startup readiness performance

This commit is contained in:
Bohdan Triapitsyn
2026-06-05 15:09:24 +03:00
parent 0b881fec8e
commit e192359da9
32 changed files with 502 additions and 110 deletions
+10 -2
View File
@@ -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 */ }
};