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(navigation): keep app lists independent across splits (#9094)
gbirmanf914e9623e9d
diff --git a/apps/web/AGENTS.md b/apps/web/AGENTS.mdindex f9f96b0a70..419011ef87 100644--- a/apps/web/AGENTS.md+++ b/apps/web/AGENTS.md@@ -32,6 +32,12 @@ Split dragging and composer reflow have a backend-free browser regression:`bunx playwright test --config src/lib/core/component/Resize/browser-test/playwright.config.ts`.It exercises the real resize solver, scroll container, and Lexical layout primitive.+Desktop app switches open the requested list in the target split when the+retained detail is claimed by another pane or preview. Keep this check in view+restoration and preserve entity deduplication and native dock stack restoration;+`split-layout/tests/view-restoration.test.tsx` covers Chat and Tasks lists in+either pane, keeping the other pane's detail and history independent.+Database document-reference cells have a backend-free desktop/touch regression:`bunx playwright test --config src/features/block-database/browser-test/playwright.config.ts references.browser.e2e.ts`.It uses the real records view with a local source and picker to exercise opening,diff --git a/apps/web/src/components/app/split-layout/README.md b/apps/web/src/components/app/split-layout/README.mdindex 8c9f93da0b..a680d959ec 100644--- a/apps/web/src/components/app/split-layout/README.md+++ b/apps/web/src/components/app/split-layout/README.md@@ -19,6 +19,12 @@ Explicit links and new-split actions stay fresh. Native dock navigation stillresets the pane stack, and dock Search starts a fresh session. Reload, sign-out,and account changes retire the saved state. Views still unmount normally.+Desktop app switches skip a retained destination claimed by another pane or+its inline preview, opening the requested root view in the target pane instead.+Check router claims, including preview owners, before applying the snapshot;+do not bypass entity deduplication. Native dock stack replacement still resumes+the retained destination.+Views retain local context through `useEntryState` or `registerEntryStateCaptor`.These slices restore through both pane Back/Forward and opted-in app switches;route/schema state stays separate. Restores use the existing router, includingdiff --git a/apps/web/src/components/app/split-layout/layoutManager.ts b/apps/web/src/components/app/split-layout/layoutManager.tsindex 8a8ad413c7..9e01ccb481 100644--- a/apps/web/src/components/app/split-layout/layoutManager.ts+++ b/apps/web/src/components/app/split-layout/layoutManager.ts@@ -10,6 +10,7 @@ import type {SplitRouter,SplitSearchUpdate,} from '@app/lib/split-router';+import { claimOf } from '@app/lib/split-router';import { trackNavigationLifecycle } from '@app/observability/navigation-lifecycle';import type {BlockAlias,@@ -1618,17 +1619,26 @@ export function createSplitLayout(/** Resolve a retained entry before the destination mounts, never by redirecting after mount. */function resumeView(- content: SplitContent+ content: SplitContent,+ targetPane?: PaneId): { content: SplitContent; routeState: unknown } | undefined {const span = Telemetry.span('navigation.view.resume');span.setAttr('view.id', content.id);try {const snapshot =content.type === 'component' ? viewState.get(content.id) : undefined;- span.setAttr('view.restored', snapshot !== undefined);+ span.setAttr('view.restored', false);if (!snapshot) return;const restored = toContent(snapshot.location);if (restored.type !== 'component') return;+ // Restoring a detail must not redirect a desktop app switch to another+ // pane. Keep the requested list when that detail is already open there.+ const claim = claimOf(router.routes, snapshot.location.route);+ if (targetPane && claim && router.claims.holderOf(claim, targetPane)) {+ span.setAttr('view.restore_skipped', 'open_elsewhere');+ return;+ }+ span.setAttr('view.restored', true);return {content: {...restored,@@ -1650,7 +1660,11 @@ export function createSplitLayout(): OpenSplitResult {const sourceOwner = options.handle?.id;if (options.resume && !options.preferNewSplit) {- const restored = resumeView(content);+ const source = options.handle ?? activeSplit();+ const restored = resumeView(+ content,+ !stacked() && source ? paneOf(source.id) : undefined+ );if (restored) {content = restored.content;options = {diff --git a/apps/web/src/components/app/split-layout/tests/view-restoration.test.tsx b/apps/web/src/components/app/split-layout/tests/view-restoration.test.tsxindex 2955c27c82..55eec122e7 100644--- a/apps/web/src/components/app/split-layout/tests/view-restoration.test.tsx+++ b/apps/web/src/components/app/split-layout/tests/view-restoration.test.tsx@@ -21,6 +21,8 @@ import {homeSplitRoute,notFoundRoute,searchRoute,+ taskDetailRoute,+ tasksSplitRoute,} from '@app/routes/routes';import type { BlockOrchestrator } from '@core/orchestrator';import { cleanup, render } from '@solidjs/testing-library';@@ -136,6 +138,11 @@ function setup(component: AuthenticatedView,children: [driveTabRoute],},+ {+ ...tasksSplitRoute,+ component: AuthenticatedView,+ children: [taskDetailRoute],+ },{ ...searchRoute, component: AuthenticatedView },notFoundRoute,],@@ -187,6 +194,81 @@ afterEach(() => {});describe('opt-in view restoration', () => {+ describe.each([+ { view: 'channels', detail: '/channels/channel-one', targetIndex: 0 },+ { view: 'channels', detail: '/channels/channel-one', targetIndex: 1 },+ { view: 'tasks', detail: '/tasks/task-one', targetIndex: 0 },+ { view: 'tasks', detail: '/tasks/task-one', targetIndex: 1 },+ ])('$view list in pane $targetIndex', ({ view, detail, targetIndex }) => {+ it.each([false, true])(+ 'keeps the existing detail independent (explicit handle: %s)',+ async (explicitHandle) => {+ const url = targetIndex === 0 ? `/home/~${detail}` : `${detail}/~/home`;+ const { router, manager } = setup(url);+ const detailIndex = 1 - targetIndex;+ const targetPane = router.panes()[targetIndex]!;+ const detailPane = router.panes()[detailIndex]!;+ const target = manager.getSplit(manager.splits()[targetIndex]!.id)!;+ const existing = manager.getSplit(manager.splits()[detailIndex]!.id)!;+ const detailEntry = router.entry(detailPane);+ manager.activateSplit(explicitHandle ? existing.id : target.id);++ manager.openWithSplit(+ { type: 'component', id: view },+ {+ resume: true,+ allowDuplicate: true,+ handle: explicitHandle ? target : undefined,+ }+ );+ await router.settled();++ expect(+ router.entry(targetPane)?.location.route.matches.at(-1)?.id+ ).toBe(`view-${view}`);+ expect(router.entry(detailPane)).toBe(detailEntry);+ expect(manager.activeSplit()?.id).toBe(target.id);+ expect(router.panes()).toHaveLength(2);+ await router.navigatePane(targetPane, -1);+ expect(+ router.entry(targetPane)?.location.route.matches.at(-1)?.id+ ).toBe('view-home');+ expect(router.entry(detailPane)).toBe(detailEntry);+ }+ );+ });++ it('opens the list when a remembered channel is held by another pane preview', async () => {+ const { router, manager } = setup();+ const leftPane = router.panes()[0]!;+ await router.navigatePane(leftPane, '/home');+ await router.open('/drive', { newPane: true });+ const rightPane = router.panes()[1]!;+ const left = manager.getSplit(manager.splits()[0]!.id)!;+ const activate = vi.fn();+ const owner = Symbol('preview');+ const unregister = router.claims.register(() => [+ {+ owner,+ pane: rightPane,+ claim: 'block:channel:channel-one',+ activate,+ },+ ]);++ manager.openWithSplit(+ { type: 'component', id: 'channels' },+ { resume: true, allowDuplicate: true, handle: left }+ );+ await router.settled();++ expect(router.entry(leftPane)?.location.route.matches.at(-1)?.id).toBe(+ 'view-channels'+ );+ expect(activate).not.toHaveBeenCalled();+ unregister();+ });+it('restores nested location, search, and UI state through existing layout navigation', async () => {const { router, manager } = setup();const pane = router.panes()[0]!;diff --git a/docs/agent-guide/media/navigation/chat-list-left-split.png b/docs/agent-guide/media/navigation/chat-list-left-split.pngnew file mode 100644index 0000000000..3ad1671e57Binary files /dev/null and b/docs/agent-guide/media/navigation/chat-list-left-split.png differdiff --git a/docs/agent-guide/navigation.md b/docs/agent-guide/navigation.mdindex daa41db743..3506faff11 100644--- a/docs/agent-guide/navigation.md+++ b/docs/agent-guide/navigation.md@@ -501,6 +501,15 @@ leave the saved snapshot unchanged. Direct links and explicit Shift/open-in-spliactions keep their requested destination. Closing a detail before switching appsremembers the list, not the closed detail. Views unmount normally; this is not akeep-alive cache for editors or other transient UI.+On desktop, if the remembered detail is already open in another split or+its inline preview, switching apps opens the requested app's list in the target+split instead of moving focus to the existing detail. For example, with Home on+the left and a Chat conversation on the right, select the left split and press+Chat: the left split shows the chat list and the right conversation stays open.+This applies in either direction across apps: with a task open on the left and+Home on the right, choosing Tasks from the right view switcher opens the task+list there and preserves the left task, its state, and its history.+See the [redacted desktop example](media/navigation/chat-list-left-split.png).Verify Chat → open channel → Calendar → Chat restores the same channel, thenrepeat with a filtered list and a nested Drive item. Check mobile dock switching,split Back/Forward, refused leave guards, explicit links, and account changes.