From 738bdc35e6c78d802d8df61a0e6d16d664ec0037 Mon Sep 17 00:00:00 2001 From: CrysisDeu <32421101+CrysisDeu@users.noreply.github.com> Date: Tue, 29 Sep 2026 03:51:47 +0000 Subject: [PATCH] feat(ui): notification panes wear the composer's liquid glass MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The in-app notification banner and the bell popover's rows were the last floating surfaces still built from their own tint, blur, border and shadow classes (MAC_CARD_* / BANNER_CARD_* / CARD_MATERIAL in notifMeta) while the composer dock and the mobile Settings capsule had moved onto the Glass primitive. Two generations of material sat one above the other on the same screen. NotificationCard is now a pane, so the banner card, every popover row, the banner's blank deck shells, its "+N more in your inbox" pill, the feed's controls card and its stack edges are one material. The card no longer knows which surface it is on: the pane reads correctly over the sheet's scrim and over page content alike, so the elevation prop (popover / banner) and its data-elevation attribute, whose only remaining job was picking one of two tints, are deleted with the tints. State is a tint step on the host, never an edge and never an opacity: glass-accent for the selected row (was a border-accent + accent-subtle fill), glass-hover on a pressable card, and a new glass-faded step (the tint thinned to 55%) for a silenced row (was a dashed border), a collapsed stack's edges and the banner's deck shells. Opacity on a glass host would make it a backdrop root and void its own blur, so the banner deck's per-depth wrapper opacity goes too; the shells carry the faded step instead. The first-note-from-a-channel prompt becomes its own accent-tinted chip pane under the row, since a pane has one radius and cannot be glued to the card's bottom edge. Action capsules are unchanged. A list of panes mounts many equal boxes in one commit, so the displacement map — a pure function of size, radius and band — is now memoised across LiquidGlass instances in a small bounded cache: N equal popover rows cost one canvas encode, not N. Every pane still carries notif-material: the index.css hook that solidifies these surfaces to the card colour where backdrop-filter is unsupported, and the selector the sheet's background-press verdict keys on. The material constants are deleted; the shared-card test pins that the card is a Glass pane with no material classes, no opacity and no surface marker of its own, and that state is a tint step. The banner capture harness gains popover-states (selected + silenced + collapsed stack) and popover-channel-prompt frames. --- .../system-specs/modules/app-notifications.md | 26 ++++-- .../scripts/capture-notification-banner.mjs | 85 +++++++++++++++++++ website/src/components/Glass.tsx | 6 +- .../notifications/NotificationBanner.tsx | 34 +++++--- .../notifications/NotificationCard.tsx | 52 ++++++------ .../notifications/NotificationFeed.tsx | 80 +++++++++-------- .../components/notifications/notifMeta.tsx | 23 ++--- website/src/components/ui/liquid-glass.tsx | 33 ++++++- website/src/index.css | 15 +++- .../src/test/ChatInput.liquidGlass.test.tsx | 3 +- website/src/test/LiquidGlass.test.tsx | 18 +++- .../src/test/NotificationCard.shared.test.tsx | 58 +++++++++---- 12 files changed, 312 insertions(+), 121 deletions(-) diff --git a/docs/system-specs/modules/app-notifications.md b/docs/system-specs/modules/app-notifications.md index 17ff12c84b73..b6652b25c9a0 100644 --- a/docs/system-specs/modules/app-notifications.md +++ b/docs/system-specs/modules/app-notifications.md @@ -287,9 +287,25 @@ macOS Notification Center-style card under the top bar for a **live** notification. The card body is `NotificationCard.tsx`, the ONE rendering the bell popover's mac rows and the banner both use (kind-tinted 26 px icon square, one-line title, two-line body, relative time with the unread dot, hover-reveal -close, quiet capsule actions); its `elevation` prop is the only difference — -`popover` (72 % card tint, the theme's `--shadow-md`) versus `banner` (88 % -tint, `--shadow-lg`); shadows are theme tokens, never literal alphas. The +close, quiet capsule actions). The card IS a Liquid Glass pane +(`components/Glass.tsx`, the `panel` recipe, `CARD_RADIUS` 16 px) — the same +material as the composer dock — so it carries no tint, blur, border or shadow +classes of its own: the pane's layers are the material, `glass-shadow` the +rest shadow. The card does not know which surface it is on: the pane reads +correctly over the sheet's scrim and over page content alike, so there is no +elevation prop and both surfaces are one glass. +State is a tint step on the host, never an edge: `glass-accent` for the feed's +selected row, `glass-hover` while a pressable card is hovered, and +`glass-faded` (the tint thinned to 55 %) for a silenced row, a collapsed +stack's edges and the banner's deck shells — recession is a tint step, never +an `opacity` on a glass host, because opacity < 1 makes the host a backdrop +root and voids the pane's own blur. The banner's blank deck +shells, its "+N more in your inbox" pill and the feed's controls card, stack +edges and first-note-from-a-channel prompt (its own accent-tinted pane under +the row, since a pane has one radius) are the same primitive. Every pane also +carries `notif-material`, the index.css hook that solidifies it to the card +color where backdrop-filter is unsupported and the selector the sheet's +background-press verdict keys on. The card's `body` prop replaces the two-line clamp: the feed passes the full read-only approval render for every approval row, because the popover card keeps one-click Approve/Reject and a clamped excerpt hides the tail of the @@ -345,8 +361,8 @@ retires every pending card. ### Stack Newest on top. Beyond the top card, up to `BANNER_DECK_DEPTH` (2) older cards -peek as a deck of BLANK shells (card material only, no text, icon or time; -4/8 px offset, .98/.96 scale, .8/.55 opacity), so nothing prints through the +peek as a deck of BLANK shells (the card's glass only, no text, icon or time; +4/8 px offset, .98/.96 scale, the `glass-faded` tint step), so nothing prints through the translucent top card. Each shell and the "Show N more" pill on the top card's corner are the same control (`Show N more notifications`) that expands to a vertical list of at most `BANNER_EXPANDED_MAX` (4) cards plus a "+N more in your diff --git a/website/scripts/capture-notification-banner.mjs b/website/scripts/capture-notification-banner.mjs index 4479a335eb01..9b8edb6eede1 100644 --- a/website/scripts/capture-notification-banner.mjs +++ b/website/scripts/capture-notification-banner.mjs @@ -31,6 +31,13 @@ * write threw: row stays, notice under it * popover-approval-row the bell popover holding a critical approval row * (Approve / Reject capsules, danger dot, no edge) + * popover-states the popover with every row state at once: a + * SELECTED row (accent tint step), a SILENCED row + * (faded pane, muted title), a collapsed STACK of + * three (count badge, two glass edges peeking below) + * and a plain unread row + * popover-channel-prompt a first note from an app channel the user has not + * decided on: the Keep / Mute prompt pane under it * * Recordings (dark, mp4 + gif when ffmpeg is present): * rec-default-autohide slide-in, hover pause, then the travel into the bell @@ -119,6 +126,10 @@ async function openPage({ theme = 'dark', viewport = DESKTOP, permission = 'gran } await page.goto(base + '/') await page.locator('button:has(svg.lucide-bell)').waitFor({ state: 'visible', timeout: 20000 }) + // Boot redirects `/` to the first chat route; the bell's sheet closes on any + // pathname change, so a sheet opened before the redirect lands is torn down + // a frame later. Let the route settle first. + await page.waitForURL(u => u.pathname !== '/', { timeout: 10000 }).catch(() => {}) // The socket binds during boot; without it no frame can reach the banner. for (let i = 0; i < 50 && !ws; i++) await page.waitForTimeout(100) if (!ws) throw new Error('websocket route never bound') @@ -128,6 +139,20 @@ async function openPage({ theme = 'dark', viewport = DESKTOP, permission = 'gran } const card = page => page.getByTestId('notification-banner-card') +/** Open the bell sheet and make sure it STAYS open: a sheet opened while boot + * is still settling (a late route change, a store replay) is torn down a few + * frames later, so the phase is re-read after a beat and the bell pressed + * again when that happened. */ +async function openSheet(page) { + for (let attempt = 0; attempt < 3; attempt++) { + await page.locator('button:has(svg.lucide-bell)').click() + await page.waitForTimeout(900) + const phase = await page.locator('[data-nc-phase]').getAttribute('data-nc-phase').catch(() => null) + if (phase === 'open') return + await page.waitForTimeout(400) + } + throw new Error('bell sheet did not stay open') +} const shoot = (page, name) => page.screenshot({ path: join(OUT, `${name}.png`) }) // ---- stills ----------------------------------------------------------------- @@ -270,6 +295,66 @@ for (const theme of ['dark', 'light']) { console.log(`popover-approval-row-${theme}: Approve/Reject capsules`) await context.close() } + { + // Every restyled row state in one frame. Rows are grouped by day, so all + // four are seeded with the same day (`ts` a few seconds apart); the stack is + // three notes sharing a group_key, the silenced note is what a muted channel + // delivers (silenced + passive), and the selection is a click on the plain + // row (which the popover also acks, so the frame shows an acked+selected + // row exactly as a user sees it after opening a note). Silenced rows hide + // behind the controls card's muted disclosure, so it is opened first. + const seeded = [ + note({ kind: 'agent', title: 'Weekly cost report is ready', body: 'Spend is down 12% week over week.' }), + note({ kind: 'cron', title: 'Backup completed', body: 'Snapshot 2026-09-21 stored.', group_key: 'backup' }), + note({ kind: 'cron', title: 'Backup completed', body: 'Snapshot 2026-09-20 stored.', group_key: 'backup' }), + note({ kind: 'cron', title: 'Backup completed', body: 'Snapshot 2026-09-19 stored.', group_key: 'backup' }), + note({ kind: 'hook', title: 'Noisy webhook fired', body: 'Muted channel: still in history.', silenced: true, priority: 'passive', source: 'github', channel: 'github.noisy' }), + note({ kind: 'subagent', title: 'Research subagent finished', body: 'Summary attached to the session.' }), + ] + const { context, page } = await openPage({ theme, seeded }) + // The silenced note's channel must not prompt: a prompt is its own frame below. + await page.evaluate(() => localStorage.setItem('mc:notif:seenChannels', JSON.stringify(['github.noisy']))) + await openSheet(page) + await page.getByText('Weekly cost report is ready').waitFor({ timeout: 5000 }) + // Silenced rows sit behind the muted disclosure in the controls card. + await page.getByRole('button', { name: 'Show muted (1)' }).click() + await page.getByText('Noisy webhook fired').waitFor({ timeout: 5000 }) + await page.getByRole('button', { name: /Weekly cost report is ready/ }).first().click() + await page.waitForTimeout(700) + const rows = page.locator('[data-notif-row]') + if ((await rows.count()) !== 4) throw new Error(`expected 4 rows (plain, stack head, silenced, plain), got ${await rows.count()}`) + // The selected row is the accent tint step, the silenced row a faded pane; neither is an edge. + const selected = await page.locator('[data-notif-row].glass-accent').count() + if (selected !== 1) throw new Error(`expected exactly 1 selected (glass-accent) row, got ${selected}`) + const faded = await page.locator('[data-notif-row].glass-faded').count() + if (faded !== 1) throw new Error(`expected exactly 1 silenced (glass-faded) row, got ${faded}`) + if ((await page.locator('[data-notif-row].border-dashed, [data-notif-row].border-accent').count()) !== 0) throw new Error('a row still carries a border state') + // The collapsed stack: one head row with the count badge and two edges under it. + if ((await page.getByText('Backup completed').count()) !== 1) throw new Error('stack did not collapse to one head row') + await shoot(page, `popover-states-${theme}`) + console.log(`popover-states-${theme}: selected + silenced + collapsed stack`) + await context.close() + } + { + const seeded = [ + note({ kind: 'agent', title: 'Deploy finished on staging', body: 'ci-bot: build 4821 is live.', source: 'ci-bot', channel: 'ci-bot.deploys' }), + note({ title: 'Nightly digest finished' }), + ] + const { context, page } = await openPage({ theme, seeded }) + await openSheet(page) + await page.getByText('Deploy finished on staging').waitFor({ timeout: 5000 }) + await page.getByRole('button', { name: 'Keep' }).waitFor({ timeout: 5000 }) + await page.waitForTimeout(700) + // The prompt is its own glass pane on the accent tint step under the row, + // not a strip glued to the card. + const promptPane = page.locator('.liquid-glass.glass-accent:has(button)').filter({ hasText: 'Keep' }) + await promptPane.first().waitFor({ timeout: 5000 }) + const promptPanes = await promptPane.count() + if (promptPanes !== 1) throw new Error(`expected the Keep / Mute prompt inside exactly 1 accent glass pane, got ${promptPanes}`) + await shoot(page, `popover-channel-prompt-${theme}`) + console.log(`popover-channel-prompt-${theme}: Keep / Mute pane`) + await context.close() + } { const seeded = [note({ title: 'Nightly digest finished' }), note({ kind: 'agent', title: 'Agent note' })] const { context, page } = await openPage({ theme, permission: 'default', seeded }) diff --git a/website/src/components/Glass.tsx b/website/src/components/Glass.tsx index 179c712bd95f..f30493bb0ed2 100644 --- a/website/src/components/Glass.tsx +++ b/website/src/components/Glass.tsx @@ -3,8 +3,10 @@ * * Every surface that floats over the transcript in the composer dock (the * composer itself, an approval bar, the follow-up chips, a tip or suggestion - * card, the queue, the memory chip, the jump-to-bottom button) and the mobile - * Settings search capsule wear the SAME material, from the SAME primitive: + * card, the queue, the memory chip, the jump-to-bottom button), the mobile + * Settings search capsule and the notification panes (the in-app banner, the + * bell popover's rows and controls card) wear the SAME material, from the SAME + * primitive: * `--glass-tint` over a blurred backdrop, an even top/bottom light band in * `--glass-band`, a 1px `--glass-edge` line down each side and a half-pixel * `--glass-hairline` just outside the top and bottom edges. No ring: the diff --git a/website/src/components/notifications/NotificationBanner.tsx b/website/src/components/notifications/NotificationBanner.tsx index 79a60171d753..8936433e31be 100644 --- a/website/src/components/notifications/NotificationBanner.tsx +++ b/website/src/components/notifications/NotificationBanner.tsx @@ -7,6 +7,7 @@ import { ackNotification } from '../../store/notificationsSlice' import { useIsMobile } from '../../hooks/useIsMobile' import { useGuardedLeave } from '../NavigationLeaveGuard' import Clickable from '../Clickable' +import Glass from '../Glass' import ErrorNotice from '../ErrorNotice' import { MC_LIVE_NOTIFICATION_EVENT, type McLiveNotificationDetail } from '../../hooks/notificationEvent' import { isWindowAway } from '../../hooks/windowAway' @@ -16,7 +17,7 @@ import { } from '../../hooks/notificationBanner' import type { Notification } from '../../types' import { notePriority, safeInternalUrl } from './notifMeta' -import NotificationCard, { CARD_MATERIAL, type NotificationCardAction } from './NotificationCard' +import NotificationCard, { CARD_RADIUS, type NotificationCardAction } from './NotificationCard' /** Where a leaving card travels: the vector from its own top-right corner to * the bell's centre, so with `transform-origin: top right` the card shrinks @@ -42,10 +43,12 @@ export function exitTarget(delta: ExitDelta | undefined, reduced: boolean): Targ } } -/** Deck geometry per depth behind the top card: offset, scale, opacity. */ +/** Deck geometry per depth behind the top card: offset and scale. Recession + * is the shell's own `glass-faded` tint step, never an opacity on this + * wrapper: opacity < 1 would make it a backdrop root and void the glass + * pane's blur, so page content would print through the shell unblurred. */ const DECK_Y = [0, 4, 8] const DECK_SCALE = [1, 0.98, 0.96] -const DECK_OPACITY = [1, 0.8, 0.55] type ExitDeltas = Record @@ -369,11 +372,11 @@ export default function NotificationBanner({ bellRef, popoverOpen, onOpenNote }: layout={!reduced} initial={enterInitial} animate={reduced - ? { opacity: DECK_OPACITY[deck ? idx : 0] } + ? { opacity: 1 } // Deck cards shrink about the top centre so both side edges // recede evenly; the exit re-anchors to the top-right corner // the travel vector was measured from. - : { x: 0, y: deck ? DECK_Y[idx] : 0, scale: deck ? DECK_SCALE[idx] : 1, opacity: DECK_OPACITY[deck ? idx : 0], originX: deck ? 0.5 : 1, originY: 0 }} + : { x: 0, y: deck ? DECK_Y[idx] : 0, scale: deck ? DECK_SCALE[idx] : 1, opacity: 1, originX: deck ? 0.5 : 1, originY: 0 }} variants={variants} exit="exit" transition={{ duration: 0.22, ease: 'easeOut' }} @@ -386,20 +389,23 @@ export default function NotificationBanner({ bellRef, popoverOpen, onOpenNote }: className="rounded-2xl" > {deck ? ( - // A peeking deck card is a BLANK shell -- the card material + // A peeking deck card is a BLANK shell -- the card's glass // and nothing else, as in the chosen mockup -- so no text, // icon or time can print through the translucent top card. // It is one control: "show me the rest". - setExpanded(true)} /> ) : ( openNote(n)} openLabel={i18nT('components.notifications.notificationBanner.open_notification', { title: n.title })} onDismiss={() => removeNotes([n.ts])} @@ -428,10 +434,14 @@ export default function NotificationBanner({ bellRef, popoverOpen, onOpenNote }: })} {overflow > 0 && ( - {i18nT('components.notifications.notificationBanner.more_in_inbox_count', { count: overflow })} + >{i18nT('components.notifications.notificationBanner.more_in_inbox_count', { count: overflow })} )} {deckHidden > 0 && ( // The deck's peeking edges are a few pixels tall, so the "N more" diff --git a/website/src/components/notifications/NotificationCard.tsx b/website/src/components/notifications/NotificationCard.tsx index fc567d5e5c05..1670a5b161cd 100644 --- a/website/src/components/notifications/NotificationCard.tsx +++ b/website/src/components/notifications/NotificationCard.tsx @@ -2,22 +2,13 @@ import type { HTMLAttributes, MouseEvent, ReactNode } from 'react' import { X } from 'lucide-react' import Clickable from '../Clickable' +import Glass from '../Glass' import type { Notification } from '../../types' -import { - KIND_META, DEFAULT_META, notePriority, stripMd, fmtRelativeMinute, - MAC_CARD_TINT_CLASS, MAC_CARD_BLUR_CLASS, MAC_CARD_SHADOW_CLASS, MAC_CARD_BORDER_CLASS, - BANNER_CARD_TINT_CLASS, BANNER_CARD_SHADOW_CLASS, MAC_ACTION_BTN_CLASS, -} from './notifMeta' +import { KIND_META, DEFAULT_META, notePriority, stripMd, fmtRelativeMinute, MAC_ACTION_BTN_CLASS } from './notifMeta' -/** Where the card floats: inside the bell sheet's own scrim (softer material) - * or over arbitrary page content as a banner (denser tint, deeper shadow). - * The material is the ONLY thing that differs between the two surfaces. */ -export type NotificationCardElevation = 'popover' | 'banner' - -export const CARD_MATERIAL: Record = { - popover: `${MAC_CARD_TINT_CLASS} ${MAC_CARD_BLUR_CLASS} ${MAC_CARD_SHADOW_CLASS} ${MAC_CARD_BORDER_CLASS}`, - banner: `${BANNER_CARD_TINT_CLASS} ${MAC_CARD_BLUR_CLASS} ${BANNER_CARD_SHADOW_CLASS} ${MAC_CARD_BORDER_CLASS}`, -} +/** Corner radius of every notification pane (the card, a deck shell, the + * feed's controls card): Tailwind's `rounded-2xl`, in px for `Glass`. */ +export const CARD_RADIUS = 16 /** Semantic tint on an action's LABEL only — never a solid fill. */ export type CardActionTone = 'text' | 'accent' | 'ok' | 'danger' | 'muted' @@ -37,10 +28,6 @@ export interface NotificationCardAction { export interface NotificationCardProps extends Omit, 'title' | 'onClick'> { n: Notification - elevation: NotificationCardElevation - /** Full material override (the feed's silenced ghost and selected row keep - * their own border/tint); default is `CARD_MATERIAL[elevation]`. */ - material?: string /** Press on the card body. Omitted → decorative body (no control, no * dismiss, no actions), for a deck card whose wrapper is the control. */ onOpen?: () => void @@ -55,9 +42,11 @@ export interface NotificationCardProps extends Omit ) const interactive = !!onOpen + // Recession is a tint step, never `opacity` on the host: opacity < 1 makes + // the host a backdrop root and voids its own blur (see index.css). + const tint = active ? 'glass-accent' : muted ? 'glass-faded' : interactive ? 'glass-hover' : '' return ( -
@@ -150,6 +152,6 @@ export default function NotificationCard({
)} {interactive && footer} -
+ ) } diff --git a/website/src/components/notifications/NotificationFeed.tsx b/website/src/components/notifications/NotificationFeed.tsx index a0a0a4f85fa6..4fde93bd5f4c 100644 --- a/website/src/components/notifications/NotificationFeed.tsx +++ b/website/src/components/notifications/NotificationFeed.tsx @@ -8,16 +8,17 @@ import { deleteNotification, clearNotifications, ackAllNotifications } from '../ import { api } from '../../api/client' import { EmptyState, SearchInput } from '../ui' import Clickable from '../Clickable' +import Glass from '../Glass' import MarkdownRenderer from '../MarkdownRenderer' import MessageErrorBoundary from '../MessageErrorBoundary' import { disintegrate } from '../../lib/disintegrate' import type { Notification } from '../../types' import { parseTs, dateGroup, KIND_META, DEFAULT_META, fmtTime, stripMd, notePriority, safeInternalUrl, - MAC_CARD_TINT_CLASS, MAC_CARD_BLUR_CLASS, MAC_CARD_SHADOW_CLASS, MAC_CARD_BORDER_CLASS, MAC_ACTION_BTN_CLASS, + MAC_ACTION_BTN_CLASS, } from './notifMeta' import NotificationPermissionHint from './NotificationPermissionHint' -import NotificationCard, { type NotificationCardAction } from './NotificationCard' +import NotificationCard, { CARD_RADIUS, type NotificationCardAction } from './NotificationCard' import { i18nT } from '../../i18n/t' /** localStorage key for app channels the user has already decided on (keep or @@ -242,13 +243,32 @@ export default function NotificationFeed({ selectedTs, onSelect, variant = 'pane ) + /** The first-note-from-a-channel prompt: keep or mute. One body, two + * shells (an accent glass pane in mac mode, an attached strip in panel mode). */ + const promptBody = (pc: { channel: string; label: string }) => ( + <> + +
{i18nT('components.notifications.notificationFeed.first_notification_from')} {pc.label}{i18nT('components.notifications.notificationFeed.keep_receiving_these')}
+ + + + ) + return (
{/* Controls: mac mode groups header + search + muted disclosure in ONE floating card (search above the disclosure); panel mode puts the disclosure first, directly on the popover surface. */} {mac ? ( -
+
{header}
{unread > 0 && ( @@ -276,7 +296,7 @@ export default function NotificationFeed({ selectedTs, onSelect, variant = 'pane of the inbox's own settings, not as a notification row. */} 0} /> {footer} -
+
) : ( <> {mutedRow} @@ -302,14 +322,12 @@ export default function NotificationFeed({ selectedTs, onSelect, variant = 'pane const active = selectedTs === n.ts const prio = notePriority(n) const silenced = !!n.silenced - // Priority tiers: passive dims, silenced renders as a - // dashed-border ghost; critical is signalled by its danger dot - // alone. The shared card carries `notif-material`: index.css - // solidifies these surfaces to var(--card) where backdrop-filter - // is unsupported (#1817). - const macCard = silenced - ? 'bg-[color-mix(in_srgb,var(--card)_35%,transparent)] backdrop-blur-xl border border-dashed border-[color-mix(in_srgb,var(--border)_70%,transparent)]' - : `${MAC_CARD_TINT_CLASS} ${MAC_CARD_BLUR_CLASS} ${MAC_CARD_SHADOW_CLASS} ${active ? 'border border-accent bg-accent-subtle' : `${MAC_CARD_BORDER_CLASS} hover:bg-[color-mix(in_srgb,var(--card)_82%,transparent)]`}` + // Priority tiers: passive dims, silenced thins the glass + // pane's tint (`muted`); critical is signalled by its danger + // dot alone. Selection is the pane's accent tint step + // (`active`). The shared card carries `notif-material`: + // index.css solidifies these surfaces to var(--card) where + // backdrop-filter is unsupported (#1817). const panelBorder = silenced ? 'border-l-muted' : prio === 'critical' ? 'border-l-danger' : km.borderColor const promptChannel = promptTs === n.ts && n.channel && n.source ? { channel: n.channel, label: `${n.source} / ${n.channel.startsWith(`${n.source}.`) ? n.channel.slice(n.source.length + 1) : n.channel}` } @@ -379,9 +397,7 @@ export default function NotificationFeed({ selectedTs, onSelect, variant = 'pane { if (collapsedStack && stackKey) toggleStack(stackKey); else onSelect(n) }} @@ -472,28 +488,24 @@ export default function NotificationFeed({ selectedTs, onSelect, variant = 'pane stack -- click anywhere on the head to expand. */} {mac && collapsedStack && (
-
-
+ {/* The same glass as the head on the faded tint step, + tucked under it: only each shell's lower edge shows. + Never `opacity` here — it would void the blur. */} + +
)} - {promptChannel && ( -
- -
{i18nT('components.notifications.notificationFeed.first_notification_from')} {promptChannel.label}{i18nT('components.notifications.notificationFeed.keep_receiving_these')}
- - + {promptChannel && (mac ? ( + // Its own accent-tinted glass under the row (a pane has + // one radius, so the strip is not glued to the card). + + {promptBody(promptChannel)} + + ) : ( +
+ {promptBody(promptChannel)}
- )} + ))}
) })} diff --git a/website/src/components/notifications/notifMeta.tsx b/website/src/components/notifications/notifMeta.tsx index 337de5a67c91..05489bf0de47 100644 --- a/website/src/components/notifications/notifMeta.tsx +++ b/website/src/components/notifications/notifMeta.tsx @@ -253,24 +253,11 @@ export function fmtRelativeMinute(ts: string): string { return fmtRelativeLocalized(at, { now }) } -/** The mac-variant floating card material, split so the bell popover's rows - * and the in-app banner share the blur and hairline border while each picks - * its own tint and shadow (the banner floats over arbitrary page content and - * needs a denser tint and a deeper shadow than a row inside the sheet's - * scrim). Every consumer must also carry `notif-material`, the index.css hook - * that solidifies these surfaces where backdrop-filter is unsupported. */ -export const MAC_CARD_BLUR_CLASS = 'backdrop-blur-2xl backdrop-saturate-150' -export const MAC_CARD_BORDER_CLASS = 'border border-[color-mix(in_srgb,var(--border)_55%,transparent)]' -/** Popover rows: 72% card tint, the theme's medium elevation (inside the - * sheet's own scrim). Shadows are theme tokens (`--shadow-md` / `--shadow-lg` - * in index.css), which is what keeps them legible on both a light and a dark - * palette without a literal alpha here. */ -export const MAC_CARD_TINT_CLASS = 'bg-[color-mix(in_srgb,var(--card)_72%,transparent)]' -export const MAC_CARD_SHADOW_CLASS = 'shadow-md' -/** Banner cards: 88% card tint, the theme's large elevation (floating over - * arbitrary page content). */ -export const BANNER_CARD_TINT_CLASS = 'bg-[color-mix(in_srgb,var(--card)_88%,transparent)]' -export const BANNER_CARD_SHADOW_CLASS = 'shadow-lg' +/* The card material itself is `Glass` (components/Glass.tsx, the `panel` + * recipe): NotificationCard, the banner's deck shells and the feed's controls + * card are all that one pane. Every consumer still carries `notif-material`, + * the index.css hook that solidifies these surfaces to the card color where + * backdrop-filter is unsupported. */ /** macOS NC action buttons: quiet translucent capsules, text-only, with any * semantic tint on the LABEL (never a solid coloured fill). The `bg-[…]` diff --git a/website/src/components/ui/liquid-glass.tsx b/website/src/components/ui/liquid-glass.tsx index acc88b833125..4a3b7f181d9a 100644 --- a/website/src/components/ui/liquid-glass.tsx +++ b/website/src/components/ui/liquid-glass.tsx @@ -146,7 +146,38 @@ function roundRectPath(w: number, h: number, radius: number): string { * is capped at MAP_MAX on the long side and only the band pixels do the trig, * so a rebuild at the composer's sizes is a few milliseconds — well inside one * frame even when it does land mid-interaction. + * + * The map is a pure function of (size, radius, band), and a LIST of panes — the + * bell popover's rows, a row of follow-up chips — mounts many at the same size + * in one commit, so the rasterised data URL is memoised across instances in a + * small bounded cache (`MAP_CACHE_MAX`, oldest key evicted): N equal rows cost + * one canvas encode, not N. */ +const MAP_CACHE_MAX = 64; +const mapCache = new Map(); + +function displacementMapFor(width: number, height: number, radius: number, band: number): string { + const key = `${width}x${height}r${radius}b${band}`; + const hit = mapCache.get(key); + if (hit !== undefined) return hit; + const map = buildDisplacementMap(width, height, radius, band); + // No 2D context yields "" (the pane renders without its bend); that is a + // property of the host, not of the size, so it is never remembered. + if (map === "") return map; + if (mapCache.size >= MAP_CACHE_MAX) { + const oldest = mapCache.keys().next().value; + if (oldest !== undefined) mapCache.delete(oldest); + } + mapCache.set(key, map); + return map; +} + +/** Test seam: the cache outlives a render, so a test counting rasterisations + * starts from an empty one. */ +export function resetDisplacementMapCache(): void { + mapCache.clear(); +} + function buildDisplacementMap(width: number, height: number, radius: number, band: number): string { const fit = Math.min(1, MAP_MAX / Math.max(width, height)); const w = Math.max(2, Math.round(width * fit)); @@ -319,7 +350,7 @@ function LiquidGlassImpl( const map = useMemo( () => mapSize.width > 1 && mapSize.height > 1 - ? buildDisplacementMap(mapSize.width, mapSize.height, cornerRadius, bandFor(mapSize)) + ? displacementMapFor(mapSize.width, mapSize.height, cornerRadius, bandFor(mapSize)) : "", [mapSize, cornerRadius] ); diff --git a/website/src/index.css b/website/src/index.css index 55be7152bad4..cd55f44d42cb 100644 --- a/website/src/index.css +++ b/website/src/index.css @@ -2942,12 +2942,18 @@ body.mc-focus-mode.mc-focus-rail .focus-chrome-rail{ * `glass-accent` (a picked chip, an attached card) and `glass-warn` (the * incognito chip) mix a hue INTO the glass tint so the pane stays a glass, and * `glass-hover` brightens an interactive pane a step on hover, as the old chip - * border-color change did. Each step is a `--glass-tint` swap on the host: the + * border-color change did, and `glass-faded` thins the tint to 55% for a pane + * that recedes (a silenced notification row, the edges of a collapsed stack, + * the blank shells behind a banner deck). Recession is a TINT step and never + * `opacity` on the host: an ancestor with opacity < 1 is a backdrop root, so + * the pane's own backdrop-filter layers would have nothing to sample and the + * glass would turn into a flat, unblurred wash. Each step is a `--glass-tint` swap on the host: the * primitive's frost box reads the token, so the pane repaints without a rule * of its own. The mixed values are computed once on :root (from the polarity's * own `--glass-tint`), so a swap on the host cannot reference itself. */ -:root { --glass-tint-accent: color-mix(in srgb, var(--accent) 14%, var(--glass-tint)); --glass-tint-warn: color-mix(in srgb, var(--warn) 12%, var(--glass-tint)); --glass-tint-hover: color-mix(in srgb, var(--text) 8%, var(--glass-tint)); } +:root { --glass-tint-accent: color-mix(in srgb, var(--accent) 14%, var(--glass-tint)); --glass-tint-warn: color-mix(in srgb, var(--warn) 12%, var(--glass-tint)); --glass-tint-hover: color-mix(in srgb, var(--text) 8%, var(--glass-tint)); --glass-tint-faded: color-mix(in srgb, var(--glass-tint) 55%, transparent); } .glass-accent { --glass-tint: var(--glass-tint-accent); } +.glass-faded { --glass-tint: var(--glass-tint-faded); } .glass-warn { --glass-tint: var(--glass-tint-warn); } .glass-hover:hover { --glass-tint: var(--glass-tint-hover); } @@ -3087,8 +3093,9 @@ body.mc-focus-mode.mc-focus-rail .focus-chrome-rail{ /* The focus cue of a neutral pane (tint + side-line step) lives in the hidden layers, so a solidified pane holding focus gets the standard ring. */ .glass-shadow:focus-within{ outline:2px solid var(--accent) !important; outline-offset:2px } - /* Floating notification cards (NotificationFeed mac variant) sit OVER page - content, so they solidify to the card color, not the page background. */ + /* Floating notification panes (the banner, the bell popover's rows) sit OVER + page content, so they solidify to the card color, not the page background. + They are Glass panes too, so this rule follows `.liquid-glass` and wins. */ .notif-material{ background:var(--card) !important } } diff --git a/website/src/test/ChatInput.liquidGlass.test.tsx b/website/src/test/ChatInput.liquidGlass.test.tsx index b2cb33d03a9e..4caf67364508 100644 --- a/website/src/test/ChatInput.liquidGlass.test.tsx +++ b/website/src/test/ChatInput.liquidGlass.test.tsx @@ -116,8 +116,9 @@ describe('composer liquid glass', () => { // and each step is a `--glass-tint` swap derived once on :root. it('has no CSS copy of the material, only tint steps on the host', () => { expect(INDEX_CSS).not.toContain('glass-pane') - expect(INDEX_CSS).toMatch(/:root \{ --glass-tint-accent: color-mix\(in srgb, var\(--accent\) 14%, var\(--glass-tint\)\); --glass-tint-warn: color-mix\(in srgb, var\(--warn\) 12%, var\(--glass-tint\)\); --glass-tint-hover: color-mix\(in srgb, var\(--text\) 8%, var\(--glass-tint\)\); \}/) + expect(INDEX_CSS).toMatch(/:root \{ --glass-tint-accent: color-mix\(in srgb, var\(--accent\) 14%, var\(--glass-tint\)\); --glass-tint-warn: color-mix\(in srgb, var\(--warn\) 12%, var\(--glass-tint\)\); --glass-tint-hover: color-mix\(in srgb, var\(--text\) 8%, var\(--glass-tint\)\); --glass-tint-faded: color-mix\(in srgb, var\(--glass-tint\) 55%, transparent\); \}/) expect(INDEX_CSS).toContain('.glass-accent { --glass-tint: var(--glass-tint-accent); }') + expect(INDEX_CSS).toContain('.glass-faded { --glass-tint: var(--glass-tint-faded); }') expect(INDEX_CSS).toContain('.glass-warn { --glass-tint: var(--glass-tint-warn); }') expect(INDEX_CSS).toContain('.glass-hover:hover { --glass-tint: var(--glass-tint-hover); }') }) diff --git a/website/src/test/LiquidGlass.test.tsx b/website/src/test/LiquidGlass.test.tsx index 1f3e18482b9f..da92a86e5aec 100644 --- a/website/src/test/LiquidGlass.test.tsx +++ b/website/src/test/LiquidGlass.test.tsx @@ -9,7 +9,7 @@ */ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' import { act, cleanup, render } from '@testing-library/react' -import { LiquidGlass } from '../components/ui/liquid-glass' +import { LiquidGlass, resetDisplacementMapCache } from '../components/ui/liquid-glass' type ResizeCallback = (entries: Array<{ contentRect: { width: number; height: number } }>) => void @@ -56,6 +56,7 @@ function frostBoxOf(layer: HTMLElement) { beforeEach(() => { vi.useFakeTimers() observers.length = 0 + resetDisplacementMapCache() fakeContext.putImageData.mockClear() vi.stubGlobal('ResizeObserver', FakeResizeObserver) vi.spyOn(HTMLCanvasElement.prototype, 'getContext').mockReturnValue(fakeContext as unknown as CanvasRenderingContext2D) @@ -234,6 +235,21 @@ describe('LiquidGlass', () => { expect(fakeContext.putImageData.mock.calls.length).toBe(2) }) + it('rasterises one map for many panes of the same size, and one more per new size', () => { + // A list of panes (the bell popover's rows, a row of chips) mounts many + // equal boxes in one commit; the map is a pure function of (size, radius, + // band), so the second pane reuses the first pane's encode. + const { container } = render(<>) + measure(400, 80) + expect(fakeContext.putImageData.mock.calls.length).toBe(1) + const roots = Array.from(container.children) as HTMLElement[] + for (const root of roots) expect((root.querySelector('feImage') as SVGElement).getAttribute('href')).toBe(MAP_URL) + // A different size (or radius) is a different map. + render() + measure(400, 80) + expect(fakeContext.putImageData.mock.calls.length).toBe(2) + }) + it('drops a pending rebuild when it unmounts mid-resize', () => { const { unmount } = render() measure(400, 80) diff --git a/website/src/test/NotificationCard.shared.test.tsx b/website/src/test/NotificationCard.shared.test.tsx index 948bd481ae0d..ff6b71e1fc5c 100644 --- a/website/src/test/NotificationCard.shared.test.tsx +++ b/website/src/test/NotificationCard.shared.test.tsx @@ -1,7 +1,9 @@ /** * The bell popover's mac rows and the in-app banner must render the SAME - * `NotificationCard`, differing only in elevation material. A second - * look-alike rendering of a note is the regression this file exists to catch. + * `NotificationCard` — one body, one material (the `Glass` pane the composer + * dock wears), with nothing on the card saying which surface it is on. A + * second look-alike rendering of a note, or a card-shaped div carrying its own + * tint/blur/border classes, is the regression this file exists to catch. */ import { describe, it, expect, vi, beforeEach } from 'vitest' import { act, screen } from '@testing-library/react' @@ -9,7 +11,7 @@ import { createRef } from 'react' import { renderWithProviders, createTestStore } from './helpers' import NotificationFeed from '../components/notifications/NotificationFeed' import NotificationBanner from '../components/notifications/NotificationBanner' -import NotificationCard, { CARD_MATERIAL } from '../components/notifications/NotificationCard' +import NotificationCard from '../components/notifications/NotificationCard' import { dispatchLiveNotification } from '../hooks/notificationEvent' import type { RootState } from '../store' import type { Notification } from '../types' @@ -48,12 +50,11 @@ beforeEach(() => { localStorage.clear(); vi.spyOn(document, 'hasFocus').mockRetu const cardsIn = (root: ParentNode) => Array.from(root.querySelectorAll('[data-notification-card]')) describe('NotificationCard is the one rendering for both mac surfaces', () => { - it('the bell popover (variant="mac") renders every row through the card at popover elevation', () => { + it('the bell popover (variant="mac") renders every row through the card', () => { const store = createTestStore({ notifications: { items: [note] } as RootState['notifications'] }) const { container } = renderWithProviders( {}} />, { store }) const cards = cardsIn(container) expect(cards).toHaveLength(1) - expect(cards[0].getAttribute('data-elevation')).toBe('popover') expect(cards[0].getAttribute('data-ts')).toBe(note.ts) // The title lives INSIDE the card, nowhere else on the surface. const title = screen.getByText('Shared card note') @@ -61,7 +62,7 @@ describe('NotificationCard is the one rendering for both mac surfaces', () => { expect(screen.getByText('Open run').closest('[data-notification-card]')).toBe(cards[0]) }) - it('the banner renders its top card through the same component at banner elevation', () => { + it('the banner renders its top card through the same component', () => { const bellRef = createRef() const { container } = renderWithProviders( <> {}} />, @@ -70,10 +71,36 @@ describe('NotificationCard is the one rendering for both mac surfaces', () => { act(() => { dispatchLiveNotification(note) }) const cards = cardsIn(container) expect(cards).toHaveLength(1) - expect(cards[0].getAttribute('data-elevation')).toBe('banner') expect(cards[0].contains(screen.getByText('Shared card note'))).toBe(true) expect(screen.getByText('Open run').closest('[data-notification-card]')).toBe(cards[0]) - for (const cls of CARD_MATERIAL.banner.split(' ')) expect(cards[0].classList.contains(cls)).toBe(true) + expect(cards[0].classList.contains('liquid-glass')).toBe(true) + }) + + it('the card is a Glass pane and carries no material of its own', () => { + const { container } = renderWithProviders( {}} openLabel="open" />) + const card = cardsIn(container)[0] + expect(card.classList.contains('liquid-glass')).toBe(true) + expect(card.classList.contains('glass-shadow')).toBe(true) + // The index.css solidifying hook the sheet-dismiss predicate also keys on. + expect(card.classList.contains('notif-material')).toBe(true) + // No hand-rolled tint / blur / border: the pane's layers are the material. + expect(card.className).not.toMatch(/\bbg-\[|backdrop-blur|\bborder\b|shadow-(md|lg)/) + expect(card.querySelectorAll(':scope > [data-liquid-glass-layer]').length).toBeGreaterThan(0) + }) + + it('state is a tint step on the pane, never a border or an opacity', () => { + const { container: a } = renderWithProviders( {}} openLabel="open" />) + expect(cardsIn(a)[0].classList.contains('glass-accent')).toBe(true) + expect(cardsIn(a)[0].className).not.toMatch(/border-accent|bg-accent-subtle/) + const { container: b } = renderWithProviders( {}} openLabel="open" />) + expect(cardsIn(b)[0].classList.contains('glass-hover')).toBe(true) + const { container: c } = renderWithProviders( {}} openLabel="open" />) + expect(cardsIn(c)[0].classList.contains('glass-faded')).toBe(true) + expect(cardsIn(c)[0].classList.contains('glass-hover')).toBe(false) + expect(cardsIn(c)[0].className).not.toMatch(/border-dashed/) + // Never `opacity` on a glass host: it would make the host a backdrop root + // and void the pane's own blur. + for (const el of [a, b, c]) expect(cardsIn(el)[0].className).not.toMatch(/\bopacity-\d/) }) it('a deck card and the non-mac page list are not extra renderings of the body', () => { @@ -85,15 +112,10 @@ describe('NotificationCard is the one rendering for both mac surfaces', () => { expect(screen.getByText('Shared card note')).toBeTruthy() }) - it('only the material differs between elevations', () => { - const { container: a } = renderWithProviders( {}} openLabel="open" />) - const { container: b } = renderWithProviders( {}} openLabel="open" />) - const strip = (el: HTMLElement) => { - const clone = el.cloneNode(true) as HTMLElement - clone.removeAttribute('class'); clone.removeAttribute('data-elevation') - return clone.innerHTML - } - expect(strip(cardsIn(a)[0])).toBe(strip(cardsIn(b)[0])) - expect(cardsIn(a)[0].className).not.toBe(cardsIn(b)[0].className) + it('the card carries no surface marker: nothing on it says popover or banner', () => { + const { container } = renderWithProviders( {}} openLabel="open" />) + const card = cardsIn(container)[0] + expect(card.hasAttribute('data-elevation')).toBe(false) + expect(card.className).not.toMatch(/popover|banner/) }) })