Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
feat(ui): refresh toast presentation (#9083)
dev-rbaa9f27e9240f
diff --git a/.agents/rules/web/design-system.md b/.agents/rules/web/design-system.mdindex 798f855e2a..6f4db1fef4 100644--- a/.agents/rules/web/design-system.md+++ b/.agents/rules/web/design-system.md@@ -25,6 +25,7 @@ construction. Browse them at `/app/component/ui` (Foundations → Controls).| Menu, popover, floating toolbar or editor panel | `Dropdown`, `Toolbar`, or `menu-surface` on the overlay root | A hand-built fill, border, and shadow, or `bg-menu-glass` || Dialog or modal card | `Dialog`, or `elevated-surface` for a custom dialog root | `bg-dialog`/`bg-surface` with its own radius and shadow || Loading placeholder, view skeleton | `ListSkeleton` (`Root`, `Row`, `Bar`); `ViewSkeleton` with the view's tabs and `controls` | `animate-pulse` boxes with their own fill |+| Transient notification or persistent notice | `toast` from `@core/component/Toast/Toast` | A second toast service or hand-built global notification overlay |- **FE-60** Pick the component for the role from the table above, and importtabs only from `@ui`. Enforced by ast-grep `tsx-tabs-from-ui`, CI error; the@@ -92,6 +93,10 @@ construction. Browse them at `/app/component/ui` (Foundations → Controls).tabs, and header controls as placeholders), so change the skeleton in thesame change as the header. Enforced for pulsing boxes by ast-grep`tsx-skeleton-shimmer`, CI error.+- Toasts retain their own `--color-toast` surface, border, and light/dark shadows from the main app, not `menu-surface`. Use standalone semantic status icons without badge backgrounds. Keep descriptions, custom content, and stacked actions aligned with their title; never add surface colors in toast callers. On desktop, inset close buttons by 8px from the right and, on multiline cards, the top; reserve room so text and actions do not collide. Mobile notices omit the close icon and support swiping left or right. Simple phone notices use content-width pills with 24px between the title and inline actions, including when the action group wraps; rich mobile cards use 92vw clamped between 320px and 480px, never exceeding the available width. Keep desktop sizing and spacing unchanged.+- Toasts with actions use primary Buttons and a secondary Dismiss button, not a close icon. Actions default to a title-aligned stacked row; set `actionLayout: 'inline'` for brief notices that place actions beside the title and wrap on narrow screens. Embedded content keeps stacked actions because it owns its title. Actionless desktop toasts keep the close icon. Use `showCloseButton: false` only to hide the visible dismissal control; it does not change expiry, Escape, swipe, or user-dismiss callbacks. Move caller-owned dismissal effects to `onUserDismiss` instead of adding duplicate Hide actions. Preserve desktop queueing, mobile replacement, and separate persistent regions when changing presentation. `ToastContent` is the shared renderer for isolated gallery regions, not an alternative application service.+- Use the shared `Spinner` for loading toasts and custom loading icons; it owns its motion and respects reduced motion. Use `decorative` when surrounding content names the operation, and retain determinate progress bars when progress is known.+- Keep Toast gallery previews isolated from app notifications. App-position examples reuse normal desktop/mobile offsets and queue behavior; clear their synthetic records and timers when switching examples or leaving the page.Check: `just check` passes the ast-grep rules; the changed bar shows one height,16px icon glyphs, tabs on the left, and islands only around actions, at desktopdiff --git a/apps/web/AGENTS.md b/apps/web/AGENTS.mdindex 6df7a9b056..26961272ef 100644--- a/apps/web/AGENTS.md+++ b/apps/web/AGENTS.md@@ -429,6 +429,7 @@ resolved session ID; keep the existing `AgentSessionProvider` subscription to- Label the notification permission toast **Enable Desktop Notifications** inthe desktop app and **Enable Notifications** in the Android app, and keeptheir Enable action on the native notification provider.+- Keep toast behavior in `@core/component/Toast/Toast`: desktop notices stack, mobile transients replace, and persistent notices use their own regions. Mobile notices omit the close icon and support swiping left or right. Follow the [toast presentation contract](../../.agents/rules/web/design-system.md) for shared surfaces, compact mobile notices, aligned content, and optional close controls.- Keep signed-out Drive document routes on the shared detail viewer withoutmounting private list/sidebar sources; let document access checks decide visibility.- Gate account-only queries, comment readers, and account WebSockets on confirmeddiff --git a/apps/web/src/components/ui/components/Spinner.docs.tsx b/apps/web/src/components/ui/components/Spinner.docs.tsxnew file mode 100644index 0000000000..722af4ea88--- /dev/null+++ b/apps/web/src/components/ui/components/Spinner.docs.tsx@@ -0,0 +1,48 @@+import { defineDoc } from '@app/features/ui-gallery/types';+import { Spinner } from './Spinner';++// #region demo:sizes+function SizesDemo() {+ return (+ <div class="flex items-center gap-6 text-ink-muted">+ <Spinner size="sm" />+ <Spinner size="md" />+ <Spinner size="lg" />+ </div>+ );+}+// #endregion++// #region demo:inline+function InlineDemo() {+ return (+ <div role="status" class="flex items-center gap-2 text-ink-muted">+ <Spinner size="sm" decorative />+ <span>Loading files</span>+ </div>+ );+}+// #endregion++export default defineDoc({+ name: 'Spinner',+ category: 'Feedback',+ description:+ 'A current-color loading ring with a quiet track, rounded arc, and reduced-motion support.',+ import: "import { Spinner } from '@ui';",+ demos: [+ { id: 'sizes', title: 'Sizes', render: SizesDemo },+ { id: 'inline', title: 'With loading text', render: InlineDemo },+ ],+ guidelines: {+ do: [+ 'Give standalone spinners a label that describes the pending operation.',+ 'Use decorative beside loading text or inside an already-labelled control.',+ 'Use a progress bar when the amount of work is known.',+ ],+ dont: [+ 'Announce the same loading message from both a spinner and its parent.',+ 'Add a second spin animation to a spinner or its parent.',+ ],+ },+});diff --git a/apps/web/src/components/ui/components/Spinner.tsx b/apps/web/src/components/ui/components/Spinner.tsxnew file mode 100644index 0000000000..3e477a41e8--- /dev/null+++ b/apps/web/src/components/ui/components/Spinner.tsx@@ -0,0 +1,61 @@+import { t } from '@app/lib/i18n';+import { Show } from 'solid-js';+import { cn } from '../utils/classname';++export type SpinnerSize = 'sm' | 'md' | 'lg';++export type SpinnerProps = {+ size?: SpinnerSize;+ label?: string;+ /** Use when nearby content already describes the loading state. */+ decorative?: boolean;+ class?: string;+};++const sizes: Record<SpinnerSize, string> = {+ sm: 'size-4',+ md: 'size-5',+ lg: 'size-8',+};++/**+ * A current-color ring with a quiet track and rounded leading arc.+ * @do Give standalone loaders a label describing the pending operation.+ * @do Use decorative mode beside a loading message or inside a labelled button.+ * @dont Replace determinate progress with an indeterminate spinner.+ */+export function Spinner(props: SpinnerProps) {+ return (+ <span+ role={props.decorative ? undefined : 'status'}+ aria-hidden={props.decorative ? true : undefined}+ class={cn(+ 'inline-flex shrink-0 align-middle',+ sizes[props.size ?? 'md'],+ props.class+ )}+ >+ <svg+ viewBox="0 0 24 24"+ fill="none"+ stroke="currentColor"+ stroke-width="2.5"+ aria-hidden="true"+ class="size-full motion-safe:animate-spin"+ >+ <circle cx="12" cy="12" r="9" opacity="0.2" />+ <circle+ cx="12"+ cy="12"+ r="9"+ pathLength="100"+ stroke-dasharray="25 75"+ stroke-linecap="round"+ />+ </svg>+ <Show when={!props.decorative}>+ <span class="sr-only">{props.label ?? t('common.loading')}</span>+ </Show>+ </span>+ );+}diff --git a/apps/web/src/components/ui/components/Toast.docs.tsx b/apps/web/src/components/ui/components/Toast.docs.tsxindex 9c094101f4..3db876fb9e 100644--- a/apps/web/src/components/ui/components/Toast.docs.tsx+++ b/apps/web/src/components/ui/components/Toast.docs.tsx@@ -1,68 +1,534 @@import { defineDoc } from '@app/features/ui-gallery/types';-import { toast } from '@core/component/Toast/Toast';+import { createMobileToastSwipe } from '@core/component/Toast/create-mobile-toast-swipe';+import { ToastContent, ToastType } from '@core/component/Toast/Toast';+import { isMobile } from '@core/mobile/isMobile';import LinkIcon from '@icon/system/regular/link.svg';-import { onCleanup } from 'solid-js';+import { Toast, toaster } from '@kobalte/core/toast';+import {+ type ComponentProps,+ createSignal,+ createUniqueId,+ Match,+ onCleanup,+ Show,+ Switch,+} from 'solid-js';+import { Portal } from 'solid-js/web';import { Button } from './Button';+import { Spinner } from './Spinner';+import { Tabs } from './Tabs';-// #region demo:notifications-function NotificationsDemo() {- const ids: number[] = [];- const remember = (id: number | undefined) => {- if (id !== undefined) ids.push(id);+type PreviewToast = Omit<ComponentProps<typeof ToastContent>, 'toastId'>;++// Each demo owns its records and simulation timers, never the app's regions.+function createToastPreview(options?: { appPosition?: boolean }) {+ const regionId = `toast-gallery-${createUniqueId()}`;+ const persistentRegionId = `${regionId}-persistent`;+ const ids = new Set<number>();+ const timers = new Set<ReturnType<typeof setTimeout>>();+ let activeTransientId: number | undefined;++ const show = (content: PreviewToast) => {+ if (+ options?.appPosition &&+ isMobile() &&+ !content.persistent &&+ activeTransientId !== undefined+ ) {+ toaster.dismiss(activeTransientId);+ }+ const id = toaster.show(+ (props) => (+ <ToastContent+ {...content}+ toastId={props.toastId}+ onDismiss={() => {+ ids.delete(props.toastId);+ if (activeTransientId === props.toastId)+ activeTransientId = undefined;+ content.onDismiss?.();+ }}+ />+ ),+ {+ region:+ options?.appPosition && content.persistent+ ? persistentRegionId+ : regionId,+ }+ );+ ids.add(id);+ if (!content.persistent) activeTransientId = id;+ return id;+ };+ const dismiss = (id: number) => {+ toaster.dismiss(id);+ ids.delete(id);};- onCleanup(() => ids.forEach((id) => toast.dismiss(id)));+ const later = (callback: () => void, delay: number) => {+ const timer = setTimeout(() => {+ timers.delete(timer);+ callback();+ }, delay);+ timers.add(timer);+ return () => {+ clearTimeout(timer);+ timers.delete(timer);+ };+ };+ const clear = () => {+ for (const timer of timers) clearTimeout(timer);+ timers.clear();+ for (const id of ids) toaster.dismiss(id);+ ids.clear();+ activeTransientId = undefined;+ };+ onCleanup(clear);+ return { regionId, persistentRegionId, show, dismiss, later, clear };+}++type ToastDemoProps = {+ preview?: ReturnType<typeof createToastPreview>;+};++function PreviewRegion(props: {+ preview: ReturnType<typeof createToastPreview>;+ label: string;+ stack?: boolean;+}) {return (- <div class="flex flex-wrap gap-2">- <Button- variant="secondary"- onClick={() =>- remember(toast.success('Changes saved', { stack: true }))- }+ <div+ class="min-h-40 w-full p-4"+ classList={{ 'max-w-lg': isMobile(), 'max-w-sm': !isMobile() }}+ >+ <Toast.Region+ regionId={props.preview.regionId}+ aria-label={props.label}+ class="macro-toast-region w-full"+ limit={3}+ duration={4500}+ pauseOnInteraction+ swipeDirection="right">- Success- </Button>- <Button- variant="secondary"- onClick={() => {- for (const message of [- 'Link copied',- 'Document saved',- 'Files organized',- ]) {- remember(toast.success(message, { stack: true, duration: 12000 }));+ <Toast.List+ class="macro-toast-list"+ data-stack={props.stack ? '' : undefined}+ />+ </Toast.Region>+ </div>+ );+}++// #region demo:notifications+function StatusesDemo(props: ToastDemoProps = {}) {+ const preview = props.preview ?? createToastPreview();+ return (+ <div class="flex w-full flex-col items-center gap-4">+ <div class="flex flex-wrap justify-center gap-2">+ <Button+ variant="secondary"+ onClick={() =>+ preview.show({+ toastType: ToastType.SUCCESS,+ message: 'Changes saved',+ })+ }+ >+ Success+ </Button>+ <Button+ variant="secondary"+ onClick={() =>+ preview.show({+ toastType: ToastType.ALERT,+ message: 'Attachment permissions',+ subtext:+ 'Some recipients cannot open this attachment. Ask its owner to update access.',+ })+ }+ >+ Warning+ </Button>+ <Button+ variant="secondary"+ onClick={() =>+ preview.show({+ toastType: ToastType.FAILURE,+ message: 'Download failed',+ subtext: 'The file could not be downloaded. Try again.',+ })+ }+ >+ Failure+ </Button>+ <Button+ variant="secondary"+ onClick={() =>+ preview.show({+ toastType: ToastType.SUCCESS,+ message: 'Link copied',+ showCloseButton: false,+ })+ }+ >+ Without close button+ </Button>+ <Button variant="ghost" onClick={preview.clear}>+ Clear+ </Button>+ </div>+ <Show when={!props.preview}>+ <PreviewRegion preview={preview} label="Status previews" />+ </Show>+ </div>+ );+}+// #endregion++// #region demo:actions+function ActionsDemo(props: ToastDemoProps = {}) {+ const preview = props.preview ?? createToastPreview();+ const undo = () => {+ const id = preview.show({+ toastType: ToastType.SUCCESS,+ message: 'Email sent',+ duration: 5000,+ actionLayout: 'inline',+ actions: [+ {+ label: 'Undo',+ onClick: () => {+ preview.dismiss(id);+ preview.show({+ toastType: ToastType.SUCCESS,+ message: 'Send cancelled',+ });+ },+ },+ ],+ });+ };+ const prompt = () => {+ const id = preview.show({+ persistent: true,+ custom: {+ title: 'Reconnect email and calendar',+ content: () => 'Reconnect your account to resume syncing.',+ icon: LinkIcon,+ actions: [+ {+ label: 'Reconnect',+ onClick: () => {+ preview.dismiss(id);+ preview.show({+ toastType: ToastType.SUCCESS,+ message: 'Preview complete',+ subtext: 'No account settings were changed.',+ });+ },+ },+ ],+ },+ });+ };+ return (+ <div class="flex w-full flex-col items-center gap-4">+ <div class="flex flex-wrap justify-center gap-2">+ <Button variant="secondary" onClick={undo}>+ Undo send+ </Button>+ <Button variant="secondary" onClick={prompt}>+ Persistent prompt+ </Button>+ <Button+ variant="secondary"+ onClick={() =>+ preview.show({+ embed: () => (+ <div class="flex flex-col gap-1">+ <Toast.Title class="text-base font-medium text-ink">+ Custom content+ </Toast.Title>+ <Toast.Description class="text-sm text-ink-muted">+ Embedded content retains the shared surface and dismissal+ controls.+ </Toast.Description>+ </div>+ ),+ })}+ >+ Embedded content+ </Button>+ <Button variant="ghost" onClick={preview.clear}>+ Clear+ </Button>+ </div>+ <Show when={!props.preview}>+ <PreviewRegion preview={preview} label="Action previews" />+ </Show>+ </div>+ );+}+// #endregion++// #region demo:async+function AsyncDemo(props: ToastDemoProps = {}) {+ const preview = props.preview ?? createToastPreview();+ const simulateOperation = (fail: boolean) => {+ preview.clear();+ let cancel: (() => void) | undefined;+ const id = preview.show({+ toastType: ToastType.LOADING,+ message: 'Moving files',+ persistent: true,+ onUserDismiss: () => cancel?.(),+ onDismiss: () => cancel?.(),+ });+ cancel = preview.later(() => {+ preview.dismiss(id);+ preview.show({+ toastType: fail ? ToastType.FAILURE : ToastType.SUCCESS,+ message: fail ? 'Some files could not be moved' : 'Files moved',+ subtext: fail+ ? 'Two files remain in their original folder.'+ : undefined,+ });+ }, 1800);+ };+ const simulateDownload = () => {+ preview.clear();+ const [progress, setProgress] = createSignal(0);+ let cancel: (() => void) | undefined;+ const id = preview.show({+ persistent: true,+ onUserDismiss: () => cancel?.(),+ onDismiss: () => cancel?.(),+ custom: {+ title: 'Downloading archive',+ icon: () => <Spinner size="md" decorative />,+ color: 'var(--color-accent)',+ content: () => (+ <div class="flex flex-col gap-2">+ <div+ role="progressbar"+ aria-label="Download progress"+ aria-valuemin={0}+ aria-valuemax={100}+ aria-valuenow={progress()}+ class="h-1.5 overflow-hidden rounded-full bg-border-tertiary"+ >+ <div+ class="h-full origin-left rounded-full bg-accent transition-transform duration-300 ease-linear motion-reduce:transition-none"+ style={{ transform: `scaleX(${progress() / 100})` }}+ />+ </div>+ <span class="text-xs text-ink-muted tabular-nums">+ {progress()} of 100 MB+ </span>+ </div>+ ),+ actions: [+ {+ label: 'Cancel',+ onClick: () => {+ cancel?.();+ preview.dismiss(id);+ },+ },+ ],+ },+ });+ const advance = () => {+ const next = Math.min(100, progress() + 10);+ setProgress(next);+ if (next === 100) {+ preview.dismiss(id);+ preview.show({+ toastType: ToastType.SUCCESS,+ message: 'Archive downloaded',+ });+ return;+ }+ cancel = preview.later(advance, 300);+ };+ cancel = preview.later(advance, 300);+ };+ return (+ <div class="flex w-full flex-col items-center gap-4">+ <div class="flex flex-wrap justify-center gap-2">+ <Button variant="secondary" onClick={() => simulateOperation(false)}>+ Loading to success+ </Button>+ <Button variant="secondary" onClick={() => simulateOperation(true)}>+ Loading to failure+ </Button>+ <Button variant="secondary" onClick={simulateDownload}>+ Download progress+ </Button>+ <Button variant="ghost" onClick={preview.clear}>+ Clear+ </Button>+ </div>+ <Show when={!props.preview}>+ <PreviewRegion preview={preview} label="Async previews" />+ </Show>+ </div>+ );+}+// #endregion++// #region demo:stack+function StackDemo(props: ToastDemoProps = {}) {+ const preview = props.preview ?? createToastPreview();+ const replay = () => {+ preview.clear();+ preview.show({+ toastType: ToastType.SUCCESS,+ message: 'Link copied',+ duration: 12000,+ });+ preview.later(+ () =>+ preview.show({+ toastType: ToastType.ALERT,+ message: 'Check attachment access',+ subtext: 'Recipients need permission before they can open the file.',+ duration: 12000,+ }),+ 300+ );+ preview.later(+ () =>+ preview.show({+ toastType: ToastType.FAILURE,+ message: 'Download failed',+ duration: 12000,+ }),+ 600+ );+ preview.later(+ () =>+ preview.show({+ toastType: ToastType.SUCCESS,+ message: 'Queued notice',+ subtext: 'A fourth notice waits until a slot is available.',+ duration: 12000,+ }),+ 900+ );+ };+ return (+ <div class="flex w-full flex-col items-center gap-4">+ <div class="flex flex-wrap justify-center gap-2">+ <Button variant="secondary" onClick={replay}>+ Replay stack+ </Button>+ <Button variant="ghost" onClick={preview.clear}>+ Clear+ </Button>+ </div>+ <Show when={!props.preview}>+ <PreviewRegion preview={preview} label="Stack preview" stack />+ </Show>+ </div>+ );+}+// #endregion++// #region demo:app-position+function AppPositionDemo() {+ const preview = createToastPreview({ appPosition: true });+ const [example, setExample] = createSignal('statuses');+ const mobileSwipe = createMobileToastSwipe();++ return (+ <div class="flex w-full flex-col items-center gap-4">+ <Tabs+ aria-label="Toast examples at the app position"+ size="sm"+ options={[+ { value: 'statuses', label: 'Status' },+ { value: 'actions', label: 'Actions' },+ { value: 'async', label: 'Loading' },+ { value: 'stack', label: 'Stack' },+ ]}+ value={example()}+ onChange={(value) => {+ preview.clear();+ setExample(value);}}- >- Preview stack- </Button>- <Button- variant="secondary"- onClick={() =>- remember(- toast.custom(- {- title: 'Reconnect email and calendar',- content: () => '[email protected]',- icon: LinkIcon,- actions: [- {- label: 'Reconnect',- onClick: () =>- remember(- toast.success('Preview only — no account changes', {- stack: true,- })- ),- },- ],- },- { persistent: true, region: 'prompt-region' }- )- )- }- >- Persistent prompt- </Button>+ />+ <Switch>+ <Match when={example() === 'statuses'}>+ <StatusesDemo preview={preview} />+ </Match>+ <Match when={example() === 'actions'}>+ <ActionsDemo preview={preview} />+ </Match>+ <Match when={example() === 'async'}>+ <AsyncDemo preview={preview} />+ </Match>+ <Match when={example() === 'stack'}>+ <StackDemo preview={preview} />+ </Match>+ </Switch>+ <Portal>+ <div+ on:pointerdown={{+ capture: true,+ handleEvent: mobileSwipe.onPointerDown,+ }}+ on:pointermove={{+ capture: true,+ handleEvent: mobileSwipe.onPointerMove,+ }}+ on:pointerup={{ capture: true, handleEvent: mobileSwipe.clearSwipe }}+ on:pointercancel={{+ capture: true,+ handleEvent: mobileSwipe.clearSwipe,+ }}+ class={+ isMobile()+ ? 'fixed left-1/2 -translate-x-1/2 w-full max-w-lg px-(--mobile-chrome-gutter) pointer-events-none z-toast-region flex flex-col gap-5'+ : 'fixed bottom-5 right-5 m-0 w-95 max-w-[calc(100vw-32px)] pointer-events-none z-toast-region flex flex-col items-stretch gap-4'+ }+ style={+ isMobile()+ ? {+ bottom:+ 'calc(var(--mobile-content-inset-bottom, 0px) + 12px)',+ }+ : undefined+ }+ >+ <Toast.Region+ regionId={preview.persistentRegionId}+ aria-label="Persistent toast previews at the app position"+ class="macro-toast-region"+ duration={Infinity}+ limit={1}+ pauseOnInteraction={false}+ swipeDirection={isMobile() ? mobileSwipe.direction() : 'right'}+ >+ <Toast.List class="macro-toast-list" />+ </Toast.Region>+ <Toast.Region+ regionId={preview.regionId}+ aria-label="Toast previews at the app position"+ class="macro-toast-region"+ limit={isMobile() ? 1 : 3}+ duration={4500}+ pauseOnInteraction+ swipeDirection={isMobile() ? mobileSwipe.direction() : 'right'}+ >+ <Toast.List+ class="macro-toast-list"+ data-stack={isMobile() ? undefined : ''}+ />+ </Toast.Region>+ </div>+ </Portal></div>);}@@ -72,20 +538,59 @@ export default defineDoc({name: 'Toast',category: 'Feedback',description:- 'Compact notifications with soft light-theme shadows, raised dark-theme surfaces, a layered desktop stack, gentle entrance and exit motion, and accessible actions. Hover or focus the stack to expand it and pause dismissal.',+ 'Standalone status icons, title-aligned content, primary actions with secondary Dismiss buttons, and compact mobile notices. Preview them inline or at the device-specific app position without triggering real operations or publishing into the app notification regions.',import: "import { toast } from '@core/component/Toast/Toast';",demos: [- { id: 'notifications', title: 'Notifications', render: NotificationsDemo },+ {+ id: 'app-position',+ title: 'App position',+ description:+ 'Desktop toasts appear at the bottom-right; mobile toasts sit above the dock and swipe away in either direction without a close icon. Multi-row mobile cards use 92vw clamped between 320px and 480px, capped by the available width. Single-row notices stay content-sized, with 24px between the title and inline actions even when the action group wraps. These previews have their own queue, separate from real app notifications. Switching examples or leaving the page clears them.',+ render: AppPositionDemo,+ fill: true,+ },+ {+ id: 'notifications',+ title: 'Statuses and close controls',+ render: StatusesDemo,+ fill: true,+ },+ {+ id: 'actions',+ title: 'Inline undo, stacked prompts, and custom content',+ render: ActionsDemo,+ fill: true,+ },+ {+ id: 'async',+ title: 'Loading and progress',+ render: AsyncDemo,+ fill: true,+ },+ {+ id: 'stack',+ title: 'Desktop stack and queue',+ description:+ 'Hover or focus to expand this three-card queue and pause dismissal. The app uses a separate, single transient slot on phones.',+ render: StackDemo,+ fill: true,+ },],guidelines: {do: ['Use a short title and put supporting details in subtext.','Reserve persistent prompts for notices that need a response.',- 'Verify both themes, keyboard focus, and reduced motion.',+ 'Keep action labels short and retain meaningful content on mobile.',+ 'Use primary actions with a secondary Dismiss button instead of a close icon.',+ 'Omit the close icon on mobile; retain swipe dismissal in either direction.',+ 'Set actionLayout to inline for brief notices; keep stacked actions for longer prompts.',+ 'Use the existing toast service so queueing, timing, and dismissal stay consistent.',+ 'Use the shared Spinner for loading; keep the progress bar for known progress.',],dont: ['Use a toast for information that must remain in the page.',- 'Add custom colors, shadows, or animations in consumers.',+ 'Add custom surfaces, shadows, or animations in consumers.',+ 'Hide the dismissal control on a persistent notice unless its content provides another way to dismiss.',],},});diff --git a/apps/web/src/components/ui/index.ts b/apps/web/src/components/ui/index.tsindex df71b721ab..fb77b11460 100644--- a/apps/web/src/components/ui/index.ts+++ b/apps/web/src/components/ui/index.ts@@ -185,6 +185,8 @@ export type {SliderTrackProps,} from './components/Slider';export { Slider } from './components/Slider';+export type { SpinnerProps, SpinnerSize } from './components/Spinner';+export { Spinner } from './components/Spinner';export { Surface } from './components/Surface';export { TabSelector } from './components/TabSelector';export type {diff --git a/apps/web/src/features/channel/Call/FullScreenCallPrompt.tsx b/apps/web/src/features/channel/Call/FullScreenCallPrompt.tsxindex cdda890526..95f83a7ffd 100644--- a/apps/web/src/features/channel/Call/FullScreenCallPrompt.tsx+++ b/apps/web/src/features/channel/Call/FullScreenCallPrompt.tsx@@ -127,13 +127,6 @@ function FullScreenCallToastTrigger(props: { onHide: () => void }) {</div>),actions: [- {- label: 'Hide',- onClick: () => {- props.onHide();- toast.dismiss(toastId);- },- },{label: 'Allow',onClick: () =>@@ -141,7 +134,7 @@ function FullScreenCallToastTrigger(props: { onHide: () => void }) {},],},- { persistent: true }+ { persistent: true, onUserDismiss: () => props.onHide() });onCleanup(() => toast.dismiss(toastId));});diff --git a/apps/web/src/features/channel/Call/tests/full-screen-call-prompt.test.tsx b/apps/web/src/features/channel/Call/tests/full-screen-call-prompt.test.tsxindex e955865ba0..fc9ba4021c 100644--- a/apps/web/src/features/channel/Call/tests/full-screen-call-prompt.test.tsx+++ b/apps/web/src/features/channel/Call/tests/full-screen-call-prompt.test.tsx@@ -12,10 +12,35 @@ const native = vi.hoisted(() => ({invoke: vi.fn(),}));-vi.mock(- '@core/component/Toast/Toast',- () => import('@core/component/Toast/tests/fake-toast')-);+vi.mock('@core/component/Toast/Toast', async () => {+ const fake = await import('@core/component/Toast/tests/fake-toast');+ return {+ ...fake,+ toast: {+ ...fake.toast,+ custom: (+ config: Parameters<typeof fake.toast.custom>[0],+ options?: { onUserDismiss?: () => void }+ ) => {+ let id: number;+ id = fake.toast.custom({+ ...config,+ actions: [+ ...(config.actions ?? []),+ {+ label: 'Dismiss',+ onClick: () => {+ options?.onUserDismiss?.();+ fake.toast.dismiss(id);+ },+ },+ ],+ });+ return id;+ },+ },+ };+});vi.mock('@core/util/platform', () => ({isPlatform: (platform: string) => platform === 'android',}));@@ -70,6 +95,9 @@ describe('full-screen call prompt', () => {expect(native.invoke).toHaveBeenCalledWith('plugin:call-kit|open_full_screen_intent_settings');+ expect(+ localStorage.getItem('full-screen-call-prompt-dismissed')+ ).toBeNull();// Back from Settings without allowing it.const checks = accessChecks();@@ -85,7 +113,11 @@ describe('full-screen call prompt', () => {it('stays hidden on this device once dismissed', async () => {const first = renderPrompt();- fireEvent.click(await screen.findByRole('button', { name: 'Hide' }));+ expect(screen.queryByRole('button', { name: 'Hide' })).toBeNull();+ fireEvent.click(await screen.findByRole('button', { name: 'Dismiss' }));+ expect(localStorage.getItem('full-screen-call-prompt-dismissed')).toBe(+ 'true'+ );expect(screen.queryByText(title)).toBeNull();first.unmount();diff --git a/apps/web/src/features/notifications/components/BrowserNotificationModal.test.tsx b/apps/web/src/features/notifications/components/BrowserNotificationModal.test.tsxindex af92a743de..58c8e368c8 100644--- a/apps/web/src/features/notifications/components/BrowserNotificationModal.test.tsx+++ b/apps/web/src/features/notifications/components/BrowserNotificationModal.test.tsx@@ -3,7 +3,13 @@*/import type { CustomToastConfig } from '@core/component/Toast/Toast';-import { cleanup, render } from '@solidjs/testing-library';+import {+ cleanup,+ fireEvent,+ render,+ screen,+ waitFor,+} from '@solidjs/testing-library';import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';import { BrowserNotificationModal } from './BrowserNotificationModal';@@ -15,12 +21,14 @@ type PromptOptions = {const mocks = vi.hoisted(() => ({custom: vi.fn((_config: CustomToastConfig, _options?: PromptOptions) => 1),+ dismiss: vi.fn(),+ toggle: vi.fn(async (_enabled: boolean) => {}),mobile: false,dismissPrompt: vi.fn(),}));vi.mock('@core/component/Toast/Toast', () => ({- toast: { custom: mocks.custom, dismiss: vi.fn() },+ toast: { custom: mocks.custom, dismiss: mocks.dismiss },}));vi.mock('@core/mobile/isMobile', () => ({ isMobile: () => mocks.mobile }));vi.mock('@core/util/platform', () => ({ isPlatform: () => false }));@@ -33,10 +41,37 @@ vi.mock('../notification-settings', () => ({isSupported: true,shouldPrompt: () => true,dismissPrompt: mocks.dismissPrompt,- toggle: vi.fn(),+ toggle: mocks.toggle,+ isEnabled: () => true,}),}));+function MockToaster() {+ return (+ <>+ <button+ onClick={() => mocks.custom.mock.lastCall?.[1]?.onUserDismiss?.()}+ >+ Dismiss+ </button>+ <button+ onClick={() => mocks.custom.mock.lastCall?.[0].actions?.[0]?.onClick()}+ >+ Enable+ </button>+ </>+ );+}++function renderPrompt() {+ return render(() => (+ <>+ <BrowserNotificationModal />+ <MockToaster />+ </>+ ));+}+beforeEach(() => vi.stubEnv('DEV', false));afterEach(() => {cleanup();@@ -47,40 +82,53 @@ afterEach(() => {describe('browser notification prompt', () => {it('waits in the phone prompt region, which open sheets cover', () => {mocks.mobile = true;- render(() => <BrowserNotificationModal />);+ renderPrompt();expect(mocks.custom).toHaveBeenCalledWith(expect.objectContaining({ title: 'Enable Browser Notifications' }),expect.objectContaining({persistent: true,region: 'mobile-prompt-region',+ onUserDismiss: expect.any(Function),}));});it('joins the other prompts on desktop', () => {mocks.mobile = false;- render(() => <BrowserNotificationModal />);+ renderPrompt();expect(mocks.custom).toHaveBeenCalledWith(expect.anything(),- expect.objectContaining({ persistent: true, region: 'prompt-region' })+ expect.objectContaining({+ persistent: true,+ region: 'prompt-region',+ onUserDismiss: expect.any(Function),+ }));});it('offers Enable as its only action', () => {- render(() => <BrowserNotificationModal />);+ renderPrompt();const [config] = mocks.custom.mock.calls[0]!;expect(config.actions?.map((action) => action.label)).toEqual(['Enable']);});- it('stops asking once the user closes it', () => {- render(() => <BrowserNotificationModal />);-- const [, options] = mocks.custom.mock.calls[0]!;- options?.onUserDismiss?.();+ it('persists user dismissal through notification settings', () => {+ renderPrompt();+ fireEvent.click(screen.getByRole('button', { name: 'Dismiss' }));expect(mocks.dismissPrompt).toHaveBeenCalledOnce();+ expect(mocks.toggle).not.toHaveBeenCalled();+ });++ it('enables notifications without persisting dismissal', async () => {+ renderPrompt();+ fireEvent.click(screen.getByRole('button', { name: 'Enable' }));++ await waitFor(() => expect(mocks.dismiss).toHaveBeenCalledWith(1));+ expect(mocks.toggle).toHaveBeenCalledWith(true);+ expect(mocks.dismissPrompt).not.toHaveBeenCalled();});});diff --git a/apps/web/src/lib/core/component/Toast/Toast.test.tsx b/apps/web/src/lib/core/component/Toast/Toast.test.tsxindex cd966da2e3..5ccfa0373c 100644--- a/apps/web/src/lib/core/component/Toast/Toast.test.tsx+++ b/apps/web/src/lib/core/component/Toast/Toast.test.tsx@@ -110,7 +110,7 @@ it('keeps keyboard-focused actions alive until focus leaves the list', () => {).toBe(true);});-it('preserves actions and only reports explicit close as a user dismissal', () => {+it('preserves actions and only reports explicit dismissal as a user dismissal', () => {render(() => <ToastRegion />);const action = vi.fn();const onUserDismiss = vi.fn();@@ -125,7 +125,8 @@ it('preserves actions and only reports explicit close as a user dismissal', () =fireEvent.click(screen.getByRole('button', { name: 'Reconnect' }));expect(action).toHaveBeenCalledOnce();expect(onUserDismiss).not.toHaveBeenCalled();- fireEvent.click(screen.getByRole('button', { name: 'Close' }));+ expect(screen.queryByRole('button', { name: 'Close' })).toBeNull();+ fireEvent.click(screen.getByRole('button', { name: 'Dismiss' }));expect(onUserDismiss).toHaveBeenCalledOnce();expect(screendiff --git a/apps/web/src/lib/core/component/Toast/Toast.tsx b/apps/web/src/lib/core/component/Toast/Toast.tsxindex a9eb4d51e3..9f74c5605a 100644--- a/apps/web/src/lib/core/component/Toast/Toast.tsx+++ b/apps/web/src/lib/core/component/Toast/Toast.tsx@@ -1,11 +1,12 @@import './toast.css';+import { t } from '@app/lib/i18n';import { isMobile } from '@core/mobile/isMobile';-import CheckIcon from '@icon/system/regular/check.svg';+import CheckIcon from '@icon/system/bold/check-bold.svg';import ExclamationIcon from '@icon/system/regular/exclamation-mark.svg';-import Spinner from '@icon/system/regular/spinner.svg';+import WarningIcon from '@icon/system/regular/warning.svg';import XIcon from '@icon/system/regular/x.svg';import { Toast, toaster } from '@kobalte/core/toast';-import { Button, cn } from '@ui';+import { Button, cn, Spinner } from '@ui';import type { Component, JSX } from 'solid-js';import { createSignal, For, onCleanup, onMount, Show } from 'solid-js';import { Dynamic } from 'solid-js/web';@@ -17,11 +18,26 @@ export enum ToastType {LOADING = 'loading',}-const TOAST_STYLES = {- [ToastType.SUCCESS]: { icon: CheckIcon, color: 'var(--color-success)' },- [ToastType.FAILURE]: { icon: ExclamationIcon, color: 'var(--color-failure)' },- [ToastType.ALERT]: { icon: ExclamationIcon, color: 'var(--color-alert)' },- [ToastType.LOADING]: { icon: Spinner, color: 'var(--color-ink-muted)' },+const TOAST_STYLES: Record<+ ToastType,+ { icon: Component<{ class?: string }>; iconClass: string }+> = {+ [ToastType.SUCCESS]: {+ icon: CheckIcon,+ iconClass: 'text-success',+ },+ [ToastType.FAILURE]: {+ icon: ExclamationIcon,+ iconClass: 'text-failure',+ },+ [ToastType.ALERT]: {+ icon: WarningIcon,+ iconClass: 'text-warning',+ },+ [ToastType.LOADING]: {+ icon: (props) => <Spinner {...props} size="md" decorative />,+ iconClass: 'text-accent',+ },};/** A single entry in the actions row — icon and label rendered as a button */@@ -31,6 +47,8 @@ interface ToastAction {onClick: () => void;}+type ToastActionLayout = 'stacked' | 'inline';+/*** Common options for all toast calls.*/@@ -40,6 +58,10 @@ interface ToastOptions {duration?: number;/** When true, don't render this toast on mobile. */hideOnMobile?: boolean;+ /** Hide the visible dismissal control; Escape, swipe, and expiry stay unchanged. */+ showCloseButton?: boolean;+ /** Place actions beside the title; defaults to a stacked action row. */+ actionLayout?: ToastActionLayout;}interface ToastActionOptions extends ToastOptions {@@ -60,6 +82,7 @@ export interface CustomToastConfig {/** Any CSS color value, e.g. 'var(--color-success)' or '#ff6600' */color?: string;actions?: ToastAction[];+ actionLayout?: ToastActionLayout;}interface ToastMessage {@@ -187,43 +210,81 @@ function alert(return createToast(message, ToastType.ALERT, options);}-function ActionButtons(props: { actions: ToastAction[] }) {+function ActionButtons(props: {+ actions: ToastAction[];+ showDismiss: boolean;+ onDismiss?: () => void;+}) {return (- <For each={props.actions}>- {(action) => (- <Button size="sm" onClick={action.onClick} variant="ghost">- <Show when={action.icon}>- {(icon) => <Dynamic component={icon()} class="size-3.5" />}- </Show>- {action.label}- </Button>- )}- </For>+ <>+ <Show when={props.showDismiss}>+ <Toast.CloseButton+ as={Button}+ size="sm"+ variant="secondary"+ aria-label={t('common.dismiss')}+ onClick={() => props.onDismiss?.()}+ >+ {t('common.dismiss')}+ </Toast.CloseButton>+ </Show>+ <For each={props.actions}>+ {(action) => (+ <Button+ size="sm"+ onClick={action.onClick}+ variant="primary"+ class="max-w-full"+ >+ <Show when={action.icon}>+ {(icon) => (+ <Dynamic component={icon()} class="size-3.5 shrink-0" />+ )}+ </Show>+ <span class="min-w-0 whitespace-normal break-words">+ {action.label}+ </span>+ </Button>+ )}+ </For>+ </>);}-function ToastContent(props: {+/** Shared presentation for the app service and isolated gallery regions. */+export function ToastContent(props: {toastId: number;toastType?: ToastType;message?: string;subtext?: string;actions?: ToastAction[];+ actionLayout?: ToastActionLayout;persistent?: boolean;duration?: number;embed?: Component;custom?: CustomToastConfig;+ showCloseButton?: boolean;onDismiss?: () => void;onUserDismiss?: () => void;}) {- const style = () =>+ const styles = () =>props.toastType ? TOAST_STYLES[props.toastType] : undefined;- const icon = () => props.custom?.icon ?? style()?.icon;- const actions = () => props.custom?.actions ?? props.actions;+ const icon = () => props.custom?.icon ?? styles()?.icon;+ const actions = () => props.custom?.actions ?? props.actions ?? [];+ const hasBody = () => Boolean(props.custom?.content || props.subtext);+ const hasActions = () => actions().length > 0;+ const inlineActions = () =>+ !props.embed &&+ hasActions() &&+ (props.custom?.actionLayout ?? props.actionLayout) === 'inline';+ const singleRow = () =>+ !props.embed && !hasBody() && (!hasActions() || inlineActions());+ const showDismiss = () => props.showCloseButton !== false;+ const showCloseButton = () => showDismiss() && !hasActions() && !isMobile();const [height, setHeight] = createSignal<number>();let surface!: HTMLDivElement;- // The content keeps its natural height even when an older card is tucked- // into the stack. This makes expansion work with async/custom content too.+ // Keep the natural height while older cards are tucked into the stack.onMount(() => {const measure = () => setHeight(surface.offsetHeight);measure();@@ -238,6 +299,8 @@ function ToastContent(props: {toastId={props.toastId}data-macro-toastdata-toast-id={props.toastId}+ data-mobile={isMobile() ? '' : undefined}+ data-single-row={singleRow() ? '' : undefined}class="macro-toast"style={{ '--toast-height': height() ? `${height()}px` : undefined }}persistent={props.persistent}@@ -248,65 +311,105 @@ function ToastContent(props: {}}><div ref={surface} class="macro-toast-surface">- <div class="macro-toast-content flex items-center gap-2.5">+ <div+ class={cn(+ 'macro-toast-content min-w-0',+ showCloseButton() && 'pr-10'+ )}+ ><Showwhen={props.embed}fallback={- <>+ <div+ class={cn(+ 'flex min-w-0 gap-2',+ singleRow() ? 'items-center' : 'items-start'+ )}+ ><Show when={icon()}>{(Icon) => (- <div- class="flex size-5 shrink-0 items-center justify-center"- style={{ color: props.custom?.color ?? style()?.color }}+ <span+ aria-hidden="true"+ class={cn(+ 'flex size-5 shrink-0 items-center justify-center',+ !singleRow() && 'mt-0.5',+ props.custom ? 'text-ink-muted' : styles()?.iconClass+ )}+ style={+ props.custom ? { color: props.custom.color } : undefined+ }data-icon-motion="none"><Dynamiccomponent={Icon()}- class={cn(- 'size-4',- props.toastType === ToastType.LOADING &&- 'motion-safe:animate-spin'- )}+ class={props.custom ? 'size-4' : 'size-5'}/>- </div>+ </span>)}</Show><div class="min-w-0 flex-1">- <Toast.Title class="text-[13px] font-medium leading-5 text-ink [overflow-wrap:anywhere]">- {props.custom?.title ?? props.message}- </Toast.Title>- <Show when={props.custom?.content || props.subtext}>- <Toast.Description class="mt-1 text-xs leading-[1.55] text-ink-muted [overflow-wrap:anywhere]">+ <div class="macro-toast-heading flex min-w-0 flex-wrap items-center gap-2">+ <Toast.Title class="min-w-0 flex-auto text-base font-medium leading-normal text-ink wrap-anywhere">+ {props.custom?.title ?? props.message}+ </Toast.Title>+ <Show when={inlineActions()}>+ <div class="flex max-w-full shrink-0 flex-wrap items-center gap-2">+ <ActionButtons+ actions={actions()}+ showDismiss={showDismiss()}+ onDismiss={props.onUserDismiss}+ />+ </div>+ </Show>+ </div>+ <Show when={hasBody()}>+ <Toast.Description class="mt-0.5 text-sm leading-normal text-ink-muted wrap-anywhere">{props.custom?.content? props.custom.content(): props.subtext}</Toast.Description></Show>+ <Show when={hasActions() && !inlineActions()}>+ <div class="mt-3 flex flex-wrap items-center gap-2">+ <ActionButtons+ actions={actions()}+ showDismiss={showDismiss()}+ onDismiss={props.onUserDismiss}+ />+ </div>+ </Show></div>- </>+ </div>}>{(Embed) => (- <div class="min-w-0 flex-1">+ <div class="min-w-0"><Dynamic component={Embed()} />+ <Show when={hasActions()}>+ <div class="mt-3 flex flex-wrap items-center gap-2">+ <ActionButtons+ actions={actions()}+ showDismiss={showDismiss()}+ onDismiss={props.onUserDismiss}+ />+ </div>+ </Show></div>)}</Show>- <Show when={actions()?.length}>- <div class="flex shrink-0 flex-col items-end gap-1.5">- <ActionButtons actions={actions()!} />- </div>- </Show>- <Show when={!isMobile()}>+ <Show when={showCloseButton()}><Toast.CloseButtonas={Button}variant="ghost"- size="icon-xs"- aria-label="Close"- class="macro-toast-corner-close shrink-0"+ size="icon-sm"+ aria-label={t('common.close')}+ class={cn(+ 'absolute right-2 z-10',+ singleRow() ? 'top-1/2 -translate-y-1/2' : 'top-2'+ )}onClick={() => props.onUserDismiss?.()}>- <XIcon class="size-2.5" />+ <XIcon class="size-4" /></Toast.CloseButton></Show></div>@@ -327,6 +430,7 @@ async function promise<T>(subtext?: string;/** When true, don't render the loading/result toasts on mobile. */hideOnMobile?: boolean;+ showCloseButton?: boolean;}): Promise<T> {if (isMobile() && options.hideOnMobile) return promiseArg;@@ -343,6 +447,7 @@ async function promise<T>(message={options.loading}subtext={options.subtext}persistent={true}+ showCloseButton={options.showCloseButton}onDismiss={() => clearTrackedToast(region, props.toastId)}/>),@@ -365,6 +470,7 @@ async function promise<T>(createToast(successMessage, toastType, {hideOnMobile: options.hideOnMobile,+ showCloseButton: options.showCloseButton,});}@@ -377,7 +483,10 @@ async function promise<T>(typeof options.error === 'function'? options.error(error): options.error;- failure(errorMessage, { hideOnMobile: options.hideOnMobile });+ failure(errorMessage, {+ hideOnMobile: options.hideOnMobile,+ showCloseButton: options.showCloseButton,+ });}throw error;});@@ -390,7 +499,15 @@ function createToast(toastType: ToastType,options?: ToastActionOptions) {- const { subtext, actions, duration, stack, hideOnMobile } = options ?? {};+ const {+ subtext,+ actions,+ actionLayout,+ duration,+ stack,+ hideOnMobile,+ showCloseButton,+ } = options ?? {};if (isMobile() && hideOnMobile) return undefined;@@ -414,7 +531,9 @@ function createToast(message={message}subtext={subtext}actions={actions}+ actionLayout={actionLayout}duration={duration}+ showCloseButton={showCloseButton}onDismiss={() => {clearTrackedToast(region, props.toastId);}}@@ -452,6 +571,7 @@ function embed(persistent?: boolean;duration?: number;region?: string;+ showCloseButton?: boolean;}) {const useMobile = isMobile();@@ -465,6 +585,7 @@ function embed(embed={component}persistent={options?.persistent}duration={options?.duration}+ showCloseButton={options?.showCloseButton}onDismiss={() => clearTrackedToast(region, props.toastId)}/>),@@ -489,6 +610,7 @@ function custom(region?: string;onDismiss?: () => void;onUserDismiss?: () => void;+ showCloseButton?: boolean;}): number {const useMobile = isMobile();@@ -503,6 +625,7 @@ function custom(persistent={options?.persistent}duration={options?.duration}onUserDismiss={options?.onUserDismiss}+ showCloseButton={options?.showCloseButton}onDismiss={() => {clearTrackedToast(region, props.toastId);options?.onDismiss?.();diff --git a/apps/web/src/lib/core/component/Toast/ToastRegion.tsx b/apps/web/src/lib/core/component/Toast/ToastRegion.tsxindex 7da6255101..b028151258 100644--- a/apps/web/src/lib/core/component/Toast/ToastRegion.tsx+++ b/apps/web/src/lib/core/component/Toast/ToastRegion.tsx@@ -5,6 +5,7 @@ import { createElementSize } from '@solid-primitives/resize-observer';import { cn } from '@ui/utils/classname';import { createSignal, type JSX, Show } from 'solid-js';import { Portal } from 'solid-js/web';+import { createMobileToastSwipe } from './create-mobile-toast-swipe';/** A column centered above the mobile dock, `lift` higher than its usual spot. */function MobileToastStack(props: {@@ -17,7 +18,7 @@ function MobileToastStack(props: {<divref={props.ref}class={cn(- 'fixed left-1/2 -translate-x-1/2 w-full max-w-[420px] px-(--mobile-chrome-gutter) pointer-events-none flex flex-col gap-5',+ 'fixed left-1/2 -translate-x-1/2 w-full max-w-lg px-(--mobile-chrome-gutter) pointer-events-none flex flex-col gap-5',props.class)}style={{@@ -30,13 +31,7 @@ function MobileToastStack(props: {}export function ToastRegion() {- const [mobileSwipeDirection, setMobileSwipeDirection] = createSignal<- 'left' | 'right'- >('left');- let swipeStart: { x: number; pointerId: number } | undefined;- const clearSwipe = (event: PointerEvent) => {- if (swipeStart?.pointerId === event.pointerId) swipeStart = undefined;- };+ const mobileSwipe = createMobileToastSwipe();const [mobileTransientStack, setMobileTransientStack] =createSignal<HTMLDivElement>();const mobileTransientSize = createElementSize(mobileTransientStack);@@ -99,23 +94,17 @@ export function ToastRegion() {class="contents"on:pointerdown={{capture: true,- handleEvent: (event) => {- if (event.button === 0)- swipeStart = { x: event.clientX, pointerId: event.pointerId };- },+ handleEvent: mobileSwipe.onPointerDown,}}on:pointermove={{capture: true,- handleEvent: (event) => {- if (!swipeStart || swipeStart.pointerId !== event.pointerId) return;- const deltaX = event.clientX - swipeStart.x;- // Choose the direction before Kobalte clamps this pointer move.- if (deltaX !== 0)- setMobileSwipeDirection(deltaX < 0 ? 'left' : 'right');- },+ handleEvent: mobileSwipe.onPointerMove,+ }}+ on:pointerup={{ capture: true, handleEvent: mobileSwipe.clearSwipe }}+ on:pointercancel={{+ capture: true,+ handleEvent: mobileSwipe.clearSwipe,}}- on:pointerup={{ capture: true, handleEvent: clearSwipe }}- on:pointercancel={{ capture: true, handleEvent: clearSwipe }}><MobileToastStackclass="z-mobile-prompt-region"@@ -127,7 +116,7 @@ export function ToastRegion() {duration={Infinity}limit={1}pauseOnInteraction={false}- swipeDirection={mobileSwipeDirection()}+ swipeDirection={mobileSwipe.direction()}><Toast.List class="macro-toast-list" /></Toast.Region>@@ -137,7 +126,7 @@ export function ToastRegion() {duration={Infinity}limit={1}pauseOnInteraction={false}- swipeDirection={mobileSwipeDirection()}+ swipeDirection={mobileSwipe.direction()}><Toast.List class="macro-toast-list" /></Toast.Region>@@ -149,7 +138,7 @@ export function ToastRegion() {limit={1}duration={4500}pauseOnInteraction- swipeDirection={mobileSwipeDirection()}+ swipeDirection={mobileSwipe.direction()}><Toast.List class="macro-toast-list" /></Toast.Region>diff --git a/apps/web/src/lib/core/component/Toast/create-mobile-toast-swipe.ts b/apps/web/src/lib/core/component/Toast/create-mobile-toast-swipe.tsnew file mode 100644index 0000000000..26c9eaffde--- /dev/null+++ b/apps/web/src/lib/core/component/Toast/create-mobile-toast-swipe.ts@@ -0,0 +1,22 @@+import { createSignal } from 'solid-js';++/** Choose either horizontal swipe direction before Kobalte handles the move. */+export function createMobileToastSwipe() {+ const [direction, setDirection] = createSignal<'left' | 'right'>('left');+ let swipeStart: { x: number; pointerId: number } | undefined;++ const onPointerDown = (event: PointerEvent) => {+ if (event.button === 0)+ swipeStart = { x: event.clientX, pointerId: event.pointerId };+ };+ const onPointerMove = (event: PointerEvent) => {+ if (!swipeStart || swipeStart.pointerId !== event.pointerId) return;+ const deltaX = event.clientX - swipeStart.x;+ if (deltaX !== 0) setDirection(deltaX < 0 ? 'left' : 'right');+ };+ const clearSwipe = (event: PointerEvent) => {+ if (swipeStart?.pointerId === event.pointerId) swipeStart = undefined;+ };++ return { direction, onPointerDown, onPointerMove, clearSwipe };+}diff --git a/apps/web/src/lib/core/component/Toast/toast.css b/apps/web/src/lib/core/component/Toast/toast.cssindex c40a959d30..e40cf35e82 100644--- a/apps/web/src/lib/core/component/Toast/toast.css+++ b/apps/web/src/lib/core/component/Toast/toast.css@@ -17,6 +17,7 @@position: relative;overflow: visible;width: 100%;+ max-width: 100%;max-height: var(--toast-height, 1000px);border-radius: 14px;pointer-events: auto;@@ -32,6 +33,22 @@box-shadow: 0 3px 10px rgb(0 0 0 / 20%), 0 20px 48px -12px rgb(0 0 0 / 50%);}+/* Phone notices keep content width; rich content gets a bounded card. */+.macro-toast[data-mobile] {+ align-self: center;+ width: clamp(320px, 92vw, 480px);+ border-radius: 16px;+}++.macro-toast[data-mobile][data-single-row] {+ width: fit-content;+ border-radius: 9999px;+}++.macro-toast[data-mobile][data-single-row] .macro-toast-heading {+ gap: 24px;+}+.macro-toast-surface {position: relative;box-sizing: border-box;@@ -42,17 +59,16 @@color: var(--color-ink);}-/* A subtle gradient and shaded lower edge give dark notices a raised surface. */+/* Keep the dark border and inset shadow over the solid toast fill. */[data-theme-light='false'] .macro-toast-surface {- background: linear-gradient(- to bottom,- color-mix(in oklch, var(--color-toast), var(--color-ink) 3%),- var(--color-toast)- );border-color: color-mix(in oklch, var(--color-ink) 8%, transparent);box-shadow: inset 0 -1px 0 rgb(0 0 0 / 20%);}+.macro-toast[data-mobile][data-single-row] .macro-toast-surface {+ padding: 8px 12px;+}+.macro-toast-content {transition: opacity 160ms ease;}@@ -122,50 +138,13 @@@media (prefers-reduced-motion: reduce) {.macro-toast,+ .macro-toast[data-opened],+ .macro-toast[data-closed],+ .macro-toast[data-swipe='move'],+ .macro-toast[data-swipe='end'],.macro-toast-list,.macro-toast-content {- animation: none !important;- transition: none !important;- }-}--/* The close button is a notch tucked into the top-right corner, like the- close notch on splits: it shares the surface's edge on its inner sides and- follows the card's radius on its outer corner. */-.macro-toast .macro-toast-corner-close {- position: absolute;- top: 0;- right: 0;- z-index: 1;- width: 23px;- height: 23px;- min-width: 0;- min-height: 0;- padding: 0;- border: 0;- border-left: 1px solid var(--color-edge-muted);- border-bottom: 1px solid var(--color-edge-muted);- border-radius: 0 13px 0 6px;- background: var(--color-toast);- color: color-mix(in oklch, var(--color-ink-muted) 70%, transparent);-}--/* The notch is smaller than the shared touch target, so extend its hit area- to the Button's 36px touch minimum without growing the visible notch. */-html[data-touch-device='true'] .macro-toast .macro-toast-corner-close::after {- content: '';- position: absolute;- inset: -7px;-}--[data-theme-light='false'] .macro-toast .macro-toast-corner-close {- border-color: color-mix(in oklch, var(--color-ink) 8%, transparent);- background: color-mix(in oklch, var(--color-toast), var(--color-ink) 3%);-}--@media (hover: hover) {- .macro-toast .macro-toast-corner-close:hover {- background: color-mix(in oklch, var(--color-toast), var(--color-ink) 6%);- color: var(--color-ink);+ animation: none;+ transition: none;}}diff --git a/apps/web/src/lib/i18n/locales/en/common.ts b/apps/web/src/lib/i18n/locales/en/common.tsindex d4615bb816..690b1f9dcf 100644--- a/apps/web/src/lib/i18n/locales/en/common.ts+++ b/apps/web/src/lib/i18n/locales/en/common.ts@@ -20,6 +20,8 @@ export default {changePriority: 'Change priority',cancel: 'Cancel',close: 'Close',+ dismiss: 'Dismiss',+ loading: 'Loading…',delete: 'Delete',rename: 'Rename',more: 'More',