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
fix(notifications): keep phone prompts under open sheets and pickers (#9265)
gbirman724c18838271
diff --git a/.agents/rules/web/mobile.md b/.agents/rules/web/mobile.mdindex 771c9e59a2..d00e186a99 100644--- a/.agents/rules/web/mobile.md+++ b/.agents/rules/web/mobile.md@@ -90,8 +90,10 @@ read their code, and follow that pattern rather than inventing a new one.- Overlays are Kobalte or corvu layers or handle Escape: Android Back sendsEscape to the top layer. Own back stacks use `useAndroidBackNavigation`.- Persistent prompts (`toast.custom` with `persistent`) go to the prompt- region (`useKeyedPersistentToasts` does it); a prompt in the transient- region would cover a sheet's controls.+ region (`useKeyedPersistentToasts` does it). Its phone layer+ (`z-mobile-prompt-region`) sits under the modal stack, so sheets and the+ pickers on them cover it; a prompt in the transient region, which stays above+ sheets, would cover a sheet's controls.- Pass a composer typeahead or picker menu's `floatWithSelection` its`fullHeight` (content cap plus panel padding) so it picks the side with roomfor its whole list instead of shrinking below the caret when its firstdiff --git a/apps/web/AGENTS.md b/apps/web/AGENTS.mdindex dd6c2977b9..29d828bc04 100644--- a/apps/web/AGENTS.md+++ b/apps/web/AGENTS.md@@ -63,7 +63,9 @@ browser regression for backdrop taps that must not press what the scrim covers,including mixed pointerdown/pointerup dismissal, for taps inside the topsheet that must still press its own controls, and for swipes whose owner keepsthe sheet open (a discard prompt, a pending confirmation, event details under a-stacked sheet), which must bring it back on screen:+stacked sheet), which must bring it back on screen. It also keeps a persistent+prompt under an open sheet and its picker, above a transient notice, and that+notice on top of the sheet:`bunx playwright test --config src/components/app/mobile/browser-test/playwright.config.ts`.Composer typeahead menus choosing the side with room for their full list@@ -868,7 +870,7 @@ See the [download walkthrough](../../docs/agent-guide/files.md#downloading-files### Creation choices and notifications- Reuse `CreateMenuItem` for explanatory New menu entries: original icons, a title, and muted wrapping descriptions, preserving the existing `ViewCreateButton` trigger and each action's feature gates.-- Keep transient toasts in their bounded stack and persistent prompts/reminders in separate regions; preserve keyboard dismissal, full mobile descriptions, and remaining-time pause on hover/focus. Mobile toasts dismiss by swiping left or right and have no corner close button.+- Keep transient toasts in their bounded stack and persistent prompts/reminders in separate regions; preserve keyboard dismissal, full mobile descriptions, and remaining-time pause on hover/focus. Mobile toasts dismiss by swiping left or right and have no corner close button. Phone prompts stay in their own stack under the modal layer, never on `z-toast-region`, and never hide with a document-wide `:has()` (#8840).- Notification sounds are off by default and saved per user per device; map each new notification event in `features/notification-sounds/core/categories.ts` and keep system alerts silent when Macro plays its own sound. See the [notification sounds walkthrough](../../docs/agent-guide/notifications.md#notification-sounds).### Sidebar tag draggingdiff --git a/apps/web/src/components/app/mobile/browser-test/fixture.tsx b/apps/web/src/components/app/mobile/browser-test/fixture.tsxindex da0845d598..4b848a280a 100644--- a/apps/web/src/components/app/mobile/browser-test/fixture.tsx+++ b/apps/web/src/components/app/mobile/browser-test/fixture.tsx@@ -2,6 +2,8 @@ import '@fontsource-variable/inter';import '../../../../index.css';import { MobileSettingsSheet } from '@app/features/settings/MobileSettingsSheet';import { SettingsPage, SettingsRow } from '@app/features/settings/primitives';+import { toast } from '@core/component/Toast/Toast';+import { ToastRegion } from '@core/component/Toast/ToastRegion';import type { SettingsTab } from '@core/constant/SettingsState';import { SETTINGS_TAB_GROUPS } from '@core/constant/settingsTabsConfig';import { EmailProviderDialog } from '@core/email-link/ProviderDialog';@@ -17,11 +19,12 @@ import {openDialog,useImperativeDialog,} from '@ui';-import { createSignal, getOwner, Match, Show, Switch } from 'solid-js';+import { createSignal, getOwner, Match, onMount, Show, Switch } from 'solid-js';import { render } from 'solid-js/web';import { macroLightTheme } from '../../../../features/theme/themes/macro-light';import { ConfirmDrawer } from '../ConfirmDrawer';import { MobileDrawer } from '../MobileDrawer';+import { PickerSheet } from '../PickerSheet';for (const [token, value] of Object.entries(macroLightTheme.colorTokens)) {document.documentElement.style.setProperty(`--color-${token}`, value);@@ -30,6 +33,10 @@ document.documentElement.dataset.themeLight = 'true';const [pressed, setPressed] = createSignal<string[]>([]);const press = (control: string) => setPressed((list) => [...list, control]);+let noticeId: number | undefined;+const showNotice = () => {+ noticeId = toast.success('Link copied', { duration: 60_000 });+};/** Connect email opens as `selectEmailProvider` opens it, under the sheet's owner. */function EmailSettingsPage() {@@ -308,6 +315,72 @@ function DiscardScenario() {);}+/**+ * Shaped like a task's Properties sheet: rows down to its bottom edge, where+ * the phone prompt sits, and a picker stacked on it, searching from the same+ * place.+ */+function PersistentPromptScenario() {+ const [properties, setProperties] = createSignal(false);+ const [picker, setPicker] = createSignal(false);+ onMount(() => {+ toast.custom(+ {+ title: 'Enable Browser Notifications',+ actions: [{ label: 'Enable', onClick: () => press('Enable') }],+ },+ { persistent: true, region: 'mobile-prompt-region' }+ );+ });+ return (+ <>+ <Button class="fixed top-20 left-4" onClick={() => setProperties(true)}>+ Properties+ </Button>+ <Button class="fixed top-32 left-4" onClick={showNotice}>+ Show notice+ </Button>+ <Button+ class="fixed top-44 left-4"+ onClick={() => {+ if (noticeId !== undefined) toast.dismiss(noticeId);+ }}+ >+ Dismiss notice+ </Button>+ <MobileDrawer+ side="bottom"+ open={properties()}+ onOpenChange={setProperties}+ >+ <MobileDrawer.Portal>+ <MobileDrawer.Overlay />+ <MobileDrawer.Content aria-label="Properties" targetHeight={92}>+ <MobileDrawer.Handle />+ <MobileDrawer.ScrollBody class="justify-end gap-3 px-6 pb-6">+ <Button onClick={showNotice}>Copy link</Button>+ <Button onClick={() => setPicker(true)}>Assignee</Button>+ <Button onClick={() => press('Due date')}>Due date</Button>+ </MobileDrawer.ScrollBody>+ <PickerSheet.Root open={picker()} onCancel={() => setPicker(false)}>+ <PickerSheet.Header+ title="Assignee"+ onDone={() => setPicker(false)}+ />+ <PickerSheet.Body>+ <div class="mt-auto px-4 pb-6">+ <Input aria-label="Search people" />+ </div>+ </PickerSheet.Body>+ </PickerSheet.Root>+ </MobileDrawer.Content>+ </MobileDrawer.Portal>+ </MobileDrawer>+ <ToastRegion />+ </>+ );+}+function Fixture() {const scenario = new URLSearchParams(location.search).get('scenario');return (@@ -319,6 +392,9 @@ function Fixture() {{pressed().join(', ')}</output><Switch fallback={<EventScenario />}>+ <Match when={scenario === 'prompt'}>+ <PersistentPromptScenario />+ </Match><Match when={scenario === 'settings'}><SettingsScenario /></Match>diff --git a/apps/web/src/components/app/mobile/browser-test/stacked-sheets.browser.e2e.ts b/apps/web/src/components/app/mobile/browser-test/stacked-sheets.browser.e2e.tsindex d826add873..8481535a5f 100644--- a/apps/web/src/components/app/mobile/browser-test/stacked-sheets.browser.e2e.ts+++ b/apps/web/src/components/app/mobile/browser-test/stacked-sheets.browser.e2e.ts@@ -297,3 +297,102 @@ test('a sheet opened by its trigger slides up, and swipes away', async ({await expect(filters).toHaveCount(0);});++test.describe('a persistent prompt', () => {+ const toastCard = (page: Page, text: string) =>+ page.locator('[data-macro-toast]', { hasText: text });+ const prompt = (page: Page) =>+ toastCard(page, 'Enable Browser Notifications');+ const notice = (page: Page) => toastCard(page, 'Link copied');++ async function middleOf(target: Locator) {+ await expect(target).toBeVisible();+ const box = await target.boundingBox();+ if (!box) throw new Error('The target is not rendered');+ return { x: box.x + box.width / 2, y: box.y + box.height / 2 };+ }++ /** Whether a tap at this spot lands in `target`, not on what covers it. */+ const receivesTapsAt = (target: Locator, spot: { x: number; y: number }) =>+ target.evaluate(+ (element, { x, y }) => element.contains(document.elementFromPoint(x, y)),+ spot+ );++ async function openProperties(page: Page) {+ await tap(page, page.getByRole('button', { name: 'Properties' }));+ const properties = page.getByRole('dialog', { name: 'Properties' });+ await settled(properties);+ return properties;+ }++ test('waits under a sheet and the picker stacked on it', async ({ page }) => {+ await page.goto('/?scenario=prompt');+ const spot = await middleOf(prompt(page));+ await tap(page, prompt(page).getByRole('button', { name: 'Enable' }));+ await expect(pressed(page)).toHaveText('Enable');++ const properties = await openProperties(page);+ expect(await receivesTapsAt(properties, spot)).toBe(true);+ await tap(page, properties.getByRole('button', { name: 'Due date' }));+ await expect(pressed(page)).toHaveText('Enable, Due date');++ await tap(page, properties.getByRole('button', { name: 'Assignee' }));+ const picker = page.getByRole('dialog', { name: 'Assignee' });+ await settled(picker);+ const search = picker.getByRole('textbox', { name: 'Search people' });+ await expect(search).toBeVisible();+ expect(await receivesTapsAt(picker, spot)).toBe(true);+ await tap(page, search);+ await expect(search).toBeFocused();++ await tap(page, picker.getByRole('button', { name: 'Cancel' }));+ await expect(picker).toHaveCount(0);+ await dragDown(page, properties);+ await expect(properties).toHaveCount(0);++ expect(await receivesTapsAt(prompt(page), spot)).toBe(true);+ await tap(page, prompt(page).getByRole('button', { name: 'Enable' }));+ await expect(pressed(page)).toHaveText('Enable, Due date, Enable');+ });++ test('moves up to clear a notice, and back when it goes', async ({+ page,+ }) => {+ await page.goto('/?scenario=prompt');+ await expect(prompt(page)).toBeVisible();+ await prompt(page).evaluate((card) =>+ Promise.all(card.getAnimations().map((motion) => motion.finished))+ );+ const resting = await prompt(page).boundingBox();+ // 12px over the dock inset, plus the 20px gap the stack keeps above notices.+ expect(+ page.viewportSize()!.height - (resting!.y + resting!.height)+ ).toBeCloseTo(32, 1);++ await tap(page, page.getByRole('button', { name: 'Show notice' }));+ await expect(notice(page)).toBeVisible();+ await expect(async () => {+ const raised = await prompt(page).boundingBox();+ const shown = await notice(page).boundingBox();+ expect(shown!.y - (raised!.y + raised!.height)).toBeCloseTo(20, 1);+ }).toPass();++ await page.getByRole('button', { name: 'Dismiss notice' }).click();+ await expect(notice(page)).toHaveCount(0);+ await expect+ .poll(async () => (await prompt(page).boundingBox())?.y)+ .toBe(resting!.y);+ });++ test('leaves a notice on top of the sheet', async ({ page }) => {+ await page.goto('/?scenario=prompt');+ const properties = await openProperties(page);++ await tap(page, properties.getByRole('button', { name: 'Copy link' }));++ expect(+ await receivesTapsAt(notice(page), await middleOf(notice(page)))+ ).toBe(true);+ });+});diff --git a/apps/web/src/features/notifications/components/BrowserNotificationModal.test.tsx b/apps/web/src/features/notifications/components/BrowserNotificationModal.test.tsxindex 53d5428811..220172cb4e 100644--- a/apps/web/src/features/notifications/components/BrowserNotificationModal.test.tsx+++ b/apps/web/src/features/notifications/components/BrowserNotificationModal.test.tsx@@ -37,7 +37,7 @@ afterEach(() => {});describe('browser notification prompt', () => {- it('waits in the phone prompt region, which steps aside for open sheets', () => {+ it('waits in the phone prompt region, which open sheets cover', () => {mocks.mobile = true;render(() => <BrowserNotificationModal />);diff --git a/apps/web/src/index.css b/apps/web/src/index.cssindex 54ea20fe4e..8cec140c4d 100644--- a/apps/web/src/index.css+++ b/apps/web/src/index.css@@ -547,7 +547,7 @@ body.tauri-ios {Bands:0- 99 in-page — viewer internals (0-19), app chrome (20-30),- cross-panel content (31), floating widgets (90)+ cross-panel content (31), floating widgets (90), phone prompts (95)100-199 modal stack, drag previews, menus200-299 always on top — tooltips, toasts@@ -597,6 +597,11 @@ body.tauri-ios {/* App-level floating widgets (`z-float`: draggable call controls, incomingcalls). Above all other in-page content, below the modal stack. */--z-index-float: 90;+ /* Phone prompts and reminders wait for an answer, so they stay above the+ dock and floating widgets but under the modal stack: an open sheet, its+ scrim and the pickers and menus on it cover them. Phone transient toasts+ stay on `z-toast-region`. */+ --z-index-mobile-prompt-region: 95;/* ---- 100-199: modal stack, drag previews, menus ----------------------- *//* Anchored at 100 so nothing in-page can ever cover a modal. */diff --git a/apps/web/src/lib/core/component/Toast/Toast.test.tsx b/apps/web/src/lib/core/component/Toast/Toast.test.tsxindex 7f935a7ba7..cd966da2e3 100644--- a/apps/web/src/lib/core/component/Toast/Toast.test.tsx+++ b/apps/web/src/lib/core/component/Toast/Toast.test.tsx@@ -17,6 +17,7 @@ beforeEach(() => {'ResizeObserver',class {observe() {}+ unobserve() {}disconnect() {}});diff --git a/apps/web/src/lib/core/component/Toast/ToastRegion.tsx b/apps/web/src/lib/core/component/Toast/ToastRegion.tsxindex 1b724489ca..7da6255101 100644--- a/apps/web/src/lib/core/component/Toast/ToastRegion.tsx+++ b/apps/web/src/lib/core/component/Toast/ToastRegion.tsx@@ -1,9 +1,34 @@import { UploadProgressIndicator } from '@core/component/UploadProgress/UploadProgressIndicator';import { isMobile } from '@core/mobile/isMobile';import { Toast } from '@kobalte/core/toast';-import { createSignal, Show } from 'solid-js';+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';+/** A column centered above the mobile dock, `lift` higher than its usual spot. */+function MobileToastStack(props: {+ ref?: (element: HTMLDivElement) => void;+ class: string;+ lift?: string;+ children: JSX.Element;+}) {+ return (+ <div+ ref={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',+ props.class+ )}+ style={{+ bottom: `calc(var(--mobile-content-inset-bottom, 0px) + 12px + ${props.lift ?? '0px'})`,+ }}+ >+ {props.children}+ </div>+ );+}+export function ToastRegion() {const [mobileSwipeDirection, setMobileSwipeDirection] = createSignal<'left' | 'right'@@ -12,6 +37,9 @@ export function ToastRegion() {const clearSwipe = (event: PointerEvent) => {if (swipeStart?.pointerId === event.pointerId) swipeStart = undefined;};+ const [mobileTransientStack, setMobileTransientStack] =+ createSignal<HTMLDivElement>();+ const mobileTransientSize = createElementSize(mobileTransientStack);return (<Portal>@@ -56,14 +84,19 @@ export function ToastRegion() {</div>{/*- Mobile-only stack: centered above the mobile dock. At most one+ Mobile-only stacks: centered above the mobile dock. At most onetransient toast is visible — Toast.tsx dismisses the previous one assoon as a new one is shown. Persistent prompts live in their ownregion above that slot, capped at one visible card with the restqueued until it is answered.++ They need separate stacks, each `fixed` and so its own stacking+ context: prompts go under the modal stack so they never cover a sheet+ or the picker on it, while transient toasts stay above sheets. The+ prompt stack measures the transient one to stay above that slot.*/}<div- class="fixed left-1/2 -translate-x-1/2 w-full max-w-[420px] px-(--mobile-chrome-gutter) pointer-events-none z-toast-region flex flex-col gap-5"+ class="contents"on:pointerdown={{capture: true,handleEvent: (event) => {@@ -83,45 +116,49 @@ export function ToastRegion() {}}on:pointerup={{ capture: true, handleEvent: clearSwipe }}on:pointercancel={{ capture: true, handleEvent: clearSwipe }}- style={{- bottom: 'calc(var(--mobile-content-inset-bottom, 0px) + 12px)',- }}>- <Toast.Region- class="macro-toast-region"- regionId="mobile-reminder-region"- duration={Infinity}- limit={1}- pauseOnInteraction={false}- swipeDirection={mobileSwipeDirection()}- >- <Toast.List class="macro-toast-list" />- </Toast.Region>- <Toast.Region- class="macro-toast-region"- regionId="mobile-prompt-region"- duration={Infinity}- limit={1}- pauseOnInteraction={false}- swipeDirection={mobileSwipeDirection()}+ <MobileToastStack+ class="z-mobile-prompt-region"+ lift={`${mobileTransientSize.height ?? 0}px + 1.25rem`}>- <Toast.List class="macro-toast-list" />- </Toast.Region>- <Toast.Region- class="macro-toast-region"- regionId="mobile-toast-region"- limit={1}- duration={4500}- pauseOnInteraction- swipeDirection={mobileSwipeDirection()}- >- <Toast.List class="macro-toast-list" />- </Toast.Region>- <Show when={isMobile()}>- <div class="flex justify-center">- <UploadProgressIndicator />- </div>- </Show>+ <Toast.Region+ class="macro-toast-region"+ regionId="mobile-reminder-region"+ duration={Infinity}+ limit={1}+ pauseOnInteraction={false}+ swipeDirection={mobileSwipeDirection()}+ >+ <Toast.List class="macro-toast-list" />+ </Toast.Region>+ <Toast.Region+ class="macro-toast-region"+ regionId="mobile-prompt-region"+ duration={Infinity}+ limit={1}+ pauseOnInteraction={false}+ swipeDirection={mobileSwipeDirection()}+ >+ <Toast.List class="macro-toast-list" />+ </Toast.Region>+ </MobileToastStack>+ <MobileToastStack ref={setMobileTransientStack} class="z-toast-region">+ <Toast.Region+ class="macro-toast-region"+ regionId="mobile-toast-region"+ limit={1}+ duration={4500}+ pauseOnInteraction+ swipeDirection={mobileSwipeDirection()}+ >+ <Toast.List class="macro-toast-list" />+ </Toast.Region>+ <Show when={isMobile()}>+ <div class="flex justify-center">+ <UploadProgressIndicator />+ </div>+ </Show>+ </MobileToastStack></div></Portal>);diff --git a/docs/agent-guide/settings.md b/docs/agent-guide/settings.mdindex c6a48d5b91..69f1e731b6 100644--- a/docs/agent-guide/settings.md+++ b/docs/agent-guide/settings.md@@ -118,7 +118,8 @@ says **Enable Notifications** and requests the Android notification permissionthrough the same native provider. The web prompt says **Enable BrowserNotifications** and uses browser permissions.Select **Hide** to dismiss the prompt. It waits in the same region as other-prompts, one card at a time.+prompts, one card at a time. On phones it stays under open sheets and their+pickers.### Notification snoozesdiff --git a/docs/agent-guide/toasts.md b/docs/agent-guide/toasts.mdindex 1ebc54cdef..b1209a153c 100644--- a/docs/agent-guide/toasts.md+++ b/docs/agent-guide/toasts.md@@ -9,7 +9,9 @@ Ordinary notices dismiss after 4.5 seconds unless the caller specifies a duratioPersistent prompts and reminders keep their separate, single-card queues andremain until answered or dismissed. A new success notice does not replace apersistent reconnect prompt. Mobile keeps one transient notice at a time above-the dock and preserves full descriptions and accessible close buttons.+the dock and preserves full descriptions and accessible close buttons. On phones,+open sheets and the pickers and menus on them cover prompts and reminders, which+sit above the transient notice; the notice itself stays on top of sheets.All toasts place actions to the right of the message, centered vertically. Theclose button floats halfway over the top-right corner; stacked cards leave room