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
web: keep Chat navigation open while no conversation is selected (#6984)
teo2199239828bc
diff --git a/apps/web/src/components/view-shell/ViewShell.test.tsx b/apps/web/src/components/view-shell/ViewShell.test.tsxindex 221e1a11f9..22fed9957e 100644--- a/apps/web/src/components/view-shell/ViewShell.test.tsx+++ b/apps/web/src/components/view-shell/ViewShell.test.tsx@@ -7,7 +7,7 @@ import {} from '@solidjs/testing-library';import { createSignal, type JSX, onMount } from 'solid-js';import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';-import { ViewShell } from './ViewShell';+import { useViewShell, ViewShell } from './ViewShell';import { ViewSidebar } from './ViewSidebar';const measurement = vi.hoisted(() => ({ width: (): number => 1200 }));@@ -211,14 +211,21 @@ describe('ViewShell aside resize preference', () => {});});-function Workspace(props: { app: string; mounted?: () => void }) {+function Workspace(props: {+ app: string;+ asideRequired?: boolean;+ mounted?: () => void;+}) {function Content() {onMount(() => props.mounted?.());return <input aria-label={`${props.app} draft`} />;}return (<section aria-label={props.app}>- <ViewShell.Root asidePreferenceKey={props.app}>+ <ViewShell.Root+ asidePreferenceKey={props.app}+ asideRequired={props.asideRequired}+ ><ViewShell.Aside><ViewSidebar.Header><ViewSidebar.Title>{props.app}</ViewSidebar.Title>@@ -299,6 +306,159 @@ it('reopens automatic narrow collapse as a dismissible overlay', () => {).toBeNull();});+describe('required navigation', () => {+ const asideDocked = () =>+ !document+ .querySelector('[data-view-shell-aside]')!+ .parentElement!.classList.contains('hidden');++ it('docks a hidden wide sidebar without a collapse control until a selection returns', () => {+ const [required, setRequired] = createSignal(false);+ render(() => <Workspace app="channels" asideRequired={required()} />);+ fireEvent.click(screen.getByRole('button', { name: 'Hide navigation' }));+ expect(asideDocked()).toBe(false);+ const savePreference = vi.spyOn(localStorage, 'setItem');++ setRequired(true);+ expect(asideDocked()).toBe(true);+ expect(+ screen.queryByRole('button', { name: 'Hide navigation' })+ ).toBeNull();+ expect(+ screen.queryByRole('button', { name: 'Show navigation' })+ ).toBeNull();++ setRequired(false);+ expect(asideDocked()).toBe(false);+ expect(+ screen.getByRole('button', { name: 'Show navigation' })+ ).toBeTruthy();+ expect(savePreference).not.toHaveBeenCalled();+ });++ it('animates the pin like a manual toggle', async () => {+ const originalAnimate = Object.getOwnPropertyDescriptor(+ HTMLElement.prototype,+ 'animate'+ );+ const animate = vi.fn<HTMLElement['animate']>(+ () => ({ cancel: vi.fn() }) as unknown as Animation+ );+ vi.stubGlobal(+ 'matchMedia',+ vi.fn(() => ({ matches: false }))+ );+ Object.defineProperty(HTMLElement.prototype, 'animate', {+ configurable: true,+ value: animate,+ });+ try {+ const [required, setRequired] = createSignal(false);+ render(() => <Workspace app="channels" asideRequired={required()} />);+ fireEvent.click(screen.getByRole('button', { name: 'Hide navigation' }));+ await Promise.resolve();+ expect(animate).toHaveBeenCalled();+ const panelsAnimated = () =>+ new Set(animate.mock.contexts as HTMLElement[]);++ animate.mockClear();+ setRequired(true);+ await Promise.resolve();+ expect(+ panelsAnimated().has(+ document.querySelector('[data-view-shell-aside]')!.parentElement!+ )+ ).toBe(true);++ animate.mockClear();+ setRequired(false);+ await Promise.resolve();+ expect(animate).toHaveBeenCalled();+ } finally {+ if (originalAnimate) {+ Object.defineProperty(+ HTMLElement.prototype,+ 'animate',+ originalAnimate+ );+ } else {+ Reflect.deleteProperty(HTMLElement.prototype, 'animate');+ }+ }+ });++ it('ignores a programmatic collapse while pinned', () => {+ const [required, setRequired] = createSignal(true);+ function Pinned() {+ const shell = useViewShell();+ return (+ <button type="button" onClick={shell.aside.collapse}>+ Collapse programmatically+ </button>+ );+ }+ render(() => (+ <ViewShell.Root asidePreferenceKey="channels" asideRequired={required()}>+ <ViewShell.Aside>+ <ViewSidebar.Header>+ <ViewSidebar.Title>channels</ViewSidebar.Title>+ </ViewSidebar.Header>+ <Pinned />+ </ViewShell.Aside>+ <ViewShell.Main>+ <ViewShell.TopBar />+ </ViewShell.Main>+ </ViewShell.Root>+ ));+ fireEvent.click(+ screen.getByRole('button', { name: 'Collapse programmatically' })+ );+ expect(asideDocked()).toBe(true);++ setRequired(false);+ expect(asideDocked()).toBe(true);+ expect(+ screen.getByRole('button', { name: 'Hide navigation' })+ ).toBeTruthy();+ });++ it('opens the narrow overlay and closes it again once something is selected', () => {+ const [width, setWidth] = createSignal(1000);+ const [required, setRequired] = createSignal(true);+ measurement.width = width;+ render(() => <Workspace app="channels" asideRequired={required()} />);++ setWidth(600);+ expect(+ screen.getByRole('button', { name: 'Close navigation backdrop' })+ ).toBeTruthy();+ fireEvent.click(+ screen.getByRole('button', { name: 'Close navigation backdrop' })+ );+ expect(+ screen.queryByRole('button', { name: 'Close navigation backdrop' })+ ).toBeNull();+ expect(+ screen.getByRole('button', { name: 'Show navigation' })+ ).toBeTruthy();++ setRequired(false);+ setRequired(true);+ expect(+ screen.getByRole('button', { name: 'Close navigation backdrop' })+ ).toBeTruthy();+ setRequired(false);+ expect(+ screen.queryByRole('button', { name: 'Close navigation backdrop' })+ ).toBeNull();++ setWidth(1000);+ expect(+ screen.getByRole('button', { name: 'Hide navigation' })+ ).toBeTruthy();+ });+});+describe.each(['inbox', 'channels', 'tasks', 'email'])('%s responsive sidebar',(app) => {diff --git a/apps/web/src/components/view-shell/ViewShell.tsx b/apps/web/src/components/view-shell/ViewShell.tsxindex c69411bb99..a5bb5e9a5f 100644--- a/apps/web/src/components/view-shell/ViewShell.tsx+++ b/apps/web/src/components/view-shell/ViewShell.tsx@@ -18,6 +18,7 @@ import {type Accessor,batch,type ComponentProps,+ createComputed,createContext,createSignal,createUniqueId,@@ -127,6 +128,13 @@ export type ViewShellRootProps = Omit<aside?: false | Partial<AsideLayout>;/** Sticky navigation visibility, scoped to this app type rather than an entry. */asidePreferenceKey?: string;+ /**+ * Keep navigation open while true, e.g. while Main has nothing selected and+ * only the aside offers a next step. Wide layouts dock it and withhold the+ * collapse control without touching the saved preference; narrow layouts+ * open the overlay, which stays dismissible.+ */+ asideRequired?: boolean;main?: Partial<MainLayout>;detail?: Partial<DetailLayout>;/** Controlled detail open state. Omit for uncontrolled. */@@ -150,6 +158,7 @@ function Root(props: ViewShellRootProps) {'resizable','aside','asidePreferenceKey',+ 'asideRequired','main','detail','detailOpen',@@ -218,24 +227,36 @@ function Root(props: ViewShellRootProps) {return match ? match() : false;};- // Each narrow layout starts closed, independently of the saved wide layout.+ const asideRequired = () => local.asideRequired ?? false;+ // Each narrow layout starts closed, independently of the saved wide layout,+ // unless navigation is required, which opens the overlay until dismissed.const [narrowAsideOpen, setNarrowAsideOpen] = createWritableMemo<boolean>(- on(atLayoutBreakpoint, () => false)+ on([atLayoutBreakpoint, asideRequired], ([, required]) => required));+ // Only a docked aside can be pinned open: a pinned overlay would hide Main+ // behind a backdrop with no way to dismiss it.+ const asidePinned = () => asideRequired() && !atLayoutBreakpoint();const asideMode = (): AsideMode =>local.aside === false ||- (atLayoutBreakpoint() ? !narrowAsideOpen() : wideAsideCollapsed())+ (atLayoutBreakpoint()+ ? !narrowAsideOpen()+ : wideAsideCollapsed() && !asidePinned())? 'collapsed': 'docked';const asideOverlay = () => atLayoutBreakpoint() && asideMode() === 'docked';const setAsideOpen = (open: boolean) => {+ if (!open && asidePinned()) return;animateSidebar(() => {if (atLayoutBreakpoint()) setNarrowAsideOpen(open);else setWideAsideCollapsed(!open);});};+ // The pin flips the docked aside without a setter, so animate it here.+ createComputed(+ on(asidePinned, () => animateSidebar(() => {}), { defer: true })+ );const canFitInlineDetail = () => {const currentWidth = width();@@ -270,7 +291,9 @@ function Root(props: ViewShellRootProps) {mode: asideMode,isCollapsed: () => asideMode() === 'collapsed',canCollapse: () =>- local.asidePreferenceKey !== undefined && local.aside !== false,+ local.asidePreferenceKey !== undefined &&+ local.aside !== false &&+ !asidePinned(),isOverlay: asideOverlay,collapse: () => setAsideOpen(false),expand: () => setAsideOpen(true),diff --git a/apps/web/src/features/channels-view/channels-view.tsx b/apps/web/src/features/channels-view/channels-view.tsxindex 660991cdee..4d6d49d819 100644--- a/apps/web/src/features/channels-view/channels-view.tsx+++ b/apps/web/src/features/channels-view/channels-view.tsx@@ -43,7 +43,7 @@ export type ChannelsViewProps = {function ChannelsViewRoot() {const panel = useSplitPanelOrThrow();- const { state, mobileLayout, setAsideWidth, setMobileTab } =+ const { state, mobileLayout, selectedChannel, setAsideWidth, setMobileTab } =useChannelsView();const [railSearchOpen, setRailSearchOpen] = createSignal(false);@@ -71,6 +71,8 @@ function ChannelsViewRoot() {<div class="size-full min-h-0 bg-panel"><ViewShell.RootasidePreferenceKey="channels"+ // The empty state only points at the rail, so keep it open.+ asideRequired={selectedChannel() === undefined}aside={{width: state.asideWidth,preserveDuringResize: false,diff --git a/docs/AGENT_GUIDE/channels.md b/docs/AGENT_GUIDE/channels.mdindex ca71402f6e..f517e674e2 100644--- a/docs/AGENT_GUIDE/channels.md+++ b/docs/AGENT_GUIDE/channels.md@@ -328,12 +328,16 @@ Participants, and Calls tabs (when calls are enabled). A message target switchesback to Messages; changing unread notifications does not restart navigation.The title bar's **Hide navigation** control hides the whole rail. Reopen it with-**Show navigation** (the hamburger) immediately before the conversation title,-or in the Chat header when no conversation is selected. Chat remembers this-choice independently of other workspaces and restores it after reload. Chat uses+**Show navigation** (the hamburger) immediately before the conversation title.+Chat remembers this choice independently of other workspaces and restores it+after reload. While no conversation is selected, the rail stays open regardless+of that choice and offers no **Hide navigation** control (`Cmd+.` is inert);+selecting a conversation applies the saved choice again. Chat usesthe shared 256px default sidebar width and resize limits. In splits narrower than720px, navigation collapses; the hamburger or `Cmd+.` opens it as a slide-over-with the same full sidebar contents. There is no separate skinny sidebar mode.+with the same full sidebar contents. With no conversation selected, the+slide-over opens on its own and closes once a conversation is picked; the+backdrop or `Escape` still dismisses it. There is no separate skinny sidebar mode.On desktop, the Chat rail has `All` and `Recent` tabs. All contains anoptional `Favorites` section and thediff --git a/docs/AGENT_GUIDE/navigation.md b/docs/AGENT_GUIDE/navigation.mdindex 4be6edc762..c85264d7bc 100644--- a/docs/AGENT_GUIDE/navigation.md+++ b/docs/AGENT_GUIDE/navigation.md@@ -141,7 +141,10 @@ workspaces reopen navigation as an overlay; the backdrop or **Hide navigation**closes it temporarily. Opening or closing the narrow overlay never changes thesaved wide-layout preference. Widening restores that preference, including inHome and Chat: navigation returns unless explicitly hidden at desktop width.-Shrinking again starts with the overlay closed.+Shrinking again starts with the overlay closed. Chat is the exception while no+conversation is selected: its navigation stays docked with no **Hide+navigation** control, and narrow Chat opens the overlay on its own (see+[Chat navigation rail](channels.md#chat-navigation-rail)).The overlay never contains the split's **Close** button. Mobile keepsits existing navigation controls. Block detail panels (including Calendar) have**Hide side panel** in their own header and a hamburger **Show side panel** beside