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.
This commit is contained in:
Zakk committed 2026-10-04 04:54:47 +11:00
1 parent da75ebdf2b
commit 3fe800ee8d
2 files changed
+14 -7

No files matched your search

+9 -6
View File
@@ -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) {
+5 -1
View File
@@ -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 = <BackendIndicator backend={backend} honk={honk} />;
const panel = (