@@ -51,6 +51,21 @@ const persister = createSyncStoragePersister({
5151 key : "lovcode:rq-cache" ,
5252} ) ;
5353
54+ const notifyAppReady = ( ) => window . dispatchEvent ( new Event ( "app:ready" ) ) ;
55+
56+ // Splash is a first-paint guard only. Chat history, sessions, and search index
57+ // work should render progressive loading states inside the app shell.
58+ window . addEventListener ( "app:ready" , ( ) => {
59+ const splash = document . getElementById ( "splash" ) ;
60+ if ( ! splash ) return ;
61+ splash . classList . add ( "fade" ) ;
62+ splash . addEventListener ( "transitionend" , ( ) => splash . remove ( ) , { once : true } ) ;
63+ } , { once : true } ) ;
64+
65+ // Safety net: if React render is delayed or a route never reports readiness,
66+ // drop the splash quickly so startup cannot get stuck behind data loading.
67+ setTimeout ( notifyAppReady , 1500 ) ;
68+
5469ReactDOM . createRoot ( document . getElementById ( "root" ) as HTMLElement ) . render (
5570 < I18nProvider >
5671 < PersistQueryClientProvider
@@ -81,16 +96,4 @@ ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
8196 </ I18nProvider > ,
8297) ;
8398
84- // Splash fade-out is triggered explicitly by the first layout that mounts
85- // (RootLayout / standalone pages dispatch "app:ready"). This avoids the
86- // flash of "Loading app…" between the splash and the real shell.
87- window . addEventListener ( "app:ready" , ( ) => {
88- const splash = document . getElementById ( "splash" ) ;
89- if ( ! splash ) return ;
90- splash . classList . add ( "fade" ) ;
91- splash . addEventListener ( "transitionend" , ( ) => splash . remove ( ) , { once : true } ) ;
92- } , { once : true } ) ;
93-
94- // Safety net: if no layout reports ready within 8s (e.g. unexpected error
95- // boundary), drop the splash anyway so the user isn't stuck staring at it.
96- setTimeout ( ( ) => window . dispatchEvent ( new Event ( "app:ready" ) ) , 8000 ) ;
99+ requestAnimationFrame ( ( ) => requestAnimationFrame ( notifyAppReady ) ) ;
0 commit comments