diff --git a/website/app/layout.ts b/website/app/layout.ts index 3c91fb4b1..6c918f1e9 100644 --- a/website/app/layout.ts +++ b/website/app/layout.ts @@ -60,8 +60,19 @@ export function generateMetadata(ctx: { url: string }) { const navLink = 'text-fg-muted no-underline font-medium text-sm px-[11px] py-2 rounded-lg transition-colors duration-[140ms] hover:text-fg hover:bg-bg-subtle'; const panelLink = 'text-fg-muted no-underline font-medium text-sm px-3 py-[10px] rounded-[9px] hover:text-fg hover:bg-bg-subtle'; -export default function RootLayout({ children }: { children: unknown }) { +export default function RootLayout({ children, url }: { children: unknown; url?: string | URL }) { const nonce = cspNonce(); + // #936 on-device A/B diagnostic. Inert unless the ENTRY page is loaded with + // ?diag=. The mode is baked into a head script that persists across + // client-router soft navs (add-only head merge keeps it), so loading + // /?diag=nudge once governs the whole session. Whitelisted so the value that + // reaches the inline script is always a known literal. + const DIAG_MODES = new Set(['control', 'reflow', 'repaint', 'recolor', 'nudge']); + let diagMode = ''; + try { + const raw = new URL(String(url ?? ''), 'http://x').searchParams.get('diag') || ''; + if (DIAG_MODES.has(raw)) diagMode = raw; + } catch { /* no url in this context */ } return html` @@ -141,6 +152,51 @@ export default function RootLayout({ children }: { children: unknown }) { }); + + ${diagMode ? html`` : ''} +