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(splits): switch a split's view from its title (#8893)

Jacob Beckerman47a10e1ad716
diff --git a/apps/web/src/components/app/Layout.tsx b/apps/web/src/components/app/Layout.tsx
index 7aa404ac58..2a3b5631a4 100644
--- a/apps/web/src/components/app/Layout.tsx
+++ b/apps/web/src/components/app/Layout.tsx
@@ -1,3 +1,4 @@
+import { ViewSwitcherContext } from '@app/components/view-shell';
import { ROUTER_BASE_CONCAT } from '@app/constants/routerBase';
import Banner from '@app/features/auth/banner/Banner';
import { CalendarPermissionPrompt } from '@app/features/auth/CalendarPermissionPrompt';
@@ -33,6 +34,8 @@ import { CreateChannelModal } from '@channel/CreateChannelModal';
import { GoToHotkeys } from '@components/app/app-sidebar/sidebar';
import { registerMailtoComposerHandler } from '@components/app/mailtoComposerHandler';
import { SidebarRail } from '@components/app/sidebar-next/sidebar-rail';
+import { SidebarPrefsProvider } from '@components/app/sidebar-next/use-sidebar-prefs';
+import { ViewSwitcher } from '@components/app/sidebar-next/view-switcher';
import {
isSidebarVisible,
SidebarVisibilityContext,
@@ -303,14 +306,19 @@ export function AppChrome(props: ParentProps) {
</Suspense>
<div class="min-h-0 flex-1 flex">
<ItemDndProvider>
- <Show when={isSidebarVisible()}>
- <SidebarRail />
- </Show>
- <PageContent>
- {/* Route loading must not detach the chrome or mobile navigation;
- the route draws its own loading state. */}
- <Suspense>{props.children}</Suspense>
- </PageContent>
+ {/* The rail and each view's switcher share the rail preferences. */}
+ <SidebarPrefsProvider>
+ <ViewSwitcherContext.Provider value={ViewSwitcher}>
+ <Show when={isSidebarVisible()}>
+ <SidebarRail />
+ </Show>
+ <PageContent>
+ {/* Route loading must not detach the chrome or mobile
+ navigation; the route draws its own loading state. */}
+ <Suspense>{props.children}</Suspense>
+ </PageContent>
+ </ViewSwitcherContext.Provider>
+ </SidebarPrefsProvider>
</ItemDndProvider>
</div>
<Show when={isTouchDevice() && isAuthenticated()}>
diff --git a/apps/web/src/components/app/sidebar-next/sidebar-rail.tsx b/apps/web/src/components/app/sidebar-next/sidebar-rail.tsx
index 4b9af17cee..ce7a712609 100644
--- a/apps/web/src/components/app/sidebar-next/sidebar-rail.tsx
+++ b/apps/web/src/components/app/sidebar-next/sidebar-rail.tsx
@@ -14,7 +14,6 @@ import { visibleNavItems } from './nav-items';
import { useNextMeetingBadge } from './queries/use-next-meeting-badge';
import { SearchRailButton } from './search-bar-button';
import { useNavItemGates } from './use-nav-item-gates';
-import { SidebarPrefsProvider } from './use-sidebar-prefs';
function ChannelsListNav(props: Omit<ListNavProps, 'activeCall'>) {
const hasActiveCall = useHasActiveChannelsCall();
@@ -36,13 +35,7 @@ function CalendarListNav(props: Omit<ListNavProps, 'badge'>) {
* separately. Each button's tooltip carries its shortcut, and after `g` is
* pressed each button shows its destination key in a corner badge.
*/
-export const SidebarRail = () => (
- <SidebarPrefsProvider>
- <SidebarRailContent />
- </SidebarPrefsProvider>
-);
-
-const SidebarRailContent = () => {
+export const SidebarRail = () => {
const gates = useNavItemGates();
const analytics = useAnalytics();
const layout = useSplitLayout();
diff --git a/apps/web/src/components/app/sidebar-next/view-switcher.test.tsx b/apps/web/src/components/app/sidebar-next/view-switcher.test.tsx
new file mode 100644
index 0000000000..6d993db393
--- /dev/null
+++ b/apps/web/src/components/app/sidebar-next/view-switcher.test.tsx
@@ -0,0 +1,176 @@
+import type { SplitPanelContextType } from '@components/app/split-layout/context';
+import { SplitPanelContext } from '@components/app/split-layout/context';
+import {
+ cleanup,
+ fireEvent,
+ render,
+ screen,
+ within,
+} from '@solidjs/testing-library';
+import type { ParentProps } from 'solid-js';
+import { createSignal } from 'solid-js';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+import { DEFAULT_HIDDEN_IDS } from './use-sidebar-prefs';
+import { ViewSwitcher } from './view-switcher';
+
+const mocks = vi.hoisted(() => ({
+ touch: false,
+ openWithSplit: vi.fn(),
+}));
+
+vi.mock('@ui', async () => ({
+ ...(await import('../../ui/utils/classname')),
+ ...(await import('../../ui/components/Dropdown')),
+ ...(await import('../../ui/components/Layer')),
+}));
+vi.mock('../../ui/components/Tooltip', () => ({
+ Tooltip: (props: ParentProps) => props.children,
+}));
+vi.mock('@core/mobile/isTouchDevice', () => ({
+ isTouchDevice: () => mocks.touch,
+}));
+vi.mock('@core/mobile/inputModality', () => ({ isModality: () => false }));
+vi.mock('@app/lib/analytics/analytics-context', () => ({
+ useAnalytics: () => ({ track: vi.fn() }),
+}));
+vi.mock('@app/signal/splitLayout', () => ({
+ globalSplitManager: () => ({
+ openWithSplit: mocks.openWithSplit,
+ preloadContent: vi.fn(),
+ }),
+}));
+// Flags are PostHog-backed; the rail's own gates decide what is listed.
+vi.mock('./use-nav-item-gates', () => ({
+ useNavItemGates: () => () => ({
+ showCalendar: true,
+ showScheduling: false,
+ showCustomers: false,
+ showCalls: true,
+ showReviews: false,
+ showActivity: false,
+ prefs: { hidden: new Set(DEFAULT_HIDDEN_IDS), order: [] },
+ }),
+}));
+
+beforeEach(() => {
+ vi.stubGlobal('scrollTo', vi.fn());
+ mocks.touch = false;
+ mocks.openWithSplit.mockImplementation(
+ (
+ content: unknown,
+ options: { handle: { setContent: (c: unknown) => void } }
+ ) => {
+ options.handle.setContent(content);
+ return { status: 'opened', split: options.handle };
+ }
+ );
+});
+
+afterEach(() => {
+ cleanup();
+ vi.clearAllMocks();
+ vi.unstubAllGlobals();
+});
+
+function renderSplits(options: { popover?: boolean } = {}) {
+ const splits = ['left', 'right'].map((id) => {
+ const [content, setContent] = createSignal({
+ type: 'component',
+ id: id === 'left' ? 'home' : 'mail',
+ });
+ return {
+ id,
+ content,
+ setContent,
+ isPopover: () => options.popover ?? false,
+ };
+ });
+ render(() =>
+ splits.map((split) => (
+ <SplitPanelContext.Provider
+ value={{ handle: split } as unknown as SplitPanelContextType}
+ >
+ <section aria-label={split.id}>
+ <ViewSwitcher caret>
+ {split.id === 'left' ? 'Home' : 'Email'}
+ </ViewSwitcher>
+ </section>
+ </SplitPanelContext.Provider>
+ ))
+ );
+ return splits;
+}
+
+/** The view's name is the trigger. */
+function openMenu(split: string) {
+ const name = split === 'left' ? 'Home' : 'Email';
+ const trigger = within(screen.getByRole('region', { name: split })).getByRole(
+ 'button',
+ { name }
+ );
+ fireEvent.keyDown(trigger, { key: 'Enter' });
+}
+
+describe('ViewSwitcher', () => {
+ it('lists rail apps then More apps and marks the current view', async () => {
+ renderSplits();
+ openMenu('right');
+
+ const items = await screen.findAllByRole('menuitem');
+ expect(items.map((item) => item.textContent)).toEqual([
+ 'Home',
+ 'Drive',
+ 'Email',
+ 'Chat',
+ 'Tasks',
+ 'Calendar',
+ 'Agents',
+ 'Calls',
+ ]);
+ expect(screen.getByRole('menuitem', { current: 'page' }).textContent).toBe(
+ 'Email'
+ );
+ });
+
+ it('replaces the view in its own split, not the active one', async () => {
+ const [left, right] = renderSplits();
+ openMenu('right');
+
+ fireEvent.keyDown(await screen.findByRole('menuitem', { name: 'Tasks' }), {
+ key: 'Enter',
+ });
+
+ expect(mocks.openWithSplit).toHaveBeenCalledWith(
+ expect.objectContaining({ id: 'tasks' }),
+ expect.objectContaining({ handle: right, preferNewSplit: false })
+ );
+ expect(right.content().id).toBe('tasks');
+ expect(left.content().id).toBe('home');
+ });
+
+ it('opens a new split when Shift is held', async () => {
+ renderSplits();
+ openMenu('left');
+
+ const drive = await screen.findByRole('menuitem', { name: 'Drive' });
+ fireEvent.keyDown(drive, { key: 'Enter', shiftKey: true });
+
+ expect(mocks.openWithSplit).toHaveBeenCalledWith(
+ expect.objectContaining({ id: 'documents' }),
+ expect.objectContaining({ preferNewSplit: true })
+ );
+ });
+
+ it('shows the plain name on touch devices and in popovers', () => {
+ mocks.touch = true;
+ renderSplits();
+ expect(screen.getByText('Email')).toBeTruthy();
+ expect(screen.queryByRole('button')).toBeNull();
+ cleanup();
+
+ mocks.touch = false;
+ renderSplits({ popover: true });
+ expect(screen.getByText('Email')).toBeTruthy();
+ expect(screen.queryByRole('button')).toBeNull();
+ });
+});
diff --git a/apps/web/src/components/app/sidebar-next/view-switcher.tsx b/apps/web/src/components/app/sidebar-next/view-switcher.tsx
new file mode 100644
index 0000000000..edc0e69bca
--- /dev/null
+++ b/apps/web/src/components/app/sidebar-next/view-switcher.tsx
@@ -0,0 +1,110 @@
+import type { ViewSwitcherProps } from '@app/components/view-shell';
+import { useAnalytics } from '@app/lib/analytics/analytics-context';
+import {
+ navigateToSidebarView,
+ sidebarContent,
+} from '@components/app/app-sidebar/sidebar';
+import { SplitPanelContext } from '@components/app/split-layout/context';
+import { useSplitLayout } from '@components/app/split-layout/layout';
+import { isTouchDevice } from '@core/mobile/isTouchDevice';
+import CaretDownIcon from '@icon/system/regular/caret-down.svg';
+import CheckIcon from '@icon/system/regular/check.svg';
+import { Dropdown } from '@ui';
+import { For, Show, useContext } from 'solid-js';
+import { Dynamic } from 'solid-js/web';
+import {
+ moreMenuItems,
+ type SidebarNextMenuItem,
+ visibleNavItems,
+} from './nav-items';
+import { useNavItemGates } from './use-nav-item-gates';
+
+/**
+ * Turns a view's name into a menu of the rail's destinations. Picking one
+ * replaces the view in this split, so a split can change apps without first
+ * being focused for the rail. Shift opens the destination in a new split.
+ */
+export function ViewSwitcher(props: ViewSwitcherProps) {
+ const panel = useContext(SplitPanelContext);
+ // Touch devices navigate with the dock, and popovers can't replace content.
+ if (!panel || isTouchDevice() || panel.handle.isPopover()) {
+ return <>{props.fallback ?? props.children}</>;
+ }
+
+ const gates = useNavItemGates();
+ const layout = useSplitLayout();
+ const analytics = useAnalytics();
+ const hiddenItems = () => moreMenuItems(gates());
+ const isCurrent = (item: SidebarNextMenuItem) =>
+ sidebarContent(item.id, item.params).id === panel.handle.content().id;
+
+ // Capture shift before onSelect fires (which omits the event).
+ let shiftHeld = false;
+ const captureSplitIntent = (event: PointerEvent | KeyboardEvent) => {
+ shiftHeld = event.shiftKey;
+ };
+
+ const open = (item: SidebarNextMenuItem) => {
+ analytics.track('sidebar_click', {
+ view: item.id,
+ source: 'view_switcher',
+ });
+ navigateToSidebarView({
+ viewId: item.id,
+ params: item.params,
+ shiftKey: shiftHeld,
+ openWithSplit: layout.openWithSplit,
+ referredFrom: 'sidebar',
+ });
+ };
+
+ const item = (navItem: SidebarNextMenuItem) => (
+ <Dropdown.Item
+ class="gap-2"
+ aria-current={isCurrent(navItem) ? 'page' : undefined}
+ onMouseEnter={() =>
+ layout.preloadContent(sidebarContent(navItem.id, navItem.params))
+ }
+ onPointerDown={captureSplitIntent}
+ onKeyDown={captureSplitIntent}
+ onSelect={() => open(navItem)}
+ >
+ <Dynamic
+ component={navItem.icon}
+ class="size-4 shrink-0 text-ink-muted"
+ />
+ <span class="flex-1 truncate text-ink">{navItem.label}</span>
+ <Show when={isCurrent(navItem)}>
+ <CheckIcon class="size-4 shrink-0 text-ink-muted" />
+ </Show>
+ </Dropdown.Item>
+ );
+
+ return (
+ <Dropdown placement="bottom-start">
+ <Dropdown.Trigger
+ variant="ghost"
+ size="sm"
+ class="-ml-2 min-w-0 max-w-[calc(100%+0.5rem)] shrink"
+ data-view-switcher=""
+ >
+ <span class="truncate text-sm font-semibold tracking-[-0.03em] text-ink">
+ {props.children}
+ </span>
+ <Show when={props.caret}>
+ <CaretDownIcon class="size-3 transition-transform in-data-expanded:rotate-180" />
+ </Show>
+ </Dropdown.Trigger>
+ <Dropdown.Content class="min-w-[14rem]">
+ <Dropdown.Group>
+ <For each={visibleNavItems(gates())}>{item}</For>
+ </Dropdown.Group>
+ <Show when={hiddenItems().length > 0}>
+ <Dropdown.Group>
+ <For each={hiddenItems()}>{item}</For>
+ </Dropdown.Group>
+ </Show>
+ </Dropdown.Content>
+ </Dropdown>
+ );
+}
diff --git a/apps/web/src/components/view-shell/SidebarCreateButton.tsx b/apps/web/src/components/view-shell/SidebarCreateButton.tsx
index 8246b760e2..e3e0617247 100644
--- a/apps/web/src/components/view-shell/SidebarCreateButton.tsx
+++ b/apps/web/src/components/view-shell/SidebarCreateButton.tsx
@@ -9,8 +9,8 @@ export function SidebarCreateHeader(props: {
title: string;
label: string;
onCreate: () => void;
+ /** View controls (e.g. filters) beside search, at the header's right. */
actions?: JSX.Element;
- titleActions?: JSX.Element;
createAction?: JSX.Element;
search?: () => JSX.Element;
searchLabel?: string;
@@ -21,13 +21,12 @@ export function SidebarCreateHeader(props: {
<ViewSidebar.Header
search={props.search}
searchLabel={props.searchLabel}
+ actions={props.actions}
>
<div class="flex min-w-0 items-center gap-1">
<ViewSidebar.CloseButton class="shrink-0" />
<ViewSidebar.Title>{props.title}</ViewSidebar.Title>
- {props.titleActions}
</div>
- {props.actions}
</ViewSidebar.Header>
</Show>
<ViewSidebar.Primary>
diff --git a/apps/web/src/components/view-shell/ViewSidebar.tsx b/apps/web/src/components/view-shell/ViewSidebar.tsx
index 69d5fa987c..b464b3ad1a 100644
--- a/apps/web/src/components/view-shell/ViewSidebar.tsx
+++ b/apps/web/src/components/view-shell/ViewSidebar.tsx
@@ -4,8 +4,14 @@ import CaretDownIcon from '@icon/system/regular/caret-down.svg';
import SearchIcon from '@icon/system/regular/magnifying-glass.svg';
import { Button, type ButtonProps, cn } from '@ui';
import { CollapseTransition } from '@ui/components/CollapseTransition';
-import type { JSX } from 'solid-js';
-import { createSignal, Show, splitProps } from 'solid-js';
+import type { Component, JSX } from 'solid-js';
+import {
+ createContext,
+ createSignal,
+ Show,
+ splitProps,
+ useContext,
+} from 'solid-js';
import { Dynamic } from 'solid-js/web';
import { ViewSidebarCloseButton, ViewSidebarToggle } from './ViewShell';
@@ -31,12 +37,15 @@ function Header(
searchLabel?: string;
searchOpen?: boolean;
onSearchOpenChange?: (open: boolean) => void;
+ /** View controls (e.g. filters) in the right group, before search. */
+ actions?: JSX.Element;
collapseControl?: JSX.Element;
}
) {
const [local, rest] = splitProps(props, [
'children',
'class',
+ 'actions',
'search',
'searchLabel',
'searchOpen',
@@ -70,6 +79,7 @@ function Header(
>
{local.children}
<div class="ml-auto flex shrink-0 items-center gap-1">
+ {local.actions}
<Show when={!isTouchDevice() && local.search}>
<Control
label={local.searchLabel ?? 'Search'}
@@ -97,17 +107,50 @@ function Header(
);
}
-function Title(props: JSX.HTMLAttributes<HTMLHeadingElement>) {
- const [local, rest] = splitProps(props, ['children', 'class']);
+export type ViewSwitcherProps = {
+ /** The view or section name; clicking it opens the menu. */
+ children: JSX.Element;
+ /** Shown beside navigation titles; collapsed headers show the name only. */
+ caret?: boolean;
+ /** Rendered instead where the menu is unavailable (touch, popovers). */
+ fallback?: JSX.Element;
+};
+
+/**
+ * The app's view switcher. The app chrome supplies it so this shell stays
+ * independent of the app's navigation.
+ */
+export const ViewSwitcherContext =
+ createContext<Component<ViewSwitcherProps>>();
+
+/** A view name that opens the view switcher, or plain text without one. */
+export function ViewSwitchTrigger(props: ViewSwitcherProps) {
+ const ViewSwitcher = useContext(ViewSwitcherContext);
+ if (!ViewSwitcher) return <>{props.fallback ?? props.children}</>;
+ return <ViewSwitcher {...props} />;
+}
+
+function Title(
+ props: JSX.HTMLAttributes<HTMLHeadingElement> & {
+ /** Navigation titles show a caret; collapsed headers omit it. */
+ caret?: boolean;
+ }
+) {
+ const [local, rest] = splitProps(props, ['caret', 'children', 'class']);
return (
<h1
{...rest}
class={cn(
- 'min-w-0 truncate text-sm font-semibold tracking-[-0.03em] text-ink',
+ 'flex min-w-0 items-center text-sm font-semibold tracking-[-0.03em] text-ink',
local.class
)}
>
- {local.children}
+ <ViewSwitchTrigger
+ caret={local.caret ?? true}
+ fallback={<span class="truncate">{local.children}</span>}
+ >
+ {local.children}
+ </ViewSwitchTrigger>
</h1>
);
}
diff --git a/apps/web/src/components/view-shell/index.ts b/apps/web/src/components/view-shell/index.ts
index cc1c98a477..7fe1e0d2a3 100644
--- a/apps/web/src/components/view-shell/index.ts
+++ b/apps/web/src/components/view-shell/index.ts
@@ -51,7 +51,12 @@ export {
type ViewShellLayout,
type ViewShellRootProps,
} from './ViewShell';
-export { ViewSidebar } from './ViewSidebar';
+export {
+ ViewSidebar,
+ ViewSwitcherContext,
+ type ViewSwitcherProps,
+ ViewSwitchTrigger,
+} from './ViewSidebar';
export {
type AsideLayout,
type AsideMode,
diff --git a/apps/web/src/features/activity/views/my-activity-view.tsx b/apps/web/src/features/activity/views/my-activity-view.tsx
index a325c6b328..fcb96ac6c8 100644
--- a/apps/web/src/features/activity/views/my-activity-view.tsx
+++ b/apps/web/src/features/activity/views/my-activity-view.tsx
@@ -1,3 +1,4 @@
+import { ViewSidebar } from '@app/components/view-shell';
import { SoupSectionHeader } from '@app/features/next-soup/soup-view/section-header';
import { SplitHeaderLeft } from '@components/app/split-layout/components/SplitHeader';
import { StaticMarkdownContext } from '@core/component/LexicalMarkdown/component/core/StaticMarkdown';
@@ -145,7 +146,7 @@ export function MyActivityView(props: {
<div class="@container/u-list flex size-full flex-col">
<SplitHeaderLeft>
<div class="flex items-center gap-3">
- <span class="font-semibold text-sm">Activity</span>
+ <ViewSidebar.Title caret={false}>Activity</ViewSidebar.Title>
<Show when={!isTouchDevice()}>
<ActivityScopeTabs
value={props.scope}
diff --git a/apps/web/src/features/agents-view/components/Topbar.test.tsx b/apps/web/src/features/agents-view/components/Topbar.test.tsx
index ace5143e3a..734d1faea8 100644
--- a/apps/web/src/features/agents-view/components/Topbar.test.tsx
+++ b/apps/web/src/features/agents-view/components/Topbar.test.tsx
@@ -8,6 +8,9 @@ vi.mock('@app/components/view-shell/ViewShell', () => ({
TopBar: (props: ParentProps) => <div>{props.children}</div>,
},
}));
+vi.mock('@app/components/view-shell/ViewSidebar', () => ({
+ ViewSidebar: { Title: (props: ParentProps) => <h1>{props.children}</h1> },
+}));
afterEach(cleanup);
it('uses the block title control without duplicating its title or session menu', () => {
diff --git a/apps/web/src/features/agents-view/components/Topbar.tsx b/apps/web/src/features/agents-view/components/Topbar.tsx
index 7f1ab37ebe..08a75a8fc6 100644
--- a/apps/web/src/features/agents-view/components/Topbar.tsx
+++ b/apps/web/src/features/agents-view/components/Topbar.tsx
@@ -1,4 +1,5 @@
import { ViewShell } from '@app/components/view-shell/ViewShell';
+import { ViewSidebar } from '@app/components/view-shell/ViewSidebar';
import ArrowLeft from '@icon/system/regular/arrow-left.svg';
import { Button } from '@ui';
import { type JSX, Show } from 'solid-js';
@@ -25,9 +26,7 @@ export function Topbar(props: {
<div class="flex min-w-0 items-center gap-1">
{props.titleContent ?? (
<Show when={props.title}>
- <h1 class="min-w-0 truncate text-sm font-semibold tracking-[-0.03em] text-ink">
- {props.title}
- </h1>
+ <ViewSidebar.Title caret={false}>{props.title}</ViewSidebar.Title>
</Show>
)}
</div>
diff --git a/apps/web/src/features/calls-view/components/calls-header.tsx b/apps/web/src/features/calls-view/components/calls-header.tsx
index c53f5d1f90..cc62be242a 100644
--- a/apps/web/src/features/calls-view/components/calls-header.tsx
+++ b/apps/web/src/features/calls-view/components/calls-header.tsx
@@ -1,6 +1,7 @@
import {
ListSortDropdown,
useViewControlHotkeys,
+ ViewSidebar,
} from '@app/components/view-shell';
import {
ListHeader,
@@ -48,11 +49,7 @@ export function CallsHeader() {
return (
<>
<ListHeader
- title={
- <h1 class="min-w-0 truncate text-sm font-semibold text-ink">
- {title()}
- </h1>
- }
+ title={<ViewSidebar.Title caret={false}>{title()}</ViewSidebar.Title>}
>
<HeaderActionGroup label="Call filters">
<UnifiedFilterDropdown hideLabel variant="ghost" />
diff --git a/apps/web/src/features/channels-view/channels-view.test.tsx b/apps/web/src/features/channels-view/channels-view.test.tsx
index 830de4b3a3..22b742b4b6 100644
--- a/apps/web/src/features/channels-view/channels-view.test.tsx
+++ b/apps/web/src/features/channels-view/channels-view.test.tsx
@@ -9,7 +9,14 @@ import {
waitFor,
} from '@solidjs/testing-library';
import { CombinedError } from '@urql/core';
-import { batch, createSignal, For, type JSX, Show } from 'solid-js';
+import {
+ batch,
+ createSignal,
+ For,
+ type JSX,
+ type ParentProps,
+ Show,
+} from 'solid-js';
import { createStore } from 'solid-js/store';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
@@ -79,6 +86,7 @@ vi.mock('@app/components/view-shell', () => ({
Main: mocks.pass,
TopBar: mocks.pass,
},
+ ViewSidebar: { Title: (props: ParentProps) => <h1>{props.children}</h1> },
}));
vi.mock('@app/features/next-soup/utils', () => ({
getChannelEntityTarget: mocks.resolveTarget,
diff --git a/apps/web/src/features/channels-view/channels-view.tsx b/apps/web/src/features/channels-view/channels-view.tsx
index 591c80a429..66b07766bb 100644
--- a/apps/web/src/features/channels-view/channels-view.tsx
+++ b/apps/web/src/features/channels-view/channels-view.tsx
@@ -1,4 +1,4 @@
-import { ViewShell } from '@app/components/view-shell';
+import { ViewShell, ViewSidebar } from '@app/components/view-shell';
import { SearchState } from '@app/features/command/mobile/mobileSearchState';
import { markChannelNotificationsSeenOnOpen } from '@app/features/next-soup/utils';
import { MaybeSoupEntityActionDrawerManager } from '@app/features/soup';
@@ -217,9 +217,9 @@ function ChannelsViewRoot() {
fallback={() => (
<>
<ViewShell.TopBar>
- <span class="text-sm font-semibold">
+ <ViewSidebar.Title caret={false}>
Chat
- </span>
+ </ViewSidebar.Title>
</ViewShell.TopBar>
<div class="flex min-h-0 flex-1 items-center justify-center px-6 text-center">
<div class="flex max-w-sm flex-col gap-2">
diff --git a/apps/web/src/features/crm/views/crm-workspace.test.tsx b/apps/web/src/features/crm/views/crm-workspace.test.tsx
index 9da07e5301..eb87da4eec 100644
--- a/apps/web/src/features/crm/views/crm-workspace.test.tsx
+++ b/apps/web/src/features/crm/views/crm-workspace.test.tsx
@@ -31,6 +31,7 @@ vi.mock('@app/components/view-shell', () => ({
Main: (props: ParentProps) => props.children,
Header: (props: ParentProps) => <header>{props.children}</header>,
},
+ ViewSidebar: { Title: (props: ParentProps) => <h1>{props.children}</h1> },
useViewShell: () => ({
aside: { isCollapsed: () => true },
breakpoints: { narrow: () => fixture.narrow },
diff --git a/apps/web/src/features/crm/views/crm-workspace.tsx b/apps/web/src/features/crm/views/crm-workspace.tsx
index 8e1d2b89d6..4b80321ae7 100644
--- a/apps/web/src/features/crm/views/crm-workspace.tsx
+++ b/apps/web/src/features/crm/views/crm-workspace.tsx
@@ -3,6 +3,7 @@ import {
useViewControlHotkeys,
useViewShell,
ViewShell,
+ ViewSidebar,
} from '@app/components/view-shell';
import {
ListHeader,
@@ -543,9 +544,9 @@ export function CrmWorkspaceView(props: {
<ArrowLeftIcon class="size-4" />
</Button>
</Tooltip>
- <h1 class="flex h-7 min-w-0 flex-1 items-center text-sm font-semibold tracking-[-0.03em]">
- <span class="truncate">CRM settings</span>
- </h1>
+ <ViewSidebar.Title caret={false} class="h-7 flex-1">
+ CRM settings
+ </ViewSidebar.Title>
</div>
{/* The header above already clears the status bar on touch. */}
<div class="min-h-0 min-w-0 flex-1 [--mobile-content-inset-top:0px]">
@@ -662,12 +663,9 @@ export function CrmWorkspaceView(props: {
<NavigationToggle onExpand={() => setCollapsed(false)}>
<Suspense>{sidebar()}</Suspense>
</NavigationToggle>
- <h1
- class="min-w-0 truncate text-sm font-semibold"
- title={title()}
- >
+ <ViewSidebar.Title caret={false} title={title()}>
{title()}
- </h1>
+ </ViewSidebar.Title>
</div>
}
/>
@@ -711,12 +709,9 @@ export function CrmWorkspaceView(props: {
<NavigationToggle onExpand={() => setCollapsed(false)}>
<Suspense>{sidebar()}</Suspense>
</NavigationToggle>
- <h1
- class="min-w-0 truncate text-sm font-semibold"
- title={title()}
- >
+ <ViewSidebar.Title caret={false} title={title()}>
{title()}
- </h1>
+ </ViewSidebar.Title>
</div>
}
>
diff --git a/apps/web/src/features/crm/views/pipeline.tsx b/apps/web/src/features/crm/views/pipeline.tsx
index 1a5bdf54ab..bae70adb58 100644
--- a/apps/web/src/features/crm/views/pipeline.tsx
+++ b/apps/web/src/features/crm/views/pipeline.tsx
@@ -1,3 +1,4 @@
+import { ViewSidebar } from '@app/components/view-shell';
import { HeaderActionGroup } from '@components/app/HeaderActionGroup';
import { InlineTitleEditor } from '@core/component/InlineTitleEditor';
import { isTouchDevice } from '@core/mobile/isTouchDevice';
@@ -114,9 +115,9 @@ export function PipelineView(props: {
<Show
when={canEdit()}
fallback={
- <h1 class="min-w-0 truncate px-1 text-sm font-semibold">
+ <ViewSidebar.Title caret={false} class="px-1">
{props.pipeline.name}
- </h1>
+ </ViewSidebar.Title>
}
>
<span ref={title} class="flex min-w-0 px-1">
diff --git a/apps/web/src/features/drive-view/components/DriveBreadcrumbs.tsx b/apps/web/src/features/drive-view/components/DriveBreadcrumbs.tsx
index bc35f0392f..44040605e2 100644
--- a/apps/web/src/features/drive-view/components/DriveBreadcrumbs.tsx
+++ b/apps/web/src/features/drive-view/components/DriveBreadcrumbs.tsx
@@ -2,6 +2,7 @@ import {
ViewBreadcrumbs,
type ViewBreadcrumbsOutletProps,
type ViewBreadcrumbsSeparatorState,
+ ViewSwitchTrigger,
} from '@app/components/view-shell';
import type { FileOperation } from '@components/app/split-layout/components/SplitFileMenu';
import { SplitFileMenu } from '@components/app/split-layout/components/SplitFileMenu';
@@ -95,14 +96,34 @@ export function DriveLocationBreadcrumbItems(props: {
>
{(item) => (
<div class="flex min-w-0 items-center">
- <ViewBreadcrumbs.Button
- class="max-w-48"
- isActive={item.isActive()}
- onClick={item.onSelect}
- tooltip={entry.label}
+ <Show
+ when={index() === 0 && item.isActive() && !folder()}
+ fallback={
+ <ViewBreadcrumbs.Button
+ class="max-w-48"
+ isActive={item.isActive()}
+ onClick={item.onSelect}
+ tooltip={entry.label}
+ >
+ <span class="truncate">{entry.label}</span>
+ </ViewBreadcrumbs.Button>
+ }
>
- <span class="truncate">{entry.label}</span>
- </ViewBreadcrumbs.Button>
+ {/* The top-level location switches views; folders keep their menu. */}
+ <ViewSwitchTrigger
+ fallback={
+ <ViewBreadcrumbs.Button
+ class="max-w-48"
+ isActive
+ tooltip={entry.label}
+ >
+ <span class="truncate">{entry.label}</span>
+ </ViewBreadcrumbs.Button>
+ }
+ >
+ {entry.label}
+ </ViewSwitchTrigger>
+ </Show>
<Show when={item.isActive() ? folder() : undefined}>
{(activeFolder) => (
<FolderBreadcrumbMenu
diff --git a/apps/web/src/features/drive-view/views/drive-header.tsx b/apps/web/src/features/drive-view/views/drive-header.tsx
index 7fa4effbef..cf91e03018 100644
--- a/apps/web/src/features/drive-view/views/drive-header.tsx
+++ b/apps/web/src/features/drive-view/views/drive-header.tsx
@@ -2,6 +2,7 @@ import {
ListSortDropdown,
useViewControlHotkeys,
ViewShell,
+ ViewSidebar,
} from '@app/components/view-shell';
import {
ListHeader,
@@ -87,9 +88,12 @@ export function DriveHeader() {
}
>
<ViewShell.TopBar>
- <h1 class="hidden min-w-0 truncate text-sm font-semibold tracking-[-0.03em] text-ink @max-[720px]/view-shell:block">
+ <ViewSidebar.Title
+ caret={false}
+ class="hidden @max-[720px]/view-shell:flex"
+ >
Drive
- </h1>
+ </ViewSidebar.Title>
<DriveBreadcrumbsOutlet
aria-label="Drive location"
class="@max-[720px]/view-shell:hidden"
diff --git a/apps/web/src/features/email-view/components/EmailHeader.tsx b/apps/web/src/features/email-view/components/EmailHeader.tsx
index e9ad52bb2a..db7391a5f9 100644
--- a/apps/web/src/features/email-view/components/EmailHeader.tsx
+++ b/apps/web/src/features/email-view/components/EmailHeader.tsx
@@ -1,6 +1,7 @@
import {
useViewControlHotkeys,
ViewBreadcrumbs,
+ ViewSwitchTrigger,
} from '@app/components/view-shell';
import {
ListHeader,
@@ -42,20 +43,33 @@ export function EmailViewBreadcrumbItem() {
metadata={{ type: 'email-view' }}
order={0}
>
- {(item) => (
- <ViewBreadcrumbs.Button
- class="shrink-0 rounded-md hover:bg-hover"
- isActive={item.isActive()}
- onClick={item.onSelect}
- >
- <span class="truncate @max-[720px]/view-shell:hidden">
- {tabTitle()}
- </span>
- <span class="hidden @max-[720px]/view-shell:inline">
- {inboxSelected() ? 'Inbox' : 'Email'}
- </span>
- </ViewBreadcrumbs.Button>
- )}
+ {(item) => {
+ const label = () => (
+ <>
+ <span class="truncate @max-[720px]/view-shell:hidden">
+ {tabTitle()}
+ </span>
+ <span class="hidden @max-[720px]/view-shell:inline">
+ {inboxSelected() ? 'Inbox' : 'Email'}
+ </span>
+ </>
+ );
+ const button = () => (
+ <ViewBreadcrumbs.Button
+ class="shrink-0 rounded-md hover:bg-hover"
+ isActive={item.isActive()}
+ onClick={item.onSelect}
+ >
+ {label()}
+ </ViewBreadcrumbs.Button>
+ );
+ // At the list itself the name switches views; deeper, it returns here.
+ return (
+ <Show when={item.isActive()} fallback={button()}>
+ <ViewSwitchTrigger fallback={button()}>{label()}</ViewSwitchTrigger>
+ </Show>
+ );
+ }}
</ViewBreadcrumbs.Item>
);
}
diff --git a/apps/web/src/features/home/components/HomeChatStart.tsx b/apps/web/src/features/home/components/HomeChatStart.tsx
index 99addf2774..ff7824fd09 100644
--- a/apps/web/src/features/home/components/HomeChatStart.tsx
+++ b/apps/web/src/features/home/components/HomeChatStart.tsx
@@ -22,7 +22,7 @@ export function HomeChatStart() {
<ChatInputProvider>
<Show when={showHomeTopBar()}>
<ViewShell.TopBar>
- <ViewSidebar.Title>Home</ViewSidebar.Title>
+ <ViewSidebar.Title caret={false}>Home</ViewSidebar.Title>
</ViewShell.TopBar>
</Show>
<DragDropWrapper class="relative min-h-0 min-w-0 flex-1 overflow-y-auto px-6">
diff --git a/apps/web/src/features/home/components/HomeFilters.tsx b/apps/web/src/features/home/components/HomeFilters.tsx
index dc82229ce6..ce9d2bbd34 100644
--- a/apps/web/src/features/home/components/HomeFilters.tsx
+++ b/apps/web/src/features/home/components/HomeFilters.tsx
@@ -213,18 +213,18 @@ export function HomeFilterDropdown() {
});
return (
- <div class="relative ml-auto shrink-0">
+ <div class="relative shrink-0">
<ListFilterDropdown
label="Filter Home"
customTrigger={
<Dropdown.Trigger
ref={tourTarget(HOME_TOUR.filter)}
variant="ghost"
- size="sm"
- square
+ size="icon-sm"
+ class="size-(--sidebar-control-size)"
label="Filter Home"
>
- <FilterIcon />
+ <FilterIcon class="size-4" />
</Dropdown.Trigger>
}
groups={HOME_FILTER_GROUPS}
diff --git a/apps/web/src/features/home/components/HomeListLayout.tsx b/apps/web/src/features/home/components/HomeListLayout.tsx
index b0d23d08d7..a39f1f9aed 100644
--- a/apps/web/src/features/home/components/HomeListLayout.tsx
+++ b/apps/web/src/features/home/components/HomeListLayout.tsx
@@ -43,7 +43,7 @@ export function HomeListLayout(
title="Home"
label="New chat"
onCreate={props.onNewChat}
- titleActions={<HomeFilterDropdown />}
+ actions={<HomeFilterDropdown />}
searchLabel="Search Home"
search={() => (
<SearchBar
diff --git a/apps/web/src/features/reviews-view/reviews-view.tsx b/apps/web/src/features/reviews-view/reviews-view.tsx
index 7e74560688..96344dfab2 100644
--- a/apps/web/src/features/reviews-view/reviews-view.tsx
+++ b/apps/web/src/features/reviews-view/reviews-view.tsx
@@ -4,6 +4,7 @@ import {
useViewShell,
ViewBreadcrumbs,
ViewShell,
+ ViewSwitchTrigger,
} from '@app/components/view-shell';
import {
ListHeader,
@@ -509,15 +510,25 @@ function ReviewsRoot() {
order={0}
metadata={{ type: 'reviews' }}
>
- {(item) => (
- <ViewBreadcrumbs.ReturnButton
- isActive={item.isActive()}
- onClick={item.onSelect}
- tooltip={scopeTitle()}
- >
- {scopeTitle()}
- </ViewBreadcrumbs.ReturnButton>
- )}
+ {(item) => {
+ const button = () => (
+ <ViewBreadcrumbs.ReturnButton
+ isActive={item.isActive()}
+ onClick={item.onSelect}
+ tooltip={scopeTitle()}
+ >
+ {scopeTitle()}
+ </ViewBreadcrumbs.ReturnButton>
+ );
+ // At the list itself the name switches views; deeper, it returns here.
+ return (
+ <Show when={item.isActive()} fallback={button()}>
+ <ViewSwitchTrigger fallback={button()}>
+ {scopeTitle()}
+ </ViewSwitchTrigger>
+ </Show>
+ );
+ }}
</ViewBreadcrumbs.Item>
<SplitPanel.Root>
<SplitPanel.Body>
diff --git a/apps/web/src/features/scheduling/components/availability-topbar.tsx b/apps/web/src/features/scheduling/components/availability-topbar.tsx
index 84f0c666ef..23b1b2cb07 100644
--- a/apps/web/src/features/scheduling/components/availability-topbar.tsx
+++ b/apps/web/src/features/scheduling/components/availability-topbar.tsx
@@ -1,3 +1,4 @@
+import { ViewSidebar } from '@app/components/view-shell';
import ArrowLeft from '@icon/system/regular/arrow-left.svg';
import Info from '@icon/system/regular/info.svg';
import { Button } from '@ui';
@@ -23,13 +24,13 @@ export function AvailabilityTopBar(props: {
</Button>
</Show>
<div class="flex min-w-0 items-center gap-1">
- <h1 class="min-w-0 truncate pl-2 text-sm font-semibold">
+ <ViewSidebar.Title caret={false} class="pl-2">
{props.editing
? props.creating
? 'Create schedule'
: 'Edit schedule'
: 'Availability'}
- </h1>
+ </ViewSidebar.Title>
<Show when={!props.editing}>
<Button
variant="ghost"
diff --git a/apps/web/src/features/scheduling/views/booking-workspace-view.tsx b/apps/web/src/features/scheduling/views/booking-workspace-view.tsx
index a21e12e520..536445f362 100644
--- a/apps/web/src/features/scheduling/views/booking-workspace-view.tsx
+++ b/apps/web/src/features/scheduling/views/booking-workspace-view.tsx
@@ -479,9 +479,9 @@ export function BookingWorkspaceView(props: {
fallback={
<div class="flex min-w-0 flex-1 items-center gap-2">
<div class="flex min-w-0 items-center gap-1">
- <h1 class="min-w-0 truncate pl-2 text-sm font-semibold">
+ <ViewSidebar.Title caret={false} class="pl-2">
{tab().label}
- </h1>
+ </ViewSidebar.Title>
<Button
variant="ghost"
size="icon-sm"
@@ -682,9 +682,9 @@ export function BookingWorkspaceView(props: {
bookingsTitle={
!isTouchDevice() ? (
<div class="flex items-center gap-2">
- <h1 class="text-sm font-semibold text-ink">
+ <ViewSidebar.Title caret={false}>
Bookings
- </h1>
+ </ViewSidebar.Title>
<div class="hidden @min-[900px]/split-header:flex">
<OwnerBadge scope={current.scope()} />
</div>
@@ -716,9 +716,9 @@ export function BookingWorkspaceView(props: {
insightsTitle={
!isTouchDevice() ? (
<div class="flex items-center gap-2">
- <h1 class="text-sm font-semibold text-ink">
+ <ViewSidebar.Title caret={false}>
Insights
- </h1>
+ </ViewSidebar.Title>
<div class="hidden @min-[900px]/split-header:flex">
<OwnerBadge scope={current.scope()} />
</div>
@@ -733,9 +733,9 @@ export function BookingWorkspaceView(props: {
owner={current}
pageTitle={
!isTouchDevice() ? (
- <h1 class="text-sm font-semibold text-ink">
+ <ViewSidebar.Title caret={false}>
Booking page
- </h1>
+ </ViewSidebar.Title>
) : undefined
}
/>
diff --git a/apps/web/src/features/tasks-view/components/TasksHeader.tsx b/apps/web/src/features/tasks-view/components/TasksHeader.tsx
index 49d60a17f7..858aaf4c1e 100644
--- a/apps/web/src/features/tasks-view/components/TasksHeader.tsx
+++ b/apps/web/src/features/tasks-view/components/TasksHeader.tsx
@@ -2,6 +2,7 @@ import {
useViewControlHotkeys,
ViewBreadcrumbs,
ViewShell,
+ ViewSwitchTrigger,
} from '@app/components/view-shell';
import {
ListHeader,
@@ -41,19 +42,32 @@ export function TaskViewBreadcrumbItem() {
metadata={{ type: 'tasks' }}
order={0}
>
- {(item) => (
- <ViewBreadcrumbs.ReturnButton
- isActive={item.isActive()}
- onClick={item.onSelect}
- tooltip={tabTitle()}
- class="gap-2"
- >
- <Show when={state.savedViewActive}>
- <BookmarkIcon class="size-4 shrink-0" aria-hidden="true" />
+ {(item) => {
+ const label = () => (
+ <>
+ <Show when={state.savedViewActive}>
+ <BookmarkIcon class="size-4 shrink-0" aria-hidden="true" />
+ </Show>
+ <span class="truncate">{tabTitle()}</span>
+ </>
+ );
+ const button = () => (
+ <ViewBreadcrumbs.ReturnButton
+ isActive={item.isActive()}
+ onClick={item.onSelect}
+ tooltip={tabTitle()}
+ class="gap-2"
+ >
+ {label()}
+ </ViewBreadcrumbs.ReturnButton>
+ );
+ // At the list itself the name switches views; deeper, it returns here.
+ return (
+ <Show when={item.isActive()} fallback={button()}>
+ <ViewSwitchTrigger fallback={button()}>{label()}</ViewSwitchTrigger>
</Show>
- <span class="truncate">{tabTitle()}</span>
- </ViewBreadcrumbs.ReturnButton>
- )}
+ );
+ }}
</ViewBreadcrumbs.Item>
);
}
diff --git a/docs/agent-guide/navigation.md b/docs/agent-guide/navigation.md
index 48103a5423..9e9f9f6278 100644
--- a/docs/agent-guide/navigation.md
+++ b/docs/agent-guide/navigation.md
@@ -339,7 +339,18 @@ controls. Use the shared slots described in
Desktop app navigation panels have **Hide navigation** at the right end of their
48px title bar. It hides only that split's navigation; **Show navigation** (the
hamburger) appears before the main header's title/breadcrumbs, including when a
-document, email, or conversation is open. Home's filter sits beside its label.
+document, email, or conversation is open. Home's filter sits in the right group,
+before search and **Hide navigation**.
+A desktop view's name opens the view switcher: clicking it shows the rail's apps
+in rail order, then the More apps, with a check on the current one. Choosing one
+replaces the view in that split, not the active split; Shift opens it in a new
+split. The navigation panel's title shows the name with a caret, sharing one
+hover background. Main headers show the name alone, with the same hover:
+`ViewSidebar.Title caret={false}` for plain titles, and the first breadcrumb
+(Drive, Email, Tasks, Reviews) while it is the current page; deeper, that crumb
+returns to the list. Titles that name content rather than the view (Calendar's
+date, a channel, an agent session, a CRM record) do not switch views. Touch
+devices show plain names and keep the dock.
The split's **Close** control aligns with the navigation icons when expanded and
appears immediately before the hamburger when collapsed. Both use 16px icons in
24px desktop buttons. Close remains hidden when the split cannot be closed.