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
Persist side panel open state across visits (#5907)
Jacob Beckerman3c8aab8b3510
diff --git a/apps/web/src/components/app/side-panel/SidePanel.tsx b/apps/web/src/components/app/side-panel/SidePanel.tsxindex 6e0b93314a..d38323d996 100644--- a/apps/web/src/components/app/side-panel/SidePanel.tsx+++ b/apps/web/src/components/app/side-panel/SidePanel.tsx@@ -1,3 +1,4 @@+import { usePreference } from '@app/preferences/use-preference';import { Resize, ResizeZoneContext } from '@core/component/Resize/Resize';import { TOKENS } from '@core/hotkey/tokens';import { isMobile } from '@core/mobile/isMobile';@@ -40,6 +41,27 @@ const SIDE_MIN_PX = 320;const SIDE_MAX_PX = 380;const MAIN_MIN_PX = 320;+/**+ * Wide-mode open state for a side panel.+ *+ * With a `persistKey`, the user's show/hide choice is remembered across+ * visits under a per-block localStorage key; without one the panel falls back+ * to a plain signal that resets to `defaultOpen` on every mount.+ *+ * Only wide mode is persisted. Narrow mode renders the panel as a full-screen+ * overlay on top of the content, so restoring it open would hide the content+ * the user came back to.+ */+function createWideOpenState(+ persistKey: string | undefined,+ defaultOpen: boolean+): [Accessor<boolean>, Setter<boolean>] {+ if (persistKey === undefined) return createSignal(defaultOpen);+ return usePreference(`macro:pref:side-panel:open:${persistKey}`, {+ default: defaultOpen,+ });+}+/*** Layout root for a block that opts in to a right-side panel.*@@ -57,15 +79,24 @@ const MAIN_MIN_PX = 320;** The side panel is suppressed entirely when no sections are registered.*+ * Pass `persistKey` to remember the wide-mode open state across visits (see+ * `createWideOpenState`); without it the panel returns to `defaultOpen` every+ * time the block mounts.+ ** Sections are rendered as a Kobalte Accordion in JSX-declared order.*/-function Layout(props: ParentProps<{ defaultOpen?: boolean }>) {+function Layout(+ props: ParentProps<{ defaultOpen?: boolean; persistKey?: string }>+) {const [sections, setSections] = createSignal<SidePanelSectionEntry[]>([]);const [openIds, setOpenIds] = createSignal<string[]>([]);// Independent open state per mode so wide and narrow can have different// defaults (and the user's preference in one mode doesn't bleed into the// other after a resize).- const [isWideOpen, setIsWideOpen] = createSignal(props.defaultOpen ?? true);+ const [isWideOpen, setIsWideOpen] = createWideOpenState(+ props.persistKey,+ props.defaultOpen ?? true+ );const [isNarrowOpen, setIsNarrowOpen] = createSignal(false);const [isNarrow, setIsNarrow] = createSignal(isMobile());diff --git a/apps/web/src/features/block-calendar/components/Workspace.tsx b/apps/web/src/features/block-calendar/components/Workspace.tsxindex a48df1995e..a2d2d79cc8 100644--- a/apps/web/src/features/block-calendar/components/Workspace.tsx+++ b/apps/web/src/features/block-calendar/components/Workspace.tsx@@ -127,7 +127,7 @@ function CalendarPagerWorkspace() {return (<Pager.Root controller={calendarPager.pager}>- <SidePanel.Layout>+ <SidePanel.Layout persistKey="calendar"><WorkspaceContent /></SidePanel.Layout></Pager.Root>