Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
perf(web): reuse and fully prefetch route payloads (MUL-9538) (#10920)
Jiayuan Zhang87dcb5746f10
diff --git a/apps/web/next.config.ts b/apps/web/next.config.tsindex 2af25d8d2a..cbf67acda8 100644--- a/apps/web/next.config.ts+++ b/apps/web/next.config.ts@@ -41,6 +41,13 @@ const allowedDevOrigins = process.env.CORS_ALLOWED_ORIGINSconst nextConfig: NextConfig = {...(process.env.STANDALONE === "true" ? { output: "standalone" as const } : {}),transpilePackages: ["@multica/core", "@multica/ui", "@multica/views", "@multica/ee"],+ experimental: {+ // Workspace pages are client components over TanStack Query, so a route's+ // RSC payload is the same on every visit. Reusing a visited or prefetched+ // one for 30s lets a click (an Inbox notification, back to an issue just+ // read) render without a server round trip first (MUL-9538).+ staleTimes: { dynamic: 30 },+ },...(allowedDevOrigins && allowedDevOrigins.length > 0? { allowedDevOrigins }: {}),diff --git a/apps/web/platform/navigation.test.tsx b/apps/web/platform/navigation.test.tsxindex 25359ad8cf..a2be57cdd7 100644--- a/apps/web/platform/navigation.test.tsx+++ b/apps/web/platform/navigation.test.tsx@@ -157,3 +157,13 @@ describe("WebNavigationProvider hash", () => {expect(adapter().hash).toBe("#comment-c2");});});++describe("WebNavigationProvider prefetch", () => {+ it("prefetches a route's full payload, not just its loading shell (MUL-9538)", () => {+ const adapter = renderAdapter();++ adapter().prefetch?.("/acme/issues/MUL-1");++ expect(router.prefetch).toHaveBeenCalledWith("/acme/issues/MUL-1", { kind: "full" });+ });+});diff --git a/apps/web/platform/navigation.tsx b/apps/web/platform/navigation.tsxindex 3215665c55..2ed5fc265f 100644--- a/apps/web/platform/navigation.tsx+++ b/apps/web/platform/navigation.tsx@@ -2,6 +2,7 @@import { Suspense, useEffect, useSyncExternalStore } from "react";import { useRouter, usePathname, useSearchParams } from "next/navigation";+import { PrefetchKind } from "next/dist/client/components/router-reducer/router-reducer-types";import {NavigationProvider,type NavigationAdapter,@@ -93,8 +94,11 @@ function NavigationProviderInner({// router.prefetch is a no-op in dev mode by Next.js design; in production// it warms the RSC payload + route chunk so the next push() commits with// no network round-trip. Safe to call repeatedly — Next dedupes internally.+ // FULL: workspace routes are dynamic, and the default prefetch stops at+ // their loading boundary, leaving the click to fetch the rest. Their+ // payload is a small client-component shell, so take all of it (MUL-9538).prefetch: (path: string) => {- router.prefetch(path);+ router.prefetch(path, { kind: PrefetchKind.FULL });},};