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(web): move inline detail content ownership to Split Manager (#6698)
Peter Chinman02946a0e9e51
diff --git a/apps/web/src/components/app/app-sidebar/sidebar.tsx b/apps/web/src/components/app/app-sidebar/sidebar.tsxindex c22f48519e..beb8390741 100644--- a/apps/web/src/components/app/app-sidebar/sidebar.tsx+++ b/apps/web/src/components/app/app-sidebar/sidebar.tsx@@ -352,7 +352,7 @@ export function navigateToSidebarView(args: {mergeHistory: false,allowDuplicate: viewId !== 'calendar',referredFrom,- });+ }).split;}export const registerSidebarHotkeys = ({@@ -1762,11 +1762,15 @@ export const SidebarOpenInSplitMenu = (props: SidebarOpenInSplitMenuProps) => {props.onOpenCurrentSplit();return;}- const split = layout.openWithSplit(props.content(), {+ const result = layout.openWithSplit(props.content(), {allowDuplicate: true,mergeHistory: false,referredFrom: 'sidebar',});+ if (result.status === 'reused' && result.owner !== result.sourceOwner) {+ toast.alert('Content already open');+ }+ const split = result.split;if (split) props.onOpened?.(split, 'current-split');};@@ -1776,12 +1780,17 @@ export const SidebarOpenInSplitMenu = (props: SidebarOpenInSplitMenuProps) => {analytics.track('split_created', { from: 'sidebar' });- const split = manager.createNewSplit({- content: props.content(),+ const result = manager.openWithSplit(props.content(), {activate: true,allowDuplicate: true,+ preferNewSplit: true,+ replaceWhenFull: false,referredFrom: 'sidebar',});+ if (result.status === 'reused' && result.owner !== result.sourceOwner) {+ toast.alert('Content already open');+ }+ const split = result.split;if (split) props.onOpened?.(split, 'new-split');};diff --git a/apps/web/src/components/app/createPreviewSelectionGuard.test.tsx b/apps/web/src/components/app/createPreviewSelectionGuard.test.tsxindex 6d687f952b..ae56933e1a 100644--- a/apps/web/src/components/app/createPreviewSelectionGuard.test.tsx+++ b/apps/web/src/components/app/createPreviewSelectionGuard.test.tsx@@ -1,19 +1,21 @@-import {- NavigationStack,- useNavigationStack,-} from '@app/components/navigation-stack/NavigationStack';+import { EntityDetailNavigationStack } from '@app/components/entity-detail/EntityDetailNavigationStack';+import { useNavigationStack } from '@app/components/navigation-stack/NavigationStack';import { toast } from '@core/component/Toast/Toast';-import { createContentInstanceRegistry } from '@core/contentInstanceRegistry';import { render } from '@solidjs/testing-library';+import { createMemo, createRoot, type ParentProps } from 'solid-js';import { beforeEach, expect, it, vi } from 'vitest';import { createPreviewSelectionGuard } from './createPreviewSelectionGuard';import type { PreviewPanelSelection } from './previewTarget';+import { createContentInstanceRegistry } from './split-layout/contentInstanceRegistry';+import { SplitLayoutContext } from './split-layout/context';+import type { SplitManager } from './split-layout/layoutManager';-const app = vi.hoisted(() => ({ orchestrator: {} as Record<string, unknown> }));-vi.mock('./GlobalAppState', () => ({- useGlobalBlockOrchestrator: () => app.orchestrator,-}));+let manager: Pick<SplitManager, 'findOpenView' | 'registerOpenViews'>;+const activate = vi.hoisted(() => vi.fn());vi.mock('@core/component/Toast/Toast', () => ({ toast: { alert: vi.fn() } }));+vi.mock('./split-layout/layoutUtils', () => ({+ useSplitPanelOrThrow: () => ({ handle: { activate } }),+}));vi.mock('@core/constant/allBlocks', () => ({resolveBlockAlias: (type: string) => (type === 'task' ? 'md' : type),}));@@ -25,28 +27,123 @@ vi.mock('./previewTarget', () => ({}));beforeEach(() => {- app.orchestrator = { contentInstances: createContentInstanceRegistry() };+ const registry = createContentInstanceRegistry();+ manager = {+ findOpenView: registry.find,+ registerOpenViews: registry.register,+ };vi.mocked(toast.alert).mockClear();+ activate.mockClear();+});++it('activates the split owning a preview and stops exposing it after close', () => {+ const view = setup();+ const channel = { type: 'channel', id: 'channel' } as const;+ view.stack.reset(channel);++ const existing = manager.findOpenView(channel);+ expect(existing).toBeDefined();+ existing?.activate?.();+ expect(activate).toHaveBeenCalledOnce();+ expect(view.stack.active()?.data).toEqual(channel);+ expect(toast.alert).not.toHaveBeenCalled();++ view.stack.clear();+ expect(manager.findOpenView(channel)).toBeUndefined();+ view.stack.reset(channel);+ view.unmount();+ expect(manager.findOpenView(channel)).toBeUndefined();+ expect(activate).toHaveBeenCalledOnce();});-function setup() {+it('reactively exposes preview claims, releases, and unmounts', () => {+ createRoot((dispose) => {+ const channel = { type: 'channel', id: 'channel' } as const;+ const existing = createMemo(() => manager.findOpenView(channel));+ expect(existing()).toBeUndefined();+ const view = setup();+ view.stack.reset(channel);+ expect(existing()).toBeDefined();+ view.stack.clear();+ expect(existing()).toBeUndefined();+ view.stack.reset(channel);+ expect(existing()).toBeDefined();+ view.unmount();+ expect(existing()).toBeUndefined();+ dispose();+ });+});++function Layout(props: ParentProps) {+ return (+ <SplitLayoutContext.Provider value={{ manager: manager as SplitManager }}>+ {props.children}+ </SplitLayoutContext.Provider>+ );+}++function setup(defaultValue?: PreviewPanelSelection[]) {let stack!: ReturnType<typeof useNavigationStack<PreviewPanelSelection>>;function Capture() {stack = useNavigationStack<PreviewPanelSelection>();return null;}function App() {- const guard = createPreviewSelectionGuard();return (- <NavigationStack.Root<PreviewPanelSelection> beforeChange={guard}>- <Capture />- </NavigationStack.Root>+ <Layout>+ <EntityDetailNavigationStack.Root defaultValue={defaultValue}>+ <Capture />+ </EntityDetailNavigationStack.Root>+ </Layout>);}const view = render(App);return { stack, ...view };}+it('does not move focus or toast for a conflicting restored selection', () => {+ const channel = { type: 'channel', id: 'channel' } as const;+ const first = setup([channel]);+ const restored = setup([channel]);+ expect(restored.stack.active()).toBeUndefined();+ expect(activate).not.toHaveBeenCalled();+ expect(toast.alert).not.toHaveBeenCalled();++ restored.stack.reset(channel);+ expect(activate).toHaveBeenCalledOnce();+ expect(toast.alert).toHaveBeenCalledWith('Content already open');+ restored.unmount();+ first.unmount();+});++it('uses the change reason independently of mount timing', () => {+ const channel = { type: 'channel', id: 'channel' } as const;+ const first = setup([channel]);+ let selectPreview!: ReturnType<typeof createPreviewSelectionGuard>;+ function NavigateBeforeMount() {+ selectPreview = createPreviewSelectionGuard();+ // Navigation requested before mount still activates the existing view.+ expect(selectPreview(channel, 'navigate')).toBe(false);+ return null;+ }+ const second = render(() => (+ <Layout>+ <NavigateBeforeMount />+ </Layout>+ ));+ expect(activate).toHaveBeenCalledOnce();+ expect(toast.alert).toHaveBeenCalledWith('Content already open');++ activate.mockClear();+ vi.mocked(toast.alert).mockClear();+ // Restoring after mount must remain passive.+ expect(selectPreview(channel, 'restore')).toBe(false);+ expect(activate).not.toHaveBeenCalled();+ expect(toast.alert).not.toHaveBeenCalled();+ second.unmount();+ first.unmount();+});+it('rejects a second detail selection without changing its current entry and releases on close', () => {const first = setup();const second = setup();@@ -55,6 +152,7 @@ it('rejects a second detail selection without changing its current entry and relconst current = second.stack.active();expect(second.stack.reset({ type: 'email', id: 'one' })).toBeUndefined();expect(second.stack.active()).toBe(current);+ expect(activate).toHaveBeenCalledOnce();expect(toast.alert).toHaveBeenCalledWith('Content already open');first.stack.clear();expect(second.stack.reset({ type: 'email', id: 'one' })).toBeDefined();diff --git a/apps/web/src/components/app/createPreviewSelectionGuard.ts b/apps/web/src/components/app/createPreviewSelectionGuard.tsindex d1df011967..615e6b2114 100644--- a/apps/web/src/components/app/createPreviewSelectionGuard.ts+++ b/apps/web/src/components/app/createPreviewSelectionGuard.ts@@ -1,30 +1,45 @@+import type { NavigationStackChangeReason } from '@app/components/navigation-stack/NavigationStack';import { toast } from '@core/component/Toast/Toast';-import type { ContentIdentity } from '@core/contentInstanceRegistry';-import { onCleanup } from 'solid-js';-import { useGlobalBlockOrchestrator } from './GlobalAppState';+import { createSignal, onCleanup, useContext } from 'solid-js';import {type PreviewPanelSelection,previewBlockTarget,} from './previewTarget';+import type { ContentIdentity } from './split-layout/contentInstanceRegistry';+import { SplitLayoutContext } from './split-layout/context';+import { useSplitPanelOrThrow } from './split-layout/layoutUtils';/** Call before changing selection. A rejected selection leaves the current preview intact. */export function createPreviewSelectionGuard() {- const registry = useGlobalBlockOrchestrator().contentInstances;+ const layout = useContext(SplitLayoutContext);+ if (!layout) throw new Error('Preview selection requires a split layout');+ const manager = layout.manager;+ const panel = useSplitPanelOrThrow();const owner = Symbol('inline-preview');- let current: ContentIdentity | undefined;- const unregister = registry.register(() =>- current ? [{ owner, content: current }] : []- );+ const [current, setCurrent] = createSignal<ContentIdentity>();+ const unregister = manager.registerOpenViews(() => {+ const content = current();+ return content+ ? [{ owner, content, activate: () => panel.handle.activate() }]+ : [];+ });onCleanup(unregister);- return (selection: PreviewPanelSelection | undefined) => {+ return (+ selection: PreviewPanelSelection | undefined,+ reason: NavigationStackChangeReason = 'navigate'+ ) => {const target = selection && previewBlockTarget(selection);const next = target && { type: target.blockType, id: target.blockId };- if (next && registry.isOpenElsewhere(next, owner)) {- toast.alert('Content already open');+ const existing = next && manager.findOpenView(next);+ if (existing && existing.owner !== owner) {+ if (reason === 'navigate') {+ existing.activate?.();+ toast.alert('Content already open');+ }return false;}- current = next;+ setCurrent(next);return true;};}diff --git a/apps/web/src/components/app/split-layout/components/PopoverSplitRenderer.tsx b/apps/web/src/components/app/split-layout/components/PopoverSplitRenderer.tsxindex d980f797db..47b389268b 100644--- a/apps/web/src/components/app/split-layout/components/PopoverSplitRenderer.tsx+++ b/apps/web/src/components/app/split-layout/components/PopoverSplitRenderer.tsx@@ -1,7 +1,6 @@import { SoupContextProvider } from '@app/features/next-soup/soup-context';import { ContentLoading } from '@components/app/ContentLoading';import { MobileDrawer } from '@components/app/mobile/MobileDrawer';-import clickOutside from '@core/directive/clickOutside';import { registerHotkey, useHotkeyDOMScope } from '@core/hotkey/hotkeys';import { isTouchDevice } from '@core/mobile/isTouchDevice';import { Dialog, Panel } from '@ui';@@ -21,7 +20,7 @@ import type {} from '../layoutManager';import { createOwnedSlots } from '../utils/createOwnedSlots';-false && clickOutside;+false;type PopoverSplitData = {id: string;diff --git a/apps/web/src/components/app/split-layout/components/SplitHeader.tsx b/apps/web/src/components/app/split-layout/components/SplitHeader.tsxindex 5d3f49525d..550f5e8690 100644--- a/apps/web/src/components/app/split-layout/components/SplitHeader.tsx+++ b/apps/web/src/components/app/split-layout/components/SplitHeader.tsx@@ -48,7 +48,10 @@ import { match, P } from 'ts-pattern';import { splitBackInterceptor } from '../back-interceptor';import { SplitLayoutContext, SplitPanelContext } from '../context';import type { SplitContent } from '../layoutManager';-import { shouldShowSplitCloseButton } from '../layoutUtils';+import {+ closeSplitOrReturnToList,+ shouldShowSplitCloseButton,+} from '../layoutUtils';import { canSpotlight } from '../utils/canSpotlight';import { HeaderIsland } from './HeaderIsland';import {@@ -200,20 +203,25 @@ function SplitCloseButton() {if (!context || !layout) return null;const label = createMemo(() => {- const isOnlySplit = layout.manager.splits().length === 1;+ const isOnlySplit = !shouldShowSplitCloseButton(layout.manager);const isNotUnifiedList = !isListViewID(context.handle.content().id);return isOnlySplit && isNotUnifiedList ? 'Return to list' : 'Close';});return (- <Show when={shouldShowSplitCloseButton(layout.manager)}>+ <Show+ when={+ shouldShowSplitCloseButton(layout.manager) ||+ !isListViewID(context.handle.content().id)+ }+ ><Buttonsquaresize="icon-sm"class="rounded-lg"label={label()}hotkey={TOKENS.split.close}- onClick={context.handle.close}+ onClick={() => closeSplitOrReturnToList(layout.manager, context.handle)}><CloseIcon class="size-4" /></Button>diff --git a/apps/web/src/components/app/split-layout/contentInstanceRegistry.ts b/apps/web/src/components/app/split-layout/contentInstanceRegistry.tsnew file mode 100644index 0000000000..4fb8809ebe--- /dev/null+++ b/apps/web/src/components/app/split-layout/contentInstanceRegistry.ts@@ -0,0 +1,56 @@+import type { BlockAlias, BlockName } from '@core/block';+import { resolveBlockAlias } from '@core/constant/allBlocks';+import { createSignal } from 'solid-js';++export type ContentIdentity = {+ type: BlockName | BlockAlias | 'component';+ id: string;+};+export type ContentOwner = object | string | symbol;++export type ContentInstance = {+ owner: ContentOwner;+ content: ContentIdentity;+ activate?: () => void;+};++export function sameContentIdentity(a: ContentIdentity, b: ContentIdentity) {+ if (a.type === 'component' || b.type === 'component') return false;+ return (+ a.id === b.id && resolveBlockAlias(a.type) === resolveBlockAlias(b.type)+ );+}++/** Owned by a split layout; sources include selections before their UI mounts. */+export function createContentInstanceRegistry() {+ const [sources, setSources] = createSignal(+ new Set<() => readonly ContentInstance[]>()+ );+ function find(content: ContentIdentity, excludeOwner?: ContentOwner) {+ for (const source of sources()) {+ const entry = source().find(+ (entry) =>+ entry.owner !== excludeOwner &&+ sameContentIdentity(entry.content, content)+ );+ if (entry) return entry;+ }+ }++ return {+ find,+ register(source: () => readonly ContentInstance[]) {+ setSources((prev) => new Set(prev).add(source));+ return () => {+ setSources((prev) => {+ const next = new Set(prev);+ next.delete(source);+ return next;+ });+ };+ },+ isOpenElsewhere(content: ContentIdentity, owner?: ContentOwner) {+ return find(content, owner) !== undefined;+ },+ };+}diff --git a/apps/web/src/components/app/split-layout/history.ts b/apps/web/src/components/app/split-layout/history.tsindex f15ffa226e..d84942cf8c 100644--- a/apps/web/src/components/app/split-layout/history.ts+++ b/apps/web/src/components/app/split-layout/history.ts@@ -6,9 +6,9 @@ export type History<T extends object> = {back: () => T | null;/*** Jump to the nearest earlier entry matching `predicate`, skipping the- * entries in between. Those entries stay in the stack, so `forward` still- * reaches them. Returns null — leaving the index put — when nothing earlier- * matches.+ * entries in between. Navigation also respects the configured `canVisit`+ * rule. Skipped entries stay in the stack and can be reached when available.+ * Returns null — leaving the index put — when no available entry matches.*/backTo: (predicate: (item: T) => boolean) => T | null;forward: () => T | null;@@ -22,16 +22,18 @@ export type History<T extends object> = {* (e.g. captured per-entry state) before navigating away.*/replaceCurrent: (next: T) => void;- remove: (- predicate: (item: T) => boolean,- canActivate?: (item: T) => boolean- ) => T | null;+ remove: (predicate: (item: T) => boolean) => T | null;};const inc = (x: number) => x + 1;-const dec = (x: number) => x - 1;-export function createHistory<T extends object>(): History<T> {+export function createHistory<T extends object>(+ options: {+ /** Evaluated on each navigation so entry availability can change over time. */+ canVisit?: (item: T) => boolean;+ } = {}+): History<T> {+ const canVisit = options.canVisit ?? (() => true);// `items` is a signal rather than a plain mutated array because SplitState.history// is held in the splits store. In-place array mutation is invisible to store// readers, which would leave `items` stale while the `index` signal stays live —@@ -39,13 +41,20 @@ export function createHistory<T extends object>(): History<T> {const [items, setItems] = createSignal<T[]>([]);const [index, setIndex] = createSignal(-1);- const canGoBack = () => {- return index() > 0;+ const findIndex = (direction: -1 | 1, predicate = (_item: T) => true) => {+ const list = items();+ for (+ let i = index() + direction;+ i >= 0 && i < list.length;+ i += direction+ ) {+ if (canVisit(list[i]) && predicate(list[i])) return i;+ }+ return -1;};- const canGoForward = () => {- return index() < items().length - 1;- };+ const canGoBack = () => findIndex(-1) !== -1;+ const canGoForward = () => findIndex(1) !== -1;const isAtEnd = () => {const len = items().length;@@ -92,33 +101,18 @@ export function createHistory<T extends object>(): History<T> {});};- const back = () => {- if (!canGoBack()) return null;- setIndex(dec);- return items()[index()];- };-- const backTo = (predicate: (item: T) => boolean) => {- const list = items();- for (let i = index() - 1; i >= 0; i--) {- const item = list[i];- if (!predicate(item)) continue;- setIndex(i);- return item;- }- return null;+ const move = (direction: -1 | 1, predicate?: (item: T) => boolean) => {+ const nextIndex = findIndex(direction, predicate);+ if (nextIndex === -1) return null;+ setIndex(nextIndex);+ return items()[nextIndex];};- const forward = () => {- if (!canGoForward()) return null;- setIndex(inc);- return items()[index()];- };+ const back = () => move(-1);+ const backTo = (predicate: (item: T) => boolean) => move(-1, predicate);+ const forward = () => move(1);- const remove = (- predicate: (item: T) => boolean,- canActivate?: (item: T) => boolean- ) => {+ const remove = (predicate: (item: T) => boolean) => {const prevItems = items();const prevIndex = index();@@ -149,7 +143,7 @@ export function createHistory<T extends object>(): History<T> {}const next = nextItems[newIndex];- if (next && canActivate?.(next) === false) return null;+ if (next && !canVisit(next)) return null;batch(() => {setItems(nextItems);setIndex(newIndex);diff --git a/apps/web/src/components/app/split-layout/layout.ts b/apps/web/src/components/app/split-layout/layout.tsindex e46da3366d..b10fd6a88d 100644--- a/apps/web/src/components/app/split-layout/layout.ts+++ b/apps/web/src/components/app/split-layout/layout.ts@@ -3,6 +3,7 @@ import { isTouchDevice } from '@core/mobile/isTouchDevice';import { useContext } from 'solid-js';import { SplitPanelContext } from './context';import type {+ OpenSplitResult,OpenWithSplitOptions,PopoverSplitOptions,ReferredFrom,@@ -15,13 +16,13 @@ export function useSplitLayout() {function openWithSplit(content: SplitContent,options?: OpenWithSplitOptions- ) {+ ): OpenSplitResult {const splitManager = globalSplitManager();const preferNewSplit = isTouchDevice() ? false : options?.preferNewSplit;if (!splitManager) {console.error('No split manager found');- return;+ return { status: 'unavailable' };}// Use the source panel for navigation. Popover handles cannot replace@@ -44,7 +45,7 @@ export function useSplitLayout() {referredFrom,handle: splitPanelContext?.handle,activate: true,- });+ }).split;}function replaceSplit(options: {@@ -59,7 +60,7 @@ export function useSplitLayout() {referredFrom,handle: splitPanelContext?.handle,preferNewSplit: false,- });+ }).split;}function insertSplit(@@ -72,7 +73,7 @@ export function useSplitLayout() {referredFrom,preferNewSplit: true,...options,- });+ }).split;}function popoverSplit(diff --git a/apps/web/src/components/app/split-layout/layoutManager.ts b/apps/web/src/components/app/split-layout/layoutManager.tsindex e7ce8daa1f..f18570fbbd 100644--- a/apps/web/src/components/app/split-layout/layoutManager.ts+++ b/apps/web/src/components/app/split-layout/layoutManager.ts@@ -10,10 +10,8 @@ import type {BlockName,} from '@core/block';import type { ResizeZoneCtx } from '@core/component/Resize/types';-import { toast } from '@core/component/Toast/Toast';import { isBlockAlias, resolveBlockAlias } from '@core/constant/allBlocks';import { settingsTabToSlug } from '@core/constant/settingsTabsConfig';-import { sameContentIdentity } from '@core/contentInstanceRegistry';import type {BlockInstanceHandle,BlockOrchestrator,@@ -34,6 +32,11 @@ import {type ComponentMetaMap,resolveComponent,} from './componentRegistry';+import {+ type ContentInstance,+ createContentInstanceRegistry,+ sameContentIdentity,+} from './contentInstanceRegistry';import { createHistory, type History } from './history';import { DEFAULT_SPLIT_MIN_WIDTH } from './splitContentSizing';@@ -218,15 +221,20 @@ export type OpenWithSplitOptions = {reopen?: 'latest';};-/**- * A navigation interceptor registered by, e.g. mobile swipe layout.- * Called at the start of `openWithSplit`. Return `{ handled: true }` to consume- * the navigation; return `{ handled: false }` to let the normal split logic run.- */-export type NavigationInterceptor = (+export type OpenSplitResult = {+ /** The source panel supplied by the caller, if any. */+ sourceOwner?: SplitId;+} & (+ | { status: 'opened'; split: SplitHandle }+ | { status: 'reused'; owner: ContentInstance['owner']; split?: SplitHandle }+ | { status: 'unavailable'; split?: undefined }+);++/** Return an outcome to consume navigation, or undefined to use normal split navigation. */+export type SplitNavigationInterceptor = (content: SplitContent,options: OpenWithSplitOptions-) => { handled: boolean };+) => OpenSplitResult | undefined;function keyOfSplitState(s: SplitState): SplitKey {return `${s.content.type}:${s.content.id}`;@@ -293,7 +301,16 @@ function attachAliasContext(content: SplitContent): SplitContent {return content;}+export type OpenView = ContentInstance & {+ /** Present when this view is a top-level layout split, rather than an inline detail or popover. */+ topLevelSplit?: SplitHandle;+};+export type SplitManager = {+ /** Find the view owning this content without activating it. */+ findOpenView: (content: SplitContent) => OpenView | undefined;+ /** Register live inline views; call the returned function when the host is disposed. */+ registerOpenViews: (source: () => readonly ContentInstance[]) => () => void;readonly splits: Accessor<ReadonlyArray<SplitState>>;readonly activeSplitId: Accessor<SplitId | undefined>;readonly activeSplit: Accessor<SplitHandle | undefined>;@@ -320,7 +337,7 @@ export type SplitManager = {openWithSplit: (content: SplitContent,options?: OpenWithSplitOptions- ) => SplitHandle | undefined;+ ) => OpenSplitResult;/** Set a split as active by its split id */activateSplit: (id: SplitId) => void;@@ -400,10 +417,12 @@ export type SplitManager = {) => void;/**- * Register a navigation interceptor. Called at the start of `openWithSplit`;- * if it returns `{ handled: true }` the normal split logic is skipped.+ * Register an interceptor for new content and existing standalone splits.+ * If it returns `{ handled: true }` the normal split logic is skipped.*/- setNavigationInterceptor: (fn: NavigationInterceptor | undefined) => void;+ setSplitNavigationInterceptor: (+ fn: SplitNavigationInterceptor | undefined+ ) => void;/** Get reactive accessor to popovers map */popovers: () => Map<@@ -619,11 +638,12 @@ export function createSplitLayout(popovers: new Map(),});- const contentInstances = orchestrator.contentInstances;+ const contentInstances = createContentInstanceRegistry();const unregisterContentInstances = contentInstances.register(() => [...state.splits.map((split) => ({owner: split.id,content: contentIdentity(split.content),+ activate: () => getSplit(split.id)?.activate(),})),...[...state.popovers.values()].filter((popover) => popover.isOpen)@@ -633,17 +653,37 @@ export function createSplitLayout(})),]);onCleanup(unregisterContentInstances);- const canOpenContent = (content: SplitContent, owner?: SplitId) => {- if (!contentInstances.isOpenElsewhere(contentIdentity(content), owner))- return true;- toast.alert('Content already open');- return false;- };+ const canOpenContent = (content: SplitContent, owner?: SplitId) =>+ !contentInstances.isOpenElsewhere(contentIdentity(content), owner);++ /** Resolve an entity to its owning view, regardless of how that view renders it. */+ function findOpenView(content: SplitContent): OpenView | undefined {+ const identity = contentIdentity(content);+ const instance = contentInstances.find(identity);+ if (instance) {+ const split = state.splits.find((split) => split.id === instance.owner);+ return {+ ...instance,+ topLevelSplit: split ? getSplit(split.id) : undefined,+ };+ }++ // Shells have no entity identity; find them by their route instead.+ if (identity.type !== 'component') return;+ const split = getSplitByContent(content.type, content.id);+ if (split)+ return {+ owner: split.id,+ content: identity,+ activate: split.activate,+ topLevelSplit: split,+ };+ }const [resizeContext, setResizeContext] = createSignal<ResizeZoneCtx>();let exclusionFilter: ((split: SplitState) => boolean) | undefined;- let navigationInterceptor: NavigationInterceptor | undefined;+ let splitNavigationInterceptor: SplitNavigationInterceptor | undefined;const isExcluded = (split: SplitState) => exclusionFilter?.(split) ?? false;const canAppendSplit = createMemo(@@ -716,14 +756,17 @@ export function createSplitLayout(state.splits.findIndex((s) => s.id === id);function buildSplit(options: {+ id?: SplitId;initialContent: SplitContent;isDefault?: boolean;referredFrom?: ReferredFrom;initialHistory?: SplitContent[];}): SplitState {const { initialContent, isDefault, referredFrom, initialHistory } = options;- const id = newSplitId();- const history = createHistory<SplitContent>();+ const id = options.id ?? newSplitId();+ const history = createHistory<SplitContent>({+ canVisit: (content) => canOpenContent(content, id),+ });const content = attachAliasContext(initialContent);if (initialHistory && initialHistory.length > 0) {@@ -851,8 +894,6 @@ export function createSplitLayout(const split = state.splits[i];if (!split.history.canGoBack()) return;- if (!canOpenContent(split.history.items[split.history.index - 1], id))- return;batch(() => {captureCurrentEntryState(split);@@ -881,7 +922,6 @@ export function createSplitLayout(}const split = state.splits[i];- const otherSplits = state.splits.filter((s) => s.id !== split.id);const result = { moved: false };batch(() => {@@ -892,12 +932,7 @@ export function createSplitLayout(// index on an entry the split never mounted. Skipping them here keeps// the index and the mounted content in step, and lets the search carry// on to an entry that can actually be shown.- const prev = split.history.backTo(- (content) =>- predicate(content) &&- !isDuplicateSplit(otherSplits, content) &&- !contentInstances.isOpenElsewhere(contentIdentity(content), id)- );+ const prev = split.history.backTo(predicate);if (!prev) return;result.moved = true;@@ -913,8 +948,6 @@ export function createSplitLayout(const split = state.splits[i];if (!split.history.canGoForward()) return;- if (!canOpenContent(split.history.items[split.history.index + 1], id))- return;batch(() => {captureCurrentEntryState(split);@@ -934,9 +967,7 @@ export function createSplitLayout(if (i < 0) return console.error(`Split with id ${id} not found`);const split = state.splits[i];- const next = split.history.remove(predicate, (content) =>- canOpenContent(content, id)- );+ const next = split.history.remove(predicate);if (!next) return;reattach(split, next, undefined, 'replace');@@ -958,7 +989,10 @@ export function createSplitLayout(if (i < 0) return console.error(`Split with id ${id} not found`);const content = attachAliasContext(next);- if (!canOpenContent(content, id)) return;+ if (!canOpenContent(content, id)) {+ openWithSplit(content);+ return;+ }const split = state.splits[i];batch(() => {@@ -998,21 +1032,12 @@ export function createSplitLayout(const split = state.splits[i];const current = split.content;if (current.type !== type || current.id === nextId) return;- if (- isDuplicateSplit(- state.splits.filter((s) => s.id !== id),- {- ...current,- id: nextId,- }- )- ) {+ const next: SplitContent = { ...current, id: nextId, params: undefined };+ if (!canOpenContent(next, id)) {+ openWithSplit(next);return;}- const next: SplitContent = { ...current, id: nextId, params: undefined };- if (!canOpenContent(next, id)) return;-batch(() => {split.history.replaceCurrent(next);setState('splits', (splits) => {@@ -1044,9 +1069,15 @@ export function createSplitLayout(const i = splitIndexById(id);if (i < 0) return console.error(`Split with id ${id} not found`);- const split = state.splits[i];- split.history = createHistory<SplitContent>();- reattach(split, DEFAULT_SPLIT_CONTENT, undefined, 'fresh');+ const history = createHistory<SplitContent>({+ canVisit: (content) => canOpenContent(content, id),+ });+ const content = attachAliasContext(DEFAULT_SPLIT_CONTENT);+ history.push(content);+ batch(() => {+ setState('splits', (splits) => splits.with(i, { ...splits[i], history }));+ reattach(state.splits[i], content, undefined, 'fresh');+ });}const getUrlSegments = () => {@@ -1262,18 +1293,12 @@ export function createSplitLayout(const initialContent = content ?? DEFAULT_SPLIT_CONTENT;const isDefault = sameContent(initialContent, DEFAULT_SPLIT_CONTENT);- if (isDuplicateSplit(state.splits, initialContent, isExcluded)) {- const existingSplit = state.splits.find(- (s) => !isExcluded(s) && sameEntityContent(s.content, initialContent)- );-- const handle = getSplit(existingSplit!.id)!;- if (activate) handle.activate();- toast.alert('Content already open');- return handle;+ // Direct split creation permits duplicate shells, but never duplicate entities.+ const existing = findOpenView(initialContent);+ if (existing && existing.content.type !== 'component') {+ if (activate) existing.activate?.();+ return existing.topLevelSplit;}-- if (!canOpenContent(initialContent)) return;const split = buildSplit({initialContent,isDefault,@@ -1365,9 +1390,10 @@ export function createSplitLayout(type: SplitContentType,id: string): SplitHandle | undefined {+ const instance = contentInstances.find(contentIdentity({ type, id }));const match = state.splits.find((s) =>- (sameEntityContent(s.content, { type, id }) ||+ (s.id === instance?.owner ||(s.content.type === type && s.content.id === id)) &&!isExcluded(s));@@ -1445,19 +1471,24 @@ export function createSplitLayout(}continue;}+ const splitAtSameIndex = visibleSplits[i];+ // A true replacement can retain the slot's ID, but never steal an ID+ // already assigned to content that moved elsewhere. Choose it before+ // building the history so its availability rule excludes the right owner.+ const retainedId =+ splitAtSameIndex && !usedIds.has(splitAtSameIndex.id)+ ? splitAtSameIndex.id+ : undefined;const newSplit = buildSplit({+ id: retainedId,initialContent: newSplits[i],referredFrom: null,});- const splitAtSameIndex = visibleSplits[i];- // A true replacement can retain the slot's ID, but never steal an ID- // already assigned to content that moved elsewhere.- if (splitAtSameIndex && !usedIds.has(splitAtSameIndex.id)) {- newSplit.id = splitAtSameIndex.id;+ if (retainedId) {setSplitNamesById(produce((map) => {- delete map[splitAtSameIndex.id];+ delete map[retainedId];return map;}));@@ -1501,7 +1532,10 @@ export function createSplitLayout(function createPopoverSplit(options: PopoverSplitOptions): PopoverSplitHandle | undefined {- if (!canOpenContent(options.content)) return;+ if (!canOpenContent(options.content)) {+ openWithSplit(options.content);+ return;+ }const id = `popover-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;// Acquire focus lock BEFORE any state updates to capture the correct element@@ -1587,13 +1621,9 @@ export function createSplitLayout(function openWithSplit(content: SplitContent,options: OpenWithSplitOptions = {}- ): SplitHandle | undefined {- // Include the mobile background split: its navigation interceptor promotes- // an existing mount instead of opening another instance.- const current = state.splits.find((split) =>- sameEntityContent(split.content, content)- );- if (!canOpenContent(content, current?.id)) return;+ ): OpenSplitResult {+ const sourceOwner = options.handle?.id;+ const existing = findOpenView(content);if (options.reopen === 'latest') {// Fire-and-forget so it covers every open path (fresh mount, duplicate@@ -1605,19 +1635,25 @@ export function createSplitLayout(.catch((e) => console.error('openWithSplit: goToLatest failed', e));}- if (navigationInterceptor) {- const result = navigationInterceptor(content, options);- if (result.handled) return undefined;+ // Mobile navigation handles new content and promotes existing top-level+ // splits.+ if (splitNavigationInterceptor && (!existing || existing.topLevelSplit)) {+ const result = splitNavigationInterceptor(content, options);+ if (result) return { ...result, sourceOwner };}- const existingSplit = getSplitByContent(content.type, content.id);+ // Entity views are always reused; only shell components may be duplicated.+ const canDuplicateShell =+ options.allowDuplicate && existing?.content.type === 'component';- if (- existingSplit &&- (contentIdentity(content).type !== 'component' || !options.allowDuplicate)- ) {+ if (existing && !canDuplicateShell) {+ const existingSplit = existing.topLevelSplit;// Preserve per-entry state when the owning split replaces its current entry.- if (options.mergeHistory && options.handle?.id === existingSplit.id) {+ if (+ existingSplit &&+ options.mergeHistory &&+ options.handle?.id === existingSplit.id+ ) {existingSplit.captureEntryState();const currentState = existingSplit.currentEntryState();const nextContent =@@ -1634,11 +1670,13 @@ export function createSplitLayout(});}- if (options.activate !== false) {- existingSplit.activate();- }-- return existingSplit;+ if (options.activate !== false) existing.activate?.();+ return {+ status: 'reused',+ owner: existing.owner,+ split: existingSplit,+ sourceOwner,+ };}let splitHandle = options.handle;@@ -1665,15 +1703,18 @@ export function createSplitLayout(splitHandle.activate();}- return splitHandle;+ return { status: 'opened', split: splitHandle, sourceOwner };} else {- return createNewSplit({+ const split = createNewSplit({content,activate: options.activate ?? true,referredFrom: options.referredFrom ?? null,allowDuplicate: options.allowDuplicate,insertIndex: options.insertIndex,});+ return split+ ? { status: 'opened', split, sourceOwner }+ : { status: 'unavailable', sourceOwner };}}@@ -1683,8 +1724,10 @@ export function createSplitLayout(): SplitHandle | undefined {if (!canOpenContent(content, getSplitByContent(content.type, content.id)?.id)- )+ ) {+ openWithSplit(content);return;+ }const visibleSplits = state.splits.filter((split) => !isExcluded(split));const splitToKeep =visibleSplits.find((split) => sameContent(split.content, content)) ??@@ -1738,6 +1781,8 @@ export function createSplitLayout(return {splits: () => state.splits,+ findOpenView,+ registerOpenViews: contentInstances.register,activeSplitId: () => state.activeSplitId,activeSplit,lastActiveSplitId: () => state.lastActiveSplitId,@@ -1773,8 +1818,8 @@ export function createSplitLayout(setExclusionFilter: (fn) => {exclusionFilter = fn;},- setNavigationInterceptor: (fn) => {- navigationInterceptor = fn;+ setSplitNavigationInterceptor: (fn) => {+ splitNavigationInterceptor = fn;},};}diff --git a/apps/web/src/components/app/split-layout/layoutUtils.ts b/apps/web/src/components/app/split-layout/layoutUtils.tsindex 26b4a8daf8..5d9865f8ad 100644--- a/apps/web/src/components/app/split-layout/layoutUtils.ts+++ b/apps/web/src/components/app/split-layout/layoutUtils.ts@@ -122,6 +122,29 @@ export function shouldShowSplitCloseButton(manager: SplitManager) {return manager.getVisibleSplitCount() > 1;}+/** Close a visible panel, or return the last one to its most recent list. */+export function closeSplitOrReturnToList(+ manager: SplitManager,+ handle: SplitHandle+) {+ if (shouldShowSplitCloseButton(manager)) {+ handle.close();+ return;+ }+ const content = handle.content();+ if (content.type === 'component' && isListViewID(content.id)) return;+ if (+ handle.goBackTo(+ (entry) => entry.type === 'component' && isListViewID(entry.id)+ )+ )+ return;+ handle.replace({+ next: { type: 'component', id: LIST_VIEW_ID.inbox },+ mergeHistory: true,+ });+}+/** Inline previews stay passive until the user focuses them. */export function useCanAutofocusSplitContent() {return !useSplitPanel()?.isInlinePreview;diff --git a/apps/web/src/components/app/split-layout/mobile/createMobileSwipeLayout.ts b/apps/web/src/components/app/split-layout/mobile/createMobileSwipeLayout.tsindex 2f84b90e87..533ad91609 100644--- a/apps/web/src/components/app/split-layout/mobile/createMobileSwipeLayout.ts+++ b/apps/web/src/components/app/split-layout/mobile/createMobileSwipeLayout.ts@@ -1,5 +1,6 @@import { batch, createSignal, onCleanup } from 'solid-js';import type {+ OpenSplitResult,OpenWithSplitOptions,ReferredFrom,SplitContent,@@ -69,14 +70,17 @@ export function createMobileSwipeLayout(// The BG split is always exactly bgSplitId() — derive exclusion directly from// the slot signals rather than maintaining a separate set.splitManager.setExclusionFilter((split) => split.id === bgSplitId());- splitManager.setNavigationInterceptor((content, options) => {- if (options.mergeHistory) return { handled: false };- navigateForward(content, options);- return { handled: true };+ splitManager.setSplitNavigationInterceptor((content, options) => {+ if (+ options.mergeHistory ||+ splitManager.findOpenView(content)?.owner === fgSplitId()+ )+ return;+ return navigateForward(content, options);});onCleanup(() => {splitManager.setExclusionFilter(undefined);- splitManager.setNavigationInterceptor(undefined);+ splitManager.setSplitNavigationInterceptor(undefined);});function canGoBack() {@@ -87,7 +91,7 @@ export function createMobileSwipeLayout(function navigateForward(content: SplitContent,options?: Pick<OpenWithSplitOptions, 'referredFrom'>- ) {+ ): OpenSplitResult {const isFgA = fgIsSlotA();const currentFgId = fgSplitId();const currentBgId = bgSplitId();@@ -105,25 +109,31 @@ export function createMobileSwipeLayout(fgHandle?.captureEntryState();// If the target is already mounted in BG, promote it instead of recreating it.- if (bgHandle && sameContent(bgHandle.content(), content)) {+ if (+ bgHandle &&+ (sameContent(bgHandle.content(), content) ||+ splitManager.findOpenView(content)?.owner === bgHandle.id)+ ) {// Reopening from a list supplies a new source even for the same entity.- bgHandle.replace({ next: content, referredFrom, mergeHistory: true });+ bgHandle.replace({+ next: sameContent(bgHandle.content(), content)+ ? content+ : bgHandle.content(),+ referredFrom,+ mergeHistory: true,+ });if (forwardNavigationTrigger) {forwardNavigationTrigger();} else {completeNavigateForward();}- return;+ return { status: 'reused', owner: bgHandle.id, split: bgHandle };}const newFgInitialHistory = fgHandle?.history() ?? [];// Batch to ensure reactive dependencies never see intermediate state.- batch(() => {- if (currentBgId) {- splitManager.removeSplit(currentBgId);- }-+ const prepared = batch(() => {const newFgHandle = splitManager.createNewSplit({content,initialHistory: newFgInitialHistory,@@ -131,14 +141,21 @@ export function createMobileSwipeLayout(referredFrom,});- setNewFgSlotId(newFgHandle?.id);+ if (!newFgHandle || newFgHandle.id === currentFgId) return false;+ if (currentBgId && currentBgId !== newFgHandle.id) {+ splitManager.removeSplit(currentBgId);+ }+ setNewFgSlotId(newFgHandle.id);+ return newFgHandle;});+ if (!prepared) return { status: 'unavailable' };if (forwardNavigationTrigger) {forwardNavigationTrigger();} else {completeNavigateForward();}+ return { status: 'opened', split: prepared };}function completeNavigateForward() {@@ -166,24 +183,28 @@ export function createMobileSwipeLayout(const bgHandle = splitManager.getSplit(currentBgId);if (!bgHandle) return;- const newBgContent = bgHandle.previousContent();- // Current content gets appended to history, so we want to slice before the new bg content- const newBgInitialHistory = bgHandle.history().slice(0, -2);-// Batch to ensure reactive dependencies never see intermediate state.batch(() => {if (currentFgId) {splitManager.removeSplit(currentFgId);}- const newBgHandle = newBgContent- ? splitManager.createNewSplit({- content: newBgContent,- initialHistory: newBgInitialHistory,- activate: false,- referredFrom: null,- })- : undefined;+ // Skip entries still mounted elsewhere, including an earlier route for+ // the conversation being promoted. Never assign both slots to one split.+ const history = bgHandle.history().slice(0, -1);+ const previousIndex = history.findLastIndex((content) => {+ const existing = splitManager.findOpenView(content);+ return !existing || existing.content.type === 'component';+ });+ const newBgHandle =+ previousIndex >= 0+ ? splitManager.createNewSplit({+ content: history[previousIndex],+ initialHistory: history.slice(0, previousIndex),+ activate: false,+ referredFrom: null,+ })+ : undefined;setNewBgSlotId(newBgHandle?.id);// Flip roles before activating: activateSplit refuses excludeddiff --git a/apps/web/src/components/app/split-layout/tests/layoutHistory.test.ts b/apps/web/src/components/app/split-layout/tests/layoutHistory.test.tsindex 896faeadcc..6a9336b1bc 100644--- a/apps/web/src/components/app/split-layout/tests/layoutHistory.test.ts+++ b/apps/web/src/components/app/split-layout/tests/layoutHistory.test.ts@@ -10,6 +10,66 @@ describe('createHistory', () => {expect(history.canGoForward()).toBe(false);});+ describe('configured availability', () => {+ it('uses the current rule for both navigation and availability checks', () => {+ const unavailable = new Set(['middle']);+ const history = createHistory<{ value: string }>({+ canVisit: (item) => !unavailable.has(item.value),+ });+ for (const value of ['first', 'middle', 'last']) history.push({ value });+ expect(history.canGoBack()).toBe(true);+ expect(history.back()).toEqual({ value: 'first' });+ expect(history.canGoForward()).toBe(true);+ expect(history.forward()).toEqual({ value: 'last' });+ expect(history.items).toHaveLength(3);++ unavailable.add('first');+ expect(history.canGoBack()).toBe(false);+ expect(history.back()).toBeNull();+ expect(history.index).toBe(2);++ unavailable.clear();+ expect(history.back()).toEqual({ value: 'middle' });+ unavailable.add('last');+ expect(history.canGoForward()).toBe(false);+ expect(history.forward()).toBeNull();+ unavailable.clear();+ expect(history.canGoForward()).toBe(true);+ expect(history.forward()).toEqual({ value: 'last' });+ });++ it('combines backTo destinations with the configured availability rule', () => {+ const history = createHistory<{ value: string; available: boolean }>({+ canVisit: (item) => item.available,+ });+ history.push({ value: 'list', available: true });+ history.push({ value: 'list', available: false });+ history.push({ value: 'detail', available: true });+ expect(history.backTo((item) => item.value === 'list')).toEqual({+ value: 'list',+ available: true,+ });+ expect(history.index).toBe(0);+ });++ it('refuses removal that would activate an unavailable entry', () => {+ let available = false;+ const history = createHistory<{ value: string }>({+ canVisit: () => available,+ });+ history.push({ value: 'first' });+ history.push({ value: 'last' });+ expect(history.remove((item) => item.value === 'last')).toBeNull();+ expect(history.items).toHaveLength(2);+ expect(history.index).toBe(1);+ available = true;+ expect(history.remove((item) => item.value === 'last')).toEqual({+ value: 'first',+ });+ expect(history.index).toBe(0);+ });+ });+describe('push', () => {it('should add items to history', () => {const history = createHistory<{ value: string }>();diff --git a/apps/web/src/components/app/split-layout/tests/layoutManager.test.ts b/apps/web/src/components/app/split-layout/tests/layoutManager.test.tsindex 9cf131c22d..2d2bf236d7 100644--- a/apps/web/src/components/app/split-layout/tests/layoutManager.test.ts+++ b/apps/web/src/components/app/split-layout/tests/layoutManager.test.ts@@ -7,16 +7,18 @@ import {} from '@app/features/soup/collection/list-navigation-source';import type { ResizeZoneCtx } from '@core/component/Resize/types';import { toast } from '@core/component/Toast/Toast';-import { createContentInstanceRegistry } from '@core/contentInstanceRegistry';import type { BlockOrchestrator } from '@core/orchestrator';-import { createRoot } from 'solid-js';+import { createMemo, createRoot, createSignal } from 'solid-js';import { beforeAll, describe, expect, it, vi } from 'vitest';import {createSplitLayout,type SplitContent,SplitEvent,} from '../layoutManager';-import { shouldShowSplitCloseButton } from '../layoutUtils';+import {+ closeSplitOrReturnToList,+ shouldShowSplitCloseButton,+} from '../layoutUtils';import { createMobileSwipeLayout } from '../mobile/createMobileSwipeLayout';vi.mock('@core/component/Toast/Toast', () => ({@@ -55,7 +57,6 @@ beforeAll(() => {function createMockOrchestrator(): BlockOrchestrator {return {- contentInstances: createContentInstanceRegistry(),isBlockMounted: vi.fn(() => false),createBlockInstance: vi.fn((_type, id, _splitId) => ({node: { type: 'mock-node', id },@@ -67,6 +68,88 @@ function createMockOrchestrator(): BlockOrchestrator {}describe('layoutManager', () => {+ describe('header close action', () => {+ it.each([false, true])(+ 'returns the sole visible split to its prior list (excluded background: %s)',+ (withBackground) => {+ createRoot((dispose) => {+ const manager = createSplitLayout(createMockOrchestrator(), [+ { type: 'component', id: 'inbox' },+ ]);+ const split = manager.getSplit(manager.splits()[0].id)!;+ const list: SplitContent = {+ type: 'component',+ id: 'tasks',+ state: { filter: 'assigned' },+ };+ split.replace({ next: list });+ split.replace({ next: { type: 'md', id: 'doc-1' } });+ split.replace({ next: { type: 'md', id: 'doc-2' } });+ if (withBackground) {+ const background = manager.createNewSplit({+ content: { type: 'md', id: 'background' },+ activate: false,+ referredFrom: null,+ })!;+ manager.setExclusionFilter((entry) => entry.id === background.id);+ }++ closeSplitOrReturnToList(manager, split);++ expect(manager.getVisibleSplitCount()).toBe(1);+ expect(manager.splits()).toHaveLength(withBackground ? 2 : 1);+ expect(split.content()).toEqual(list);+ expect(split.canGoForward()).toBe(true);+ split.goBack();+ expect(split.content()).toEqual({ type: 'component', id: 'inbox' });+ dispose();+ });+ }+ );++ it('falls back to inbox without keeping the current detail as a Back entry', () => {+ createRoot((dispose) => {+ const manager = createSplitLayout(createMockOrchestrator(), [+ { type: 'md', id: 'direct-link' },+ ]);+ const split = manager.getSplit(manager.splits()[0].id)!;+ closeSplitOrReturnToList(manager, split);+ expect(split.content()).toEqual({ type: 'component', id: 'inbox' });+ expect(split.canGoBack()).toBe(false);+ dispose();+ });+ });++ it('closes the panel when another visible split remains', () => {+ createRoot((dispose) => {+ const manager = createSplitLayout(createMockOrchestrator(), [+ { type: 'md', id: 'detail' },+ { type: 'component', id: 'tasks' },+ ]);+ const split = manager.getSplit(manager.splits()[0].id)!;+ closeSplitOrReturnToList(manager, split);+ expect(manager.getSplit(split.id)).toBeUndefined();+ expect(manager.splits().map((entry) => entry.content.id)).toEqual([+ 'tasks',+ ]);+ dispose();+ });+ });++ it('leaves a sole list unchanged', () => {+ createRoot((dispose) => {+ const manager = createSplitLayout(createMockOrchestrator(), [+ { type: 'component', id: 'tasks' },+ ]);+ const split = manager.getSplit(manager.splits()[0].id)!;+ closeSplitOrReturnToList(manager, split);+ expect(split.content()).toEqual({ type: 'component', id: 'tasks' });+ expect(manager.getVisibleSplitCount()).toBe(1);+ dispose();+ });+ });+ });+it.each([true, false, undefined])('honors activate=%s when direct split creation finds an existing entity',(activate) => {@@ -90,7 +173,7 @@ describe('layoutManager', () => {expect(result?.id).toBe(existing.id);expect(manager.splits()).toHaveLength(2);expect(manager.activeSplitId()).toBe(activate ? existing.id : other.id);- expect(toast.alert).toHaveBeenCalledWith('Content already open');+ expect(toast.alert).not.toHaveBeenCalled();dispose();});}@@ -125,6 +208,11 @@ describe('layoutManager', () => {);manager.activateSplit(other.id);+ const view = manager.findOpenView(target);+ expect(view?.owner).toBe(existing.id);+ expect(view?.topLevelSplit?.id).toBe(existing.id);+ expect(view?.content).toEqual(entity);+ expect(manager.activeSplitId()).toBe(other.id);const direct = manager.createNewSplit({content: target,activate: true,@@ -135,45 +223,64 @@ describe('layoutManager', () => {expect(manager.activeSplitId()).toBe(existing.id);manager.activateSplit(other.id);+ vi.mocked(toast.alert).mockClear();const opened = manager.openWithSplit(target, {activate: true,allowDuplicate: true,handle: manager.getSplit(other.id),});- expect(opened?.id).toBe(existing.id);+ expect(opened).toMatchObject({+ status: 'reused',+ owner: existing.id,+ sourceOwner: other.id,+ });+ expect(opened.split?.id).toBe(existing.id);expect(manager.activeSplitId()).toBe(existing.id);expect(manager.splits()).toHaveLength(2);expect(existing.mount).toBe(mount);expect(existing.content).toEqual(initial);expect(other.content).toEqual({ type: 'component', id: 'inbox' });+ expect(toast.alert).not.toHaveBeenCalled();++ manager.openWithSplit(target);+ expect(toast.alert).not.toHaveBeenCalled();dispose();});}});- it('rejects opening a previewed block until its mount is released', () => {+ it('reports reuse even when the owning view has no activation target', () => {createRoot((dispose) => {const orchestrator = createMockOrchestrator();const manager = createSplitLayout(orchestrator, [{ type: 'component', id: 'inbox' },]);- const release = orchestrator.contentInstances.register(() => [+ const release = manager.registerOpenViews(() => [{owner: 'preview',content: { type: 'channel', id: 'preview-channel' },},]);+ vi.mocked(toast.alert).mockClear();expect(manager.openWithSplit({ type: 'channel', id: 'preview-channel' },{ preferNewSplit: true })- ).toBeUndefined();+ ).toMatchObject({ status: 'reused', owner: 'preview' });+ expect(manager.splits()).toHaveLength(1);+ expect(orchestrator.createBlockInstance).not.toHaveBeenCalled();+ expect(toast.alert).not.toHaveBeenCalled();++ manager.openWithSplit(+ { type: 'channel', id: 'preview-channel' },+ { preferNewSplit: true }+ );expect(manager.splits()).toHaveLength(1);expect(orchestrator.createBlockInstance).not.toHaveBeenCalled();- expect(toast.alert).toHaveBeenCalledWith('Content already open');+ expect(toast.alert).not.toHaveBeenCalled();release();manager.openWithSplit(@@ -186,6 +293,177 @@ describe('layoutManager', () => {});});+ it.each([+ {+ name: 'channel',+ content: { type: 'channel', id: 'conversation' },+ target: { type: 'channel', id: 'conversation' },+ },+ ...(+ [+ { mode: 'chat', type: 'agent_session', block: 'agent' },+ { mode: 'code', type: 'agent_session', block: 'agent' },+ { mode: 'chat', type: 'chat', block: 'chat' },+ ] as const+ ).map(({ mode, type, block }) => ({+ name: `${mode} ${type}`,+ content: { type: block, id: 'conversation' },+ target: {+ type: 'component' as const,+ id: agentsRouteId({ mode, conversation: { type, id: 'conversation' } }),+ },+ })),+ ] satisfies { name: string; content: SplitContent; target: SplitContent }[])(+ 'reports inline $name reuse without notifications',+ ({ content, target }) => {+ createRoot((dispose) => {+ const orchestrator = createMockOrchestrator();+ const manager = createSplitLayout(orchestrator, [+ { type: 'component', id: 'channels' },+ { type: 'component', id: 'inbox' },+ ]);+ const [chat, inbox] = manager.splits();+ manager.activateSplit(inbox.id);+ const activate = vi.fn(() => manager.activateSplit(chat.id));+ manager.registerOpenViews(() => [+ { owner: 'preview', content, activate },+ ]);+ const intercept = vi.fn(() => ({ status: 'unavailable' as const }));+ manager.setSplitNavigationInterceptor(intercept);++ const view = manager.findOpenView(target);+ expect(view?.owner).toBe('preview');+ expect(view?.content).toEqual(content);+ expect(view?.topLevelSplit).toBeUndefined();+ expect(activate).not.toHaveBeenCalled();++ vi.mocked(toast.alert).mockClear();+ const result = manager.openWithSplit(target, {+ referredFrom: 'kommand-menu',+ });+ expect(result).toMatchObject({ status: 'reused', owner: 'preview' });+ expect(result.split).toBeUndefined();+ expect(activate).toHaveBeenCalledOnce();+ expect(manager.activeSplitId()).toBe(chat.id);+ expect(toast.alert).not.toHaveBeenCalled();++ vi.mocked(toast.alert).mockClear();+ manager.activateSplit(inbox.id);+ manager.openWithSplit(target);+ expect(activate).toHaveBeenCalledTimes(2);+ expect(manager.activeSplitId()).toBe(chat.id);+ expect(manager.splits()).toHaveLength(2);+ expect(orchestrator.createBlockInstance).not.toHaveBeenCalled();+ expect(toast.alert).not.toHaveBeenCalled();++ manager.activateSplit(inbox.id);+ manager.openWithSplit(target, { activate: false });+ expect(activate).toHaveBeenCalledTimes(2);+ expect(manager.activeSplitId()).toBe(inbox.id);+ expect(toast.alert).not.toHaveBeenCalled();+ expect(intercept).not.toHaveBeenCalled();+ dispose();+ });+ }+ );++ it('reports the owner when reusing a standalone split', () => {+ createRoot((dispose) => {+ const manager = createSplitLayout(createMockOrchestrator(), [+ { type: 'channel', id: 'channel' },+ { type: 'component', id: 'inbox' },+ ]);+ const [channel, inbox] = manager.splits();+ manager.activateSplit(inbox.id);+ vi.mocked(toast.alert).mockClear();+ manager.openWithSplit(channel.content);+ expect(manager.activeSplitId()).toBe(channel.id);+ expect(toast.alert).not.toHaveBeenCalled();+ vi.mocked(toast.alert).mockClear();+ manager.activateSplit(inbox.id);+ manager.openWithSplit(channel.content);+ expect(manager.activeSplitId()).toBe(channel.id);+ expect(toast.alert).not.toHaveBeenCalled();+ dispose();+ });+ });++ it('finds an existing shell even when an open action allows duplicating it', () => {+ createRoot((dispose) => {+ const content = { type: 'component', id: 'channels' } as const;+ const manager = createSplitLayout(createMockOrchestrator(), [+ content,+ { type: 'component', id: 'inbox' },+ ]);+ const [channels, inbox] = manager.splits();+ manager.activateSplit(inbox.id);+ vi.mocked(toast.alert).mockClear();++ expect(manager.findOpenView(content)?.topLevelSplit?.id).toBe(+ channels.id+ );+ expect(manager.activeSplitId()).toBe(inbox.id);+ expect(toast.alert).not.toHaveBeenCalled();++ const duplicate = manager.openWithSplit(content, {+ preferNewSplit: true,+ allowDuplicate: true,+ });+ expect(duplicate.status).toBe('opened');+ expect(duplicate.split?.id).not.toBe(channels.id);+ expect(manager.splits()).toHaveLength(3);+ expect(manager.findOpenView(content)?.topLevelSplit?.id).toBe(+ channels.id+ );+ expect(toast.alert).not.toHaveBeenCalled();+ dispose();+ });+ });++ it('distinguishes opening new content from reusing content in the source split', () => {+ createRoot((dispose) => {+ const manager = createSplitLayout(createMockOrchestrator(), [+ { type: 'component', id: 'inbox' },+ ]);+ const handle = manager.getSplit(manager.splits()[0].id)!;+ const content = { type: 'email', id: 'selected' } as const;+ vi.mocked(toast.alert).mockClear();+ expect(manager.openWithSplit(content, { handle })).toMatchObject({+ status: 'opened',+ split: { id: handle.id },+ });+ expect(manager.openWithSplit(content, { handle })).toMatchObject({+ status: 'reused',+ owner: handle.id,+ sourceOwner: handle.id,+ split: { id: handle.id },+ });+ expect(handle.content()).toMatchObject(content);+ expect(toast.alert).not.toHaveBeenCalled();+ dispose();+ });+ });++ it('restoring occupied content does not focus or notify its owner', () => {+ createRoot((dispose) => {+ const manager = createSplitLayout(createMockOrchestrator(), [+ { type: 'component', id: 'inbox' },+ ]);+ const source = manager.splits()[0];+ const content = { type: 'email', id: 'occupied' } as const;+ const activate = vi.fn();+ manager.registerOpenViews(() => [+ { owner: 'preview', content, activate },+ ]);+ vi.mocked(toast.alert).mockClear();+ manager.reconcile([content]);+ expect(manager.splits()[0].content).toEqual(source.content);+ expect(activate).not.toHaveBeenCalled();+ expect(toast.alert).not.toHaveBeenCalled();+ dispose();+ });+ });+it('blocks detail-owned email through direct split creation, replacement, and history', () => {createRoot((dispose) => {const orchestrator = createMockOrchestrator();@@ -194,7 +472,7 @@ describe('layoutManager', () => {]);const handle = manager.getSplit(manager.splits()[0].id)!;handle.replace({ next: { type: 'email', id: 'two' } });- const release = orchestrator.contentInstances.register(() => [+ const release = manager.registerOpenViews(() => [{ owner: 'detail', content: { type: 'email', id: 'one' } },]);expect(@@ -216,6 +494,73 @@ describe('layoutManager', () => {});});+ it.each(['replace', 'adopt', 'replaceAll', 'popover'] as const)(+ '%s focuses an inline owner when it refuses duplicate content',+ (action) => {+ createRoot((dispose) => {+ const manager = createSplitLayout(createMockOrchestrator(), [+ { type: 'email', id: 'pending' },+ { type: 'component', id: 'mail' },+ ]);+ const [source, host] = manager.splits();+ const handle = manager.getSplit(source.id)!;+ const target = { type: 'email', id: 'owned' } as const;+ manager.registerOpenViews(() => [+ {+ owner: 'detail',+ content: target,+ activate: () => manager.activateSplit(host.id),+ },+ ]);+ handle.activate();+ vi.mocked(toast.alert).mockClear();++ if (action === 'replace') handle.replace({ next: target });+ if (action === 'adopt')+ handle.adoptContentId({ type: 'email', nextId: target.id });+ if (action === 'replaceAll') manager.replaceAllSplits(target);+ if (action === 'popover')+ manager.createPopoverSplit({ content: target });++ expect(manager.activeSplitId()).toBe(host.id);+ expect(handle.content().id).toBe('pending');+ expect(handle.history()).toHaveLength(1);+ expect(manager.splits()).toHaveLength(2);+ expect(toast.alert).not.toHaveBeenCalled();+ dispose();+ });+ }+ );++ it.each(['replace', 'adopt'] as const)(+ '%s focuses an existing block instead of mounting its Agents route',+ (action) => {+ createRoot((dispose) => {+ const orchestrator = createMockOrchestrator();+ const manager = createSplitLayout(orchestrator, [+ { type: 'chat', id: 'conversation' },+ { type: 'component', id: 'agents' },+ ]);+ const [owner, source] = manager.splits();+ const handle = manager.getSplit(source.id)!;+ const route = agentsRouteId({+ mode: 'chat',+ conversation: { type: 'chat', id: 'conversation' },+ });+ const mount = source.mount;+ handle.activate();+ if (action === 'replace')+ handle.replace({ next: { type: 'component', id: route } });+ else handle.adoptContentId({ type: 'component', nextId: route });+ expect(manager.activeSplitId()).toBe(owner.id);+ expect(handle.content().id).toBe('agents');+ expect(manager.splits()[1].mount).toBe(mount);+ expect(orchestrator.createBlockInstance).toHaveBeenCalledTimes(1);+ dispose();+ });+ }+ );+it('exposes split ownership before block mount and releases it on close', () => {createRoot((dispose) => {const orchestrator = createMockOrchestrator();@@ -223,18 +568,60 @@ describe('layoutManager', () => {{ type: 'email', id: 'one' },]);expect(- orchestrator.contentInstances.isOpenElsewhere({+ manager.findOpenView({type: 'email',id: 'one',})- ).toBe(true);+ ).toBeDefined();manager.removeSplit(manager.splits()[0].id);expect(- orchestrator.contentInstances.isOpenElsewhere({+ manager.findOpenView({type: 'email',id: 'one',})- ).toBe(false);+ ).toBeUndefined();+ dispose();+ });+ });++ it('scopes content ownership to the layout even when an orchestrator is shared', () => {+ createRoot((dispose) => {+ const orchestrator = createMockOrchestrator();+ const content = { type: 'channel', id: 'channel' } as const;+ const first = createSplitLayout(orchestrator, [content]);+ const second = createSplitLayout(orchestrator, []);++ expect(first.findOpenView(content)).toBeDefined();+ expect(second.findOpenView(content)).toBeUndefined();++ dispose();+ expect(first.findOpenView(content)).toBeUndefined();+ });+ });++ it('navigates and closes adjacent list and detail splits independently', () => {+ createRoot((dispose) => {+ const manager = createSplitLayout(createMockOrchestrator(), [+ { type: 'component', id: 'inbox' },+ { type: 'md', id: 'detail' },+ ]);+ const [list, detail] = manager.splits();+ const listHandle = manager.getSplit(list.id)!;+ const detailHandle = manager.getSplit(detail.id)!;++ manager.openWithSplit(+ { type: 'email', id: 'thread' },+ { handle: listHandle }+ );+ expect(listHandle.content()).toEqual({ type: 'email', id: 'thread' });+ expect(detailHandle.content()).toEqual({ type: 'md', id: 'detail' });+ expect(manager.splits()).toHaveLength(2);++ listHandle.goBack();+ expect(listHandle.content()).toEqual({ type: 'component', id: 'inbox' });+ expect(detailHandle.content()).toEqual({ type: 'md', id: 'detail' });+ listHandle.close();+ expect(manager.splits().map((split) => split.id)).toEqual([detail.id]);dispose();});});@@ -294,6 +681,51 @@ describe('layoutManager', () => {});describe('reconciler', () => {+ it('uses the retained split id for history ownership after reconciliation', () => {+ createRoot((dispose) => {+ const manager = createSplitLayout(createMockOrchestrator(), [+ { type: 'component', id: 'inbox' },+ ]);+ const handle = manager.getSplit(manager.splits()[0].id)!;+ const content = { type: 'email', id: 'same-entity' } as const;+ manager.reconcile([content]);+ expect(manager.splits()[0].id).toBe(handle.id);+ handle.replace({ next: content });+ expect(handle.canGoBack()).toBe(true);+ handle.goBack();+ expect(handle.history()).toHaveLength(1);+ expect(handle.canGoForward()).toBe(true);+ dispose();+ });+ });++ it('keeps history availability configured after reset', () => {+ createRoot((dispose) => {+ const manager = createSplitLayout(createMockOrchestrator(), [+ { type: 'component', id: 'inbox' },+ ]);+ const handle = manager.getSplit(manager.splits()[0].id)!;+ handle.reset();+ expect(handle.history()).toEqual([{ type: 'component', id: 'inbox' }]);+ expect(handle.canGoBack()).toBe(false);+ handle.replace({ next: { type: 'email', id: 'occupied' } });+ handle.replace({ next: { type: 'email', id: 'current' } });+ const release = manager.registerOpenViews(() => [+ { owner: 'preview', content: { type: 'email', id: 'occupied' } },+ ]);+ expect(handle.canGoBack()).toBe(true);+ handle.goBack();+ expect(handle.content().id).toBe('inbox');+ handle.goForward();+ expect(handle.content().id).toBe('current');+ release();+ expect(handle.canGoBack()).toBe(true);+ handle.goBack();+ expect(handle.content().id).toBe('occupied');+ dispose();+ });+ });+it('should reconcile between current state and url changes', () => {createRoot((dispose) => {const manager = createSplitLayout(createMockOrchestrator(), [@@ -490,6 +922,96 @@ describe('layoutManager', () => {});});+ it.each(['split', 'inline'] as const)(+ 'back and forward skip content owned by another %s without focusing it',+ (owner) => {+ createRoot((dispose) => {+ const manager = createSplitLayout(createMockOrchestrator(), [+ { type: 'component', id: 'inbox' },+ ]);+ const handle = manager.getSplit(manager.splits()[0].id)!;+ const occupied = { type: 'email', id: 'occupied' } as const;+ handle.replace({ next: occupied });+ handle.replace({ next: { type: 'channel', id: 'end' } });+ const activate = vi.fn();+ const release =+ owner === 'inline'+ ? manager.registerOpenViews(() => [+ { owner: 'detail', content: occupied, activate },+ ])+ : (() => {+ const split = manager.createNewSplit({+ content: occupied,+ referredFrom: null,+ })!;+ return () => manager.removeSplit(split.id);+ })();+ handle.activate();+ vi.mocked(toast.alert).mockClear();++ expect(handle.canGoBack()).toBe(true);+ handle.goBack();+ expect(handle.content().id).toBe('inbox');+ expect(handle.canGoBack()).toBe(false);+ expect(handle.canGoForward()).toBe(true);+ handle.goForward();+ expect(handle.content().id).toBe('end');+ expect(handle.canGoForward()).toBe(false);+ expect(handle.history().map((entry) => entry.id)).toEqual([+ 'inbox',+ 'occupied',+ 'end',+ ]);+ expect(manager.activeSplitId()).toBe(handle.id);+ expect(activate).not.toHaveBeenCalled();+ expect(toast.alert).not.toHaveBeenCalled();++ release();+ handle.goBack();+ expect(handle.content().id).toBe('occupied');+ dispose();+ });+ }+ );++ it('disables history directions with only occupied entries and restores them when released', () => {+ createRoot((dispose) => {+ const manager = createSplitLayout(createMockOrchestrator(), [+ { type: 'email', id: 'before' },+ ]);+ const handle = manager.getSplit(manager.splits()[0].id)!;+ handle.replace({ next: { type: 'component', id: 'inbox' } });+ handle.replace({ next: { type: 'email', id: 'after' } });+ handle.goBack();+ const canGoBack = createMemo(handle.canGoBack);+ const canGoForward = createMemo(handle.canGoForward);+ expect(canGoBack()).toBe(true);+ expect(canGoForward()).toBe(true);+ const [occupied, setOccupied] = createSignal(['before', 'after']);+ const release = manager.registerOpenViews(() =>+ occupied().map((id) => ({+ owner: id,+ content: { type: 'email', id },+ }))+ );+ expect(canGoBack()).toBe(false);+ expect(canGoForward()).toBe(false);+ handle.goBack();+ handle.goForward();+ expect(handle.content().id).toBe('inbox');+ setOccupied([]);+ expect(canGoBack()).toBe(true);+ expect(canGoForward()).toBe(true);+ setOccupied(['before', 'after']);+ expect(canGoBack()).toBe(false);+ expect(canGoForward()).toBe(false);+ release();+ expect(canGoBack()).toBe(true);+ expect(canGoForward()).toBe(true);+ dispose();+ });+ });+it('skips history entries another split already displays', () => {createRoot((dispose) => {const manager = createSplitLayout(createMockOrchestrator(), [@@ -872,7 +1394,7 @@ describe('layoutManager', () => {'unified-list','current',]);- expect(manager.activeSplitId()).toBe(inserted?.id);+ expect(manager.activeSplitId()).toBe(inserted.split?.id);dispose();});@@ -880,6 +1402,164 @@ describe('layoutManager', () => {});describe('activation invariant', () => {+ it.each(['foreground', 'background'] as const)(+ 'reuses the mobile %s conversation across Agents routes and blocks',+ (position) => {+ const route: SplitContent = {+ type: 'component',+ id: agentsRouteId({+ mode: 'chat',+ conversation: { type: 'chat', id: 'conversation' },+ }),+ };+ const block: SplitContent = { type: 'chat', id: 'conversation' };+ for (const [initial, target] of [+ [route, block],+ [block, route],+ [block, block],+ ]) {+ createRoot((dispose) => {+ const manager = createSplitLayout(createMockOrchestrator(), [+ position === 'foreground'+ ? { type: 'component', id: 'inbox' }+ : initial,+ ]);+ const swipe = createMobileSwipeLayout(manager);+ manager.openWithSplit(+ position === 'foreground'+ ? initial+ : { type: 'component', id: 'inbox' }+ );+ const owner = manager.findOpenView(target)!.topLevelSplit!;+ const mount = manager+ .splits()+ .find((split) => split.id === owner.id)!.mount;+ const ids = manager.splits().map((split) => split.id);+ vi.mocked(toast.alert).mockClear();++ manager.openWithSplit(target);++ expect(manager.activeSplitId()).toBe(owner.id);+ expect(manager.splits().map((split) => split.id)).toEqual(ids);+ expect(+ manager.splits().find((split) => split.id === owner.id)!.mount+ ).toBe(mount);+ expect(swipe.slotASplitId()).not.toBe(swipe.slotBSplitId());+ expect(swipe.canGoBack()).toBe(true);+ expect(toast.alert).not.toHaveBeenCalled();+ swipe.swipeBack();+ expect(+ manager.getSplit(manager.activeSplitId()!)!.content().id+ ).toBe('inbox');+ dispose();+ });+ }+ }+ );++ it('reports reuse when mobile navigation promotes an existing pane', () => {+ createRoot((dispose) => {+ const content = { type: 'email', id: 'background' } as const;+ const manager = createSplitLayout(createMockOrchestrator(), [content]);+ const owner = manager.splits()[0].id;+ createMobileSwipeLayout(manager);+ manager.openWithSplit({ type: 'email', id: 'foreground' });+ vi.mocked(toast.alert).mockClear();+ const result = manager.openWithSplit(content);+ expect(result).toMatchObject({+ status: 'reused',+ owner,+ split: { id: owner },+ });+ expect(manager.activeSplitId()).toBe(owner);+ expect(manager.splits()).toHaveLength(2);+ expect(toast.alert).not.toHaveBeenCalled();+ dispose();+ });+ });++ it.each(['refused', 'reused'] as const)(+ 'preserves mobile slots when creation is %s',+ (result) => {+ createRoot((dispose) => {+ const manager = createSplitLayout(createMockOrchestrator(), [+ { type: 'component', id: 'inbox' },+ ]);+ const swipe = createMobileSwipeLayout(manager);+ manager.openWithSplit({ type: 'email', id: 'foreground' });+ const foreground = manager.getSplit(manager.activeSplitId()!)!;+ const ids = manager.splits().map((split) => split.id);+ const slots = [+ swipe.slotASplitId(),+ swipe.slotBSplitId(),+ swipe.fgIsSlotA(),+ ];+ const animate = vi.fn();+ swipe.setForwardNavigationTrigger(animate);+ vi.spyOn(manager, 'createNewSplit').mockReturnValueOnce(+ result === 'reused' ? foreground : undefined+ );+ expect(+ manager.openWithSplit({ type: 'email', id: 'next' })+ ).toMatchObject({ status: 'unavailable' });+ expect(manager.splits().map((split) => split.id)).toEqual(ids);+ expect([+ swipe.slotASplitId(),+ swipe.slotBSplitId(),+ swipe.fgIsSlotA(),+ ]).toEqual(slots);+ expect(manager.activeSplitId()).toBe(foreground.id);+ expect(animate).not.toHaveBeenCalled();+ dispose();+ });+ }+ );++ it('promotes an occupied mobile background when direct replacement is refused', () => {+ createRoot((dispose) => {+ const manager = createSplitLayout(createMockOrchestrator(), [+ { type: 'email', id: 'background' },+ ]);+ const owner = manager.splits()[0].id;+ const swipe = createMobileSwipeLayout(manager);+ manager.openWithSplit({ type: 'email', id: 'foreground' });+ const source = manager.getSplit(manager.activeSplitId()!)!;+ source.replace({ next: { type: 'email', id: 'background' } });+ expect(manager.activeSplitId()).toBe(owner);+ expect(source.content().id).toBe('foreground');+ expect(manager.splits()).toHaveLength(2);+ expect(swipe.slotASplitId()).not.toBe(swipe.slotBSplitId());+ dispose();+ });+ });++ it('skips already-mounted history when rebuilding the mobile background', () => {+ createRoot((dispose) => {+ const manager = createSplitLayout(createMockOrchestrator(), [+ { type: 'component', id: 'inbox' },+ ]);+ const handle = manager.getSplit(manager.splits()[0].id)!;+ handle.replace({ next: { type: 'chat', id: 'conversation' } });+ handle.replace({ next: { type: 'chat', id: 'conversation' } });+ const swipe = createMobileSwipeLayout(manager);+ manager.openWithSplit({ type: 'email', id: 'next' });+ vi.mocked(toast.alert).mockClear();+ swipe.swipeBack();+ expect(manager.activeSplitId()).toBe(handle.id);+ expect(swipe.slotASplitId()).not.toBe(swipe.slotBSplitId());+ expect(manager.splits().map((split) => split.content.id)).toEqual([+ 'conversation',+ 'inbox',+ ]);+ expect(toast.alert).not.toHaveBeenCalled();+ swipe.swipeBack();+ expect(manager.getSplit(manager.activeSplitId()!)!.content().id).toBe(+ 'inbox'+ );+ dispose();+ });+ });+it('refreshes the list source when reopening an email already mounted in the native background', () => {createRoot((dispose) => {const manager = createSplitLayout(createMockOrchestrator(), [diff --git a/apps/web/src/components/app/split-layout/tests/layoutUrlSync.test.ts b/apps/web/src/components/app/split-layout/tests/layoutUrlSync.test.tsindex f826e5d6c9..b3396be4fa 100644--- a/apps/web/src/components/app/split-layout/tests/layoutUrlSync.test.ts+++ b/apps/web/src/components/app/split-layout/tests/layoutUrlSync.test.ts@@ -1,5 +1,4 @@import { agentsRouteId } from '@app/features/agents-view/core/route';-import { createContentInstanceRegistry } from '@core/contentInstanceRegistry';import type { BlockOrchestrator } from '@core/orchestrator';import type { Navigator } from '@solidjs/router';import { batch, createRoot, createSignal } from 'solid-js';@@ -38,7 +37,6 @@ beforeAll(() => {function createMockOrchestrator(): BlockOrchestrator {return {- contentInstances: createContentInstanceRegistry(),isBlockMounted: vi.fn(() => false),createBlockInstance: vi.fn((_type, id, _splitId) => ({node: { type: 'mock-node', id },diff --git a/apps/web/src/components/app/split-layout/tests/splitFocusTracker.test.ts b/apps/web/src/components/app/split-layout/tests/splitFocusTracker.test.tsindex aa323e34cd..b495dbf84a 100644--- a/apps/web/src/components/app/split-layout/tests/splitFocusTracker.test.ts+++ b/apps/web/src/components/app/split-layout/tests/splitFocusTracker.test.ts@@ -1,4 +1,3 @@-import { createContentInstanceRegistry } from '@core/contentInstanceRegistry';import type { BlockOrchestrator } from '@core/orchestrator';import { createRoot } from 'solid-js';import {@@ -44,7 +43,6 @@ beforeAll(() => {function createMockOrchestrator(): BlockOrchestrator {return {- contentInstances: createContentInstanceRegistry(),isBlockMounted: vi.fn(() => false),createBlockInstance: vi.fn((_type, id, _splitId) => ({node: { type: 'mock-node', id },diff --git a/apps/web/src/components/entity-detail/EntityDetailNavigationStack.tsx b/apps/web/src/components/entity-detail/EntityDetailNavigationStack.tsxindex 826565e4e1..a79c64b3e0 100644--- a/apps/web/src/components/entity-detail/EntityDetailNavigationStack.tsx+++ b/apps/web/src/components/entity-detail/EntityDetailNavigationStack.tsx@@ -106,8 +106,9 @@ function Root(props: EntityDetailNavigationStackRootProps) {return (<NavigationStack.Root<EntityDetailTarget, EntityDetailNavigationOptions>{...props}- beforeChange={(target) =>- props.beforeChange?.(target) !== false && selectPreview(target)+ beforeChange={(target, reason) =>+ props.beforeChange?.(target, reason) !== false &&+ selectPreview(target, reason)}shouldNavigate={(target, options) =>props.shouldNavigatediff --git a/apps/web/src/components/navigation-stack/NavigationStack.tsx b/apps/web/src/components/navigation-stack/NavigationStack.tsxindex bf100a9878..67afa6eaeb 100644--- a/apps/web/src/components/navigation-stack/NavigationStack.tsx+++ b/apps/web/src/components/navigation-stack/NavigationStack.tsx@@ -13,6 +13,8 @@ export type NavigationStackEntry<TData> = {data: TData;};+export type NavigationStackChangeReason = 'restore' | 'navigate';+export type NavigationStackState<TData, TNavigateOptions = unknown> = {entries: Store<NavigationStackEntry<TData>[]>;active: () => NavigationStackEntry<TData> | undefined;@@ -57,7 +59,10 @@ export type NavigationStackRootProps<> = ParentProps<{defaultValue?: readonly TData[];/** Validates the resulting active entry before any state change, including history. */- beforeChange?: (data: TData | undefined) => boolean;+ beforeChange?: (+ data: TData | undefined,+ reason: NavigationStackChangeReason+ ) => boolean;shouldNavigate?: (data: TData, options?: TNavigateOptions) => boolean;onChange?: (entries: readonly NavigationStackEntry<TData>[]) => void;}>;@@ -74,14 +79,14 @@ function Root<TData = unknown, TNavigateOptions = unknown>(});const [entries, setEntries] = createStore<NavigationStackEntry<TData>[]>(props.defaultValue- ?.filter((data) => props.beforeChange?.(data) !== false)+ ?.filter((data) => props.beforeChange?.(data, 'restore') !== false).map(createEntry) ?? []);const active = () => entries.at(-1);const notifyChange = () => props.onChange?.([...entries]);const push = (data: TData) => {- if (props.beforeChange?.(data) === false) return;+ if (props.beforeChange?.(data, 'navigate') === false) return;const entry = createEntry(data);setEntries(entries.length, entry);notifyChange();@@ -98,7 +103,7 @@ function Root<TData = unknown, TNavigateOptions = unknown>(const replace = (data: TData) => {if (entries.length === 0) return push(data);- if (props.beforeChange?.(data) === false) return;+ if (props.beforeChange?.(data, 'navigate') === false) return;const entry = createEntry(data);setEntries(@@ -111,7 +116,7 @@ function Root<TData = unknown, TNavigateOptions = unknown>(};const reset = (data: TData) => {- if (props.beforeChange?.(data) === false) return;+ if (props.beforeChange?.(data, 'navigate') === false) return;const entry = createEntry(data);setEntries(produce((draft) => {@@ -124,7 +129,8 @@ function Root<TData = unknown, TNavigateOptions = unknown>(const pop = () => {if (entries.length === 0) return;- if (props.beforeChange?.(entries.at(-2)?.data) === false) return;+ if (props.beforeChange?.(entries.at(-2)?.data, 'navigate') === false)+ return;setEntries(produce((draft) => {draft.pop();@@ -136,7 +142,7 @@ function Root<TData = unknown, TNavigateOptions = unknown>(const popTo = (value: string) => {const index = entries.findIndex((entry) => entry.value === value);if (index < 0 || index === entries.length - 1) return;- if (props.beforeChange?.(entries[index].data) === false) return;+ if (props.beforeChange?.(entries[index].data, 'navigate') === false) return;setEntries(produce((draft) => {draft.splice(index + 1);@@ -147,7 +153,7 @@ function Root<TData = unknown, TNavigateOptions = unknown>(const clear = () => {if (entries.length === 0) return;- if (props.beforeChange?.(undefined) === false) return;+ if (props.beforeChange?.(undefined, 'navigate') === false) return;setEntries(produce((draft) => {draft.splice(0);diff --git a/apps/web/src/features/activity/open-entity-in-split.ts b/apps/web/src/features/activity/open-entity-in-split.tsindex 0d85c1ae45..224a23cac0 100644--- a/apps/web/src/features/activity/open-entity-in-split.ts+++ b/apps/web/src/features/activity/open-entity-in-split.ts@@ -1,4 +1,5 @@import { openDocument } from '@core/component/LexicalMarkdown/component/core/BlockLink';+import { toast } from '@core/component/Toast/Toast';import type { OpenEntityTarget } from './context/activity-context';/** The app's `onOpen` for activity rows: open the entity in the split layout. */@@ -8,5 +9,8 @@ export function openEntityInSplit({params,newSplit,}: OpenEntityTarget): void {- openDocument(block, id, params, newSplit);+ const result = openDocument(block, id, params, newSplit);+ if (result?.status === 'reused' && result.owner !== result.sourceOwner) {+ toast.alert('Content already open');+ }}diff --git a/apps/web/src/features/agents-view/primitives/open-composer.test.ts b/apps/web/src/features/agents-view/primitives/open-composer.test.tsindex 443eede97a..e13cafdcf4 100644--- a/apps/web/src/features/agents-view/primitives/open-composer.test.ts+++ b/apps/web/src/features/agents-view/primitives/open-composer.test.ts@@ -28,7 +28,9 @@ function layout(existing = false) {} as unknown as SplitHandle;const openWithSplit = vi.fn<SplitManager['openWithSplit']>((next) => {if (!existing) content = next;- return split;+ return existing+ ? { status: 'reused', owner: split.id, split }+ : { status: 'opened', split };});return { openWithSplit, replace, content: () => content };}@@ -94,8 +96,8 @@ describe('openAgentComposer', () => {expect(home.textContent).toBe('Keep this draft');});- it('does not steal focus when navigation is intercepted', () => {- openAgentComposer({ openWithSplit: () => undefined });+ it('does not steal focus when navigation is unavailable', () => {+ openAgentComposer({ openWithSplit: () => ({ status: 'unavailable' }) });expect(focus.target).toBeUndefined();});});diff --git a/apps/web/src/features/agents-view/primitives/open-composer.ts b/apps/web/src/features/agents-view/primitives/open-composer.tsindex 3ce43b4ad5..9d14061a76 100644--- a/apps/web/src/features/agents-view/primitives/open-composer.ts+++ b/apps/web/src/features/agents-view/primitives/open-composer.ts@@ -15,7 +15,7 @@ export function openAgentComposer(const split = layout.openWithSplit(content, {referredFrom: 'launcher',preferNewSplit,- });+ }).split;if (!split) return;// Opening an existing split activates it without updating its params.// Publish a new request so an open roster returns to the composer as well.diff --git a/apps/web/src/features/agents-view/primitives/open-page.test.ts b/apps/web/src/features/agents-view/primitives/open-page.test.tsindex 51c70f46a3..23da05ad17 100644--- a/apps/web/src/features/agents-view/primitives/open-page.test.ts+++ b/apps/web/src/features/agents-view/primitives/open-page.test.ts@@ -8,7 +8,11 @@ describe('openAgentsPage', () => {const replace = vi.fn(({ next }: { next: SplitContent }) => {content = next;});- const openWithSplit = vi.fn(() => ({ content: () => content, replace }));+ const openWithSplit = vi.fn(() => ({+ status: 'reused',+ owner: 'agents',+ split: { content: () => content, replace },+ }));// Only the navigation handle's content and replace capabilities are exercised.const layout = { openWithSplit } as unknown as Parameters<typeof openAgentsPage@@ -26,7 +30,10 @@ describe('openAgentsPage', () => {it('allows navigation to be intercepted', () => {expect(() =>- openAgentsPage({ openWithSplit: () => undefined }, 'connections')+ openAgentsPage(+ { openWithSplit: () => ({ status: 'unavailable' }) },+ 'connections'+ )).not.toThrow();});});diff --git a/apps/web/src/features/agents-view/primitives/open-page.ts b/apps/web/src/features/agents-view/primitives/open-page.tsindex 7d0f39b7d9..e8f37f8056 100644--- a/apps/web/src/features/agents-view/primitives/open-page.ts+++ b/apps/web/src/features/agents-view/primitives/open-page.ts@@ -12,7 +12,7 @@ export function openAgentsPage(preserveParams: true,params: { agentPage: page, agentPageRequest: crypto.randomUUID() },};- const split = layout.openWithSplit(content, { activate: true });+ const split = layout.openWithSplit(content, { activate: true }).split;if (!split) return;const current = split.content();if (diff --git a/apps/web/src/features/agents-view/views/AgentsView.tsx b/apps/web/src/features/agents-view/views/AgentsView.tsxindex 587339ca3a..d2d868cee8 100644--- a/apps/web/src/features/agents-view/views/AgentsView.tsx+++ b/apps/web/src/features/agents-view/views/AgentsView.tsx@@ -224,18 +224,17 @@ function AgentsWorkspace(props: { initialRoute?: AgentsRoute }) {type: 'component' as const,id: agentsRouteId({ mode: targetMode, conversation }),};- if (event?.shiftKey) {- layout.openWithSplit(next, {- preferNewSplit: true,- referredFrom: 'agents',- });- return;- }- if (panel.handle.content().id === next.id) {+ if (!event?.shiftKey && panel.handle.content().id === next.id) {setSelected({ conversation, activeConversationId: conversation.id });return;}- panel.handle.replace({ next, referredFrom: 'agents' });+ const result = layout.openWithSplit(next, {+ preferNewSplit: event?.shiftKey,+ referredFrom: 'agents',+ });+ if (result.status === 'reused' && result.owner !== result.sourceOwner) {+ toast.alert('Content already open');+ }};const startConversation = (start: StartConversation) => {const id = startPendingSession({diff --git a/apps/web/src/features/block-md/component/ComposeTask.tsx b/apps/web/src/features/block-md/component/ComposeTask.tsxindex 9014dfeca0..4f542dcbd7 100644--- a/apps/web/src/features/block-md/component/ComposeTask.tsx+++ b/apps/web/src/features/block-md/component/ComposeTask.tsx@@ -655,7 +655,7 @@ export function ComposeTask(props: ComposeTaskProps) {const split = openWithSplit({ type: 'component', id: 'loading' },{ referredFrom: 'launcher', preferNewSplit: true }- );+ ).split;const createdTask = await createTaskWithProperties(taskTitle,diff --git a/apps/web/src/features/channels-view/channels-view-context.test.tsx b/apps/web/src/features/channels-view/channels-view-context.test.tsxindex cee170d9bd..c2308d4f51 100644--- a/apps/web/src/features/channels-view/channels-view-context.test.tsx+++ b/apps/web/src/features/channels-view/channels-view-context.test.tsx@@ -14,6 +14,7 @@ const entry = vi.hoisted(() => ({const touch = vi.hoisted(() => ({ value: false }));const guard = vi.hoisted(() => ({selections: [] as unknown[],+ reasons: [] as unknown[],allow: true,}));@@ -22,8 +23,9 @@ vi.mock('@core/mobile/isTouchDevice', () => ({isTouchDevice: () => touch.value,}));vi.mock('@components/app/createPreviewSelectionGuard', () => ({- createPreviewSelectionGuard: () => (selection: unknown) => {+ createPreviewSelectionGuard: () => (selection: unknown, reason: unknown) => {guard.selections.push(selection);+ guard.reasons.push(reason);return selection === undefined || guard.allow;},}));@@ -59,6 +61,7 @@ beforeEach(() => {entry.captors.clear();touch.value = false;guard.selections = [];+ guard.reasons = [];guard.allow = true;});afterEach(cleanup);@@ -78,6 +81,7 @@ describe('ChannelsViewProvider preview selection', () => {expect(first.context.state.selectedChannelId).toBe('c1');expect(first.context.previewChannelId()).toBeUndefined();+ expect(guard.reasons.at(-1)).toBe('restore');// Unrelated preference writes must retain the blocked selection too.first.context.setGroupOpen('channels', false);expect(JSON.parse(localStorage.getItem(storageKey)!)).toMatchObject(@@ -103,6 +107,7 @@ describe('ChannelsViewProvider preview selection', () => {guard.allow = true;context.setSelectedChannelId('c1');expect(context.previewChannelId()).toBe('c1');+ expect(guard.reasons.at(-1)).toBe('navigate');guard.allow = false;context.setSelectedChannelId('c2');diff --git a/apps/web/src/features/channels-view/channels-view-context.tsx b/apps/web/src/features/channels-view/channels-view-context.tsxindex 1df5ad262b..364962d2bc 100644--- a/apps/web/src/features/channels-view/channels-view-context.tsx+++ b/apps/web/src/features/channels-view/channels-view-context.tsx@@ -1,3 +1,4 @@+import type { NavigationStackChangeReason } from '@app/components/navigation-stack/NavigationStack';import { makePersistedState } from '@app/lib/persistence';import { createPreviewSelectionGuard } from '@components/app/createPreviewSelectionGuard';import { useSplitPanelOrThrow } from '@components/app/split-layout/layoutUtils';@@ -95,18 +96,21 @@ export const [ChannelsViewProvider, useChannelsView] =const mobileLayout = () => isTouchDevice();const selectPreview = createPreviewSelectionGuard();const [previewChannelId, setPreviewChannelId] = createSignal<string>();- const setSelectedChannelId = (id: string | undefined) => {+ const setSelectedChannelId = (+ id: string | undefined,+ reason: NavigationStackChangeReason = 'navigate'+ ) => {// The mobile layout keeps the selection for row highlighting only, so// there is no preview to claim.const preview =id && !mobileLayout() ? { type: 'channel' as const, id } : undefined;- if (!selectPreview(preview)) return;+ if (!selectPreview(preview, reason)) return;setPreviewChannelId(preview?.id);setState('selectedChannelId', id);};// Keep restored selection in persistence even if another view currently// owns its preview. It can be retried on selection or the next mount.- setSelectedChannelId(state.selectedChannelId);+ setSelectedChannelId(state.selectedChannelId, 'restore');return {state,diff --git a/apps/web/src/features/command/CommandMenu.tsx b/apps/web/src/features/command/CommandMenu.tsxindex f829165dad..3854fd06bf 100644--- a/apps/web/src/features/command/CommandMenu.tsx+++ b/apps/web/src/features/command/CommandMenu.tsx@@ -5,6 +5,7 @@ import { getSearchSplit } from '@app/features/next-soup/soup-view/search-controlimport { useAnalytics } from '@app/lib/analytics/analytics-context';import { globalSplitManager } from '@app/signal/splitLayout';import { useSplitLayout } from '@components/app/split-layout/layout';+import { toast } from '@core/component/Toast/Toast';import { itemToBlockName } from '@core/constant/allBlocks';import { USE_MACRO_PR_SUMMARY_BLOCK } from '@core/constant/featureFlags';import { getActiveCommandsFromScope } from '@core/hotkey/getCommands';@@ -282,10 +283,19 @@ export function CommandMenuInner(props: {if (isEntityItem(item)) {if (isGithubPrEntity(item.data)) {if (USE_MACRO_PR_SUMMARY_BLOCK) {- openWithSplit(+ const result = openWithSplit({ type: 'pr', id: item.data.id },- { referredFrom: 'kommand-menu', preferNewSplit: openInNewSplit }+ {+ referredFrom: 'kommand-menu',+ preferNewSplit: openInNewSplit,+ });+ if (+ result.status === 'reused' &&+ result.owner !== result.sourceOwner+ ) {+ toast.alert('Content already open');+ }} else {openExternalUrl(item.data.metadata.url);}@@ -297,7 +307,7 @@ export function CommandMenuInner(props: {if (item.data.type !== 'foreign') {const blockName = itemToBlockName(item.data);if (blockName) {- openWithSplit(+ const result = openWithSplit({ type: blockName, id: item.id },{referredFrom: 'kommand-menu',@@ -305,6 +315,12 @@ export function CommandMenuInner(props: {reopen: blockName === 'channel' ? 'latest' : undefined,});+ if (+ result.status === 'reused' &&+ result.owner !== result.sourceOwner+ ) {+ toast.alert('Content already open');+ }}}CommandState.close();diff --git a/apps/web/src/features/command/FavoritesCommands.tsx b/apps/web/src/features/command/FavoritesCommands.tsxindex c9c01c8dda..15e6939637 100644--- a/apps/web/src/features/command/FavoritesCommands.tsx+++ b/apps/web/src/features/command/FavoritesCommands.tsx@@ -4,6 +4,7 @@ import {useFavoriteDisplayName,} from '@app/util/favorites';import { useSplitLayout } from '@components/app/split-layout/layout';+import { toast } from '@core/component/Toast/Toast';import { createHotkeyGroup, registerHotkey } from '@core/hotkey/hotkeys';import { registerScope } from '@core/hotkey/utils';import Star from '@phosphor/star.svg';@@ -36,9 +37,12 @@ export function FavoritesCommands() {const { openWithSplit } = useSplitLayout();const openFavorite = (favorite: Favorite) => {- openWithSplit(favoriteSplitContent(favorite), {+ const result = openWithSplit(favoriteSplitContent(favorite), {referredFrom: 'kommand-menu',});+ if (result.status === 'reused' && result.owner !== result.sourceOwner) {+ toast.alert('Content already open');+ }// Close the menu and clear the query once a favorite is opened.CommandState.close();CommandState.setQuery('');diff --git a/apps/web/src/features/command/Launcher.tsx b/apps/web/src/features/command/Launcher.tsxindex b2dd49df78..feec61a863 100644--- a/apps/web/src/features/command/Launcher.tsx+++ b/apps/web/src/features/command/Launcher.tsx@@ -165,20 +165,15 @@ const createBlock = async (spec: {setCreateMenuOpen(false, false);- // WORKAROUND: On mobile, the navigation interceptor in createMobileSwipeLayout- // consumes openWithSplit calls and returns undefined instead of a SplitHandle.- // This means we can't show a loading spinner then replace it via split.replace(),- // because we never get a handle back. Instead, on mobile we skip the loading state- // and navigate directly to the created block after the async creation completes.- // If the mobile navigation interceptor is refactored to return handles, this- // workaround can be removed and both paths can use the loading-then-replace flow.+ // On mobile, navigate directly after creation instead of showing an+ // intermediate loading pane during the swipe transition.const showLoadingFirst = loading && !isMobile();const split = showLoadingFirst? openWithSplit({ type: 'component', id: 'loading' },{ referredFrom: 'launcher', preferNewSplit: spec.shouldInsert }- )+ ).split: undefined;const id = await createFn();diff --git a/apps/web/src/features/drive-view/drive-host-actions.ts b/apps/web/src/features/drive-view/drive-host-actions.tsindex 04431d6617..41ce945704 100644--- a/apps/web/src/features/drive-view/drive-host-actions.ts+++ b/apps/web/src/features/drive-view/drive-host-actions.ts@@ -15,6 +15,7 @@ import { useHandleFileUpload } from '@app/util/handleFileUpload';import { useGlobalNotificationSource } from '@components/app/GlobalAppState';import { useSplitLayout } from '@components/app/split-layout/layout';import { useSplitPanelOrThrow } from '@components/app/split-layout/layoutUtils';+import { toast } from '@core/component/Toast/Toast';import { useUserId } from '@core/context/user';import { isTouchDevice } from '@core/mobile/isTouchDevice';import {@@ -130,10 +131,13 @@ export function createDriveHostActions(options: {}}- layout.openWithSplit(favoriteSplitContent(favorite), {+ const result = layout.openWithSplit(favoriteSplitContent(favorite), {referredFrom: 'sidebar',preferNewSplit: event.shiftKey,});+ if (result.status === 'reused' && result.owner !== result.sourceOwner) {+ toast.alert('Content already open');+ }},openFolderInNewSplit: (folder) => {diff --git a/apps/web/src/features/favorites/FavoriteContextMenu.tsx b/apps/web/src/features/favorites/FavoriteContextMenu.tsxindex c1146f7bc3..b7512e4ec1 100644--- a/apps/web/src/features/favorites/FavoriteContextMenu.tsx+++ b/apps/web/src/features/favorites/FavoriteContextMenu.tsx@@ -30,7 +30,7 @@ export function FavoriteContextMenu(props: FavoriteContextMenuProps) {referredFrom: 'sidebar',activate: true,preferNewSplit,- });+ }).split;globalSplitManager()?.returnFocus();return split;};diff --git a/apps/web/src/features/favorites/sidebar/favorites-section.tsx b/apps/web/src/features/favorites/sidebar/favorites-section.tsxindex fed9cd34cf..2148106bd1 100644--- a/apps/web/src/features/favorites/sidebar/favorites-section.tsx+++ b/apps/web/src/features/favorites/sidebar/favorites-section.tsx@@ -21,6 +21,7 @@ import {MenuSeparator,} from '@core/component/ContextMenu';import type { EntityIconSelector } from '@core/component/EntityIcon';+import { toast } from '@core/component/Toast/Toast';import {enableGraphqlSoup,isFeatureEnabled,@@ -393,11 +394,15 @@ const FavoriteRow = (props: {};const openFavorite = (preferNewSplit: boolean) => {- const split = layout.openWithSplit(content(), {+ const result = layout.openWithSplit(content(), {referredFrom: 'sidebar',activate: true,preferNewSplit,});+ if (result.status === 'reused' && result.owner !== result.sourceOwner) {+ toast.alert('Content already open');+ }+ const split = result.split;globalSplitManager()?.returnFocus();return split;};diff --git a/apps/web/src/features/next-soup/utils.test.ts b/apps/web/src/features/next-soup/utils.test.tsindex be1863f58a..85921e4804 100644--- a/apps/web/src/features/next-soup/utils.test.ts+++ b/apps/web/src/features/next-soup/utils.test.ts@@ -151,14 +151,46 @@ describe('agent session search navigation', () => {};expect(getRowClickFallbackLocation(titleOnly)).toBeUndefined();});+ it.each([+ { status: 'opened', notify: false },+ { status: 'unavailable', notify: false },+ { status: 'reused', owner: 'existing', sourceOwner: 'list', notify: true },+ {+ status: 'reused',+ owner: 'existing',+ sourceOwner: 'existing',+ notify: false,+ },+ ])(+ 'owns the toast policy for $status from $sourceOwner',+ async ({ notify, ...result }) => {+ const openWithSplit = vi.fn(() => result);+ setGlobalSplitManager({+ activeSplit: () => undefined,+ getOrchestrator: () => ({+ getBlockHandle: vi.fn(async () => undefined),+ }),+ openWithSplit,+ } as unknown as SplitManager);+ await openEntityInSplitFromUnifiedList(entity, {});+ expect(openWithSplit).toHaveBeenCalledOnce();+ if (notify)+ expect(toastAlert).toHaveBeenCalledExactlyOnceWith(+ 'Content already open'+ );+ else expect(toastAlert).not.toHaveBeenCalled();+ }+ );+it('opens the agent block with durable params and retargets it on each snippet click', async () => {- const openWithSplit = vi.fn();+ const openWithSplit = vi.fn(() => ({ status: 'unavailable' }));const goToLocationFromParams = vi.fn();const getBlockHandle = vi.fn(async () => ({ goToLocationFromParams }));setGlobalSplitManager({activeSplit: () => undefined,getOrchestrator: () => ({ getBlockHandle }),getSplitByContent: vi.fn(),+ findOpenView: vi.fn(),openWithSplit,} as unknown as SplitManager);await openEntityInSplitFromUnifiedList(entity, {});@@ -304,13 +336,14 @@ describe('mark-done orchestration', () => {describe('calendar block navigation', () => {it('opens and targets the singleton calendar block', async () => {- const openWithSplit = vi.fn();+ const openWithSplit = vi.fn(() => ({ status: 'unavailable' }));const goToLocationFromParams = vi.fn();const getBlockHandle = vi.fn(async () => ({ goToLocationFromParams }));setGlobalSplitManager({activeSplit: vi.fn(),getOrchestrator: vi.fn(() => ({ getBlockHandle })),getSplitByContent: vi.fn(),+ findOpenView: vi.fn(),openWithSplit,} as unknown as SplitManager);@@ -433,13 +466,14 @@ describe('getChannelEntityTarget', () => {it('marks attached channel notifications through the shared split-open path', async () => {const notification = sendNotification('shared-open', 'message');- const openWithSplit = vi.fn();+ const openWithSplit = vi.fn(() => ({ status: 'unavailable' }));setGlobalSplitManager({activeSplit: vi.fn(),getOrchestrator: vi.fn(() => ({getBlockHandle: vi.fn(async () => undefined),})),getSplitByContent: vi.fn(),+ findOpenView: vi.fn(),openWithSplit,} as unknown as SplitManager);@@ -465,7 +499,7 @@ describe('getChannelEntityTarget', () => {const unread = sendNotification('mobile-unread', 'message');const read = asRead(sendNotification('mobile-read', 'read-message'));const reply = replyNotification('mobile-reply', 'reply', 'thread-root');- const openWithSplit = vi.fn();+ const openWithSplit = vi.fn(() => ({ status: 'unavailable' }));setGlobalSplitManager({activeSplit: vi.fn(),getOrchestrator: vi.fn(() => ({@@ -546,7 +580,8 @@ describe('getChannelEntityTarget', () => {getBlockHandle: vi.fn(async () => undefined),})),getSplitByContent: vi.fn(),- openWithSplit: vi.fn(),+ findOpenView: vi.fn(),+ openWithSplit: vi.fn(() => ({ status: 'unavailable' })),} as unknown as SplitManager);const bulkMarkAsRead = vi.fn(async () => {});diff --git a/apps/web/src/features/next-soup/utils.ts b/apps/web/src/features/next-soup/utils.tsindex 75ba070143..2694d2fc0e 100644--- a/apps/web/src/features/next-soup/utils.ts+++ b/apps/web/src/features/next-soup/utils.ts@@ -589,7 +589,7 @@ export const openEntityInSplitFromUnifiedList = async (if (isGithubPrEntity(entity)) {if (USE_MACRO_PR_SUMMARY_BLOCK) {- splitManager.openWithSplit(+ const result = splitManager.openWithSplit({ type: 'pr', id: entity.id },{referredFrom: options.referredFrom,@@ -599,6 +599,9 @@ export const openEntityInSplitFromUnifiedList = async (mergeHistory,});+ if (result.status === 'reused' && result.owner !== result.sourceOwner) {+ toast.alert('Content already open');+ }} else {openExternalUrl(entity.metadata.url);}@@ -687,7 +690,7 @@ export const openEntityInSplitFromUnifiedList = async (splitContent = withListNavigationSource(splitContent, splitHandle);}- splitManager.openWithSplit(splitContent, {+ const result = splitManager.openWithSplit(splitContent, {referredFrom,activate: true,preferNewSplit: openInNewSplit,@@ -699,6 +702,9 @@ export const openEntityInSplitFromUnifiedList = async (? 'latest': undefined,});+ if (result.status === 'reused' && result.owner !== result.sourceOwner) {+ toast.alert('Content already open');+ }// Navigate to specific location if providedif (location) {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.tsnew file mode 100644index 0000000000..7a736d77e4--- /dev/null+++ b/apps/web/src/features/notifications/tests/channel-notification-navigation.test.ts@@ -0,0 +1,178 @@+import { createSplitLayout } from '@components/app/split-layout/layoutManager';+import { toast } from '@core/component/Toast/Toast';+import type { BlockOrchestrator } from '@core/orchestrator';+import { createRoot } from 'solid-js';+import { beforeEach, expect, it, onTestFinished, vi } from 'vitest';+import { openNotification } from '../notification-navigation';+import type { UnifiedNotification } from '../types';++vi.mock('@app/signal/splitLayout', () => ({+ globalSplitManager: () => undefined,+}));+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('@block-calendar/calendar-range', () => ({+ createCalendarBlockRange: vi.fn(),+}));+vi.mock('@core/constant/allBlocks', () => ({+ isBlockAlias: () => false,+ itemToBlockName: (value: { fileType: string }) => value.fileType,+ resolveBlockAlias: (type: string) => type,+}));++beforeEach(() => vi.clearAllMocks());+vi.mock('@core/constant/featureFlags', () => ({+ enableCalendarUi: false,+ enableReminders: false,+ isFeatureEnabled: vi.fn(),+ USE_MACRO_PR_SUMMARY_BLOCK: true,+}));+vi.mock('@core/util/url', () => ({ openExternalUrl: vi.fn() }));+vi.mock('@queries/notification/user-notifications', () => ({+ getNotificationById: vi.fn(),+}));+vi.mock('@queries/reminders/reminders', () => ({ getReminderById: vi.fn() }));+vi.mock('../notification-resolvers', () => ({+ DefaultNotificationBlockNameResolver: vi.fn(),+}));+vi.mock('../notification-helpers', () => ({+ isChannelNotification: (notification: UnifiedNotification) =>+ [+ 'channel_message_send',+ 'channel_message_reply',+ 'channel_mention',+ ].includes(notification.notification_metadata.tag),+}));+vi.mock('../notification-source', () => ({+ CHANNEL_EVENT_TYPES: [+ 'channel_mention',+ 'channel_message_send',+ 'channel_message_reply',+ 'document_mention',+ ],+}));+vi.mock('../notification-stacking', () => ({+ getMostRecentNotification: vi.fn(),+ stackNotifications: vi.fn(),+}));++function setup(location: 'preview' | 'split' | 'closed') {+ const navigate = vi.fn();+ const createBlockInstance = vi.fn(() => ({+ element: undefined,+ dispose: vi.fn(),+ detach: vi.fn(),+ }));+ const orchestrator = {+ createBlockInstance,+ getBlockHandle: async () => ({ goToLocationFromParams: navigate }),+ } as unknown as BlockOrchestrator;+ const layout = createRoot((dispose) => {+ onTestFinished(dispose);+ return createSplitLayout(orchestrator, [+ location === 'split'+ ? { type: 'channel', id: 'channel' }+ : { type: 'component', id: 'channels' },+ { type: 'component', id: 'inbox' },+ ]);+ });+ const [first, other] = layout.splits();+ layout.activateSplit(other.id);+ const activate = vi.fn(() => layout.activateSplit(first.id));+ const release = layout.registerOpenViews(() =>+ location === 'preview'+ ? [+ {+ owner: 'chat',+ content: { type: 'channel', id: 'channel' },+ activate,+ },+ ]+ : []+ );+ return { layout, activate, navigate, release, createBlockInstance, first };+}++it.each([+ 'channel_message_send',+ 'channel_message_reply',+ 'channel_mention',+] as const)(+ 'reuses the Chat preview for %s and navigates to the notification target',+ async (tag) => {+ const { layout, activate, navigate, release, createBlockInstance, first } =+ setup('preview');+ const notification = {+ entity_id: 'channel',+ notification_metadata: {+ tag,+ content: { messageId: 'message', threadId: 'thread' },+ },+ } as UnifiedNotification;++ const result = await openNotification(notification, layout);++ expect(result.isOk()).toBe(true);+ expect(activate).toHaveBeenCalledOnce();+ expect(layout.activeSplitId()).toBe(first.id);+ expect(createBlockInstance).not.toHaveBeenCalled();+ expect(toast.alert).not.toHaveBeenCalled();+ expect(navigate).toHaveBeenCalledWith({+ channel_message_id: 'message',+ ...(tag === 'channel_message_send'+ ? {}+ : { channel_thread_id: 'thread' }),+ });++ release();+ await openNotification(notification, layout);+ expect(createBlockInstance).toHaveBeenCalledOnce();+ }+);++it.each(['channel_invite', 'call_started'] as const)(+ 'activates the existing preview for %s without opening a split',+ async (tag) => {+ const { layout, activate, navigate, createBlockInstance } =+ setup('preview');+ await openNotification(+ {+ entity_id: 'channel',+ notification_metadata: { tag, content: {} },+ } as UnifiedNotification,+ layout+ );++ expect(activate).toHaveBeenCalledOnce();+ expect(createBlockInstance).not.toHaveBeenCalled();+ expect(toast.alert).not.toHaveBeenCalled();+ expect(navigate).not.toHaveBeenCalled();+ }+);++it.each(['split', 'closed'] as const)(+ 'preserves notification navigation when the channel is %s',+ async (location) => {+ const { layout, navigate, createBlockInstance, first } = setup(location);+ await openNotification(+ {+ entity_id: 'channel',+ notification_metadata: {+ tag: 'channel_message_send',+ content: { messageId: 'message' },+ },+ } as UnifiedNotification,+ layout+ );++ expect(createBlockInstance).toHaveBeenCalledOnce();+ if (location === 'split') expect(layout.activeSplitId()).toBe(first.id);+ expect(toast.alert).not.toHaveBeenCalled();+ expect(navigate).toHaveBeenCalledWith({ channel_message_id: 'message' });+ }+);diff --git a/apps/web/src/features/tasks-view/components/TasksSidebar.tsx b/apps/web/src/features/tasks-view/components/TasksSidebar.tsxindex 98d5c500ba..3accf4533d 100644--- a/apps/web/src/features/tasks-view/components/TasksSidebar.tsx+++ b/apps/web/src/features/tasks-view/components/TasksSidebar.tsx@@ -12,6 +12,7 @@ import {} from '@app/util/favorites';import { useSplitLayout } from '@components/app/split-layout/layout';import { useSplitPanelOrThrow } from '@components/app/split-layout/layoutUtils';+import { toast } from '@core/component/Toast/Toast';import CheckSquareIcon from '@phosphor/check-square.svg';import ListChecksIcon from '@phosphor/list-checks.svg';import NoteIcon from '@phosphor/note-pencil.svg';@@ -98,10 +99,13 @@ function TaskFavorites(props: {) => {if (openTask({ id: favorite.entityId, fallbackName }, { event })) return;- layout.openWithSplit(favoriteSplitContent(favorite), {+ const result = layout.openWithSplit(favoriteSplitContent(favorite), {referredFrom: 'sidebar',preferNewSplit: event.shiftKey,});+ if (result.status === 'reused' && result.owner !== result.sourceOwner) {+ toast.alert('Content already open');+ }};return (diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/component/core/BlockLink.test.tsx b/apps/web/src/lib/core/component/LexicalMarkdown/component/core/BlockLink.test.tsxnew file mode 100644index 0000000000..7893bab8ff--- /dev/null+++ b/apps/web/src/lib/core/component/LexicalMarkdown/component/core/BlockLink.test.tsx@@ -0,0 +1,112 @@+import { openEntityInSplit } from '@app/features/activity/open-entity-in-split';+import {+ createSplitLayout,+ type SplitManager,+} from '@components/app/split-layout/layoutManager';+import { toast } from '@core/component/Toast/Toast';+import type { BlockOrchestrator } from '@core/orchestrator';+import { createRoot } from 'solid-js';+import { beforeEach, expect, it, onTestFinished, vi } from 'vitest';+import { openDocument } from './BlockLink';++const app = vi.hoisted(() => ({+ manager: undefined as SplitManager | undefined,+ orchestrator: undefined as BlockOrchestrator | undefined,+}));+vi.mock('@components/app/GlobalAppState', () => ({+ useGlobalBlockOrchestrator: () => app.orchestrator,+}));+vi.mock('@components/app/split-layout/layout', () => ({+ useSplitLayout: () => app.manager,+}));+vi.mock('@components/app/split-layout/componentRegistry', () => ({+ resolveComponent: () => ({ element: undefined }),+}));+vi.mock('@core/block', () => ({ useMaybeBlockId: () => undefined }));+vi.mock('@core/constant/allBlocks', () => ({+ isBlockAlias: () => false,+ resolveBlockAlias: (type: string) => type,+ fileTypeToBlockName: (type: string) => type,+}));+vi.mock('@core/component/Toast/Toast', () => ({ toast: { alert: vi.fn() } }));+vi.mock('@core/util/useSplitNavigationHandler', () => ({+ useSplitNavigationHandler: vi.fn(),+}));++beforeEach(() => vi.clearAllMocks());++function setup() {+ const navigate = vi.fn();+ const latest = vi.fn();+ const createBlockInstance = vi.fn();+ const orchestrator = {+ createBlockInstance,+ getBlockHandle: async () => ({+ goToLocationFromParams: navigate,+ goToLatest: latest,+ }),+ } as unknown as BlockOrchestrator;+ const manager = createRoot((dispose) => {+ onTestFinished(dispose);+ return createSplitLayout(orchestrator, [+ { type: 'component', id: 'channels' },+ { type: 'component', id: 'inbox' },+ ]);+ });+ const [chat, inbox] = manager.splits();+ manager.activateSplit(inbox.id);+ const activate = vi.fn(() => manager.activateSplit(chat.id));+ manager.registerOpenViews(() => [+ {+ owner: 'preview',+ content: { type: 'channel', id: 'channel' },+ activate,+ },+ ]);+ app.manager = manager;+ app.orchestrator = orchestrator;+ return {+ manager,+ chat,+ inbox,+ activate,+ navigate,+ latest,+ createBlockInstance,+ };+}++it.each([false, true])(+ 'follows a channel mention into its inline detail (new split intent: %s)',+ async (newSplit) => {+ const { manager, chat, activate, navigate, createBlockInstance } = setup();+ const params = {+ channel_message_id: 'message',+ channel_thread_id: 'thread',+ };++ openDocument('channel', 'channel', params, newSplit);++ await vi.waitFor(() => expect(navigate).toHaveBeenCalledWith(params));+ expect(activate).toHaveBeenCalledOnce();+ expect(manager.activeSplitId()).toBe(chat.id);+ expect(manager.splits()).toHaveLength(2);+ expect(createBlockInstance).not.toHaveBeenCalled();+ expect(toast.alert).not.toHaveBeenCalled();+ }+);++it('keeps latest-message navigation when reusing an open channel', async () => {+ const { latest } = setup();+ openDocument('channel', 'channel');+ await vi.waitFor(() => expect(latest).toHaveBeenCalledOnce());+ expect(toast.alert).not.toHaveBeenCalled();+});++it('orients users when an activity-list selection reuses a previewed channel', () => {+ const { manager, chat, activate } = setup();+ openEntityInSplit({ block: 'channel', id: 'channel', newSplit: true });+ expect(activate).toHaveBeenCalledOnce();+ expect(manager.activeSplitId()).toBe(chat.id);+ expect(toast.alert).toHaveBeenCalledWith('Content already open');+});diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/component/core/BlockLink.tsx b/apps/web/src/lib/core/component/LexicalMarkdown/component/core/BlockLink.tsxindex b37d1f5827..840a57d29a 100644--- a/apps/web/src/lib/core/component/LexicalMarkdown/component/core/BlockLink.tsx+++ b/apps/web/src/lib/core/component/LexicalMarkdown/component/core/BlockLink.tsx@@ -58,7 +58,7 @@ export function openDocument(return;}- openWithSplit(+ const result = openWithSplit({ type: targetBlock, id, params },{preferNewSplit: inNewSplit,@@ -69,6 +69,7 @@ export function openDocument(if (isBlockNameWithLocation(targetBlock)) {openLocation(targetBlock, id, params);}+ return result;}export function BlockLink(diff --git a/apps/web/src/lib/core/contentInstanceRegistry.ts b/apps/web/src/lib/core/contentInstanceRegistry.tsdeleted file mode 100644index 0f624680b5..0000000000--- a/apps/web/src/lib/core/contentInstanceRegistry.ts+++ /dev/null@@ -1,40 +0,0 @@-import type { BlockAlias, BlockName } from './block';-import { resolveBlockAlias } from './constant/allBlocks';--export type ContentIdentity = {- type: BlockName | BlockAlias | 'component';- id: string;-};-export type ContentOwner = object | string | symbol;--export function sameContentIdentity(a: ContentIdentity, b: ContentIdentity) {- if (a.type === 'component' || b.type === 'component') return false;- return (- a.id === b.id && resolveBlockAlias(a.type) === resolveBlockAlias(b.type)- );-}--/** Owned by the app orchestrator; sources include selections before their UI mounts. */-export function createContentInstanceRegistry() {- const sources = new Set<- () => readonly { owner: ContentOwner; content: ContentIdentity }[]- >();- return {- register(- source: () => readonly { owner: ContentOwner; content: ContentIdentity }[]- ) {- sources.add(source);- return () => {- sources.delete(source);- };- },- isOpenElsewhere(content: ContentIdentity, owner?: ContentOwner) {- return [...sources].some((source) =>- source().some(- (entry) =>- entry.owner !== owner && sameContentIdentity(entry.content, content)- )- );- },- };-}diff --git a/apps/web/src/lib/core/orchestrator.tsx b/apps/web/src/lib/core/orchestrator.tsxindex 831c8558d1..5ebcb5678c 100644--- a/apps/web/src/lib/core/orchestrator.tsx+++ b/apps/web/src/lib/core/orchestrator.tsx@@ -23,7 +23,6 @@ import {import type { BlockMethodsFor } from './blockMethodRegistry';import { LoadingBlock } from './component/LoadingBlock';import { blocks as BLOCK_REGISTRY } from './constant/allBlocks';-import { createContentInstanceRegistry } from './contentInstanceRegistry';import { BlockEffectRunner } from './internal/BlockEffectRunner';import { BlockLoader } from './internal/BlockLoader';import type { Source } from './source';@@ -311,7 +310,6 @@ type CreateBlockInstanceFn = () => BlockInstance;export type BlockOrchestrator = {- contentInstances: ReturnType<typeof createContentInstanceRegistry>;/** Whether a managed block is currently mounted in any surface. */isBlockMounted: (type: BlockName, id: string) => boolean;/** Get a publicly accessible handle to a block instance */@@ -491,7 +489,6 @@ export function createBlockOrchestrator(): BlockOrchestrator {}return {- contentInstances: createContentInstanceRegistry(),isBlockMounted: (type, id) =>instances.get(keyOf(type, id))?.isMounted() ?? false,getBlockHandle,diff --git a/docs/AGENT_GUIDE/channels.md b/docs/AGENT_GUIDE/channels.mdindex 0f03e00429..6c4e045247 100644--- a/docs/AGENT_GUIDE/channels.md+++ b/docs/AGENT_GUIDE/channels.md@@ -314,6 +314,11 @@ records `path` (`catch_up` or `full`) and `reason`## Chat navigation rail+Following a channel mention or browser notification for the conversation already+shown in Chat activates that workspace and jumps to the targeted message or reply. It keeps+the existing preview and does not show a **Content already open** toast. The+same applies to a channel preview in Home; a closed channel opens normally.+The title bar's **Hide navigation** control hides the whole rail. Reopen it with**Show navigation** (the hamburger) immediately before the conversation title,or in the Chat header when no conversation is selected. Chat remembers thisdiff --git a/docs/AGENT_GUIDE/navigation.md b/docs/AGENT_GUIDE/navigation.mdindex c5daa81337..252a11ccfa 100644--- a/docs/AGENT_GUIDE/navigation.md+++ b/docs/AGENT_GUIDE/navigation.md@@ -97,9 +97,9 @@ Unmodified clicks keep each surface’s default (same split, preview, or new splExisting-content deduplication and split-capacity limits still apply; touch devicescontinue to navigate in place.-A block mounted in an inline preview cannot also open in a split. An attempt-shows `Content already open.` and keeps the preview in place. Select another-preview item or leave that view before opening the block in a split. Duplicate+A block mounted in an inline detail is reused when opened elsewhere. Mentions+and notifications activate its host without a toast; explicit list or Cmd+K+selection shows `Content already open` to explain the move. Duplicatemounts reached through direct layout paths show the same message instead of asecond block instance.@@ -163,7 +163,11 @@ to Home's starting pane without creating a chat. Email and Tasks use the samepill styling and top placement for **New email** and **New task**, replacingthe sidebar title bars. When multiple desktop splits are open, a **Close** (X)button appears beside each sidebar's New button and closes that split. The last-logical split has no close button; mobile chrome is unchanged.+logical split has no sidebar close button; mobile chrome is unchanged.+A lone non-list content split still shows a header X labeled **Return to list**,+which returns that split to the most recent list in its history, preserving+that list’s state. If there is no prior list, it replaces the current entry with+inbox. Excluded background panels do not count toward close eligibility.These buttons and Home items activate on primary-buttonpress; keyboard activation remains supported. Home, Chat, Email,Tasks, and other views using the shared inner@@ -380,15 +384,29 @@ create a session before the user sends. Repeating it focuses the existing draft.Splits navigate independently. The retired Preview Pair mode no longer createsan adjacent viewer, redirects list navigation, or links split sizes and history.Inline details in workspaces continue to use their own navigation stack.+Split back/forward navigation skips entries whose entities are open elsewhere,+without moving focus or showing a toast. Those entries remain in history and+become reachable again after their owning view releases them. A direction is+unavailable when no reachable entries remain. Mobile swipe navigation reuses+an already-mounted conversation without losing the other pane.+History controls update when an inline detail claims or releases an entry,+including when the detail closes.+Resetting a split clears its previous history and starts at the default view;+after opening another item, Back returns to that default view.Entity content can be open in only one split or inline preview/detail view at atime. Shell components may have duplicate splits when `allowDuplicate` is enabled.An Agents conversation route counts as the same entity as its agent or chat block.+Following a mention or notification reuses the existing split or inline detail,+activates its workspace, and navigates to any specified location without a toast.+Explicit entity selections from lists or Cmd+K also reuse the existing view, but+show the duplicate-content toast to explain the move. A list whose detail cannot+claim that entity keeps its previous selection and history.Opening an entity already in a split focuses that split when activation isrequested; the sidebar's **Open in new split** also shows a **Content already open** toast.Selecting an entity owned by another view from a detail view leaves the current-detail and navigation history unchanged and shows a **Content already open**-toast. Close or navigate away+detail and navigation history unchanged, focuses the owning view, and shows a+**Content already open** toast. Close or navigate awayfrom the owning view before opening it elsewhere. The same rule applies to mouseselection, keyboard preview navigation, and detail breadcrumbs. Touch layoutsnever render inline previews or detail views: a tap opens the entity in the