diff --git a/web/src/components/ui/charts/BusterChartJS/helpers/formatChartLabel.test.ts b/web/src/components/ui/charts/BusterChartJS/helpers/formatChartLabel.test.ts index 52d9cd038..c1ef3e09d 100644 --- a/web/src/components/ui/charts/BusterChartJS/helpers/formatChartLabel.test.ts +++ b/web/src/components/ui/charts/BusterChartJS/helpers/formatChartLabel.test.ts @@ -67,10 +67,10 @@ describe('formatChartLabel', () => { let result = formatChartLabel('recent_total__🔑__', columnLabelFormats, true, false); expect(result).toBe('Recent Total'); - // result = formatChartLabel('recent_total__🔑__', columnLabelFormats, false, false); - // expect(result).toBe('Recent Total'); + result = formatChartLabel('recent_total__🔑__', columnLabelFormats, false, false); + expect(result).toBe('Recent Total'); - // result = formatChartLabel('recent_total__🔑__', columnLabelFormats, false, true); - // expect(result).toBe('Recent Total'); + result = formatChartLabel('recent_total__🔑__', columnLabelFormats, false, true); + expect(result).toBe('Recent Total'); }); }); diff --git a/web/src/context/RoutePrefetcher.tsx b/web/src/context/RoutePrefetcher.tsx index 02695aecf..a586e8473 100644 --- a/web/src/context/RoutePrefetcher.tsx +++ b/web/src/context/RoutePrefetcher.tsx @@ -5,19 +5,26 @@ import { useRouter } from 'next/navigation'; import { BusterRoutes, createBusterRoute } from '@/routes'; import { BusterAppRoutes } from '@/routes/busterRoutes/busterAppRoutes'; import { useAsyncEffect } from '@/hooks'; +import { timeout } from '@/lib'; const PRIORITY_ROUTES = [ - BusterRoutes.APP_COLLECTIONS, - BusterRoutes.APP_DASHBOARDS, + BusterRoutes.APP_HOME, BusterRoutes.APP_CHAT, BusterRoutes.APP_CHAT_ID, - BusterRoutes.APP_CHAT_ID_METRIC_ID_CHART, - BusterRoutes.APP_HOME, + BusterRoutes.APP_METRIC_ID_CHART +]; + +const LOW_PRIORITY_ROUTES = [ BusterRoutes.APP_LOGS, BusterRoutes.APP_DATASETS, BusterRoutes.SETTINGS, BusterRoutes.APP_DASHBOARD_ID, - BusterRoutes.APP_METRIC_ID_CHART + BusterRoutes.APP_METRIC_ID_CHART, + BusterRoutes.APP_COLLECTIONS, + BusterRoutes.APP_DASHBOARDS, + BusterRoutes.APP_CHAT, + BusterRoutes.APP_CHAT_ID, + BusterRoutes.APP_CHAT_ID_METRIC_ID_CHART ]; export const RoutePrefetcher: React.FC<{}> = React.memo(() => { @@ -26,24 +33,29 @@ export const RoutePrefetcher: React.FC<{}> = React.memo(() => { const isPreFetchedRef = useRef(false); useAsyncEffect(async () => { - // Wait for page load - if (document.readyState !== 'complete') { - await new Promise((resolve) => { - window.addEventListener('load', resolve, { once: true }); - }); - } - - const prefetchRoutes = () => { + const prefetchRoutes = (routes: BusterRoutes[]) => { if (isPreFetchedRef.current) return; isPreFetchedRef.current = true; - PRIORITY_ROUTES.forEach((route) => { + routes.forEach((route) => { const path = createBusterRoute({ route: route as BusterAppRoutes.APP_COLLECTIONS }); router.prefetch(path); }); }; + prefetchRoutes(PRIORITY_ROUTES); + + // Wait for page load + if (document.readyState !== 'complete') { + await Promise.race([ + new Promise((resolve) => { + window.addEventListener('load', resolve, { once: true }); + }), + timeout(5000) + ]); + } + // Setup network activity monitoring const observer = new PerformanceObserver((list) => { // Clear any existing debounce timer @@ -53,7 +65,7 @@ export const RoutePrefetcher: React.FC<{}> = React.memo(() => { // Set a new debounce timer - will trigger if no network activity for 1500ms debounceTimerRef.current = setTimeout(() => { - prefetchRoutes(); + prefetchRoutes(LOW_PRIORITY_ROUTES); observer.disconnect(); }, 1500); }); @@ -62,9 +74,9 @@ export const RoutePrefetcher: React.FC<{}> = React.memo(() => { // Fallback - ensure prefetch happens even if network is already quiet const fallbackTimer = setTimeout(() => { - prefetchRoutes(); + prefetchRoutes(LOW_PRIORITY_ROUTES); observer.disconnect(); - }, 5000); + }, 6000); return () => { if (debounceTimerRef.current) clearTimeout(debounceTimerRef.current); diff --git a/web/src/layouts/ChatLayout/ChatContainer/ChatContent/ChatUserMessage.tsx b/web/src/layouts/ChatLayout/ChatContainer/ChatContent/ChatUserMessage.tsx index 4d24f0844..bf1b46e7b 100644 --- a/web/src/layouts/ChatLayout/ChatContainer/ChatContent/ChatUserMessage.tsx +++ b/web/src/layouts/ChatLayout/ChatContainer/ChatContent/ChatUserMessage.tsx @@ -59,7 +59,7 @@ export const ChatUserMessage: React.FC<{ ) : ( <>