Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(navigation): derive rail selection from the active split (#8099)

dev-rb5ea6b4b75b65
diff --git a/apps/web/src/components/app/sidebar-next/list-nav.test.tsx b/apps/web/src/components/app/sidebar-next/list-nav.test.tsx
index 7472a32420..24b098978d 100644
--- a/apps/web/src/components/app/sidebar-next/list-nav.test.tsx
+++ b/apps/web/src/components/app/sidebar-next/list-nav.test.tsx
@@ -1,13 +1,29 @@
+import {
+ createMemoryHistory,
+ createMemoryPaneStore,
+ createSplitRouter,
+ defineRoute,
+ type PaneId,
+ SplitRouter,
+ type SplitRouterOptions,
+} from '@app/lib/split-router';
+import { createTestPolicy } from '@app/lib/split-router/tests/fixtures';
import { cleanup, fireEvent, render, screen } from '@solidjs/testing-library';
-import { createSignal, type JSX, type ParentProps, splitProps } from 'solid-js';
-import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+import {
+ createSignal,
+ type JSX,
+ onCleanup,
+ type ParentProps,
+ splitProps,
+} from 'solid-js';
+import { afterEach, describe, expect, it, vi } from 'vitest';
import { ListNav } from './list-nav';
-import type { SidebarNextNavItem } from './nav-items';
+import { SIDEBAR_NEXT_NAV_ITEMS } from './nav-items';
import { SidebarPrefsProvider } from './use-sidebar-prefs';
const mocks = vi.hoisted(() => ({
- setActiveView: (_view: string) => {},
- activeView: (): string => 'settings',
+ activeContent: (): { type: 'component'; id: string } | undefined => undefined,
+ activePane: (): PaneId | undefined => undefined,
navigate: vi.fn(),
}));
@@ -17,7 +33,8 @@ vi.mock('@app/lib/analytics/analytics-context', () => ({
vi.mock('@app/signal/splitLayout', () => ({
globalSplitManager: () => ({
activeSplit: () => ({
- content: () => ({ type: 'component', id: mocks.activeView() }),
+ id: mocks.activePane(),
+ content: mocks.activeContent,
}),
returnFocus: vi.fn(),
}),
@@ -28,10 +45,10 @@ vi.mock('@components/app/app-sidebar/sidebar', () => ({
SidebarOpenInSplitMenu: (props: ParentProps) => props.children,
}));
vi.mock('@components/app/split-layout/layout', () => ({
- useSplitLayout: () => ({ openWithSplit: vi.fn() }),
-}));
-vi.mock('@solidjs/router', () => ({
- useLocation: () => ({ pathname: '/app' }),
+ useSplitLayout: () => ({
+ openWithSplit: vi.fn(),
+ preloadContent: vi.fn(),
+ }),
}));
vi.mock('@ui', async () => ({
...(await import('@ui/utils/classname')),
@@ -43,58 +60,431 @@ vi.mock('@ui', async () => ({
},
}));
-const Icon = () => <svg aria-hidden="true" />;
-
-const item = (id: string, label: string) =>
- ({
- id,
- label,
- href: `/${id}`,
- icon: Icon,
- iconActive: Icon,
- hotkeyToken: `sidebar.goTo.${id}`,
- }) as unknown as SidebarNextNavItem;
-
-beforeEach(() => {
- vi.useFakeTimers();
- const [activeView, setActiveView] = createSignal('settings');
- mocks.activeView = activeView;
- mocks.setActiveView = setActiveView;
- mocks.navigate.mockReset();
- mocks.navigate.mockImplementation(({ viewId }: { viewId: string }) =>
- setActiveView(viewId)
+const home = SIDEBAR_NEXT_NAV_ITEMS.find((item) => item.id === 'home')!;
+const agents = SIDEBAR_NEXT_NAV_ITEMS.find((item) => item.id === 'agents')!;
+
+function setup(initial = '/home', agentsPreload?: () => Promise<void>) {
+ const history = createMemoryHistory(initial);
+ let router!: ReturnType<typeof createSplitRouter>;
+ let focus!: (pane: PaneId) => void;
+ render(() => {
+ router = createSplitRouter({
+ routes: {
+ definitions: [
+ defineRoute({
+ id: 'app',
+ children: [
+ defineRoute({
+ id: 'home',
+ path: 'home',
+ search: '*',
+ children: [
+ defineRoute({ id: 'home-detail', path: 'detail/:id' }),
+ ],
+ }),
+ defineRoute({ id: 'calendar', path: 'calendar', search: '*' }),
+ defineRoute({
+ id: 'agents',
+ path: 'agents',
+ preload: agentsPreload,
+ }),
+ defineRoute({
+ id: 'agent-detail',
+ path: 'agents/:id',
+ search: '*',
+ }),
+ defineRoute({ id: 'settings', path: 'settings' }),
+ ],
+ }),
+ ],
+ defaultRoute: () => ({
+ matches: [
+ { id: 'app', params: {} },
+ { id: 'home', params: {} },
+ ],
+ }),
+ },
+ history,
+ paneStore: createMemoryPaneStore(),
+ policy: createTestPolicy().policy,
+ } satisfies SplitRouterOptions);
+ const [focusedPane, setFocusedPane] = createSignal(router.panes()[0]!);
+ focus = setFocusedPane;
+ mocks.activePane = focusedPane;
+ mocks.activeContent = () => {
+ const entry = router.entry(focusedPane());
+ const root = entry?.location.route.matches[1];
+ const id =
+ root?.id === 'agent-detail'
+ ? `agents-session~agents~${root.params.id}`
+ : root?.id;
+ return id ? { type: 'component', id } : undefined;
+ };
+ mocks.navigate.mockImplementation(
+ async ({ viewId, shiftKey }: { viewId: string; shiftKey: boolean }) => {
+ const target = {
+ location: {
+ route: {
+ matches: [
+ { id: 'app', params: {} },
+ { id: viewId, params: {} },
+ ],
+ },
+ },
+ } satisfies Parameters<typeof router.navigatePane>[1];
+ const result = await (shiftKey
+ ? router.open(
+ target,
+ { newPane: true, source: focusedPane() },
+ { allowDuplicate: true }
+ )
+ : router.navigatePane(focusedPane(), target, {
+ allowDuplicate: true,
+ }));
+ if (shiftKey && result.status === 'committed')
+ setFocusedPane(result.pane);
+ }
+ );
+ onCleanup(() => router.dispose());
+ return (
+ <SplitRouter.Root router={router}>
+ <SidebarPrefsProvider>
+ <ListNav item={home} />
+ <ListNav item={agents} />
+ <ListNav
+ item={
+ SIDEBAR_NEXT_NAV_ITEMS.find((item) => item.id === 'calendar')!
+ }
+ />
+ </SidebarPrefsProvider>
+ </SplitRouter.Root>
+ );
+ });
+ return { router, history, focus };
+}
+
+function expectSelection(label?: string) {
+ const buttons = screen.getAllByRole('button');
+ const selected = buttons.filter((button) =>
+ button.hasAttribute('data-active')
);
-});
+ expect(selected).toHaveLength(label ? 1 : 0);
+ for (const button of buttons) {
+ const active = button.getAttribute('aria-label') === label;
+ expect(button.hasAttribute('data-active')).toBe(active);
+ expect(button.getAttribute('aria-current')).toBe(active ? 'page' : null);
+ }
+}
+
+function press(label: string) {
+ fireEvent.mouseDown(screen.getByRole('button', { name: label }), {
+ button: 0,
+ });
+}
afterEach(() => {
cleanup();
- vi.useRealTimers();
+ mocks.navigate.mockReset();
});
describe('ListNav', () => {
- it('does not reclaim the highlight when the view it left becomes active again', () => {
- render(() => (
- <SidebarPrefsProvider>
- <ListNav item={item('home', 'Home')} />
- <ListNav item={item('agents', 'Agents')} />
- </SidebarPrefsProvider>
- ));
- const agents = screen.getByRole('button', { name: 'Agents' });
-
- fireEvent.mouseDown(agents, { button: 0 });
- // Optimistic: highlighted before the view swaps in.
- expect(agents.hasAttribute('data-active')).toBe(true);
-
- vi.runAllTimers();
+ it('lets a rapid Home press supersede Agents without losing the current selection', () => {
+ const { router, history } = setup();
+ press('Agents');
+ press('Home');
+
+ expect(mocks.navigate).toHaveBeenCalledTimes(2);
+ expect(
+ router.entry(router.panes()[0]!)?.location.route.matches.at(-1)?.id
+ ).toBe('home');
+ expect(history.read().path).toBe('/home');
+ expectSelection('Home');
+ });
+
+ it('ignores a late Agents preload after Home supersedes it', async () => {
+ let finishPreload!: () => void;
+ const preload = new Promise<void>((resolve) => {
+ finishPreload = resolve;
+ });
+ const { router, history } = setup('/home', () => preload);
+ press('Agents');
+ expect(
+ router.pending(router.panes()[0]!)?.to.location.route.matches.at(-1)?.id
+ ).toBe('agents');
+ expectSelection('Home');
+
+ press('Home');
+ finishPreload();
+ await router.settled();
+ expect(history.read().path).toBe('/home');
+ expect(
+ router.entry(router.panes()[0]!)?.location.route.matches.at(-1)?.id
+ ).toBe('home');
+ expectSelection('Home');
+ });
+
+ it('opens and selects a Shift destination when no later press supersedes it', async () => {
+ const { router, history } = setup();
+ fireEvent.mouseDown(screen.getByRole('button', { name: 'Agents' }), {
+ button: 0,
+ shiftKey: true,
+ });
+ await router.settled();
+
+ expect(router.panes()).toHaveLength(2);
+ expect(history.read().path).toBe('/home/~/agents');
+ expectSelection('Agents');
+ });
+
+ it.each(['Home', 'Calendar'])(
+ 'cancels a pending Shift-open when %s is pressed afterward',
+ async (label) => {
+ let finishPreload!: () => void;
+ const preload = new Promise<void>((resolve) => {
+ finishPreload = resolve;
+ });
+ const { router, history } = setup('/home', () => preload);
+ const original = router.panes()[0]!;
+ fireEvent.mouseDown(screen.getByRole('button', { name: 'Agents' }), {
+ button: 0,
+ shiftKey: true,
+ });
+ expect(router.panes()).toEqual([original]);
+ expectSelection('Home');
+
+ press(label);
+ finishPreload();
+ await router.settled();
+
+ expect(router.panes()).toEqual([original]);
+ expect(history.read().path).toBe(
+ label === 'Home' ? '/home' : '/calendar'
+ );
+ expectSelection(label);
+ }
+ );
+
+ it('preserves a pending new pane requested from another split', async () => {
+ let finishPreload!: () => void;
+ const preload = new Promise<void>((resolve) => {
+ finishPreload = resolve;
+ });
+ const { router, history } = setup('/home/~/settings', () => preload);
+ const [first, second] = router.panes();
+ const original = router.entry(first!);
+ const opening = router.open('/agents', { newPane: true, source: second! });
+
+ press('Home');
+ finishPreload();
+ await opening;
+ await router.settled();
+
+ expect(router.panes()).toHaveLength(3);
+ expect(router.entry(first!)).toBe(original);
+ expect(history.read().path).toBe('/home/~/settings/~/agents');
+ expectSelection('Home');
+ });
+
+ it('preserves a selected nested detail and its search on an idle repeat', () => {
+ const { router, history } = setup(
+ '/home/detail/document?s0.home.tab=signal'
+ );
+ const pane = router.panes()[0]!;
+ const entry = router.entry(pane);
+ const before = router.history(pane);
+
+ press('Home');
+
+ expect(mocks.navigate).not.toHaveBeenCalled();
+ expect(router.entry(pane)).toBe(entry);
+ expect(router.history(pane)).toEqual(before);
+ expect(history.read().path).toBe('/home/detail/document');
+ expect(history.read().search).toBe('?s0.home.tab=signal');
+ expectSelection('Home');
+ });
+
+ it('preserves the selected Agents conversation instead of opening a new conversation', () => {
+ const { router, history } = setup(
+ '/agents/conversation?s0.agents.tab=changes'
+ );
+ const pane = router.panes()[0]!;
+ const entry = router.entry(pane);
+ expectSelection('Agents');
+
+ press('Agents');
+
+ expect(mocks.navigate).not.toHaveBeenCalled();
+ expect(router.entry(pane)).toBe(entry);
+ expect(history.read().path).toBe('/agents/conversation');
+ expect(history.read().search).toBe('?s0.agents.tab=changes');
+ expectSelection('Agents');
+ });
+
+ it.each([
+ ['/home/detail/document?s0.home.tab=signal', 'Home'],
+ ['/calendar?s0.calendar.event=meeting', 'Calendar'],
+ ])(
+ 'preserves %s when a selected %s press supersedes a preload',
+ async (initial, label) => {
+ let finishPreload!: () => void;
+ const preload = new Promise<void>((resolve) => {
+ finishPreload = resolve;
+ });
+ const { router, history } = setup(initial, () => preload);
+ const pane = router.panes()[0]!;
+ const originalEntry = router.entry(pane);
+ const count = router.history(pane)?.entries.length;
+ press('Agents');
+ expect(router.pending(pane)).toBeDefined();
+ expectSelection(label);
+
+ press(label);
+ finishPreload();
+ await router.settled();
+
+ expect(router.entry(pane)).toBe(originalEntry);
+ expect(router.history(pane)?.entries).toHaveLength(count!);
+ expect(router.pending(pane)).toBeUndefined();
+ expect(`${history.read().path}${history.read().search}`).toBe(initial);
+ expectSelection(label);
+ }
+ );
+
+ it('cancels a pending leave guard when the shown workspace is pressed', async () => {
+ const { router, history } = setup(
+ '/home/detail/document?s0.home.tab=signal'
+ );
+ const pane = router.panes()[0]!;
+ let allowLeave!: (allowed: boolean) => void;
+ const guard = new Promise<boolean>((resolve) => {
+ allowLeave = resolve;
+ });
+ router.registerGuard(pane, 1, () => guard);
+ press('Agents');
+ expect(router.pending(pane)).toBeDefined();
+
+ press('Home');
+ allowLeave(true);
+ await router.settled();
+
+ expect(history.read().path).toBe('/home/detail/document');
+ expect(history.read().search).toBe('?s0.home.tab=signal');
+ expectSelection('Home');
+ });
+
+ it('keeps the current view selected when a leave guard refuses navigation', () => {
+ const { router, history } = setup();
+ const pane = router.panes()[0]!;
+ router.registerGuard(pane, 1, () => false);
+ press('Agents');
+
+ expect(mocks.navigate).toHaveBeenCalledOnce();
+ expect(router.entry(pane)?.location.route.matches.at(-1)?.id).toBe('home');
+ expect(history.read().path).toBe('/home');
+ expectSelection('Home');
+ });
+
+ it('tracks history traversal instead of the last pressed destination', () => {
+ const { router, history } = setup();
+ press('Agents');
+ expect(history.read().path).toBe('/agents');
+ expectSelection('Agents');
+
+ history.back();
+ expect(history.read().path).toBe('/home');
+ expect(
+ router.entry(router.panes()[0]!)?.location.route.matches.at(-1)?.id
+ ).toBe('home');
+ expectSelection('Home');
+ history.forward();
+ expect(history.read().path).toBe('/agents');
+ expectSelection('Agents');
+ });
+
+ it('selects the view in the focused split, not the first URL pane', () => {
+ const { router, history, focus } = setup('/home/~/agents');
+ const [first, second] = router.panes();
+ expect(history.read().path).toBe('/home/~/agents');
+ expect(router.entry(first!)?.location.route.matches.at(-1)?.id).toBe(
+ 'home'
+ );
+ expect(router.entry(second!)?.location.route.matches.at(-1)?.id).toBe(
+ 'agents'
+ );
+ expectSelection('Home');
+ focus(second!);
+ expectSelection('Agents');
+ press('Home');
+ expect(history.read().path).toBe('/home/~/home');
+ expect(router.entry(first!)?.location.route.matches.at(-1)?.id).toBe(
+ 'home'
+ );
+ expect(router.entry(second!)?.location.route.matches.at(-1)?.id).toBe(
+ 'home'
+ );
+ expectSelection('Home');
+ focus(first!);
+ press('Agents');
+ expect(history.read().path).toBe('/agents/~/home');
+ expectSelection('Agents');
+ focus(second!);
+ expectSelection('Home');
+ });
+
+ it('leaves another split navigation alone when the shown workspace is pressed', async () => {
+ let finishPreload!: () => void;
+ const preload = new Promise<void>((resolve) => {
+ finishPreload = resolve;
+ });
+ const { router, history } = setup(
+ '/home/detail/document/~/settings?s0.home.tab=signal',
+ () => preload
+ );
+ const [first, second] = router.panes();
+ const entry = router.entry(first!);
+ void router.navigatePane(second!, '/agents');
+ expect(router.pending(second!)).toBeDefined();
+
+ press('Home');
+ finishPreload();
+ await router.settled();
+
+ expect(router.entry(first!)).toBe(entry);
+ expect(router.entry(second!)?.location.route.matches.at(-1)?.id).toBe(
+ 'agents'
+ );
+ expect(history.read().search).toBe('?s0.home.tab=signal');
+ expectSelection('Home');
+ });
+
+ it('handles a pointer press once and still accepts a keyboard-only click', () => {
+ const { router, history } = setup();
+ const agentsButton = screen.getByRole('button', { name: 'Agents' });
+ fireEvent.mouseDown(agentsButton, { button: 0 });
+ fireEvent.click(agentsButton, { button: 0, detail: 1 });
expect(mocks.navigate).toHaveBeenCalledOnce();
- expect(mocks.activeView()).toBe('agents');
- expect(agents.hasAttribute('data-active')).toBe(true);
+ expectSelection('Agents');
+
+ fireEvent.click(screen.getByRole('button', { name: 'Home' }), {
+ button: 0,
+ detail: 0,
+ });
+ expect(mocks.navigate).toHaveBeenCalledTimes(2);
+ expect(history.read().path).toBe('/home');
+ expect(router.history(router.panes()[0]!)?.entries).toHaveLength(3);
+ expectSelection('Home');
+ });
+
+ it('does not reclaim the highlight when Settings becomes active again', () => {
+ const { router, history } = setup('/settings');
+ expectSelection();
+ press('Agents');
+ expect(history.read().path).toBe('/agents');
+ expectSelection('Agents');
// Settings opens from outside the rail list (the gear, a hotkey).
- mocks.setActiveView('settings');
- expect(agents.hasAttribute('data-active')).toBe(false);
- expect(
- screen.getByRole('button', { name: 'Home' }).hasAttribute('data-active')
- ).toBe(false);
+ router.navigatePane(router.panes()[0]!, '/settings');
+ expect(history.read().path).toBe('/settings');
+ expectSelection();
});
});
diff --git a/apps/web/src/components/app/sidebar-next/list-nav.tsx b/apps/web/src/components/app/sidebar-next/list-nav.tsx
index 76349c7357..93cf369b2e 100644
--- a/apps/web/src/components/app/sidebar-next/list-nav.tsx
+++ b/apps/web/src/components/app/sidebar-next/list-nav.tsx
@@ -1,5 +1,6 @@
import { parseAgentsRoute } from '@app/features/agents-view/core/route';
import { useAnalytics } from '@app/lib/analytics/analytics-context';
+import { useSplitRouter } from '@app/lib/split-router';
import { globalSplitManager } from '@app/signal/splitLayout';
import {
navigateToSidebarView,
@@ -10,9 +11,8 @@ import { useSplitLayout } from '@components/app/split-layout/layout';
import { MenuItem, MenuSeparator } from '@core/component/ContextMenu';
import { TOKENS } from '@core/hotkey/tokens';
import PhoneCallIcon from '@phosphor-fill/phone-call-fill.svg';
-import { useLocation } from '@solidjs/router';
import { Button, cn } from '@ui';
-import { createSignal, onCleanup, Show } from 'solid-js';
+import { Show } from 'solid-js';
import { NavGlyph } from './nav-glyph';
import type { SidebarNextNavItem } from './nav-items';
import { SidebarUnreadDot } from './unread-dot';
@@ -27,25 +27,6 @@ export type ListNavProps = {
onContextMenuOpenChange?: (open: boolean) => void;
};
-type PendingNav = {
- itemId: SidebarNextNavItem['id'];
- /** The active split's content when the item was pressed. */
- activeContentKey: string | undefined;
-};
-
-/**
- * The nav item pressed most recently, highlighted before the split layout
- * catches up. Shared across every rail button so only one item is ever
- * pending. It stops applying the moment the active content changes — to the
- * pressed view, or to anything else — so a stale press never sticks.
- */
-const [pendingNav, setPendingNav] = createSignal<PendingNav>();
-
-const activeContentKey = () => {
- const content = globalSplitManager()?.activeSplit()?.content();
- return content ? `${content.type}:${content.id}` : undefined;
-};
-
/**
* A SidebarRail nav button: an icon-only `@ui` Button, plus the behaviour
* behind it — active detection, navigation, shift-click into a new split, the
@@ -62,22 +43,16 @@ export const ListNav = (props: ListNavProps) => {
const { hideSidebarItem } = useSidebarPrefs();
const analytics = useAnalytics();
const layout = useSplitLayout();
- const location = useLocation();
+ const router = useSplitRouter();
const content = () => sidebarContent(props.item.id, props.item.params);
const preload = () => layout.preloadContent(content());
- // Read the manager signal live: it is undefined until the split layout
- // mounts, which happens after the sidebar.
- const matchesActiveContent = () => {
+ // Split content mirrors the router's current entry, including the owning
+ // workspace for nested details. Never infer selection from the multi-pane URL.
+ const isActive = () => {
const activeContent = globalSplitManager()?.activeSplit()?.content();
- // With no active split to match on, fall back to the URL path.
- if (!activeContent) {
- return location.pathname
- .split('/')
- .filter(Boolean)
- .includes(props.item.id);
- }
+ if (!activeContent) return false;
const expected = content();
if (
props.item.id === 'agents' &&
@@ -90,77 +65,29 @@ export const ListNav = (props: ListNavProps) => {
);
};
- // Optimistic: the pressed item takes the highlight on mousedown, before the
- // view swaps in. The pending press only counts while the active content is
- // still what it was at press time; once anything moves, the real state wins.
- const isActive = () => {
- const pending = pendingNav();
- if (pending && pending.activeContentKey === activeContentKey()) {
- return pending.itemId === props.item.id;
- }
- return matchesActiveContent();
- };
-
- // Opening a view is a synchronous store replace plus the new view's first
- // render, all inside the event handler. Painted in the same frame, the
- // highlight would only appear once that render finished. Let the browser
- // paint the pending highlight first, then navigate on the next tick.
- let scheduledFrame: number | undefined;
- let scheduledTick: ReturnType<typeof setTimeout> | undefined;
- const afterNextPaint = (run: () => void) => {
- if (scheduledFrame !== undefined) cancelAnimationFrame(scheduledFrame);
- if (scheduledTick !== undefined) clearTimeout(scheduledTick);
- scheduledFrame = requestAnimationFrame(() => {
- scheduledFrame = undefined;
- scheduledTick = setTimeout(() => {
- scheduledTick = undefined;
- run();
- }, 0);
- });
- };
- onCleanup(() => {
- if (scheduledFrame !== undefined) cancelAnimationFrame(scheduledFrame);
- if (scheduledTick !== undefined) clearTimeout(scheduledTick);
- });
-
const navigate = (event: MouseEvent) => {
// The row acts on mousedown to beat the focus change, so suppress the
// default selection/focus behaviour.
event.preventDefault();
analytics.track('sidebar_click', { view: props.item.id });
- const activeSplit = globalSplitManager()?.activeSplit();
- const activeContent = activeSplit?.content();
- const expected = content();
- const isSameContent =
- activeContent?.type === expected.type && activeContent.id === expected.id;
-
- if (!isSameContent || event.shiftKey) {
- setPendingNav({
- itemId: props.item.id,
- activeContentKey: activeContentKey(),
- });
- const { shiftKey } = event;
- afterNextPaint(() => {
- navigateToSidebarView({
- viewId: props.item.id,
- params: props.item.params,
- shiftKey,
- openWithSplit: layout.openWithSplit,
- referredFrom: 'sidebar',
- });
- // Navigation is synchronous, so the real state now holds. Drop the
- // press: left in place, it would claim the highlight again whenever
- // the active content returned to what it was at press time (e.g.
- // Settings → Agents → Settings would light up Agents).
- setPendingNav((pending) =>
- pending?.itemId === props.item.id ? undefined : pending
- );
- globalSplitManager()?.returnFocus();
+ const split = globalSplitManager()?.activeSplit();
+ const selected = isActive();
+ if (!event.shiftKey) {
+ const pane = router.panes().find((pane) => pane.toString() === split?.id);
+ // A later ordinary press also supersedes a pending Shift-open from this
+ // pane. Cancelling preserves the current entry and split-owned state.
+ if (pane) void router.cancelNavigation(pane);
+ }
+ if (!selected || event.shiftKey) {
+ navigateToSidebarView({
+ viewId: props.item.id,
+ params: props.item.params,
+ shiftKey: event.shiftKey,
+ openWithSplit: layout.openWithSplit,
+ referredFrom: 'sidebar',
});
- return;
}
-
globalSplitManager()?.returnFocus();
};
diff --git a/apps/web/src/lib/split-router/router/create-router.ts b/apps/web/src/lib/split-router/router/create-router.ts
index 248e46a4e5..c11ae9f6c0 100644
--- a/apps/web/src/lib/split-router/router/create-router.ts
+++ b/apps/web/src/lib/split-router/router/create-router.ts
@@ -128,6 +128,12 @@ export function createSplitRouter(options: SplitRouterOptions) {
panes: panes.ids,
navigate: urlNavigation.navigate,
navigatePane: paneNavigation.navigate,
+ /** Cancels pending navigation and new panes requested from this pane. */
+ cancelNavigation: (pane: PaneId) =>
+ runner.act(undefined, () => {
+ runner.abort(pane);
+ paneList.cancelOpeningFrom(pane);
+ }),
updateSearch: paneNavigation.updateSearch,
goBackTo: paneNavigation.goBackTo,
removeEntries: paneNavigation.removeEntries,
diff --git a/apps/web/src/lib/split-router/router/pane-list.ts b/apps/web/src/lib/split-router/router/pane-list.ts
index 3926e59e9e..b337d98c96 100644
--- a/apps/web/src/lib/split-router/router/pane-list.ts
+++ b/apps/web/src/lib/split-router/router/pane-list.ts
@@ -63,7 +63,7 @@ export function createPaneList(options: {
navigation: PaneNavigation;
}) {
const { routes, panes, url, runner, claims, navigation } = options;
- let opening = 0;
+ let opening: { pane: PaneId; source?: PaneId }[] = [];
/** The entry an open's relative target resolves against. */
const openBase = (target: OpenTarget): Entry | undefined => {
@@ -88,7 +88,7 @@ export function createPaneList(options: {
intent: target.intent,
holder,
allowDuplicate: navigateOptions.allowDuplicate,
- opening,
+ opening: opening.length,
});
return { placement, holder };
@@ -122,10 +122,10 @@ export function createPaneList(options: {
*/
function openNew(
location: SplitLocation,
- placement: { insertAt: number; besides?: PaneId },
+ placement: { insertAt: number; besides?: PaneId; source?: PaneId },
navigateOptions: SplitNavigateOptions
): MaybePromise<NavigationResult> {
- const { insertAt, besides } = placement;
+ const { insertAt, besides, source } = placement;
const pane = panes.createPaneId();
const entry = createEntry(routes, location, undefined, navigateOptions);
const decided = panes.ids();
@@ -150,11 +150,11 @@ export function createPaneList(options: {
apply,
};
- opening += 1;
+ opening.push({ pane, source });
const result = runner.start(pane, opened);
return mapMaybe(result, (outcome) => {
- opening -= 1;
+ opening = opening.filter((item) => item.pane !== pane);
return outcome;
});
@@ -238,12 +238,23 @@ export function createPaneList(options: {
return openNew(
location,
- { insertAt, besides: holder },
+ {
+ insertAt,
+ besides: holder,
+ source: 'pane' in target ? undefined : target.source,
+ },
navigateOptions
);
});
},
+ /** Cancel new panes that have not committed yet, without touching open panes. */
+ cancelOpeningFrom(source: PaneId): void {
+ const cancelled = opening.filter((item) => item.source === source);
+ opening = opening.filter((item) => item.source !== source);
+ for (const { pane } of cancelled) runner.abort(pane);
+ },
+
/** Close a pane the way the policy decides; removal waits for leave guards. */
close(pane: PaneId): MaybePromise<boolean> {
return runner.act(false, () => {
diff --git a/docs/agent-guide/navigation.md b/docs/agent-guide/navigation.md
index 856496add5..82526596d1 100644
--- a/docs/agent-guide/navigation.md
+++ b/docs/agent-guide/navigation.md
@@ -364,6 +364,21 @@ Touch devices retain the flag-gated Reviews tab in Tasks.
split (Shift-click for a new split); there is no account menu. Log out lives
at the bottom of the Settings sidebar, and the command menu is `Ctrl K`.
+The rail highlights the workspace shown by the **active split**, not every app
+named in the multi-split URL. Nested details keep their owning workspace selected
+(for example, a thread under Email or a document under Home). Selection changes
+when navigation commits; a pending preload or a refused leave guard does not
+select a destination that is not shown. Pressing the current workspace preserves
+its filters and nested detail; during a pending navigation, the same press
+cancels that navigation without adding a duplicate history step.
+A later ordinary rail press also cancels a new split still preloading from the
+active split's earlier Shift-press. Already-open splits and pending work from
+other splits remain intact.
+Verify rapid app presses, returning to the currently shown app while another app
+loads, split focus changes, closing a split, and split Back/Forward. The last
+requested destination must win, and a later return to an earlier view must not
+revive an old highlight.
+
Start a new AI chat from the Agents workspace; the rail has no separate
new-chat-in-a-new-split button. Its tooltips
use the standard 400 ms hover delay and 300 ms grace period between items. Home,