From cab64a4abf06be00df8138bbbdeaf84450a53d55 Mon Sep 17 00:00:00 2001 From: Alan Daniel Date: Wed, 8 Apr 2026 11:52:32 -0400 Subject: [PATCH 1/2] Improve dashboard caching and preloading --- .../components/layouts/dashboard-topbar.tsx | 127 ++-- .../src/components/pulls/pull-request-row.tsx | 11 +- apps/dashboard/src/lib/auth-runtime.ts | 76 +++ apps/dashboard/src/lib/auth.functions.ts | 12 +- apps/dashboard/src/lib/github-cache-policy.ts | 12 +- apps/dashboard/src/lib/github-cache.test.ts | 3 + apps/dashboard/src/lib/github-cache.ts | 32 +- apps/dashboard/src/lib/github.functions.ts | 541 +++++++++++------- apps/dashboard/src/lib/github.query.ts | 67 ++- apps/dashboard/src/lib/github.server.ts | 6 +- apps/dashboard/src/lib/github.types.ts | 11 + apps/dashboard/src/lib/query-client.tsx | 108 +++- apps/dashboard/src/lib/route-preload.ts | 32 ++ apps/dashboard/src/lib/tab-store.ts | 10 +- .../$owner/$repo/issues.$issueId.tsx | 138 ++++- .../_protected/$owner/$repo/pull.$pullId.tsx | 148 ++++- .../dashboard/src/routes/_protected/index.tsx | 8 + .../src/routes/_protected/issues.tsx | 6 + .../dashboard/src/routes/_protected/pulls.tsx | 4 + .../src/routes/_protected/reviews.tsx | 4 + 20 files changed, 1007 insertions(+), 349 deletions(-) create mode 100644 apps/dashboard/src/lib/auth-runtime.ts create mode 100644 apps/dashboard/src/lib/route-preload.ts diff --git a/apps/dashboard/src/components/layouts/dashboard-topbar.tsx b/apps/dashboard/src/components/layouts/dashboard-topbar.tsx index 22f47f4..6da67d4 100644 --- a/apps/dashboard/src/components/layouts/dashboard-topbar.tsx +++ b/apps/dashboard/src/components/layouts/dashboard-topbar.tsx @@ -25,6 +25,7 @@ import { Link, useRouter } from "@tanstack/react-router"; import { useTheme } from "next-themes"; import { useCallback, useEffect, useRef, useState } from "react"; import { signOutToLogin } from "#/lib/auth-actions"; +import { preloadRouteOnce } from "#/lib/route-preload"; import { removeTab, type Tab, useTabs } from "#/lib/tab-store"; interface DashboardTopbarProps { @@ -59,6 +60,8 @@ const tabIconMap = { issue: IssuesIcon, } as const; +const primaryNavRoutes = ["/", "/pulls", "/issues", "/reviews"] as const; + export function DashboardTopbar({ user, tabsReady, @@ -124,8 +127,24 @@ export function DashboardTopbar({ }, ]; + useEffect(() => { + if (!tabsReady) return; + + void Promise.allSettled( + primaryNavRoutes.map((to) => router.preloadRoute({ to })), + ); + }, [router, tabsReady]); + + useEffect(() => { + if (!tabsReady || openTabs.length === 0) return; + + void Promise.allSettled( + openTabs.map((tab) => preloadRouteOnce(router, tab.url)), + ); + }, [router, tabsReady, openTabs]); + return ( -