Skip to content

Commit 02e6509

Browse files
Programcodeclaude
andcommitted
Address review round 2: load layout and page together after sign-in
- After a client-side navigation into /app (sign-in, the callback), the page chunk now starts with the layout chunk instead of after it. - The offline no-retry rule also matches reads through the dev:preview staging proxy path. - hero-visual.jpg and placeholder.svg also feed the worker's build id. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 9cb7200 commit 02e6509

3 files changed

Lines changed: 14 additions & 6 deletions

File tree

‎src/App.tsx‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { hasCompletedOnboarding, useOnboardingStore } from "@/hooks/use-onboardi
1414
import { OfflineIndicator } from "@/components/OfflineIndicator";
1515
import { StagingBanner } from "@/components/StagingBanner";
1616
import { captureException, captureProductEvent, toTelemetrySafeError } from "@/lib/observability";
17-
import { appLayoutLoader, routeLoaders, type RouteLoader } from "@/lib/route-modules";
17+
import { appLayoutLoader, preloadStartupRoute, routeLoaders, type RouteLoader } from "@/lib/route-modules";
1818
import type { PrerenderedRoute } from "@/lib/seo/pages";
1919
import { usePrivateRouteHead } from "@/lib/seo/use-page-head";
2020
import { RouteSkeleton, type RouteSkeletonVariant } from "@/components/loading/RouteSkeleton";
@@ -69,7 +69,12 @@ const MotionGeneratorToolPage = prerenderedPage("/tools/debate-motion-generator"
6969
const FlowSheetToolPage = prerenderedPage("/tools/debate-flow-sheet");
7070
const SpeechTimeCalculatorToolPage = prerenderedPage("/tools/speech-time-calculator");
7171
// Public pages never load the signed-in header, navigation and debate dialogs.
72-
const AppLayout = lazy(appLayoutLoader);
72+
// Arriving from sign-in, the page being opened loads alongside the layout
73+
// instead of after it.
74+
const AppLayout = lazy(() => {
75+
void preloadStartupRoute(window.location.pathname);
76+
return appLayoutLoader();
77+
});
7378
const OnboardingTour = lazy(() => import("@/components/features/onboarding/OnboardingTour")
7479
.then(({ OnboardingTour: Tour }) => ({ default: Tour })));
7580

‎src/lib/supabase/client.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
} from '@supabase/supabase-js';
77
import { e2eRefusesProductionRequest } from './e2e-guard';
88
import { getActiveEnv, SUPABASE_URL, SUPABASE_ANON_KEY } from './env';
9+
import { STAGING_PREVIEW_PROXY_PATH } from './projects';
910
import { verifySessionAfterRejection } from './session-expiry';
1011

1112
export { SUPABASE_URL };
@@ -48,7 +49,9 @@ function requestUrl(input: RequestInfo | URL): string {
4849
function isRetriedRead(url: string, method: string): boolean {
4950
if (method !== 'GET' && method !== 'HEAD') return false;
5051
try {
51-
const path = new URL(url, SUPABASE_URL).pathname;
52+
// `npm run dev:preview` reaches Supabase through a proxy path on its own origin.
53+
const fullPath = new URL(url, SUPABASE_URL).pathname;
54+
const path = fullPath.startsWith(`${STAGING_PREVIEW_PROXY_PATH}/`) ? fullPath.slice(STAGING_PREVIEW_PROXY_PATH.length) : fullPath;
5255
return path.startsWith('/rest/v1/') || path.startsWith('/functions/v1/') || path.startsWith('/storage/v1/');
5356
} catch {
5457
return false;

‎vite.config.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,11 @@ function serviceWorkerPrecache(): Plugin {
161161
const worker = readFileSync(workerPath, "utf8");
162162
if (!worker.includes(SERVICE_WORKER_BUILD)) throw new Error(`serviceWorkerPrecache: public/sw.js no longer contains ${SERVICE_WORKER_BUILD}`);
163163
// The unhashed files the worker serves cache-first (theme-init.js, the
164-
// icons) change the id too, so a deploy that changes only them still
165-
// ships a new worker.
164+
// icons and images) change the id too, so a deploy that changes only
165+
// them still ships a new worker.
166166
const hash = createHash("sha256").update(worker).update(assets.join("\n"));
167167
const publicDir = path.resolve(__dirname, "public");
168-
for (const file of readdirSync(publicDir).filter((name) => /\.(?:js|png|ico|webmanifest)$/.test(name) && name !== "sw.js").sort()) {
168+
for (const file of readdirSync(publicDir).filter((name) => /\.(?:js|png|ico|jpg|svg|webmanifest)$/.test(name) && name !== "sw.js").sort()) {
169169
hash.update(file).update(readFileSync(path.join(publicDir, file)));
170170
}
171171
const id = hash.digest("hex").slice(0, 12);

0 commit comments

Comments
 (0)