From 2fd1e2b05de7d83f0f514d878c21440cafc22267 Mon Sep 17 00:00:00 2001 From: Jesse_Chen Date: Thu, 1 Oct 2026 00:19:56 +0800 Subject: [PATCH] perf(home): the HTML sends the cold-boot reads before the bundle runs (BUG-1127) An inline classic script on / starts account, people list, sessions and models; the boot takes each once from one global, falls back to the normal request on failure, drops another person's or another account's list, and trusts nothing older than 30s. Paths and init come from one shared module. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01N4f2nya58RoRu4yEmJgRGE --- frontend/src/app/layout.tsx | 4 + frontend/src/lib/boot-early-reads.ts | 123 ++++++++++++++++ frontend/src/lib/current-subject.ts | 10 +- frontend/src/lib/home-bootstrap-run.ts | 3 +- frontend/src/lib/home-cloud-sync.ts | 11 +- frontend/src/lib/session-list-context.tsx | 12 +- frontend/tests/chart-page-view.test.tsx | 13 +- .../tests/home-first-load-20260930.test.ts | 138 ++++++++++++++++++ frontend/tests/session-list-provider.test.ts | 13 +- 9 files changed, 310 insertions(+), 17 deletions(-) create mode 100644 frontend/src/lib/boot-early-reads.ts diff --git a/frontend/src/app/layout.tsx b/frontend/src/app/layout.tsx index e84f5edf..0aaeb1fd 100644 --- a/frontend/src/app/layout.tsx +++ b/frontend/src/app/layout.tsx @@ -5,6 +5,7 @@ import { Toaster } from "@/components/ui/sonner"; import { StaleBuildGuard } from "@/components/stale-build-guard"; import { StaleClientRecovery } from "@/components/stale-client-recovery"; import { ViewportScrollLock } from "@/components/viewport-scroll-lock"; +import { bootEarlyReadsScript } from "@/lib/boot-early-reads"; import { firstPaintFallbackBootScript } from "@/lib/first-paint-fallback"; import { themePreferenceBootScript } from "@/lib/theme-preference"; @@ -57,6 +58,9 @@ export default function RootLayout({ children }: Readonly<{ children: React.Reac