From 3fe800ee8dcf253c8fdf25e77042d66bb477f3c6 Mon Sep 17 00:00:00 2001 From: Zakk Date: Sun, 4 Oct 2026 04:45:10 +1100 Subject: [PATCH] perf(shell): mount the widget panel once the backend accepts the tab The sidebar's widget panel shows backend data, and its code shares the activity chunk. The frame painted while the first capabilities read is in flight mounted it for a moment, so from 1024 px a hosted sign-in page downloaded that chunk. The panel now mounts once capabilities load, the signal that starts the page warm-up; the backend indicator is unchanged. The hosted chunks test now runs at 1280 as well as 390. --- e2e/chunks.spec.ts | 15 +++++++++------ src/shell/widgets/host.tsx | 6 +++++- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/e2e/chunks.spec.ts b/e2e/chunks.spec.ts index 155e71f0..ac1f810d 100644 --- a/e2e/chunks.spec.ts +++ b/e2e/chunks.spec.ts @@ -190,18 +190,21 @@ const signInPages = [ }); } }, - { - // The first visit to a password-protected honk: no profile until discovery saves one. At phone width, since from - // 1024 px the sidebar's widget panel shares the Activity chunk. - name: 'a hosted backend on first visit', + // The first visit to a password-protected honk: no profile until discovery saves one. From 1024 px the sidebar hosts + // the widget panel, whose code shares the Activity chunk. + ...[ + {width: 1280, height: 800}, + {width: 390, height: 844} + ].map(viewport => ({ + name: `a hosted backend on first visit at ${viewport.width}`, pages: ['activity', ...pageChunks], - viewport: {width: 390, height: 844}, + viewport, ready: (page: Page) => page.getByRole('heading', {name: 'Token required'}), async setup(page: Page) { await page.route('**/api', route => route.fulfill(challenge)); await page.route('**/api/v1/**', route => route.fulfill(challenge)); } - } + })) ]; for (const {name, pages, viewport, ready, setup} of signInPages) { diff --git a/src/shell/widgets/host.tsx b/src/shell/widgets/host.tsx index 675e00b4..b30cac86 100644 --- a/src/shell/widgets/host.tsx +++ b/src/shell/widgets/host.tsx @@ -1,5 +1,6 @@ import {lazy, Suspense, useState, useSyncExternalStore, type ReactNode} from 'react'; import {useT} from '../../i18n'; +import {useCapabilities} from '../../store'; import {Button, VisuallyHidden, phoneQuery, sidebarQuery, useMediaQuery} from '../../ui/ui'; import {LoadBoundary} from '../../ui/LoadBoundary'; import WidgetsIcon from '../../ui/icons/Widgets'; @@ -34,7 +35,10 @@ export function SidebarWidgets({route, backend, honk}: {route: string; backend: const phone = useMediaQuery(phoneQuery); const layout = useWidgetLayout(); const [announcement, setAnnouncement] = useState({text: '', serial: 0}); - const shown = !phone && layout.visible; + // The panel shows backend data, so it mounts once the backend accepts the tab, as the pages warm; before that the + // frame painted during sign-in would download its code. + const accepted = !!useCapabilities().data; + const shown = accepted && !phone && layout.visible; const docked = sidebar && !!layout.docked; const indicator = ; const panel = (