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): preserve back navigation after cold push launches (#9213)
Peter Chinman6e2a98672344
diff --git a/apps/web/AGENTS.md b/apps/web/AGENTS.mdindex b973f38a5f..67bf25dfb9 100644--- a/apps/web/AGENTS.md+++ b/apps/web/AGENTS.md@@ -580,6 +580,10 @@ older work. Older native builds and pushes retain authenticated notificationlookup. The local bridge and native release requirement are documented in[`docs/ios-releases.md`](docs/ios-releases.md).+Cold channel push launches retain Home behind the target channel so the mobile+header Back control and swipe-back have a destination. Keep this launch layout+in `notificationLaunchPath`; warm taps retain their current pane stack.+Bound the pre-router bridge handoff to 1.5 seconds and release the native coveron failure or timeout without consuming the pending tap. Late responses mustuse normal account-checked navigation, never reset the mounted router's hash.diff --git a/apps/web/src/components/app/split-layout/tests/fixtures.ts b/apps/web/src/components/app/split-layout/tests/fixtures.tsindex 13ed1d0c11..d4c1b1ca90 100644--- a/apps/web/src/components/app/split-layout/tests/fixtures.ts+++ b/apps/web/src/components/app/split-layout/tests/fixtures.ts@@ -51,7 +51,8 @@ const routes: SplitRoutes = {*/export function createRoutedSplitLayout(orchestrator: BlockOrchestrator,- url: string+ url: string,+ stacked = false): SplitManager {let manager: SplitManager | undefined;const router = createSplitRouter({@@ -62,13 +63,14 @@ export function createRoutedSplitLayout(manager: () => manager,toContent: splitContentFromLocation,defaultLocation: () => homeLocation,- stacked: () => false,+ stacked: () => stacked,}),});manager = createSplitLayout(orchestrator, {router,toLocation: (content) => resolveContentLocation(router.routes, content),toContent: splitContentFromLocation,+ stacked: () => stacked,});return manager;}diff --git a/apps/web/src/features/notifications/notification-navigation-intent.test.ts b/apps/web/src/features/notifications/notification-navigation-intent.test.tsindex ea34695774..babbb031a4 100644--- a/apps/web/src/features/notifications/notification-navigation-intent.test.ts+++ b/apps/web/src/features/notifications/notification-navigation-intent.test.ts@@ -35,7 +35,7 @@ it('decodes nested APNs routing metadata and retains known top-level identity',).toEqual(navigation);receiveNotificationTap({ type: 'BACKGROUND_TAP', payload }, vi.fn());expect(notificationLaunchPath(payload.recipientId)).toBe(- '/channel/11111111-1111-4111-8111-111111111111?channel_message_id=22222222-2222-4222-8222-222222222222&channel_thread_id=22222222-2222-4222-8222-222222222222'+ '/home/~/channel/11111111-1111-4111-8111-111111111111?channel_message_id=22222222-2222-4222-8222-222222222222&channel_thread_id=22222222-2222-4222-8222-222222222222');expect(notificationLaunchPath('macro|[email protected]')).toBeUndefined();});diff --git a/apps/web/src/features/notifications/notification-navigation-intent.ts b/apps/web/src/features/notifications/notification-navigation-intent.tsindex 1ad310fd22..cf8b4a7849 100644--- a/apps/web/src/features/notifications/notification-navigation-intent.ts+++ b/apps/web/src/features/notifications/notification-navigation-intent.ts@@ -1,3 +1,4 @@+import { DEFAULT_ROUTE } from '@app/constants/defaultRoute';import { getChannelParams } from '@channel/Channel/link';import { fireAndForget } from '@core/util/fireAndForget';import { pushNotificationNavigation } from '@service-notification/generated/push';@@ -134,7 +135,13 @@ export function notificationLaunchPath(const params = new URLSearchParams(getChannelParams(messageId, threadId ?? messageId));- return `/channel/${encodeURIComponent(channelId)}?${params}`;+ // A cold launch has no pane history. Keep Home behind the destination so+ // the channel has the same Back control as a notification opened in-app.+ notificationOpenSpan(intent.notificationId)?.setAttr(+ 'notification.launch_pane_count',+ 2+ );+ return `${DEFAULT_ROUTE}/~/channel/${encodeURIComponent(channelId)}?${params}`;}export function finishNotificationNavigation(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 abd47c620b..56999d30fb 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,4 +1,5 @@import { setGlobalSplitManager } from '@app/signal/splitLayout';+import { createMobilePaneStack } from '@components/app/split-layout/mobile/createMobilePaneStack';import { createRoutedSplitLayout } from '@components/app/split-layout/tests/fixtures';import { toast } from '@core/component/Toast/Toast';import {@@ -14,6 +15,7 @@ import {openNotificationFromId,} from '../notification-navigation';import {+ notificationLaunchPath,pendingNotificationNavigation,receiveNotificationTap,setPendingNotificationNavigationId,@@ -188,6 +190,59 @@ it('opens a direct push target without looking up the notification or loading thexpect(onApplied).toHaveBeenCalledOnce();});+it('returns to Home from a channel opened by a cold push launch', async () => {+ const target = {+ type: 'channel' as const,+ channelId: '11111111-1111-4111-8111-111111111111',+ messageId: '22222222-2222-4222-8222-222222222222',+ threadId: null,+ };+ const recipientId = 'macro|[email protected]';+ receiveNotificationTap(+ {+ type: 'BACKGROUND_TAP',+ payload: { notificationId: 'cold-push', recipientId, navigation: target },+ },+ vi.fn()+ );+ const path = notificationLaunchPath(recipientId);+ if (!path) throw new Error('Expected the authenticated push destination');+ const navigate = vi.fn();+ const orchestrator = {+ createBlockInstance: () => ({ element: undefined }),+ getBlockHandle: async () => ({ goToLocationFromParams: navigate }),+ } as unknown as BlockOrchestrator;+ const { layout, stack } = createRoot((dispose) => {+ onTestFinished(dispose);+ const layout = createRoutedSplitLayout(orchestrator, path, true);+ return { layout, stack: createMobilePaneStack(layout) };+ });++ const result = await openNotificationFromId(+ 'cold-push',+ layout,+ { notifications: () => [] },+ { target }+ );+ expect(result.isOk()).toBe(true);+ expect(layout.splits().map((split) => split.content)).toMatchObject([+ { type: 'component', id: 'home' },+ { type: 'channel', id: target.channelId },+ ]);+ expect(stack.canGoBack()).toBe(true);+ expect(layout.activeSplit()?.content().id).toBe(target.channelId);+ expect(navigate).toHaveBeenCalledWith({+ channel_message_id: target.messageId,+ channel_thread_id: target.messageId,+ });++ stack.completeGoBack();+ expect(layout.splits().map((split) => split.content)).toMatchObject([+ { type: 'component', id: 'home' },+ ]);+ expect(stack.canGoBack()).toBe(false);+});+it('acknowledges a failed lookup and opens the next native tap', async () => {const { layout } = setup('closed');const lookup = Promise.withResolvers<UnifiedNotification | undefined>();diff --git a/apps/web/src/routes/BasePath.test.tsx b/apps/web/src/routes/BasePath.test.tsxindex 0b463ea9f3..8031dc323f 100644--- a/apps/web/src/routes/BasePath.test.tsx+++ b/apps/web/src/routes/BasePath.test.tsx@@ -209,7 +209,7 @@ describe('BasePathComponent', () => {resolveIdentity({ authenticated: true, userId: recipientId });await vi.waitFor(() =>expect(mocks.navigate).toHaveBeenCalledExactlyOnceWith(- '/channel/11111111-1111-4111-8111-111111111111?channel_message_id=22222222-2222-4222-8222-222222222222&channel_thread_id=22222222-2222-4222-8222-222222222222',+ '/home/~/channel/11111111-1111-4111-8111-111111111111?channel_message_id=22222222-2222-4222-8222-222222222222&channel_thread_id=22222222-2222-4222-8222-222222222222',{ replace: true }));diff --git a/docs/agent-guide/notifications.md b/docs/agent-guide/notifications.mdindex ef905a3054..e1a490daad 100644--- a/docs/agent-guide/notifications.md+++ b/docs/agent-guide/notifications.md@@ -69,9 +69,12 @@ Linux WebKit/D-Bus regression is `bun run native:e2e:notifications`; compositorfocus behavior still needs a real Wayland/X11 desktop check.On iOS builds with durable push navigation, a tapped channel push chooses the-first route after verifying its recipient account. A failed or stalled native-bridge must release startup within 1.5 seconds; the app can show its auth or-retry UI while retaining the tap. If the bridge recovers later, the tap uses+first route after verifying its recipient account. Cold launches open the+channel in front of Home, retaining the header Back chevron and swipe-back+destination. Verify both return to Home without reopening the channel first.+A failed or stalled native bridge must release startup within 1.5 seconds;+the app can show its auth or retry UI while retaining the tap. If the bridge+recovers later, the tap usesnormal navigation without resetting the current page to the app root. Checkboth listener attachment and pending-intent reads, including a tap deliveredbefore the pending read stalls. Receiving a push without tapping it must not