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
feat(new-layout): add new thin, big icon sidebar behind layout feature flag (#6149)
Seamusa4ec749c2af3
diff --git a/apps/web/src/components/app/Layout.tsx b/apps/web/src/components/app/Layout.tsxindex 2d6a29bdad..668db8cf30 100644--- a/apps/web/src/components/app/Layout.tsx+++ b/apps/web/src/components/app/Layout.tsx@@ -41,6 +41,8 @@ import {type SidebarState,} from '@components/app/app-sidebar/sidebar';import { registerMailtoComposerHandler } from '@components/app/mailtoComposerHandler';+import { SidebarRail } from '@components/app/sidebar-next/sidebar-rail';+import { useSidebarNextFlag } from '@components/app/sidebar-next/use-sidebar-next-flag';import {isSidebarVisible,SidebarCollapseContext,@@ -350,8 +352,12 @@ function LayoutInner(props: RouteSectionProps) {createSignal(false);const callCtx = useCallContextOptional();const incomingCallWidgetVisible = useIncomingCallWidgetVisible();+ const sidebarNextEnabled = useSidebarNextFlag();+ // SidebarRail is already narrow and has no slim mode, so nothing should arm+ // the hover-peek overlay strip or the slim-mode call widget under it.const sidebarCollapsed = createMemo(- () => isSidebarVisible() && sidebarState() === 'slim'+ () =>+ !sidebarNextEnabled() && isSidebarVisible() && sidebarState() === 'slim');const activeCallWidgetVisible = createMemo(() =>@@ -491,19 +497,32 @@ function LayoutInner(props: RouteSectionProps) {sortables with the same drag-drop context as the entity drags. */}<ItemDndProvider><Show when={isSidebarVisible()}>- <AppSidebar- sidebarState={sidebarState()}- overlayOpen={sidebarOverlayOpen()}- onOverlayOpenChange={setSidebarOverlayOpenGuarded}- onOpenChange={(open) => {- if (!open) {- setSidebarState(isTouchDevice() ? 'hidden' : 'slim');- return;+ <Show+ when={sidebarNextEnabled()}+ fallback={+ <AppSidebar+ sidebarState={sidebarState()}+ overlayOpen={sidebarOverlayOpen()}+ onOverlayOpenChange={setSidebarOverlayOpenGuarded}+ onOpenChange={(open) => {+ if (!open) {+ setSidebarState(isTouchDevice() ? 'hidden' : 'slim');+ return;+ }++ setSidebarState('expanded');+ }}+ />+ }+ >+ <SidebarRail+ sidebarState={sidebarState()}+ onOpenChange={(open) =>+ // The rail has no slim mode, so `cmd+.` hides it outright.+ setSidebarState(open ? 'expanded' : 'hidden')}-- setSidebarState('expanded');- }}- />+ />+ </Show></Show><Show when={sidebarCollapsed()}><divdiff --git a/apps/web/src/components/app/app-sidebar/sidebar.tsx b/apps/web/src/components/app/app-sidebar/sidebar.tsxindex 5b1be57b71..a22633c6c8 100644--- a/apps/web/src/components/app/app-sidebar/sidebar.tsx+++ b/apps/web/src/components/app/app-sidebar/sidebar.tsx@@ -124,7 +124,8 @@ import {import { Dynamic } from 'solid-js/web';import { CalendarSidebarPreview } from './calendar-sidebar-preview';-interface SidebarItem {+// TODO(sidebar-next): move to app-sidebar/navigation.tsx once SidebarRail ships.+export interface SidebarItem {id: ListView | (string & {});label: string;href: string;@@ -304,7 +305,7 @@ const isMarkdownDocumentsParams = (return initialClientFilters?.or?.includes('doc-markdown') ?? false;};-function sidebarContent(+export function sidebarContent(viewId: SidebarItem['id'],params?: SidebarItem['params']): SplitContent {@@ -318,7 +319,7 @@ function sidebarContent(* Holding shift opens it in a new split. Use in-app back/forward to return to* prior entries.*/-function navigateToSidebarView(args: {+export function navigateToSidebarView(args: {viewId: SidebarItem['id'];params?: SidebarItem['params'];shiftKey: boolean;@@ -353,7 +354,7 @@ function navigateToSidebarView(args: {});}-const registerSidebarHotkeys = ({+export const registerSidebarHotkeys = ({isSlim,onOpenChange,}: SidebarHotkeyDeps) => {@@ -824,9 +825,15 @@ type SidebarSettingsWidgetProps = {* menu once the user removes its dedicated row.*/gettingStartedLink?: SidebarItem;+ /**+ * Icon-only: drops the trigger's leading padding and start alignment so the+ * avatar centres in its square, and grows the avatar to nearly fill it. For+ * `SidebarRail`, where the name and caret are hidden anyway.+ */+ compact?: boolean;};-const SidebarSettingsWidget = (props: SidebarSettingsWidgetProps) => {+export const SidebarSettingsWidget = (props: SidebarSettingsWidgetProps) => {const userId = useUserId();const email = useEmail();const logout = useLogout();@@ -867,7 +874,9 @@ const SidebarSettingsWidget = (props: SidebarSettingsWidgetProps) => {variant="ghost"class={cn('flex items-center rounded-md cursor-default text-ink-extra-muted not-disabled:hover:bg-ink/3 h-9',- 'justify-start gap-3 px-1.5 py-1'+ props.compact+ ? 'justify-center gap-0 p-0'+ : 'justify-start gap-3 px-1.5 py-1')}label={displayName()}fullWidth@@ -880,10 +889,17 @@ const SidebarSettingsWidget = (props: SidebarSettingsWidgetProps) => {><Showwhen={userId()}- fallback={<div class="size-5 shrink-0 rounded-full bg-ink/10" />}+ fallback={+ <div+ class={cn(+ 'shrink-0 rounded-full bg-ink/10',+ props.compact ? 'size-8' : 'size-5'+ )}+ />+ }>{(id) => (- <div class="size-5 shrink-0">+ <div class={cn('shrink-0', props.compact ? 'size-8' : 'size-5')}><UserIconid={id()}size="fill"@@ -1727,6 +1743,12 @@ interface SidebarOpenInSplitMenuProps {*/onOpened?: (split: SplitHandle, action: SidebarOpenAction) => void;onOpenChange?: (open: boolean) => void;+ /**+ * Overrides the trigger's default `h-7`, which otherwise clips triggers of a+ * different shape (`SidebarRail`'s are 36px squares). Merged with `cn`, so a+ * size utility here wins.+ */+ triggerClass?: string;children: JSX.Element;}@@ -1735,7 +1757,7 @@ interface SidebarOpenInSplitMenuProps {* split, in a new split, or fullscreen. Wraps any sidebar row — the top-level* links and the nested Email account rows both use it.*/-const SidebarOpenInSplitMenu = (props: SidebarOpenInSplitMenuProps) => {+export const SidebarOpenInSplitMenu = (props: SidebarOpenInSplitMenuProps) => {const analytics = useAnalytics();const layout = useSplitLayout();@@ -1777,7 +1799,7 @@ const SidebarOpenInSplitMenu = (props: SidebarOpenInSplitMenuProps) => {return (<ContextMenu onOpenChange={props.onOpenChange}>- <ContextMenu.Trigger class="w-full h-7">+ <ContextMenu.Trigger class={cn('w-full h-7', props.triggerClass)}>{props.children}</ContextMenu.Trigger>diff --git a/apps/web/src/components/app/sidebar-next/create-button.tsx b/apps/web/src/components/app/sidebar-next/create-button.tsxnew file mode 100644index 0000000000..7846c83889--- /dev/null+++ b/apps/web/src/components/app/sidebar-next/create-button.tsx@@ -0,0 +1,40 @@+import { SidebarCreateMenu } from '@app/features/command/sidebar/sidebar-create-menu';+import { TOKENS } from '@core/hotkey/tokens';+import PlusIcon from '@phosphor/plus.svg';+import { Button, type ButtonProps } from '@ui';++/**+ * The rail's create trigger, as a CTA.+ *+ * The app's canonical `cta` Button: this is the one control in the rail meant+ * to pull the eye, and the accent fill along with its hover/active scrims,+ * focus ring and contrast tokens is already themed there. Only the geometry is+ * overridden, to sit in the rail's 36px column beside the search button.+ *+ * Kobalte's trigger props arrive via `as` and are spread on, so the ref and+ * handlers land on the real element. `variant`/`size` deliberately follow that+ * spread: `Dropdown.Trigger` blanks both for a custom trigger.+ */+const RailCreateTrigger = (props: ButtonProps) => (+ <Button+ {...props}+ variant="cta"+ class="rounded-full"+ size="icon-md"+ // class="rounded-full shadow-md shadow-drop-shadow bg-surface-2"+ label="Create"+ tooltipPlacement="right"+ hotkey={TOKENS.global.createCommand}+ >+ <PlusIcon class="size-5" />+ </Button>+);++export const SidebarRailCreateButton = (props: {+ onMenuOpenChange?: (open: boolean) => void;+}) => (+ <SidebarCreateMenu+ trigger={RailCreateTrigger}+ onMenuOpenChange={props.onMenuOpenChange}+ />+);diff --git a/apps/web/src/components/app/sidebar-next/footer-actions.tsx b/apps/web/src/components/app/sidebar-next/footer-actions.tsxnew file mode 100644index 0000000000..584edbbd46--- /dev/null+++ b/apps/web/src/components/app/sidebar-next/footer-actions.tsx@@ -0,0 +1,114 @@+import { runCreateAction } from '@app/features/command/Launcher';+import { globalSplitManager } from '@app/signal/splitLayout';+import { CALENDAR_BLOCK_ID } from '@block-calendar/types';+import { SidebarSettingsWidget } from '@components/app/app-sidebar/sidebar';+import { ENABLE_CHAT_V3_AGENTS } from '@core/constant/featureFlags';+import {+ type SettingsTab,+ useSettingsState,+} from '@core/constant/SettingsState';+import { useSettingsTabAvailable } from '@core/constant/settingsTabsConfig';+import { TOKENS } from '@core/hotkey/tokens';+import CalendarPlusIcon from '@phosphor/calendar-plus.svg';+import SparkleIcon from '@phosphor/sparkle.svg';+import { Button } from '@ui';+import { Show } from 'solid-js';+import { MoreAppsPopover } from './more-apps-popover';+import { useNavItemGates } from './use-nav-item-gates';++/**+ * The rail's bottom actions, stacked: new AI chat, calendar in a new split, and+ * the More Apps grid, with the account card below a divider. Settings is+ * reached from that card's menu rather than its own button.+ */+export const FooterActions = (props: {+ onMenuOpenChange?: (open: boolean) => void;+}) => {+ const { openSettings, selectTab, settingsOpen } = useSettingsState();+ const isTabAvailable = useSettingsTabAvailable();+ const gates = useNavItemGates();++ // Same handling as `AppSidebar`: retarget the panel when it is already open+ // rather than reopening it, and ignore tabs this account cannot reach.+ const openSettingsTab = (tab: SettingsTab) => {+ if (!isTabAvailable(tab)) return;+ if (settingsOpen()) {+ selectTab(tab);+ return;+ }+ openSettings(tab);+ };++ const canOpenNewSplit = () => globalSplitManager()?.canAppendSplit() ?? true;++ const openCalendarInNewSplit = () => {+ const manager = globalSplitManager();+ if (!manager?.canAppendSplit()) return;+ manager.createNewSplit({+ content: { type: 'calendar', id: CALENDAR_BLOCK_ID },+ activate: true,+ allowDuplicate: false,+ referredFrom: 'sidebar',+ });+ };++ return (+ <div class="flex w-full shrink-0 flex-col gap-2">+ <div class="flex w-full flex-col items-center gap-1">+ <Button+ size="icon-md"+ variant="ghost"+ class="text-ink-subtle hover:text-ink rounded-xl"+ label="New AI chat in a new split"+ hotkey={TOKENS.create.chatNewSplit}+ onClick={() =>+ // The two creatables both bind `a` and are mutually exclusive on the+ // agents flag, so pick the one that is actually registered.+ // `shouldInsert` is what `createBlock` turns into `preferNewSplit`.+ runCreateAction(ENABLE_CHAT_V3_AGENTS() ? 'agent' : 'chat', {+ shouldInsert: true,+ source: 'sidebar',+ })+ }+ >+ <SparkleIcon />+ </Button>++ <Show when={gates().showCalendar}>+ <Button+ size="icon-md"+ variant="ghost"+ class="text-ink-subtle hover:text-ink rounded-xl"+ label="Open calendar in a new split"+ disabled={!canOpenNewSplit()}+ onClick={openCalendarInNewSplit}+ >+ <CalendarPlusIcon />+ </Button>+ </Show>++ <MoreAppsPopover onOpenChange={props.onMenuOpenChange} />+ </div>++ {/* Inset within the sidebar's `px-3` rather than breaking out of it, so+ the rule stops short of the edges. `my-2` sits on top of the wrapper's+ `gap-2`, giving it 16px of clearance above and below. */}+ <div class="my-2 h-px shrink-0 self-stretch bg-edge-muted" />++ {/*+ The account card from the old sidebar, reused whole. Its trigger already+ collapses to the bare avatar under that sidebar's slim contract, so the+ group is scoped to this wrapper — setting `data-slim` on the rail root+ would expose every descendant to those selectors.+ */}+ <div class="group/sidebar flex w-full justify-center" data-slim="true">+ <SidebarSettingsWidget+ compact+ isSlim={() => true}+ onSelect={openSettingsTab}+ onMenuOpenChange={props.onMenuOpenChange}+ />+ </div>+ </div>+ );+};diff --git a/apps/web/src/components/app/sidebar-next/list-nav.tsx b/apps/web/src/components/app/sidebar-next/list-nav.tsxnew file mode 100644index 0000000000..0a5cab0367--- /dev/null+++ b/apps/web/src/components/app/sidebar-next/list-nav.tsx@@ -0,0 +1,134 @@+import { useAnalytics } from '@app/lib/analytics/analytics-context';+import { globalSplitManager } from '@app/signal/splitLayout';+import {+ navigateToSidebarView,+ SidebarOpenInSplitMenu,+ sidebarContent,+} from '@components/app/app-sidebar/sidebar';+import { useSplitLayout } from '@components/app/split-layout/layout';+import { TOKENS } from '@core/hotkey/tokens';+import { useLocation } from '@solidjs/router';+import { Button, cn } from '@ui';+import { NavGlyph } from './nav-glyph';+import type { SidebarNextNavItem } from './nav-items';++export type ListNavProps = {+ item: SidebarNextNavItem;+ onContextMenuOpenChange?: (open: boolean) => void;+};++/**+ * A SidebarRail nav button: an icon-only `@ui` Button, plus the behaviour+ * behind it — active detection, navigation, shift-click into a new split, the+ * open-in-split context menu.+ *+ * There is no room for a label or a `g`-leader hint in a 36px square, so both+ * live in the tooltip instead.+ *+ * Named for the shape it grows into: each nav is expected to expand into a list+ * of its own live items (Email accounts, Chat channels, Drive files). The slot+ * for that is deliberately absent until there is a data source to fill it.+ */+export const ListNav = (props: ListNavProps) => {+ const analytics = useAnalytics();+ const layout = useSplitLayout();+ const location = useLocation();++ const content = () => sidebarContent(props.item.id, props.item.params);++ // Read the manager signal live: it is undefined until the split layout+ // mounts, which happens after the sidebar.+ 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);+ }+ const expected = content();+ return (+ activeContent.type === expected.type && activeContent.id === expected.id+ );+ };++ const navigate = (event: MouseEvent) => {+ if (event.button !== 0) return;+ // 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) {+ navigateToSidebarView({+ viewId: props.item.id,+ params: props.item.params,+ shiftKey: event.shiftKey,+ activeSplit,+ openWithSplit: layout.openWithSplit,+ referredFrom: 'sidebar',+ });+ }++ globalSplitManager()?.returnFocus();+ };++ return (+ <SidebarOpenInSplitMenu+ content={content}+ onOpenChange={props.onContextMenuOpenChange}+ // The trigger defaults to `w-full h-7`, which clips the square button.+ triggerClass="size-9"+ >+ <Button+ variant="ghost"+ size="icon-md"+ class="cursor-default rounded-xl"+ label={props.item.label}+ tooltip={`Go to ${props.item.label}`}+ tooltipPlacement="right"+ hotkey={[TOKENS.sidebar.goToLeader, props.item.hotkeyToken]}+ draggable={false}+ aria-current={isActive() ? 'page' : undefined}+ // An attribute rather than a class-only state, so the styling can be+ // retargeted from CSS and the `data-active` selectors the old sidebar's+ // tests use keep working.+ data-active={isActive() ? '' : undefined}+ data-sidebar-next-item={props.item.id}+ onMouseDown={navigate}+ >+ {/* Flush to the screen edge: the button sits inside the rail's own+ `px-3`, so -12px lands the bar's outer edge at x=0. Absolutely+ positioned, so activating a button never shifts its glyph, and grown+ on the Y axis only — scaling X too would pull the bar off the edge+ mid-transition. Faded rather than mounted so it arrives on the same+ curve as the glyph's outline-to-fill swap. */}+ <span+ aria-hidden="true"+ class={cn(+ 'absolute -left-3 top-1/2 h-3/4 w-1 -translate-y-1/2 rounded-r-full bg-accent',+ 'transition-[opacity,transform] duration-150 ease-out motion-reduce:transition-none',+ isActive() ? 'scale-y-100 opacity-100' : 'scale-y-90 opacity-0'+ )}+ />++ {/* The accent sits on the glyph rather than the button: `ghost`+ brightens its own text on hover, which would otherwise pull an+ active button back to `text-ink` under the cursor. */}+ <NavGlyph+ icon={props.item.icon}+ iconActive={props.item.iconActive}+ filled={isActive()}+ class={cn('size-5.5', isActive() && 'text-accent')}+ />+ </Button>+ </SidebarOpenInSplitMenu>+ );+};diff --git a/apps/web/src/components/app/sidebar-next/more-apps-popover.tsx b/apps/web/src/components/app/sidebar-next/more-apps-popover.tsxnew file mode 100644index 0000000000..8474b2561c--- /dev/null+++ b/apps/web/src/components/app/sidebar-next/more-apps-popover.tsx@@ -0,0 +1,93 @@+import { sidebarContent } from '@components/app/app-sidebar/sidebar';+import { isTauri } from '@core/util/platform';+import { openExternalUrl } from '@core/util/url';+import SquaresFourIcon from '@phosphor/squares-four.svg';+import { Button, Dropdown } from '@ui';+import { createSignal, For } from 'solid-js';+import { NavGlyph } from './nav-glyph';+import { type SidebarNextNavItem, visibleNavItems } from './nav-items';+import { splitContentUrl } from './urls';+import { useNavItemGates } from './use-nav-item-gates';++/**+ * One cell of the grid. A real `<a href>` so cmd-click, middle-click and the+ * browser's own "open in new tab" work — the point of the grid. Plain+ * left-click still routes through `openExternalUrl`, because Tauri needs a+ * `_self` navigation to hand the URL to the system browser.+ *+ * The only surface in the rail that isn't a `Button`: it stacks a label under+ * the glyph, and has no active state of its own — every entry opens a new tab —+ * so the outline-to-fill swap runs off hover instead.+ */+const AppTile = (props: { item: SidebarNextNavItem }) => {+ const [hovering, setHovering] = createSignal(false);+ const url = () =>+ splitContentUrl(sidebarContent(props.item.id, props.item.params));++ return (+ <a+ href={url()}+ target="_blank"+ rel="noopener noreferrer"+ draggable={false}+ data-sidebar-next-tile={props.item.id}+ class="flex aspect-square cursor-default select-none flex-col items-center justify-center gap-2 rounded-xl text-[12px] text-ink outline-none transition-colors duration-150 ease-out hover:bg-hover focus-visible:ring-2 focus-visible:ring-accent/40 motion-reduce:transition-none"+ onMouseEnter={() => setHovering(true)}+ onMouseLeave={() => setHovering(false)}+ onClick={(event) => {+ // Let the browser handle the modified clicks it already does better+ // than we can.+ if (+ event.button !== 0 ||+ event.metaKey ||+ event.ctrlKey ||+ event.shiftKey ||+ event.altKey+ ) {+ return;+ }+ if (!isTauri()) return;+ event.preventDefault();+ openExternalUrl(new URL(url(), window.location.origin).href);+ }}+ >+ <NavGlyph+ icon={props.item.icon}+ iconActive={props.item.iconActive}+ filled={hovering()}+ class="size-6"+ />+ <span class="max-w-full truncate">{props.item.label}</span>+ </a>+ );+};++/** The grid of every nav, each opening in a new browser tab. */+export const MoreAppsPopover = (props: {+ onOpenChange?: (open: boolean) => void;+}) => {+ const gates = useNavItemGates();++ return (+ <Dropdown onOpenChange={props.onOpenChange} placement="top" gutter={8}>+ <Dropdown.Trigger+ as={Button}+ size="icon-md"+ variant="ghost"+ class="text-ink-subtle hover:text-ink rounded-xl"+ label="More apps"+ >+ <SquaresFourIcon />+ </Dropdown.Trigger>+ <Dropdown.Content class="w-72 rounded-2xl">+ {/* Group rather than a bare div: it paints the `bg-menu` ground that+ Content's inner `bg-edge-muted` wrapper otherwise shows through. */}+ <Dropdown.Group class="grid grid-cols-3 gap-2 rounded-2xl p-3">+ <For each={visibleNavItems(gates())}>+ {(item) => <AppTile item={item} />}+ </For>+ </Dropdown.Group>+ </Dropdown.Content>+ </Dropdown>+ );+};diff --git a/apps/web/src/components/app/sidebar-next/nav-glyph.tsx b/apps/web/src/components/app/sidebar-next/nav-glyph.tsxnew file mode 100644index 0000000000..fdbdb4b841--- /dev/null+++ b/apps/web/src/components/app/sidebar-next/nav-glyph.tsx@@ -0,0 +1,57 @@+import { cn } from '@ui';+import { type Component, type JSX, Show } from 'solid-js';+import { Dynamic } from 'solid-js/web';++/** Any SVG component — in practice the Phosphor icons `nav-items` imports. */+export type NavIcon = Component<JSX.SvgSVGAttributes<SVGSVGElement>>;++const SWAP = cn(+ 'absolute inset-0 transition-opacity duration-150 ease-out',+ 'motion-reduce:transition-none'+);++/**+ * A nav glyph, optionally cross-fading to a filled counterpart.+ *+ * Both weights are stacked in the same square box and swapped by opacity+ * alone, so neither reflows its button and the outline glyph does not blink out+ * before the filled one arrives. Phosphor glyphs are `fill="currentColor"`, so+ * the caller's text colour — an active nav button's `text-accent` included —+ * carries into both.+ */+export const NavGlyph = (props: {+ icon: NavIcon;+ /** Filled counterpart of `icon`. Omit to keep one glyph in every state. */+ iconActive?: NavIcon;+ /** Cross-fades `iconActive` in. Ignored when there isn't one. */+ filled?: boolean;+ /** Sizes the box and, with it, both glyphs — e.g. `size-5`. */+ class: string;+}) => (+ <div+ class={cn(+ 'pointer-events-none relative flex shrink-0 items-center justify-center',+ props.class+ )}+ >+ <Show+ when={props.iconActive}+ fallback={<Dynamic component={props.icon} class="size-full" />}+ >+ {(iconActive) => (+ <>+ <Dynamic+ component={props.icon}+ aria-hidden="true"+ class={cn(SWAP, props.filled ? 'opacity-0' : 'opacity-100')}+ />+ <Dynamic+ component={iconActive()}+ aria-hidden="true"+ class={cn(SWAP, props.filled ? 'opacity-100' : 'opacity-0')}+ />+ </>+ )}+ </Show>+ </div>+);diff --git a/apps/web/src/components/app/sidebar-next/nav-items.ts b/apps/web/src/components/app/sidebar-next/nav-items.tsnew file mode 100644index 0000000000..ecd9eb8367--- /dev/null+++ b/apps/web/src/components/app/sidebar-next/nav-items.ts@@ -0,0 +1,140 @@+import { LIST_VIEW_PATHS } from '@app/constants/list-views';+import type { SidebarItem } from '@components/app/app-sidebar/sidebar';+import { TOKENS } from '@core/hotkey/tokens';+import BellIcon from '@phosphor/bell.svg';+import BuildingsIcon from '@phosphor/buildings.svg';+import CalendarBlankIcon from '@phosphor/calendar-blank.svg';+import ChatsCircleIcon from '@phosphor/chats-circle.svg';+import EnvelopeIcon from '@phosphor/envelope.svg';+import FolderSimpleIcon from '@phosphor/folder-simple.svg';+import ListChecksIcon from '@phosphor/list-checks.svg';+import SparkleIcon from '@phosphor/sparkle.svg';+import BellFillIcon from '@phosphor-fill/bell-fill.svg';+import BuildingsFillIcon from '@phosphor-fill/buildings-fill.svg';+import CalendarBlankFillIcon from '@phosphor-fill/calendar-blank-fill.svg';+import ChatsCircleFillIcon from '@phosphor-fill/chats-circle-fill.svg';+import EnvelopeFillIcon from '@phosphor-fill/envelope-fill.svg';+import FolderSimpleFillIcon from '@phosphor-fill/folder-simple-fill.svg';+import ListChecksFillIcon from '@phosphor-fill/list-checks-fill.svg';+import SparkleFillIcon from '@phosphor-fill/sparkle-fill.svg';+import type { NavIcon } from './nav-glyph';++/**+ * A SidebarRail nav button's definition: a `SidebarItem` plus the filled icon+ * the button cross-fades to while its view is active. Both are required here,+ * unlike `SidebarItem['icon']` — a rail button is nothing but its glyph.+ */+export type SidebarNextNavItem = SidebarItem & {+ icon: NavIcon;+ /** Phosphor `fill` weight of `icon`, shown while the view is active. */+ iconActive: NavIcon;+};++/**+ * SidebarRail's nav buttons, in render order.+ *+ * Phosphor icons rather than the animated `wide-*` set the old sidebar uses:+ * they are plain `fill="currentColor"` SVGs, so the active button's+ * `text-accent` colours the glyph.+ *+ * The labels are new but every destination is an existing view id, so the+ * `hotkeyToken`s are the ones `GoToHotkeys` already registers — `g i` still+ * reaches Activity, `g f` still reaches Drive. `GoToHotkeys` is mounted from+ * `Layout` off `buildSidebarLinks` and is independent of which sidebar renders,+ * so the shortcuts work unchanged; these tokens only label the tooltips.+ */+const SIDEBAR_NEXT_NAV_ITEMS = [+ {+ id: 'inbox',+ label: 'Activity',+ href: LIST_VIEW_PATHS.inbox,+ icon: BellIcon,+ iconActive: BellFillIcon,+ hotkey: 'i',+ hotkeyToken: TOKENS.sidebar.goTo.inbox,+ },+ {+ id: 'documents',+ label: 'Drive',+ href: LIST_VIEW_PATHS.documents,+ icon: FolderSimpleIcon,+ iconActive: FolderSimpleFillIcon,+ hotkey: 'f',+ hotkeyToken: TOKENS.sidebar.goTo.documents,+ },+ {+ id: 'mail',+ label: 'Email',+ href: LIST_VIEW_PATHS.mail,+ icon: EnvelopeIcon,+ iconActive: EnvelopeFillIcon,+ hotkey: 'e',+ hotkeyToken: TOKENS.sidebar.goTo.mail,+ },+ {+ id: 'channels',+ label: 'Chat',+ href: LIST_VIEW_PATHS.channels,+ icon: ChatsCircleIcon,+ iconActive: ChatsCircleFillIcon,+ hotkey: 'c',+ hotkeyToken: TOKENS.sidebar.goTo.channels,+ },+ {+ id: 'tasks',+ label: 'Tasks',+ href: LIST_VIEW_PATHS.tasks,+ icon: ListChecksIcon,+ iconActive: ListChecksFillIcon,+ hotkey: 't',+ hotkeyToken: TOKENS.sidebar.goTo.tasks,+ },+ {+ id: 'calendar',+ label: 'Calendar',+ href: '/calendar',+ icon: CalendarBlankIcon,+ iconActive: CalendarBlankFillIcon,+ hotkey: 'r',+ hotkeyToken: TOKENS.sidebar.goTo.calendar,+ },+ {+ id: 'agents',+ label: 'Agents',+ href: LIST_VIEW_PATHS.agents,+ icon: SparkleIcon,+ iconActive: SparkleFillIcon,+ hotkey: 'a',+ hotkeyToken: TOKENS.sidebar.goTo.agents,+ },+ {+ id: 'companies',+ label: 'Customers',+ href: LIST_VIEW_PATHS.companies,+ icon: BuildingsIcon,+ iconActive: BuildingsFillIcon,+ hotkey: 'o',+ hotkeyToken: TOKENS.sidebar.goTo.companies,+ },+] satisfies SidebarNextNavItem[];++/** The flag gates Calendar and Customers keep from `AppSidebar`. */+export type NavItemGates = {+ showCalendar: boolean;+ showCustomers: boolean;+};++/**+ * The nav buttons on offer right now.+ *+ * Gates are passed in rather than read here: both are PostHog-backed, and the+ * imperative `ENABLE_CRM()` / `ENABLE_CALENDAR_UI()` readers call+ * `isFeatureEnabled` without tracking it, so a flag that resolves after mount+ * would never reach the rendered list. Callers subscribe with `useFeatureFlag`.+ */+export const visibleNavItems = (gates: NavItemGates): SidebarNextNavItem[] =>+ SIDEBAR_NEXT_NAV_ITEMS.filter((item) => {+ if (item.id === 'calendar') return gates.showCalendar;+ if (item.id === 'companies') return gates.showCustomers;+ return true;+ });diff --git a/apps/web/src/components/app/sidebar-next/search-bar-button.tsx b/apps/web/src/components/app/sidebar-next/search-bar-button.tsxnew file mode 100644index 0000000000..9ab52db664--- /dev/null+++ b/apps/web/src/components/app/sidebar-next/search-bar-button.tsx@@ -0,0 +1,63 @@+import { requestSearchFocus } from '@app/features/next-soup/soup-view/search-controllers';+import { useAnalytics } from '@app/lib/analytics/analytics-context';+import { globalSplitManager } from '@app/signal/splitLayout';+import { navigateToSidebarView } from '@components/app/app-sidebar/sidebar';+import { useSplitLayout } from '@components/app/split-layout/layout';+import { TOKENS } from '@core/hotkey/tokens';+import MagnifyingGlassIcon from '@phosphor/magnifying-glass.svg';+import { Button } from '@ui';++/**+ * The rail's search button: the magnifier alone, its label in the tooltip.+ *+ * An `@ui` Button on the same geometry as the create CTA beside it — same size,+ * rounding and lift — so the pair reads as one row of actions and either can be+ * restyled through `variant` and `class` alone.+ *+ * Takes the active split to the search view and focuses its input — the same+ * behaviour as the old sidebar's magnifier (`SidebarHeaderSearchButton`), not+ * the command menu. Already on search, it just refocuses the input rather than+ * pushing a second entry.+ */+export const SearchRailButton = () => {+ const analytics = useAnalytics();+ const layout = useSplitLayout();++ const openSearch = (event: MouseEvent) => {+ analytics.track('sidebar_click', { view: 'search' });++ let split = globalSplitManager()?.activeSplit();+ const content = split?.content();++ if (split && content?.type === 'component' && content.id === 'search') {+ requestSearchFocus(split.id);+ globalSplitManager()?.returnFocus();+ return;+ }++ split = navigateToSidebarView({+ viewId: 'search',+ shiftKey: event.shiftKey,+ activeSplit: split,+ openWithSplit: layout.openWithSplit,+ referredFrom: 'sidebar',+ });+ if (split) requestSearchFocus(split.id);+ globalSplitManager()?.returnFocus();+ };++ return (+ <Button+ size="icon-md"+ variant="ghost"+ // class="rounded-full shadow-md shadow-drop-shadow bg-surface-2"+ label="Search"+ tooltipPlacement="right"+ hotkey={TOKENS.sidebar.goTo.search}+ data-sidebar-next-search=""+ onClick={openSearch}+ >+ <MagnifyingGlassIcon class="size-5" />+ </Button>+ );+};diff --git a/apps/web/src/components/app/sidebar-next/sidebar-rail.tsx b/apps/web/src/components/app/sidebar-next/sidebar-rail.tsxnew file mode 100644index 0000000000..7a8a613244--- /dev/null+++ b/apps/web/src/components/app/sidebar-next/sidebar-rail.tsx@@ -0,0 +1,91 @@+import { useAnalytics } from '@app/lib/analytics/analytics-context';+import { globalSplitManager } from '@app/signal/splitLayout';+import {+ navigateToSidebarView,+ registerSidebarHotkeys,+ type SidebarState,+} from '@components/app/app-sidebar/sidebar';+import { useSplitLayout } from '@components/app/split-layout/layout';+import { hotkeyScopeNeutralAttribute } from '@core/dom-selectors';+import { For } from 'solid-js';+import { SidebarRailCreateButton } from './create-button';+import { FooterActions } from './footer-actions';+import { ListNav } from './list-nav';+import { visibleNavItems } from './nav-items';+import { SearchRailButton } from './search-bar-button';+import { useNavItemGates } from './use-nav-item-gates';++export type SidebarRailProps = {+ sidebarState?: SidebarState;+ onOpenChange: (open: boolean) => void;+};++/** 36px buttons plus the 12px of padding either side. */+const RAIL_WIDTH = 'w-15';++/**+ * The rebuilt app sidebar, behind `enable-new-app-views`: a single always-narrow+ * column of 36px icon buttons, labels in tooltips.+ *+ * Always narrow by design — there is no slim mode and no hover-peek overlay, so+ * `cmd+.` hides the rail outright rather than collapsing it. The `g`-prefixed+ * nav shortcuts are unaffected: `GoToHotkeys` is mounted from `Layout` and does+ * not depend on which sidebar renders. There is no room for the leader-key+ * hints the old sidebar paints on its rows, so each button's tooltip carries+ * its shortcut instead.+ */+export const SidebarRail = (props: SidebarRailProps) => {+ const gates = useNavItemGates();+ const analytics = useAnalytics();+ const layout = useSplitLayout();++ const isExpanded = () => (props.sidebarState ?? 'expanded') === 'expanded';++ // `cmd+.` lives on the rendered sidebar, so the rail has to register it too+ // or the shortcut goes dead whenever this replaces `AppSidebar`.+ registerSidebarHotkeys({+ isSlim: () => !isExpanded(),+ onOpenChange: props.onOpenChange,+ });++ const _openHome = (event: MouseEvent) => {+ if (event.button !== 0) return;+ event.preventDefault();+ analytics.track('sidebar_click', { view: 'home' });+ navigateToSidebarView({+ viewId: 'home',+ shiftKey: event.shiftKey,+ activeSplit: globalSplitManager()?.activeSplit(),+ openWithSplit: layout.openWithSplit,+ referredFrom: 'sidebar',+ });+ globalSplitManager()?.returnFocus();+ };++ return (+ <div+ {...hotkeyScopeNeutralAttribute}+ data-ui="sidebar-rail"+ class={`relative flex h-full ${RAIL_WIDTH} shrink-0 flex-col items-center gap-2 overflow-hidden bg-surface px-3 pb-3 pt-3`}+ >+ <SidebarRailCreateButton />+ <SearchRailButton />++ <nav class="shrink-0 pt-5">+ <ul class="flex flex-col items-center gap-2">+ <For each={visibleNavItems(gates())}>+ {(item) => (+ <li class="flex">+ <ListNav item={item} />+ </li>+ )}+ </For>+ </ul>+ </nav>++ <div class="min-h-0 flex-1" />++ <FooterActions />+ </div>+ );+};diff --git a/apps/web/src/components/app/sidebar-next/urls.ts b/apps/web/src/components/app/sidebar-next/urls.tsnew file mode 100644index 0000000000..6ea49a2ef2--- /dev/null+++ b/apps/web/src/components/app/sidebar-next/urls.ts@@ -0,0 +1,20 @@+import { ROUTER_BASE_CONCAT } from '@app/constants/routerBase';+import type { SplitContent } from '@components/app/split-layout/layoutManager';++/**+ * The browser URL a split content deserializes from, e.g.+ * `/app/component/documents` or `/app/calendar/view`.+ *+ * Mirrors `contentUrlSegments` in `layoutManager` and the `decodePairs` reader+ * in `layoutUtils`: the layout URL is `<type>/<id>` pairs, so the bare+ * `LIST_VIEW_PATHS` entries (`/documents`) are *not* usable as tab URLs —+ * `decodePairs` breaks on the missing id and falls back to the inbox.+ */+export const splitContentUrl = (content: SplitContent): string => {+ // Aliased blocks serialise under their alias, matching `getAliasOrType`.+ const type =+ content.type === 'component'+ ? content.type+ : (content.aliasContext?.alias ?? content.type);+ return `${ROUTER_BASE_CONCAT}${type}/${content.id}`;+};diff --git a/apps/web/src/components/app/sidebar-next/use-nav-item-gates.ts b/apps/web/src/components/app/sidebar-next/use-nav-item-gates.tsnew file mode 100644index 0000000000..f38a7e018c--- /dev/null+++ b/apps/web/src/components/app/sidebar-next/use-nav-item-gates.ts@@ -0,0 +1,25 @@+import { useCalendarUiFlag } from '@app/features/calendar/hooks/use-calendar-ui-flag';+import { useFeatureFlag } from '@app/lib/analytics/posthog';+import {+ ENABLE_CRM_FLAG,+ ENABLE_CRM_OVERRIDE,+} from '@core/constant/featureFlags';+import type { Accessor } from 'solid-js';+import type { NavItemGates } from './nav-items';++/**+ * Subscribes to the flags gating the Calendar and Customers rows, so a flag+ * that resolves after mount still reaches the rendered list. Shared by the+ * sidebar's nav and the More Apps grid so the two can't disagree about which+ * apps exist.+ */+export function useNavItemGates(): Accessor<NavItemGates> {+ const calendar = useCalendarUiFlag();+ const crm = useFeatureFlag(ENABLE_CRM_FLAG, {+ enabledOverride: ENABLE_CRM_OVERRIDE,+ });+ return () => ({+ showCalendar: calendar(),+ showCustomers: crm().enabled,+ });+}diff --git a/apps/web/src/components/app/sidebar-next/use-sidebar-next-flag.ts b/apps/web/src/components/app/sidebar-next/use-sidebar-next-flag.tsnew file mode 100644index 0000000000..704023c4ec--- /dev/null+++ b/apps/web/src/components/app/sidebar-next/use-sidebar-next-flag.ts@@ -0,0 +1,18 @@+import { useFeatureFlag } from '@app/lib/analytics/posthog';+import {+ ENABLE_SIDEBAR_NEXT_FLAG,+ ENABLE_SIDEBAR_NEXT_OVERRIDE,+} from '@core/constant/featureFlags';+import type { Accessor } from 'solid-js';++/**+ * Whether `SidebarRail` renders in place of `AppSidebar`. Needs the+ * `enable-new-app-views` PostHog flag, in dev as much as anywhere else. Set+ * VITE_ENABLE_SIDEBAR_NEXT=true to force it on locally without PostHog.+ */+export function useSidebarNextFlag(): Accessor<boolean> {+ const flag = useFeatureFlag(ENABLE_SIDEBAR_NEXT_FLAG, {+ enabledOverride: ENABLE_SIDEBAR_NEXT_OVERRIDE,+ });+ return () => flag().enabled;+}diff --git a/apps/web/src/features/command/sidebar/sidebar-create-menu.tsx b/apps/web/src/features/command/sidebar/sidebar-create-menu.tsxindex 38de0f67f8..cdf9f5e883 100644--- a/apps/web/src/features/command/sidebar/sidebar-create-menu.tsx+++ b/apps/web/src/features/command/sidebar/sidebar-create-menu.tsx@@ -8,19 +8,39 @@ import { activateClosestDOMScope } from '@core/hotkey/utils';import CreateIcon from '@icon/square-pen-create.svg';import PlusIcon from '@phosphor/plus.svg';import { Button, Dropdown, Hotkey, NavRow } from '@ui';-import { createSignal, For, onCleanup, Show } from 'solid-js';+import {+ createSignal,+ For,+ onCleanup,+ Show,+ type ValidComponent,+} from 'solid-js';import { Dynamic } from 'solid-js/web';-export const SidebarCreateMenu = (props: {- isSlim: () => boolean;+export type SidebarCreateMenuProps = {+ /** Only read by the built-in `row` variant, for its tooltip. */+ isSlim?: () => boolean;variant?: 'row' | 'icon';+ /**+ * Your own trigger, rendered as the Kobalte `Dropdown.Trigger` via `as` — so+ * the ref, aria wiring and open/close handlers are attached for you. Spread+ * the props you receive onto one interactive element, and style the open+ * state off the `data-expanded` attribute Kobalte sets on it.+ *+ * Takes precedence over `variant`.+ */+ trigger?: ValidComponent;onMenuOpenChange?: (open: boolean) => void;-}) => {+};++export const SidebarCreateMenu = (props: SidebarCreateMenuProps) => {const analytics = useAnalytics();const [open, setOpen] = createSignal(false);const [focusedIndex, setFocusedIndex] = createSignal(-1);const blocks = useCreateMenuBlocks();+ const isSlim = () => props.isSlim?.() ?? false;+const handleOpenChange = (nextOpen: boolean) => {if (nextOpen && !open()) {analytics.track('create_menu_open', { from: 'sidebar' });@@ -72,54 +92,72 @@ export const SidebarCreateMenu = (props: {gutter={8}><Show- when={props.variant === 'icon'}+ when={props.trigger}fallback={- <Dropdown.Trigger- as={NavRow}- class="center h-8 bg-ink/4 text-[13px]"- fullWidth- tooltipPlacement="right"- tooltipDisabled={!props.isSlim()}- label="Create"- hotkey={TOKENS.global.createCommand}- onMouseDown={(e: MouseEvent) => {- if (e.button !== 0) return;- e.preventDefault();- }}+ <Show+ when={props.variant === 'icon'}+ fallback={+ <Dropdown.Trigger+ as={NavRow}+ class="center h-8 bg-ink/4 text-[13px]"+ fullWidth+ tooltipPlacement="right"+ tooltipDisabled={!isSlim()}+ label="Create"+ hotkey={TOKENS.global.createCommand}+ onMouseDown={(e: MouseEvent) => {+ if (e.button !== 0) return;+ e.preventDefault();+ }}+ >+ <div class="size-4 shrink-0">+ <PlusIcon class="size-4" />+ </div>+ <span class="whitespace-nowrap group-data-[slim=true]/sidebar:hidden">+ Create+ </span>+ <Show when={open()}>+ <div class="text-xxs text-ink-extra-muted/50 rounded-sm ml-auto border border-ink/5 px-1.5 py-px -my-1 group-data-[slim=true]/sidebar:hidden">+ <Hotkey+ token={TOKENS.global.createCommand}+ class="flex gap-1"+ />+ </div>+ </Show>+ </Dropdown.Trigger>+ }>- <div class="size-4 shrink-0">- <PlusIcon class="size-4" />- </div>- <span class="whitespace-nowrap group-data-[slim=true]/sidebar:hidden">- Create- </span>- <Show when={open()}>- <div class="text-xxs text-ink-extra-muted/50 rounded-sm ml-auto border border-ink/5 px-1.5 py-px -my-1 group-data-[slim=true]/sidebar:hidden">- <Hotkey- token={TOKENS.global.createCommand}- class="flex gap-1"- />- </div>- </Show>- </Dropdown.Trigger>+ <Dropdown.Trigger+ as={Button}+ variant="outline"+ size="icon-sm"+ depth={1}+ class="size-[26px] rounded-full bg-surface shadow-md shadow-drop-shadow [&_svg]:size-4!"+ label="Create"+ hotkey={TOKENS.global.createCommand}+ onMouseDown={(e: MouseEvent) => {+ if (e.button !== 0) return;+ e.preventDefault();+ }}+ >+ <CreateIcon />+ </Dropdown.Trigger>+ </Show>}>- <Dropdown.Trigger- as={Button}- variant="outline"- size="icon-sm"- depth={1}- class="size-[26px] rounded-full bg-surface shadow-md shadow-drop-shadow [&_svg]:size-4!"- label="Create"- hotkey={TOKENS.global.createCommand}- onMouseDown={(e: MouseEvent) => {- if (e.button !== 0) return;- e.preventDefault();- }}- >- <CreateIcon />- </Dropdown.Trigger>+ {(trigger) => (+ <Dropdown.Trigger+ as={trigger()}+ // `Dropdown.Trigger` hardcodes `variant`/`size` for its default+ // `as={Button}` and spreads props after them, so both leak into a+ // custom trigger — and land on its element as junk attributes if it+ // is a plain `<button>`. Blank them for callers' own elements.+ variant={undefined}+ size={undefined}+ />+ )}</Show>+<Dropdown.Content class="min-w-52 shadow-menu"><Dropdown.Group><For each={blocks()}>diff --git a/apps/web/src/lib/core/constant/featureFlags.ts b/apps/web/src/lib/core/constant/featureFlags.tsindex 1b23d2c122..3209cbe482 100644--- a/apps/web/src/lib/core/constant/featureFlags.ts+++ b/apps/web/src/lib/core/constant/featureFlags.ts@@ -163,6 +163,31 @@ export function ENABLE_EMAIL_SIGNATURES(): boolean {);}+// SidebarNext: the rebuilt app sidebar — the narrow icon rail in+// `components/app/sidebar-next` — rendered in place of `AppSidebar`.+// PostHog-gated everywhere, dev included: no dev-mode default, so `AppSidebar`+// stays the sidebar you get by default until the flag is on for you. Set+// VITE_ENABLE_SIDEBAR_NEXT=true to force the rail on locally without PostHog.+//+// The PostHog key is deliberately broader than the local names: `enable-new-app-views`+// is the rollout switch for the rebuilt app surfaces, of which this sidebar is one.+export const ENABLE_SIDEBAR_NEXT_FLAG = 'enable-new-app-views';+// Read statically rather than through `getFeatureFlagOverride` for the same+// reason as VITE_ENABLE_REMINDERS below: Vite substitutes `import.meta.env.VITE_X`+// by text at build time, so that helper's dynamic lookup can come back+// undefined in a production bundle.+//+// Written out rather than using `|| undefined` so an explicit+// VITE_ENABLE_SIDEBAR_NEXT=false stays false instead of being coerced to+// undefined and falling through to PostHog.+const SIDEBAR_NEXT_ENV_OVERRIDE = import.meta.env.VITE_ENABLE_SIDEBAR_NEXT;+export const ENABLE_SIDEBAR_NEXT_OVERRIDE: boolean | undefined =+ SIDEBAR_NEXT_ENV_OVERRIDE === 'true'+ ? true+ : SIDEBAR_NEXT_ENV_OVERRIDE === 'false'+ ? false+ : undefined;+// CRM companies & contacts frontend: the Companies view + sidebar entry, the// company/contact detail blocks, CRM mentions / quick-access, and CRM rows in// global search. PostHog-gated (currently targeted at the Macro team in prod)diff --git a/apps/web/tsconfig.json b/apps/web/tsconfig.jsonindex fa63a9d539..949968261d 100644--- a/apps/web/tsconfig.json+++ b/apps/web/tsconfig.json@@ -77,6 +77,9 @@"@phosphor/*": ["../../node_modules/@phosphor-icons/core/assets/regular/*"],+ "@phosphor-fill/*": [+ "../../node_modules/@phosphor-icons/core/assets/fill/*"+ ],"@block-canvas/*": ["./src/features/block-canvas/*"],