From e5f1ff34ed415bce13ccfe08898dc08aba4246f5 Mon Sep 17 00:00:00 2001 From: 1xDed Date: Sat, 28 Nov 2026 17:30:39 +0300 Subject: [PATCH] test(startup): expose startup performance marks and clear cache on auth loss Marks splash/session/render/home timings in production as well, and drops cached home data when the session is rejected. --- src/components/splash/index.tsx | 2 +- src/main.tsx | 6 ++++++ src/routes/_api/home/index.tsx | 1 - 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/components/splash/index.tsx b/src/components/splash/index.tsx index 7321648..0740d82 100644 --- a/src/components/splash/index.tsx +++ b/src/components/splash/index.tsx @@ -13,7 +13,7 @@ const SplashHider = () => { // The effect runs after React committed the app shell; the static // splash has done its job and can fade out immediately. splash.classList.add("hidden"); - if (import.meta.env.DEV) performance.mark("blink:splash-hidden"); + performance.mark("blink:splash-hidden"); const timer = window.setTimeout(() => splash.remove(), 260); return () => window.clearTimeout(timer); }, []); diff --git a/src/main.tsx b/src/main.tsx index c77795d..96fa815 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -11,6 +11,7 @@ import { } from "./utils/store/api"; import { CentralProvider, useCentralStore } from "./utils/store/central"; import { + clearPersistedQueryCache, persistQueryCache, restoreQueryCache, } from "./utils/queryCachePersistence"; @@ -90,6 +91,8 @@ function ProviderWrapper() { // Only an actual authorization failure should log the user out. if (status !== 401 && status !== 403) return; await delUser(); + queryClient.clear(); + clearPersistedQueryCache(); createApi(api.basePath, undefined); router.navigate({ to: "/login/manual", @@ -122,6 +125,7 @@ function ProviderWrapper() { } const init = async () => { + performance.mark("blink:init-start"); // Frameless titlebar: macOS keeps the native traffic lights; Windows and // Linux use the custom window buttons in the header. const userAgent = navigator.userAgent; @@ -145,6 +149,7 @@ const init = async () => { }); const { api: initialApi, user: initialUser } = await initializeApi(); + performance.mark("blink:session-restored"); const owner = initialApi?.basePath && initialUser?.Id @@ -172,6 +177,7 @@ const init = async () => { , ); + performance.mark("blink:react-render"); }; init(); diff --git a/src/routes/_api/home/index.tsx b/src/routes/_api/home/index.tsx index 9116164..a53f5b6 100644 --- a/src/routes/_api/home/index.tsx +++ b/src/routes/_api/home/index.tsx @@ -179,7 +179,6 @@ function HomeContent({ api, user }: { api: Api; user: UserDto }) { }, []); useEffect(() => { - if (!import.meta.env.DEV) return; if (!libraries.data || !latestMedia.data) return; performance.mark("blink:home-ready"); }, [libraries.data, latestMedia.data]);