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(ios): release notification cover after failed or stalled opens (#9081)
gbirman003448e0a173
diff --git a/apps/web/AGENTS.md b/apps/web/AGENTS.mdindex 17b5fdbd3e..363236cc2e 100644--- a/apps/web/AGENTS.md+++ b/apps/web/AGENTS.md@@ -544,6 +544,20 @@ on failure or timeout without consuming the pending tap. Late responses mustuse normal account-checked navigation, never reset the mounted router's hash.`notification.launch` records whether startup continued ready, failed, or timed out.+Bound the native cover to eight seconds for each received durable tap, including+warm resumes and stalled route acknowledgments. Release without consuming the+intent on timeout; duplicate delivery must not extend the deadline, and a newer+tap gets its own deadline. Convert fallible notification lookups and navigation+promises into error results so failure cleanup acknowledges the tap and shows+the existing error toast. Keep the startup cover fallback in the same owner,+and let it defer to a pending tap's deadline. The deadline requires responsive+JavaScript and IPC; it cannot recover a frozen WebContent process.++The frontend cover deadline has a backend-free phone browser regression:+`bunx playwright test --config src/lib/tauri/browser-test/playwright.config.ts`.+It uses the real navigation intent and push API with simulated native IPC;+UIKit presentation still requires an iOS device or simulator.+Generate APNs validators with `scripts/generate-api-schema.ts`; its compact`generated/push.ts` entry avoids importing every notification-service schemaon the startup path. Carry known channel root IDs in push navigation (a nulldiff --git a/apps/web/src/features/notifications/PendingNotificationNavigationEffect.test.tsx b/apps/web/src/features/notifications/PendingNotificationNavigationEffect.test.tsxindex b54ef64577..a8beec9cb4 100644--- a/apps/web/src/features/notifications/PendingNotificationNavigationEffect.test.tsx+++ b/apps/web/src/features/notifications/PendingNotificationNavigationEffect.test.tsx@@ -30,6 +30,7 @@ type OpenAttempt = {canOpen: () => boolean;onApplied: VoidFunction;succeed: VoidFunction;+ fail: (error: { tag: 'NavigationFailedError'; cause: unknown }) => void;};function managerHarness(initiallyReady = false) {@@ -77,8 +78,8 @@ describe('usePendingNotificationNavigationEffect', () => {_source: NotificationSource,options: Pick<OpenAttempt, 'canOpen' | 'onApplied'>) => ({- match: (onSuccess: VoidFunction) => {- attempts.push({ ...options, succeed: onSuccess });+ match: (onSuccess: VoidFunction, onError: OpenAttempt['fail']) => {+ attempts.push({ ...options, succeed: onSuccess, fail: onError });},}));@@ -261,4 +262,40 @@ describe('usePendingNotificationNavigationEffect', () => {attempts[1]?.onApplied();expect(pendingNotificationNavigationId()).toBeUndefined();});++ it('does not acknowledge a newer tap when an older lookup fails', async () => {+ const host = managerHarness(true);+ mount();+ setGlobalSplitManager(host.manager);+ const acknowledge = vi.fn(async () => {});+ receiveNotificationTap(+ {+ type: 'BACKGROUND_TAP',+ deliveryId: 'older-delivery',+ payload: { notificationId: 'older-notification' },+ },+ acknowledge+ );+ receiveNotificationTap(+ {+ type: 'BACKGROUND_TAP',+ deliveryId: 'newer-delivery',+ payload: { notificationId: 'newer-notification' },+ },+ acknowledge+ );+ expect(attempts).toHaveLength(2);++ attempts[0]?.fail({+ tag: 'NavigationFailedError',+ cause: new Error('lookup unavailable'),+ });+ expect(acknowledge).not.toHaveBeenCalled();+ expect(pendingNotificationNavigationId()).toBe('newer-notification');++ attempts[1]?.onApplied();+ await Promise.resolve();+ expect(acknowledge).toHaveBeenCalledExactlyOnceWith('newer-delivery');+ expect(pendingNotificationNavigationId()).toBeUndefined();+ });});diff --git a/apps/web/src/features/notifications/PendingNotificationNavigationEffect.tsx b/apps/web/src/features/notifications/PendingNotificationNavigationEffect.tsxindex 1beabd561d..4d73b16f81 100644--- a/apps/web/src/features/notifications/PendingNotificationNavigationEffect.tsx+++ b/apps/web/src/features/notifications/PendingNotificationNavigationEffect.tsx@@ -5,6 +5,7 @@ import type {} from '@components/app/split-layout/layoutManager';import { toast } from '@core/component/Toast/Toast';import { fireAndForget } from '@core/util/fireAndForget';+import { Telemetry } from '@macro-inc/observability';import {type NotificationSource,openNotificationFromId,@@ -28,7 +29,7 @@ type NavigationAttempt = {};export function usePendingNotificationNavigationEffect(- notificationSource: NotificationSource,+ notificationSource: Pick<NotificationSource, 'notifications'>,recipientId: Accessor<string | undefined>) {const [retryRevision, setRetryRevision] = createSignal(0);@@ -143,6 +144,11 @@ export function usePendingNotificationNavigationEffect() {return;}+ if (error.tag === 'NavigationFailedError') {+ Telemetry.error(error.cause, {+ surface: 'notification-navigation',+ });+ }finishNotificationNavigation(intent, 'failed');toast.failure('Failed to open notification.');}diff --git a/apps/web/src/features/notifications/notification-navigation.ts b/apps/web/src/features/notifications/notification-navigation.tsindex b51fc3b0a1..b3367111b7 100644--- a/apps/web/src/features/notifications/notification-navigation.ts+++ b/apps/web/src/features/notifications/notification-navigation.ts@@ -204,10 +204,16 @@ type NavigationDeferredError = {notificationId: string;};+type NavigationFailedError = {+ tag: 'NavigationFailedError';+ cause: unknown;+};+type OpenNotificationFromIdError =| NotSupportedError| NotFoundError- | NavigationDeferredError;+ | NavigationDeferredError+ | NavigationFailedError;function getSupportedHandler(notification: UnifiedNotification,@@ -727,7 +733,7 @@ export function openSingleStackNotification(export function openNotificationFromId(notificationId: string,layoutManager: SplitManager,- notificationSource: NotificationSource,+ notificationSource: Pick<NotificationSource, 'notifications'>,options: {canOpen?: () => boolean;onApplied?: VoidFunction;@@ -746,14 +752,18 @@ export function openNotificationFromId(}),'notification-navigation');- return ResultAsync.fromSafePromise(+ return ResultAsync.fromPromise(navigateToChannelMessage(layoutManager.getOrchestrator(),channelId,messageId,threadId ?? messageId,{ splitManager: layoutManager, onApplied: options.onApplied }- )+ ),+ (cause): NavigationFailedError => ({+ tag: 'NavigationFailedError',+ cause,+ }));}const openIfReady = (notification: UnifiedNotification) => {@@ -763,14 +773,22 @@ export function openNotificationFromId(notificationId,});}- return openNotification(- notification,- layoutManager,- false,- undefined,- undefined,- { onApplied: options.onApplied, source: 'native_push' }- );+ // Preserve the in-app caller contract while giving native navigation one+ // error result for both rejected handlers and unsupported destinations.+ return ResultAsync.fromPromise(+ openNotification(+ notification,+ layoutManager,+ false,+ undefined,+ undefined,+ { onApplied: options.onApplied, source: 'native_push' }+ ),+ (cause): NavigationFailedError => ({+ tag: 'NavigationFailedError',+ cause,+ })+ ).andThen((result) => result);};// Check notification source first@@ -782,8 +800,9 @@ export function openNotificationFromId(}// Fetch if not in notification source- return ResultAsync.fromSafePromise(- getNotificationById(notificationId)+ return ResultAsync.fromPromise(+ getNotificationById(notificationId),+ (cause): NavigationFailedError => ({ tag: 'NavigationFailedError', cause })).andThen((unified) => {if (!unified) {const err: NotFoundError = { tag: 'NotFoundError', notificationId };diff --git a/apps/web/src/features/notifications/tests/channel-notification-navigation.test.ts b/apps/web/src/features/notifications/tests/channel-notification-navigation.test.tsindex 24791fd4be..abd47c620b 100644--- a/apps/web/src/features/notifications/tests/channel-notification-navigation.test.ts+++ b/apps/web/src/features/notifications/tests/channel-notification-navigation.test.ts@@ -1,3 +1,4 @@+import { setGlobalSplitManager } from '@app/signal/splitLayout';import { createRoutedSplitLayout } from '@components/app/split-layout/tests/fixtures';import { toast } from '@core/component/Toast/Toast';import {@@ -7,24 +8,32 @@ import {import type { BlockOrchestrator } from '@core/orchestrator';import { getNotificationById } from '@queries/notification/user-notifications';import { createRoot } from 'solid-js';-import { beforeEach, expect, it, onTestFinished, vi } from 'vitest';+import { afterEach, beforeEach, expect, it, onTestFinished, vi } from 'vitest';import {openNotification,openNotificationFromId,} from '../notification-navigation';+import {+ pendingNotificationNavigation,+ receiveNotificationTap,+ setPendingNotificationNavigationId,+} from '../notification-navigation-intent';+import { endNotificationOpen } from '../notification-open-trace';import type { NotificationSource } from '../notification-source';+import { usePendingNotificationNavigationEffect } from '../PendingNotificationNavigationEffect';import type { UnifiedNotification } from '../types';-vi.mock('@app/signal/splitLayout', () => ({- globalSplitManager: () => undefined,-}));+// Keep the actual navigation functions without loading unrelated barrel exports.+vi.mock('@notifications', async () => import('../notification-navigation'));vi.mock('@components/app/split-layout/componentRegistry', () => ({resolveComponent: () => ({ element: undefined }),}));vi.mock('@core/constant/settingsTabsConfig', () => ({settingsTabToSlug: (tab: string) => tab,}));-vi.mock('@core/component/Toast/Toast', () => ({ toast: { alert: vi.fn() } }));+vi.mock('@core/component/Toast/Toast', () => ({+ toast: { alert: vi.fn(), failure: vi.fn() },+}));vi.mock('@app/features/calendar-view/calendar-range', () => ({createCalendarRange: vi.fn(),}));@@ -39,6 +48,11 @@ vi.mock('@core/constant/allBlocks', () => ({}));beforeEach(() => vi.clearAllMocks());+afterEach(() => {+ setGlobalSplitManager(undefined);+ setPendingNotificationNavigationId(undefined);+ endNotificationOpen('test_complete');+});vi.mock('@core/constant/featureFlags', async (importOriginal) => ({...(await importOriginal<typeof import('@core/constant/featureFlags')>()),enableCalendarUi: false,@@ -174,6 +188,116 @@ it('opens a direct push target without looking up the notification or loading thexpect(onApplied).toHaveBeenCalledOnce();});+it('acknowledges a failed lookup and opens the next native tap', async () => {+ const { layout } = setup('closed');+ const lookup = Promise.withResolvers<UnifiedNotification | undefined>();+ vi.mocked(getNotificationById).mockReturnValueOnce(lookup.promise);+ const source = { notifications: () => [] };+ createRoot((dispose) => {+ onTestFinished(dispose);+ usePendingNotificationNavigationEffect(+ source,+ () => 'macro|[email protected]'+ );+ });+ setGlobalSplitManager(layout);+ const failedAck = Promise.withResolvers<void>();+ const nextAck = Promise.withResolvers<void>();+ const acknowledge = vi.fn(async (deliveryId: string) => {+ if (deliveryId === 'failed-delivery') failedAck.resolve();+ if (deliveryId === 'next-delivery') nextAck.resolve();+ });+ receiveNotificationTap(+ {+ type: 'BACKGROUND_TAP',+ payload: { notificationId: 'failed-notification' },+ deliveryId: 'failed-delivery',+ },+ acknowledge+ );+ lookup.reject(new Error('notification lookup unavailable'));+ await failedAck.promise;+ await Promise.resolve();+ expect(acknowledge).toHaveBeenCalledWith('failed-delivery');+ expect(pendingNotificationNavigation()).toBeUndefined();+ expect(toast.failure).toHaveBeenCalledOnce();+ expect(layout.getSplitByContent('channel', 'channel')).toBeUndefined();++ vi.mocked(getNotificationById).mockResolvedValueOnce({+ id: 'next-notification',+ entity_id: 'channel',+ entity_type: 'channel',+ created_at: '2026-01-01T00:00:00Z',+ updated_at: '2026-01-01T00:00:00Z',+ notification_event_type: 'channel_invite',+ notification_metadata: {+ tag: 'channel_invite',+ content: { invitedBy: 'macro|[email protected]' },+ },+ state: 'unseen',+ sent: true,+ });+ receiveNotificationTap(+ {+ type: 'BACKGROUND_TAP',+ payload: { notificationId: 'next-notification' },+ deliveryId: 'next-delivery',+ },+ acknowledge+ );+ await nextAck.promise;+ await Promise.resolve();+ expect(acknowledge).toHaveBeenCalledWith('next-delivery');+ expect(pendingNotificationNavigation()).toBeUndefined();+ expect(layout.getSplitByContent('channel', 'channel')).toBeDefined();+});++it.each(['direct', 'cached'] as const)(+ 'reports a rejected %s destination through the error result',+ async (kind) => {+ const { layout } = setup('closed');+ const failure = new Error('destination unavailable');+ vi.spyOn(layout, 'openWithSplit').mockImplementationOnce(() => {+ throw failure;+ });+ const notification: UnifiedNotification = {+ id: 'notification',+ entity_id: 'channel',+ entity_type: 'channel',+ created_at: '2026-01-01T00:00:00Z',+ updated_at: '2026-01-01T00:00:00Z',+ notification_event_type: 'channel_invite',+ notification_metadata: {+ tag: 'channel_invite',+ content: { invitedBy: 'macro|[email protected]' },+ },+ state: 'unseen',+ sent: true,+ };+ const source = { notifications: () => [notification] };+ const onApplied = vi.fn();+ const failed = vi.fn();+ await openNotificationFromId('notification', layout, source, {+ onApplied,+ ...(kind === 'direct'+ ? {+ target: {+ type: 'channel' as const,+ channelId: 'channel',+ messageId: 'message',+ threadId: null,+ },+ }+ : {}),+ }).match(() => {}, failed);+ expect(failed).toHaveBeenCalledWith({+ tag: 'NavigationFailedError',+ cause: failure,+ });+ expect(onApplied).not.toHaveBeenCalled();+ }+);+it.each(['channel_invite', 'call_started'] as const)('activates the existing preview for %s without opening a split',async (tag) => {diff --git a/apps/web/src/lib/tauri/browser-test/cover.browser.e2e.ts b/apps/web/src/lib/tauri/browser-test/cover.browser.e2e.tsnew file mode 100644index 0000000000..8cef23e7ab--- /dev/null+++ b/apps/web/src/lib/tauri/browser-test/cover.browser.e2e.ts@@ -0,0 +1,105 @@+import { expect, test } from '@playwright/test';++test.beforeEach(async ({ page }) => {+ await page.clock.install();+ await page.goto('/');+ await expect(+ page.getByRole('button', { name: 'Open another page' })+ ).toBeVisible();+});++test('releases a warm tap while acknowledgment waits for a frame, retaining it for completion', async ({+ page,+}) => {+ // The initial mount deadline would already have expired on a warm resume.+ await page.clock.fastForward(20_000);+ await page.evaluate(() => {+ window.notificationCoverFixture.blockFrames();+ window.notificationCoverFixture.tap('first');+ window.notificationCoverFixture.complete();+ });+ expect(+ await page.evaluate(() => window.notificationCoverFixture.snapshot())+ ).toEqual({+ commands: ['plugin:notifications|release_notification_cover'],+ nativePending: 'first',+ pending: 'first',+ blockedFrames: 1,+ covered: true,+ });+ await page.clock.fastForward(8000);+ expect(+ await page.evaluate(() => window.notificationCoverFixture.snapshot())+ ).toEqual({+ commands: [+ 'plugin:notifications|release_notification_cover',+ 'plugin:notifications|release_notification_cover',+ ],+ nativePending: 'first',+ pending: 'first',+ blockedFrames: 1,+ covered: false,+ });+ await page.getByRole('button', { name: 'Open another page' }).click();+ await expect(page.locator('#navigation')).toHaveText('Another page');++ await page.evaluate(() => window.notificationCoverFixture.flushFrames());+ expect(+ await page.evaluate(() => window.notificationCoverFixture.snapshot())+ ).toEqual({+ commands: [+ 'plugin:notifications|release_notification_cover',+ 'plugin:notifications|release_notification_cover',+ 'plugin:notifications|acknowledge_notification',+ ],+ nativePending: undefined,+ pending: undefined,+ blockedFrames: 0,+ covered: false,+ });+});++test('the startup cap does not release a later notification cover', async ({+ page,+}) => {+ await page.clock.fastForward(7000);+ await page.evaluate(() => window.notificationCoverFixture.tap('startup-tap'));+ await page.clock.fastForward(1000);+ expect(+ await page.evaluate(() => window.notificationCoverFixture.snapshot())+ ).toMatchObject({ commands: [], pending: 'startup-tap', covered: true });+ await page.clock.fastForward(7000);+ expect(+ await page.evaluate(() => window.notificationCoverFixture.snapshot())+ ).toMatchObject({+ commands: ['plugin:notifications|release_notification_cover'],+ pending: 'startup-tap',+ covered: false,+ });+});++test('a newer tap replaces the old deadline and duplicate delivery does not extend it', async ({+ page,+}) => {+ await page.evaluate(() => window.notificationCoverFixture.tap('first'));+ await page.clock.fastForward(4000);+ await page.evaluate(() => window.notificationCoverFixture.tap('second'));+ await page.clock.fastForward(4000);+ await page.evaluate(() => window.notificationCoverFixture.tap('second'));+ expect(+ await page.evaluate(() => window.notificationCoverFixture.snapshot())+ ).toMatchObject({+ commands: [],+ pending: 'second',+ covered: true,+ });+ await page.clock.fastForward(4000);+ expect(+ await page.evaluate(() => window.notificationCoverFixture.snapshot())+ ).toMatchObject({+ commands: ['plugin:notifications|release_notification_cover'],+ nativePending: 'second',+ pending: 'second',+ covered: false,+ });+});diff --git a/apps/web/src/lib/tauri/browser-test/index.html b/apps/web/src/lib/tauri/browser-test/index.htmlnew file mode 100644index 0000000000..a2f3e84f2d--- /dev/null+++ b/apps/web/src/lib/tauri/browser-test/index.html@@ -0,0 +1,15 @@+<!doctype html>+<html lang="en">+ <head>+ <meta charset="UTF-8" />+ <meta name="viewport" content="width=device-width, initial-scale=1" />+ <title>Notification cover bridge fixture</title>+ </head>+ <body style="margin: 0; padding: 64px 16px 16px; font: 16px system-ui">+ <p style="position: fixed; z-index: 1; inset: 0 0 auto; margin: 0; padding: 12px; background: #ffe89a; color: #111; font-size: 13px">Simulated native cover — browser fixture, not the iOS app</p>+ <button id="navigate" type="button">Open another page</button>+ <output id="navigation">Ready</output>+ <div id="cover" hidden style="position: fixed; inset: 56px 0 0; background: black"></div>+ <script type="module" src="./main.ts"></script>+ </body>+</html>diff --git a/apps/web/src/lib/tauri/browser-test/main.ts b/apps/web/src/lib/tauri/browser-test/main.tsnew file mode 100644index 0000000000..966975db98--- /dev/null+++ b/apps/web/src/lib/tauri/browser-test/main.ts@@ -0,0 +1,91 @@+import {+ finishNotificationNavigation,+ pendingNotificationNavigation,+ receiveNotificationTap,+} from '@notifications/notification-navigation-intent';+import { mockIPC } from '@tauri-apps/api/mocks';+import { createRoot } from 'solid-js';+import { useNotificationCoverTimeout } from '../notification-launch';+import { createPushApi } from '../push-api';++const COVER = document.getElementById('cover');+const NAVIGATE = document.getElementById('navigate');+const NAVIGATION = document.getElementById('navigation');+if (!COVER || !NAVIGATE || !NAVIGATION) throw new Error('Missing fixture UI');++const COMMANDS: string[] = [];+let nativePending: string | undefined;+const FRAMES: FrameRequestCallback[] = [];+const requestFrame = window.requestAnimationFrame;+window.__MACRO_IOS_NOTIFICATION_LAUNCH__ = true;+mockIPC((command, payload) => {+ COMMANDS.push(command);+ if (command === 'plugin:notifications|release_notification_cover') {+ COVER.hidden = true;+ return;+ }+ if (command === 'plugin:notifications|acknowledge_notification') {+ if (+ payload &&+ 'deliveryId' in payload &&+ payload.deliveryId === nativePending+ ) {+ nativePending = undefined;+ COVER.hidden = true;+ }+ return;+ }+ throw new Error(`Unexpected native command: ${command}`);+});++const PUSH = createPushApi('ios');+const dispose = createRoot((dispose) => {+ useNotificationCoverTimeout();+ return dispose;+});+window.addEventListener('pagehide', dispose, { once: true });+NAVIGATE.addEventListener('click', () => {+ NAVIGATION.textContent = 'Another page';+});++const FIXTURE = {+ tap(deliveryId: string) {+ nativePending = deliveryId;+ COVER.hidden = false;+ receiveNotificationTap(+ {+ type: 'BACKGROUND_TAP',+ payload: { notificationId: deliveryId },+ deliveryId,+ },+ PUSH.acknowledge+ );+ },+ complete() {+ const intent = pendingNotificationNavigation();+ if (intent) finishNotificationNavigation(intent);+ },+ blockFrames() {+ window.requestAnimationFrame = (callback) => FRAMES.push(callback);+ },+ flushFrames() {+ window.requestAnimationFrame = requestFrame;+ for (const frame of FRAMES.splice(0)) frame(performance.now());+ },+ snapshot() {+ return {+ commands: [...COMMANDS],+ nativePending,+ pending: pendingNotificationNavigation()?.deliveryId,+ blockedFrames: FRAMES.length,+ covered: !COVER.hidden,+ };+ },+};++declare global {+ interface Window {+ notificationCoverFixture: typeof FIXTURE;+ }+}+window.notificationCoverFixture = FIXTURE;diff --git a/apps/web/src/lib/tauri/browser-test/playwright.config.ts b/apps/web/src/lib/tauri/browser-test/playwright.config.tsnew file mode 100644index 0000000000..4bf96712b8--- /dev/null+++ b/apps/web/src/lib/tauri/browser-test/playwright.config.ts@@ -0,0 +1,33 @@+import { fileURLToPath } from 'node:url';+import { defineConfig, devices } from '@playwright/test';++const DIRECTORY = fileURLToPath(new URL('.', import.meta.url));+const WEB_DIRECTORY = fileURLToPath(new URL('../../../../', import.meta.url));+const PORT = Number(process.env.NOTIFICATION_COVER_BROWSER_PORT ?? 3008);++export default defineConfig({+ testDir: DIRECTORY,+ testMatch: '*.browser.e2e.ts',+ outputDir: `${DIRECTORY}/test-results`,+ workers: 1,+ timeout: 30_000,+ use: {+ baseURL: `http://127.0.0.1:${PORT}`,+ trace: 'retain-on-failure',+ launchOptions: {+ executablePath: process.env.PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH,+ },+ },+ webServer: {+ command: `bunx --bun vite --config src/lib/tauri/browser-test/vite.config.ts --port ${PORT}`,+ cwd: WEB_DIRECTORY,+ url: `http://127.0.0.1:${PORT}`,+ reuseExistingServer: false,+ },+ projects: [+ {+ name: 'phone',+ use: { ...devices['iPhone 13'], defaultBrowserType: 'chromium' },+ },+ ],+});diff --git a/apps/web/src/lib/tauri/browser-test/vite.config.ts b/apps/web/src/lib/tauri/browser-test/vite.config.tsnew file mode 100644index 0000000000..e7043511bc--- /dev/null+++ b/apps/web/src/lib/tauri/browser-test/vite.config.ts@@ -0,0 +1,25 @@+import { fileURLToPath } from 'node:url';+import { defineConfig } from 'vite';+import solidPlugin from 'vite-plugin-solid';+import tsconfigPaths from 'vite-tsconfig-paths';++const DIRECTORY = fileURLToPath(new URL('.', import.meta.url));+const WEB_DIRECTORY = fileURLToPath(new URL('../../../../', import.meta.url));+const WORKSPACE_DIRECTORY = fileURLToPath(+ new URL('../../../../../../', import.meta.url)+);++export default defineConfig({+ root: DIRECTORY,+ cacheDir: `${DIRECTORY}/.vite`,+ plugins: [+ solidPlugin(),+ tsconfigPaths({ projects: [`${WEB_DIRECTORY}/tsconfig.json`] }),+ ],+ resolve: { dedupe: ['solid-js'] },+ server: {+ host: '127.0.0.1',+ strictPort: true,+ fs: { allow: [WORKSPACE_DIRECTORY] },+ },+});diff --git a/apps/web/src/lib/tauri/notification-launch.test.ts b/apps/web/src/lib/tauri/notification-launch.test.tsindex d82a0e999d..2e2e8fdea1 100644--- a/apps/web/src/lib/tauri/notification-launch.test.ts+++ b/apps/web/src/lib/tauri/notification-launch.test.ts@@ -1,10 +1,16 @@import {+ finishNotificationNavigation,pendingNotificationNavigation,+ receiveNotificationTap,setPendingNotificationNavigationId,} from '@notifications/notification-navigation-intent';import { endNotificationOpen } from '@notifications/notification-open-trace';-import { afterEach, beforeEach, expect, it, vi } from 'vitest';-import { prepareNotificationLaunch } from './notification-launch';+import { createRoot } from 'solid-js';+import { afterEach, beforeEach, expect, it, onTestFinished, vi } from 'vitest';+import {+ prepareNotificationLaunch,+ useNotificationCoverTimeout,+} from './notification-launch';import type { PushEvent } from './push-api';const bridge = vi.hoisted(() => ({@@ -110,6 +116,151 @@ it.each(['watch', 'pending'] as const)(});+function mountCoverTimeout() {+ return createRoot((dispose) => {+ useNotificationCoverTimeout();+ onTestFinished(dispose);+ return dispose;+ });+}++it('releases a stalled warm tap without consuming it or extending the deadline on redelivery', async () => {+ mountCoverTimeout();+ await vi.advanceTimersByTimeAsync(10_000);+ expect(bridge.releaseCover).toHaveBeenCalledOnce();+ bridge.releaseCover.mockClear();++ const tap = {+ type: 'BACKGROUND_TAP',+ payload: { notificationId: 'notification' },+ deliveryId: 'warm-tap',+ };+ receiveNotificationTap(tap, bridge.acknowledge);+ const intent = pendingNotificationNavigation();+ await vi.advanceTimersByTimeAsync(7000);+ receiveNotificationTap(tap, bridge.acknowledge);+ await vi.advanceTimersByTimeAsync(999);+ expect(bridge.releaseCover).not.toHaveBeenCalled();+ await vi.advanceTimersByTimeAsync(1);+ expect(bridge.releaseCover).toHaveBeenCalledOnce();+ expect(pendingNotificationNavigation()).toBe(intent);+ expect(bridge.acknowledge).not.toHaveBeenCalled();+});++it('reveals the app while an acknowledgment is stalled and still accepts its late completion', async () => {+ mountCoverTimeout();+ const acknowledgment = Promise.withResolvers<void>();+ bridge.acknowledge.mockReturnValue(acknowledgment.promise);+ receiveNotificationTap(+ {+ type: 'BACKGROUND_TAP',+ payload: { notificationId: 'notification' },+ deliveryId: 'stalled-ack',+ },+ bridge.acknowledge+ );+ const intent = pendingNotificationNavigation()!;+ finishNotificationNavigation(intent);+ await vi.advanceTimersByTimeAsync(8000);+ expect(bridge.releaseCover).toHaveBeenCalledOnce();+ expect(pendingNotificationNavigation()).toBe(intent);++ acknowledgment.resolve();+ await vi.advanceTimersByTimeAsync(0);+ expect(pendingNotificationNavigation()).toBeUndefined();+});++it('gives a newer tap its own deadline instead of releasing it on the previous timer', async () => {+ mountCoverTimeout();+ receiveNotificationTap(+ {+ type: 'BACKGROUND_TAP',+ payload: { notificationId: 'first' },+ deliveryId: 'first',+ },+ bridge.acknowledge+ );+ await vi.advanceTimersByTimeAsync(7000);+ receiveNotificationTap(+ {+ type: 'BACKGROUND_TAP',+ payload: { notificationId: 'second' },+ deliveryId: 'second',+ },+ bridge.acknowledge+ );+ const intent = pendingNotificationNavigation();+ await vi.advanceTimersByTimeAsync(1000);+ expect(bridge.releaseCover).not.toHaveBeenCalled();+ await vi.advanceTimersByTimeAsync(7000);+ expect(bridge.releaseCover).toHaveBeenCalledOnce();+ expect(pendingNotificationNavigation()).toBe(intent);+});++it.each(['completed', 'disposed'] as const)(+ 'cancels the cover deadline when the navigation is %s',+ async (outcome) => {+ const dispose = mountCoverTimeout();+ await vi.advanceTimersByTimeAsync(10_000);+ bridge.releaseCover.mockClear();+ receiveNotificationTap(+ {+ type: 'BACKGROUND_TAP',+ payload: { notificationId: 'notification' },+ deliveryId: 'tap',+ },+ bridge.acknowledge+ );+ await vi.advanceTimersByTimeAsync(1000);+ if (outcome === 'completed') {+ finishNotificationNavigation(pendingNotificationNavigation()!);+ } else {+ dispose();+ }+ await vi.advanceTimersByTimeAsync(8000);+ expect(bridge.releaseCover).not.toHaveBeenCalled();+ }+);++it('lets a tap received during startup keep its own cover deadline', async () => {+ mountCoverTimeout();+ await vi.advanceTimersByTimeAsync(7000);+ receiveNotificationTap(+ {+ type: 'BACKGROUND_TAP',+ payload: { notificationId: 'notification' },+ deliveryId: 'startup-tap',+ },+ bridge.acknowledge+ );+ const intent = pendingNotificationNavigation();+ await vi.advanceTimersByTimeAsync(1000);+ expect(bridge.releaseCover).not.toHaveBeenCalled();+ await vi.advanceTimersByTimeAsync(7000);+ expect(bridge.releaseCover).toHaveBeenCalledOnce();+ expect(pendingNotificationNavigation()).toBe(intent);+});++it.each(['unsupported', 'legacy'] as const)(+ 'does not release a cover for %s notifications',+ async (kind) => {+ bridge.supported = kind !== 'unsupported';+ mountCoverTimeout();+ await vi.advanceTimersByTimeAsync(10_000);+ bridge.releaseCover.mockClear();+ receiveNotificationTap(+ {+ type: 'BACKGROUND_TAP',+ payload: { notificationId: 'notification' },+ ...(kind === 'unsupported' ? { deliveryId: 'tap' } : {}),+ },+ bridge.acknowledge+ );+ await vi.advanceTimersByTimeAsync(8000);+ expect(bridge.releaseCover).not.toHaveBeenCalled();+ }+);+it('preserves a buffered tap when the pending snapshot stalls', async () => {bridge.watch.mockImplementation(async (receive: (event: PushEvent) => void) => {diff --git a/apps/web/src/lib/tauri/notification-launch.ts b/apps/web/src/lib/tauri/notification-launch.tsindex 9b3d229e77..afd998fb2c 100644--- a/apps/web/src/lib/tauri/notification-launch.ts+++ b/apps/web/src/lib/tauri/notification-launch.ts@@ -4,12 +4,52 @@ import {pendingNotificationNavigation,receiveNotificationTap,} from '@notifications/notification-navigation-intent';+import { notificationOpenSpan } from '@notifications/notification-open-trace';+import { createEffect, on, onCleanup, onMount } from 'solid-js';import {createPushApi,releaseNotificationCover,supportsNotificationLaunch,} from './push-api';+const NOTIFICATION_COVER_MAX_WAIT_MS = 8000;++/** Keep every tap usable even when navigation or its acknowledgment stalls. */+export function useNotificationCoverTimeout(): void {+ onMount(() => {+ if (!supportsNotificationLaunch()) return;+ const startedAt = performance.now();+ const timeout = setTimeout(() => {+ // A tap received during startup owns its later deadline. Keep the+ // bootstrap fallback for launches that have not delivered an intent.+ if (pendingNotificationNavigation()?.deliveryId) return;+ const span = Telemetry.span('notification.cover_startup_fallback');+ span.setAttr('notification.cover.outcome', 'startup_timeout');+ span.setAttr('notification.cover.wait_ms', performance.now() - startedAt);+ span.event('notification.cover_timeout');+ span.end();+ fireAndForget(releaseNotificationCover(), 'notification-launch');+ }, NOTIFICATION_COVER_MAX_WAIT_MS);+ onCleanup(() => clearTimeout(timeout));+ });++ createEffect(+ on(pendingNotificationNavigation, (intent) => {+ if (!supportsNotificationLaunch() || !intent?.deliveryId) return;+ const timeout = setTimeout(() => {+ if (pendingNotificationNavigation() !== intent) return;+ notificationOpenSpan(intent.notificationId)?.event(+ 'notification.cover_timeout'+ );+ // Revealing the app does not consume the durable destination. Native+ // can redeliver it, and a later route acknowledgment still completes it.+ fireAndForget(releaseNotificationCover(), 'notification-launch');+ }, NOTIFICATION_COVER_MAX_WAIT_MS);+ onCleanup(() => clearTimeout(timeout));+ })+ );+}+/** Read the native launch intent before the hash router can restore another page. */export async function prepareNotificationLaunch(): Promise<void> {if (!supportsNotificationLaunch()) return;diff --git a/apps/web/src/routes/Root.tsx b/apps/web/src/routes/Root.tsxindex d14f035c96..a320faef73 100644--- a/apps/web/src/routes/Root.tsx+++ b/apps/web/src/routes/Root.tsx@@ -33,7 +33,7 @@ import { isTauri } from '@core/util/platform';import { transformShortIdInUrlPathname } from '@core/util/url';import { EntityProvider } from '@entity';import { MaybeTauriProvider } from '@macro/tauri';-import { releaseNotificationCover } from '@macro/tauri/push-api';+import { useNotificationCoverTimeout } from '@macro/tauri/notification-launch';import { TauriRouteListener } from '@macro/tauri/TauriProvider';import { Telemetry } from '@macro-inc/observability';import { BrowserNotificationModal } from '@notifications';@@ -180,10 +180,10 @@ const BOOT_SHELL_MAX_WAIT_MS = 8000;function AppRouteFrame(props: RouteSectionProps) {useUserInfoSideEffects();useSessionWebsockets();+ useNotificationCoverTimeout();onMount(() => {const cap = setTimeout(() => {dismissBootShell();- fireAndForget(releaseNotificationCover(), 'notification-launch');}, BOOT_SHELL_MAX_WAIT_MS);onCleanup(() => clearTimeout(cap));});diff --git a/docs/agent-guide/notifications.md b/docs/agent-guide/notifications.mdindex 75ab289e06..83f0e2875c 100644--- a/docs/agent-guide/notifications.md+++ b/docs/agent-guide/notifications.md@@ -76,6 +76,17 @@ both listener attachment and pending-intent reads, including a tap deliveredbefore the pending read stalls. Receiving a push without tapping it must notnavigate.+For an iOS warm resume, leave the app running past its startup timeout before+backgrounding it. Tap an uncached notification without a direct channel target+and fail its notification lookup: the app must reveal the existing page and+show **Failed to open notification.** A later tap must still open normally.+Also stall navigation or its native acknowledgment: after eight seconds the+frontend releases the cover without discarding the pending destination. Duplicate+delivery must not restart that deadline; a newer tap must get its own deadline.+`notification.cover_timeout` is recorded on the notification-open trace. This+frontend recovery requires responsive JavaScript and native IPC; verify actual+iOS presentation separately from browser bridge simulations.+On iOS, Macro requests provisional authorization at launch, so**Settings → Apps → Macro → Notifications** exists before any prompt, and asigned-in device registers for pushes that arrive quietly in Notification