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.

fix(viewshell): dismissing narrow sidebar is not recorded as preference at wider view (#6612)

Peter Chinman25e422fc358a
diff --git a/apps/web/src/components/view-shell/ViewShell.test.tsx b/apps/web/src/components/view-shell/ViewShell.test.tsx
index ff3e16142a..221e1a11f9 100644
--- a/apps/web/src/components/view-shell/ViewShell.test.tsx
+++ b/apps/web/src/components/view-shell/ViewShell.test.tsx
@@ -146,6 +146,7 @@ describe('ViewShell aside resize preference', () => {
expect(view.asideWidth()).toBeCloseTo(276);
view.setWidth(600);
+ fireEvent.click(view.getByRole('button', { name: 'Show navigation' }));
expect(view.getByRole('button', { name: 'Hide navigation' })).toBeTruthy();
const overlay = view.container.querySelector<HTMLElement>(
'[data-view-shell-aside]'
@@ -155,8 +156,7 @@ describe('ViewShell aside resize preference', () => {
view.getByRole('button', { name: 'Close navigation backdrop' })
);
view.setWidth(1200);
- expect(view.getByRole('button', { name: 'Show navigation' })).toBeTruthy();
- fireEvent.click(view.getByRole('button', { name: 'Show navigation' }));
+ expect(view.getByRole('button', { name: 'Hide navigation' })).toBeTruthy();
expect(view.asideWidth()).toBeCloseTo(276);
view.setWidth(1100);
expect(view.asideWidth()).toBeCloseTo(276);
@@ -298,3 +298,124 @@ it('reopens automatic narrow collapse as a dismissible overlay', () => {
screen.queryByRole('button', { name: 'Close navigation backdrop' })
).toBeNull();
});
+
+describe.each(['inbox', 'channels', 'tasks', 'email'])(
+ '%s responsive sidebar',
+ (app) => {
+ it('restores automatic collapse but preserves an explicit desktop collapse', () => {
+ const [width, setWidth] = createSignal(1000);
+ measurement.width = width;
+ render(() => <Workspace app={app} />);
+
+ setWidth(600);
+ expect(
+ screen.getByRole('button', { name: 'Show navigation' })
+ ).toBeTruthy();
+ setWidth(1000);
+ expect(
+ screen.getByRole('button', { name: 'Hide navigation' })
+ ).toBeTruthy();
+
+ fireEvent.click(screen.getByRole('button', { name: 'Hide navigation' }));
+ setWidth(600);
+ setWidth(1000);
+ expect(
+ screen.getByRole('button', { name: 'Show navigation' })
+ ).toBeTruthy();
+ });
+
+ it.each(['open', 'escape', 'backdrop', 'toggle'] as const)(
+ 'restores navigation after using a narrow overlay (%s)',
+ (dismissal) => {
+ const [width, setWidth] = createSignal(1000);
+ measurement.width = width;
+ const view = render(() => <Workspace app={app} />);
+
+ setWidth(600);
+ fireEvent.click(
+ screen.getByRole('button', { name: 'Show navigation' })
+ );
+ if (dismissal === 'escape') {
+ fireEvent.keyDown(
+ screen.getByRole('button', { name: 'Hide navigation' }),
+ {
+ key: 'Escape',
+ }
+ );
+ } else if (dismissal !== 'open') {
+ fireEvent.click(
+ screen.getByRole('button', {
+ name:
+ dismissal === 'backdrop'
+ ? 'Close navigation backdrop'
+ : 'Hide navigation',
+ })
+ );
+ }
+ if (dismissal !== 'open') {
+ expect(
+ screen.getByRole('button', { name: 'Show navigation' })
+ ).toBeTruthy();
+ }
+
+ setWidth(1000);
+ expect(
+ screen.getByRole('button', { name: 'Hide navigation' })
+ ).toBeTruthy();
+ expect(
+ screen.queryByRole('button', { name: 'Close navigation backdrop' })
+ ).toBeNull();
+ setWidth(600);
+ expect(
+ screen.queryByRole('button', { name: 'Hide navigation' })
+ ).toBeNull();
+ setWidth(1000);
+ view.unmount();
+ render(() => <Workspace app={app} />);
+ expect(
+ screen.getByRole('button', { name: 'Hide navigation' })
+ ).toBeTruthy();
+ }
+ );
+
+ it.each([false, true])(
+ 'preserves a hidden wide sidebar after using a narrow overlay (dismiss=%s)',
+ (dismiss) => {
+ const [width, setWidth] = createSignal(1000);
+ measurement.width = width;
+ const view = render(() => <Workspace app={app} />);
+ fireEvent.click(
+ screen.getByRole('button', { name: 'Hide navigation' })
+ );
+ const savePreference = vi.spyOn(localStorage, 'setItem');
+
+ setWidth(600);
+ fireEvent.click(
+ screen.getByRole('button', { name: 'Show navigation' })
+ );
+ expect(
+ screen.getByRole('button', { name: 'Hide navigation' })
+ ).toBeTruthy();
+ if (dismiss) {
+ fireEvent.click(
+ screen.getByRole('button', { name: 'Hide navigation' })
+ );
+ }
+ expect(savePreference).not.toHaveBeenCalled();
+
+ setWidth(1000);
+ expect(
+ screen.queryByRole('button', { name: 'Hide navigation' })
+ ).toBeNull();
+ expect(
+ screen.getByRole('button', { name: 'Show navigation' })
+ ).toBeTruthy();
+ view.unmount();
+ render(() => <Workspace app={app} />);
+ expect(
+ screen.getByRole('button', { name: 'Show navigation' })
+ ).toBeTruthy();
+ }
+ );
+ }
+);
diff --git a/apps/web/src/components/view-shell/ViewShell.tsx b/apps/web/src/components/view-shell/ViewShell.tsx
index 66007e4909..c512302c85 100644
--- a/apps/web/src/components/view-shell/ViewShell.tsx
+++ b/apps/web/src/components/view-shell/ViewShell.tsx
@@ -11,6 +11,7 @@ import { registerHotkey } from '@core/hotkey/hotkeys';
import { TOKENS } from '@core/hotkey/tokens';
import ListIcon from '@phosphor/list.svg';
import SidebarIcon from '@phosphor/sidebar-simple.svg';
+import { createWritableMemo } from '@solid-primitives/memo';
import { createElementSize } from '@solid-primitives/resize-observer';
import { Button, cn } from '@ui';
import {
@@ -22,6 +23,7 @@ import {
createUniqueId,
type JSX,
Match,
+ on,
Show,
Switch,
splitProps,
@@ -155,13 +157,12 @@ function Root(props: ViewShellRootProps) {
'onDetailOpenChange',
]);
- const [asideCollapsed, setAsideCollapsed] = local.asidePreferenceKey
+ const [wideAsideCollapsed, setWideAsideCollapsed] = local.asidePreferenceKey
? usePreference(
`macro:pref:view-sidebar:collapsed:${local.asidePreferenceKey}`,
{ default: false }
)
: createSignal(false);
- const [narrowAsideOpen, setNarrowAsideOpen] = createSignal(false);
const id = createUniqueId();
const [root, setRoot] = createSignal<HTMLDivElement>();
const animateSidebar = createSidebarMotion(root);
@@ -217,14 +218,25 @@ function Root(props: ViewShellRootProps) {
return match ? match() : false;
};
+ // Each narrow layout starts closed, independently of the saved wide layout.
+ const [narrowAsideOpen, setNarrowAsideOpen] = createWritableMemo<boolean>(
+ on(atLayoutBreakpoint, () => false)
+ );
+
const asideMode = (): AsideMode =>
local.aside === false ||
- asideCollapsed() ||
- (atLayoutBreakpoint() && !narrowAsideOpen())
+ (atLayoutBreakpoint() ? !narrowAsideOpen() : wideAsideCollapsed())
? 'collapsed'
: 'docked';
const asideOverlay = () => atLayoutBreakpoint() && asideMode() === 'docked';
+ const setAsideOpen = (open: boolean) => {
+ animateSidebar(() => {
+ if (atLayoutBreakpoint()) setNarrowAsideOpen(open);
+ else setWideAsideCollapsed(!open);
+ });
+ };
+
const canFitInlineDetail = () => {
const currentWidth = width();
if (currentWidth === undefined) return false;
@@ -260,22 +272,8 @@ function Root(props: ViewShellRootProps) {
canCollapse: () =>
local.asidePreferenceKey !== undefined && local.aside !== false,
isOverlay: asideOverlay,
- collapse: () => {
- animateSidebar(() =>
- batch(() => {
- setAsideCollapsed(true);
- setNarrowAsideOpen(false);
- })
- );
- },
- expand: () => {
- animateSidebar(() =>
- batch(() => {
- setAsideCollapsed(false);
- setNarrowAsideOpen(true);
- })
- );
- },
+ collapse: () => setAsideOpen(false),
+ expand: () => setAsideOpen(true),
toggle: () => {
if (value.aside.isCollapsed()) value.aside.expand();
else value.aside.collapse();
diff --git a/docs/AGENT_GUIDE/navigation.md b/docs/AGENT_GUIDE/navigation.md
index b43028e5ad..70e34b0a04 100644
--- a/docs/AGENT_GUIDE/navigation.md
+++ b/docs/AGENT_GUIDE/navigation.md
@@ -68,7 +68,11 @@ Narrow navigation overlays use the same brief width and opacity animation.
Visibility is a sticky preference per app type (Home, Email, Chat, Tasks, Drive,
Agents, Customers), independent of other apps and restored on reload. Narrow
workspaces reopen navigation as an overlay; the backdrop or **Hide navigation**
-closes it. The overlay never contains the split's **Close** button. Mobile keeps
+closes it temporarily. Opening or closing the narrow overlay never changes the
+saved wide-layout preference. Widening restores that preference, including in
+Home and Chat: navigation returns unless explicitly hidden at desktop width.
+Shrinking again starts with the overlay closed.
+The overlay never contains the split's **Close** button. Mobile keeps
its existing navigation controls. Block detail panels (including Calendar) have
**Hide side panel** in their own header and a hamburger **Show side panel** beside
the main title when hidden, with separate preferences per block type.