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.

feat(desktop): add title bar history navigation (#8040)

Eric Hayesc45648d1c637
diff --git a/apps/web/src/components/app/DesktopTitleBar.test.tsx b/apps/web/src/components/app/DesktopTitleBar.test.tsx
new file mode 100644
index 0000000000..e4cef16534
--- /dev/null
+++ b/apps/web/src/components/app/DesktopTitleBar.test.tsx
@@ -0,0 +1,78 @@
+import { setGlobalSplitManager } from '@app/signal/splitLayout';
+import type {
+ SplitHandle,
+ SplitManager,
+} from '@components/app/split-layout/layoutManager';
+import { cleanup, fireEvent, render, screen } from '@solidjs/testing-library';
+import { createSignal, type JSX } from 'solid-js';
+import { afterEach, expect, it, vi } from 'vitest';
+import { DesktopTitleBar } from './DesktopTitleBar';
+
+vi.mock('@ui', () => ({
+ Button: (
+ props: JSX.ButtonHTMLAttributes<HTMLButtonElement> & { label: string }
+ ) => (
+ <button
+ aria-label={props.label}
+ disabled={props.disabled}
+ onClick={props.onClick}
+ >
+ {props.children}
+ </button>
+ ),
+}));
+
+afterEach(() => {
+ cleanup();
+ setGlobalSplitManager(undefined);
+});
+
+it('navigates the active split and disables unavailable directions', () => {
+ const [firstCanGoBack, setFirstCanGoBack] = createSignal(false);
+ const [firstCanGoForward, setFirstCanGoForward] = createSignal(false);
+ const first = {
+ canGoBack: firstCanGoBack,
+ canGoForward: firstCanGoForward,
+ goBack: vi.fn(),
+ goForward: vi.fn(),
+ } as unknown as SplitHandle;
+ const second = {
+ canGoBack: () => true,
+ canGoForward: () => true,
+ goBack: vi.fn(),
+ goForward: vi.fn(),
+ } as unknown as SplitHandle;
+ const [activeSplit, setActiveSplit] = createSignal(first);
+ setGlobalSplitManager({
+ activeSplit,
+ canAppendSplit: () => false,
+ } as unknown as SplitManager);
+
+ render(() => <DesktopTitleBar />);
+ const back = screen.getByRole('button', {
+ name: 'Go Back',
+ }) as HTMLButtonElement;
+ const forward = screen.getByRole('button', {
+ name: 'Go Forward',
+ }) as HTMLButtonElement;
+ expect(back.disabled).toBe(true);
+ expect(forward.disabled).toBe(true);
+
+ setFirstCanGoBack(true);
+ fireEvent.click(back);
+ expect(first.goBack).toHaveBeenCalledOnce();
+ expect(forward.disabled).toBe(true);
+
+ setActiveSplit(second);
+ expect(back.disabled).toBe(false);
+ expect(forward.disabled).toBe(false);
+ fireEvent.click(back);
+ fireEvent.click(forward);
+ expect(second.goBack).toHaveBeenCalledOnce();
+ expect(second.goForward).toHaveBeenCalledOnce();
+ expect(first.goForward).not.toHaveBeenCalled();
+
+ setFirstCanGoForward(true);
+ setActiveSplit(first);
+ expect(forward.disabled).toBe(false);
+});
diff --git a/apps/web/src/components/app/DesktopTitleBar.tsx b/apps/web/src/components/app/DesktopTitleBar.tsx
index 248dec138b..b137f3cb18 100644
--- a/apps/web/src/components/app/DesktopTitleBar.tsx
+++ b/apps/web/src/components/app/DesktopTitleBar.tsx
@@ -1,24 +1,46 @@
import { LIST_VIEW_ID } from '@app/constants/list-views';
import { globalSplitManager } from '@app/signal/splitLayout';
+import { splitBackInterceptor } from '@components/app/split-layout/back-interceptor';
import { TOKENS } from '@core/hotkey/tokens';
+import CaretLeftIcon from '@phosphor/caret-left.svg';
+import CaretRightIcon from '@phosphor/caret-right.svg';
import ColumnsPlusIcon from '@phosphor/columns-plus-right.svg';
import { Button } from '@ui';
import { Show } from 'solid-js';
-export function DesktopTitleBar(props: {
- navigationRef: (element: HTMLDivElement) => void;
-}) {
+export function DesktopTitleBar() {
+ const activeSplit = () => globalSplitManager()?.activeSplit();
+
return (
<div
data-tauri-drag-region
class="absolute inset-x-0 top-0 flex h-[40px] items-center justify-between pl-[88px] pr-3 select-none"
>
- {/* The portal wrapper must use flex layout so inline tooltip triggers
- cannot add text-baseline space below the navigation button. */}
- <div
- ref={props.navigationRef}
- class="flex items-center [&>div]:flex [&>div]:items-center"
- />
+ <div class="flex items-center gap-1">
+ <Button
+ variant="ghost"
+ size="icon-sm"
+ label="Go Back"
+ hotkey={TOKENS.split.go.back}
+ disabled={!activeSplit()?.canGoBack()}
+ onClick={() => {
+ if (splitBackInterceptor()?.()) return;
+ activeSplit()?.goBack();
+ }}
+ >
+ <CaretLeftIcon class="size-4" />
+ </Button>
+ <Button
+ variant="ghost"
+ size="icon-sm"
+ label="Go Forward"
+ hotkey={TOKENS.split.go.forward}
+ disabled={!activeSplit()?.canGoForward()}
+ onClick={() => activeSplit()?.goForward()}
+ >
+ <CaretRightIcon class="size-4" />
+ </Button>
+ </div>
<Show when={globalSplitManager()}>
{(manager) => (
<Button
diff --git a/apps/web/src/components/app/Layout.tsx b/apps/web/src/components/app/Layout.tsx
index 65f4f67fe8..ce59f95b1b 100644
--- a/apps/web/src/components/app/Layout.tsx
+++ b/apps/web/src/components/app/Layout.tsx
@@ -58,7 +58,6 @@ import { cn, ImperativeDialogHost } from '@ui';
import {
createEffect,
createMemo,
- createSignal,
lazy,
onCleanup,
onMount,
@@ -66,7 +65,6 @@ import {
Show,
Suspense,
} from 'solid-js';
-import { ViewNavigationSlotContext } from '../view-shell/navigation-slot';
import { AppProviders } from './AppProviders';
import { BundleUpdateProgressBar } from './BundleUpdateProgressBar';
import { DesktopTitleBar } from './DesktopTitleBar';
@@ -125,7 +123,6 @@ function hasOpened(opened: () => boolean) {
*/
export function RootFrame(props: ParentProps) {
const hasOverlayTitleBar = isPlatform('desktop') && osType() === 'macos';
- const [navigationSlot, setNavigationSlot] = createSignal<HTMLElement>();
const { paywallOpen, showPaywall } = usePaywallState();
const { usageLimitOpen } = useAiUsageLimitState();
const location = useLocation();
@@ -164,35 +161,33 @@ export function RootFrame(props: ParentProps) {
return (
<MobileSettingsProvider>
- <ViewNavigationSlotContext.Provider value={navigationSlot}>
- <div
- class={cn(
- 'relative flex flex-col justify-between not-touch:bg-panel w-dvw h-[calc(var(--dvh,1dvh)*100)] pl-(--safe-left) pr-(--safe-right)',
- hasOverlayTitleBar && 'pt-[40px]'
- )}
- >
- <Show when={hasOverlayTitleBar}>
- <DesktopTitleBar navigationRef={setNavigationSlot} />
- </Show>
- <ImperativeDialogHost />
- <BundleUpdateProgressBar />
- <Show when={paywallOpen()}>
- <Suspense>
- <Paywall />
- </Suspense>
- </Show>
- <Show when={usageLimitOpen()}>
- <AiUsageLimitDialog />
- </Show>
- <div class="min-h-0 flex-1 flex flex-col">
- {/* Route loading must not detach the frame. Routes draw their own
+ <div
+ class={cn(
+ 'relative flex flex-col justify-between not-touch:bg-panel w-dvw h-[calc(var(--dvh,1dvh)*100)] pl-(--safe-left) pr-(--safe-right)',
+ hasOverlayTitleBar && 'pt-[40px]'
+ )}
+ >
+ <Show when={hasOverlayTitleBar}>
+ <DesktopTitleBar />
+ </Show>
+ <ImperativeDialogHost />
+ <BundleUpdateProgressBar />
+ <Show when={paywallOpen()}>
+ <Suspense>
+ <Paywall />
+ </Suspense>
+ </Show>
+ <Show when={usageLimitOpen()}>
+ <AiUsageLimitDialog />
+ </Show>
+ <div class="min-h-0 flex-1 flex flex-col">
+ {/* Route loading must not detach the frame. Routes draw their own
loading state, so the frame adds none. */}
- <Suspense>{props.children}</Suspense>
- </div>
- <SwipeDownDismissKeyboard />
- <DevStatusBar />
+ <Suspense>{props.children}</Suspense>
</div>
- </ViewNavigationSlotContext.Provider>
+ <SwipeDownDismissKeyboard />
+ <DevStatusBar />
+ </div>
</MobileSettingsProvider>
);
}
diff --git a/apps/web/src/components/view-shell/ViewShell.test.tsx b/apps/web/src/components/view-shell/ViewShell.test.tsx
index 8e93702091..9240b561c2 100644
--- a/apps/web/src/components/view-shell/ViewShell.test.tsx
+++ b/apps/web/src/components/view-shell/ViewShell.test.tsx
@@ -11,7 +11,6 @@ import {
} from '@solidjs/testing-library';
import { createSignal, type JSX, onMount } from 'solid-js';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
-import { ViewNavigationSlotContext } from './navigation-slot';
import { useViewShell, ViewShell, ViewSidebarToggle } from './ViewShell';
import { ViewSidebar } from './ViewSidebar';
@@ -58,9 +57,7 @@ afterEach(() => {
vi.unstubAllGlobals();
});
-it('moves navigation into the host and follows the active split', () => {
- const [active, setActive] = createSignal('home');
- const [host, setHost] = createSignal<HTMLDivElement>();
+it('keeps navigation controls inside their own workspaces', () => {
const collapsed = new Map<string, () => boolean>();
function Workspace(props: { id: string }) {
function Controls() {
@@ -77,39 +74,33 @@ it('moves navigation into the host and follows the active split', () => {
value={
{
handle: { isFirst: () => true },
- isPanelActive: () => active() === props.id,
+ isPanelActive: () => true,
splitHotkeyScope: props.id,
} as unknown as SplitPanelContextType
}
>
- <ViewShell.Root asidePreferenceKey={props.id}>
+ <ViewShell.Root asidePreferenceKey={props.id} data-testid={props.id}>
<Controls />
</ViewShell.Root>
</SplitPanelContext.Provider>
);
}
const view = render(() => (
- <ViewNavigationSlotContext.Provider value={host}>
- <div ref={setHost} data-testid="navigation-host" />
+ <>
<Workspace id="home" />
<Workspace id="mail" />
- </ViewNavigationSlotContext.Provider>
+ </>
));
- const toolbar = within(view.getByTestId('navigation-host'));
- expect(view.getAllByRole('button')).toHaveLength(1);
- fireEvent.click(toolbar.getByRole('button', { name: 'Hide navigation' }));
+ const home = within(view.getByTestId('home'));
+ const mail = within(view.getByTestId('mail'));
+ fireEvent.click(home.getByRole('button', { name: 'Hide navigation' }));
expect(collapsed.get('home')?.()).toBe(true);
expect(collapsed.get('mail')?.()).toBe(false);
- setActive('mail');
- expect(view.getAllByRole('button')).toHaveLength(1);
- fireEvent.click(toolbar.getByRole('button', { name: 'Hide navigation' }));
+ fireEvent.click(mail.getByRole('button', { name: 'Hide navigation' }));
expect(collapsed.get('mail')?.()).toBe(true);
- setActive('home');
- fireEvent.click(toolbar.getByRole('button', { name: 'Show navigation' }));
+ fireEvent.click(home.getByRole('button', { name: 'Show navigation' }));
expect(collapsed.get('home')?.()).toBe(false);
expect(collapsed.get('mail')?.()).toBe(true);
- view.unmount();
- expect(document.querySelector('[data-testid="navigation-host"]')).toBeNull();
});
function setup(preserveDuringResize: boolean, persistWidth = false) {
diff --git a/apps/web/src/components/view-shell/ViewShell.tsx b/apps/web/src/components/view-shell/ViewShell.tsx
index 65a6b3bb4e..972756bc29 100644
--- a/apps/web/src/components/view-shell/ViewShell.tsx
+++ b/apps/web/src/components/view-shell/ViewShell.tsx
@@ -34,9 +34,7 @@ import {
untrack,
useContext,
} from 'solid-js';
-import { Portal } from 'solid-js/web';
import { createSidebarMotion } from './create-sidebar-motion';
-import { ViewNavigationSlotContext } from './navigation-slot';
import { VIEW_SHELL_TOUR } from './tour';
import {
type AsideLayout,
@@ -347,7 +345,6 @@ function Root(props: ViewShellRootProps) {
},
};
- const navigationSlot = useContext(ViewNavigationSlotContext);
if (panel) {
registerHotkey({
hotkey: 'cmd+.',
@@ -365,29 +362,6 @@ function Root(props: ViewShellRootProps) {
return (
<ViewShellContext.Provider value={value}>
- <Show
- when={
- navigationSlot?.() &&
- panel?.isPanelActive() &&
- value.aside.canCollapse()
- }
- >
- <Portal mount={navigationSlot?.()}>
- <Button
- variant="ghost"
- size="icon-sm"
- label={
- value.aside.isCollapsed() ? 'Show navigation' : 'Hide navigation'
- }
- hotkey={TOKENS.workspace.toggleNavigation}
- aria-expanded={!value.aside.isCollapsed()}
- ref={tourTarget(VIEW_SHELL_TOUR.sidebarToggle)}
- onClick={value.aside.toggle}
- >
- <SidebarIcon class="size-4" />
- </Button>
- </Portal>
- </Show>
<div
{...rest}
ref={setRoot}
@@ -580,13 +554,10 @@ export function ViewSidebarCloseButton(
/** Safe outside a shell so block preview headers can share this control. */
export function ViewSidebarToggle(props: { action: 'collapse' | 'expand' }) {
const ws = useContext(ViewShellContext);
- const navigationSlot = useContext(ViewNavigationSlotContext);
- const panel = useContext(SplitPanelContext);
// A conditional expression as `ref` is dropped by the Solid compiler, so
// only the expand toggle registers, from inside the callback.
const toggleTarget = tourTarget(VIEW_SHELL_TOUR.sidebarToggle);
const visible = () =>
- !(navigationSlot?.() && panel) &&
ws?.aside.canCollapse() &&
(props.action === 'expand'
? ws.aside.isCollapsed() || ws.aside.isOverlay()
diff --git a/apps/web/src/components/view-shell/navigation-slot.ts b/apps/web/src/components/view-shell/navigation-slot.ts
deleted file mode 100644
index dd969c7633..0000000000
--- a/apps/web/src/components/view-shell/navigation-slot.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-import { type Accessor, createContext } from 'solid-js';
-
-/** Optional host for the active workspace's navigation control. */
-export const ViewNavigationSlotContext =
- createContext<Accessor<HTMLElement | undefined>>();
diff --git a/docs/AGENT_GUIDE/navigation.md b/docs/AGENT_GUIDE/navigation.md
index 987b48d689..b387f7000f 100644
--- a/docs/AGENT_GUIDE/navigation.md
+++ b/docs/AGENT_GUIDE/navigation.md
@@ -6,9 +6,10 @@ double-click it to toggle zoom. The loading shell uses the same inset; browser,
Windows, Linux, and mobile layouts do not add this space.
Native desktop content keeps its rounded split frame even with only one split,
-and the app icon rail has no right divider. On macOS, the sidebar icon beside the
-traffic lights toggles navigation for the active split; it replaces the controls
-inside the workspace. The top-right split icon opens another Home split, even
+and the app icon rail has no right divider. On macOS, Back and Forward arrows
+beside the traffic lights navigate the active split's history. Each arrow is
+disabled when its direction has no entry. Sidebar controls remain inside each
+workspace. The top-right split icon opens another Home split, even
when Home is already open, and is disabled when there is no room for a new split.
Its tooltip is “New Split” and displays the registered new-split shortcut (`\`).