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
fix(view-shell): keep a split's navigation open when it changes view (#8564)
gbirmanabc230c8b81c
diff --git a/apps/web/src/components/app/split-layout/components/SplitPanel.tsx b/apps/web/src/components/app/split-layout/components/SplitPanel.tsxindex 9a63c2ee7e..2735b606f1 100644--- a/apps/web/src/components/app/split-layout/components/SplitPanel.tsx+++ b/apps/web/src/components/app/split-layout/components/SplitPanel.tsx@@ -52,6 +52,7 @@ export function SplitPanel(props: SplitPanelProps) {);const [panelRef, setPanelRef] = createSignal<HTMLDivElement | null>(null);const [contentOffsetTop, setContentOffsetTop] = createSignal(0);+ const navigationCollapsed = createSignal(true);const [titleFileMenuRef, setTitleFileMenuRef] =createSignal<HTMLDivElement>();const [titleFileMenuTrigger, setTitleFileMenuTrigger] =@@ -210,6 +211,7 @@ export function SplitPanel(props: SplitPanelProps) {handle: props.handle,setContentOffsetTop,contentOffsetTop,+ navigationCollapsed,splitHotkeyScope,bottomPanel,registerBottomPanel: (panel) => {diff --git a/apps/web/src/components/app/split-layout/context.ts b/apps/web/src/components/app/split-layout/context.tsindex c2af487e19..550fe4e5b7 100644--- a/apps/web/src/components/app/split-layout/context.ts+++ b/apps/web/src/components/app/split-layout/context.ts@@ -6,6 +6,7 @@ import {createContext,type JSX,type Setter,+ type Signal,} from 'solid-js';import type { SplitHandle, SplitManager } from './layoutManager';import type { ReplaceOwnedSlot } from './utils/createOwnedSlots';@@ -89,6 +90,11 @@ export type SplitPanelContextType = {panelSize: NullableSize;contentOffsetTop: Accessor<number>;setContentOffsetTop: Setter<number>;+ /**+ * Whether workspace navigation is hidden in a split other than the first.+ * Owned by the split, so it carries across the views the split shows.+ */+ navigationCollapsed?: Signal<boolean>;bottomPanel: Accessor<SplitBottomPanelRegistration | undefined>;registerBottomPanel: (panel: SplitBottomPanelRegistration) => () => void;layoutRefs: {diff --git a/apps/web/src/components/view-shell/ViewShell.test.tsx b/apps/web/src/components/view-shell/ViewShell.test.tsxindex 5a4b2fb5a1..35e442da37 100644--- a/apps/web/src/components/view-shell/ViewShell.test.tsx+++ b/apps/web/src/components/view-shell/ViewShell.test.tsx@@ -10,7 +10,7 @@ import {screen,within,} from '@solidjs/testing-library';-import { createSignal, type JSX, onMount } from 'solid-js';+import { createSignal, type JSX, onMount, Show } from 'solid-js';import { Portal } from 'solid-js/web';import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';import { useViewShell, ViewShell, ViewSidebarToggle } from './ViewShell';@@ -417,6 +417,33 @@ it('opens secondary splits without navigation and leaves the preference alone',expect(screen.getByRole('button', { name: 'Hide navigation' })).toBeTruthy();});+it('keeps a secondary split navigation choice when the split changes view', () => {+ const [app, setApp] = createSignal('home');+ render(() => (+ <SplitPanelContext.Provider+ value={+ {+ handle: { isFirst: () => false },+ isPanelActive: () => false,+ splitHotkeyScope: 'split',+ navigationCollapsed: createSignal(true),+ } as unknown as SplitPanelContextType+ }+ >+ <Show when={app()} keyed>+ {(current) => <Workspace app={current} />}+ </Show>+ </SplitPanelContext.Provider>+ ));+ fireEvent.click(screen.getByRole('button', { name: 'Show navigation' }));+ setApp('agents');+ expect(screen.getByRole('region', { name: 'agents' })).toBeTruthy();+ expect(screen.getByRole('button', { name: 'Hide navigation' })).toBeTruthy();+ fireEvent.click(screen.getByRole('button', { name: 'Hide navigation' }));+ setApp('home');+ expect(screen.getByRole('button', { name: 'Show navigation' })).toBeTruthy();+});+it('reopens automatic narrow collapse as a dismissible overlay', () => {measurement.width = () => 600;render(() => <Workspace app="documents" />);diff --git a/apps/web/src/components/view-shell/ViewShell.tsx b/apps/web/src/components/view-shell/ViewShell.tsxindex e94e8c8bbe..f564fc55e4 100644--- a/apps/web/src/components/view-shell/ViewShell.tsx+++ b/apps/web/src/components/view-shell/ViewShell.tsx@@ -181,19 +181,21 @@ function Root(props: ViewShellRootProps) {]);const panel = useContext(SplitPanelContext);- // A view opened beside another split starts without navigation; only the- // primary split follows, and writes, the saved preference.+ // A view opened beside another split starts without navigation, then keeps+ // that split's choice as the split moves between views; only the primary+ // split follows, and writes, the saved preference.const secondarySplit =local.asidePreferenceKey !== undefined &&panel !== undefined &&!untrack(panel.handle.isFirst);- const [wideAsideCollapsed, setWideAsideCollapsed] =- local.asidePreferenceKey && !secondarySplit+ const [wideAsideCollapsed, setWideAsideCollapsed] = secondarySplit+ ? (panel?.navigationCollapsed ?? createSignal(true))+ : local.asidePreferenceKey? usePreference(`macro:pref:view-sidebar:collapsed:${local.asidePreferenceKey}`,{ default: false })- : createSignal(secondarySplit);+ : createSignal(false);const id = createUniqueId();const [root, setRoot] = createSignal<HTMLDivElement>();const animateSidebar = createSidebarMotion(root);