mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-14 06:40:50 +00:00
perf(prefetch): server-prefetch above-the-fold data for /insights, /medications, /coach
Extend the dashboard's RSC server-prefetch pattern to three more route roots so their above-the-fold content paints populated on first load instead of flashing a shell that fills in on mount. Each route gains a thin RSC wrapper that runs the same cached read its API route uses, dehydrates the result under the exact client query key, and hands it to the client leaf through a HydrationBoundary. Every wrapper fails soft to today's client-fetch path on any error and honours the DASHBOARD_SSR_PREFETCH kill-switch the e2e server sets. - /insights: prefetch the dashboard snapshot — the same locale-keyed cell the dashboard warms, resolved once server-side so the key matches by construction. The AI briefing and the heavy analytics aggregations stay client-lazy (the briefing must never trigger generation; a cold analytics read would trade FCP for TTFB). - /medications: prefetch the medications list through the shared caches.medications cell (extracted to src/lib/medications/list-read.ts). The list cell keeps refetchOnMount: "always" — a cross-device take/skip produces no client mutation event, so the mount refetch is a correctness gate; the prefetch removes the initial skeleton flash without dropping that guarantee. - /coach: prefetch the nudge status (extracted to src/lib/ai/coach/nudge-status.ts) so the auto-open-most-recent decision is ready at hydrate, collapsing the one sequential waterfall. Only runs when the Coach surface is reachable; the streaming conversation is never warmed. Add per-route tests pinning server-key === client-key, JSON wire-shape round-trip, and the fail-soft / module-gate paths. Repoint the source-reading insights, take-all-due, and Coach gate-cascade tests at the client leaves.
This commit is contained in:
1 parent
3743a46a40
commit
e0387c5ceb
20 files changed
+2349
-1691
No files matched your search
@@ -508,7 +508,7 @@ describe("<TakeAllDueDialog> — confirm dialog lists the due medications", () =
|
||||
"utf8",
|
||||
);
|
||||
const pageSrc = readFileSync(
|
||||
resolve(__dirname, "../../../app/medications/page.tsx"),
|
||||
resolve(__dirname, "../../../app/medications/page-client.tsx"),
|
||||
"utf8",
|
||||
);
|
||||
|
||||
|
||||
Reference in new issue
Block a user