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(view-shell): start secondary splits without navigation (#7933)

Jacob Beckerman615444c8927a
diff --git a/apps/web/src/components/view-shell/ViewShell.test.tsx b/apps/web/src/components/view-shell/ViewShell.test.tsx
index 676a1de663..fc6ea044f4 100644
--- a/apps/web/src/components/view-shell/ViewShell.test.tsx
+++ b/apps/web/src/components/view-shell/ViewShell.test.tsx
@@ -76,9 +76,10 @@ it('moves navigation into the host and follows the active split', () => {
<SplitPanelContext.Provider
value={
{
+ handle: { isFirst: () => true },
isPanelActive: () => active() === props.id,
splitHotkeyScope: props.id,
- } as SplitPanelContextType
+ } as unknown as SplitPanelContextType
}
>
<ViewShell.Root asidePreferenceKey={props.id}>
@@ -345,6 +346,33 @@ it('restores visibility per app after remount and persists reopening', () => {
expect(screen.getByRole('button', { name: 'Hide navigation' })).toBeTruthy();
});
+it('opens secondary splits without navigation and leaves the preference alone', () => {
+ function InSplit(props: { app: string; first: boolean }) {
+ return (
+ <SplitPanelContext.Provider
+ value={
+ {
+ handle: { isFirst: () => props.first },
+ isPanelActive: () => false,
+ splitHotkeyScope: props.app,
+ } as unknown as SplitPanelContextType
+ }
+ >
+ <Workspace app={props.app} />
+ </SplitPanelContext.Provider>
+ );
+ }
+ const split = render(() => <InSplit app="email" first={false} />);
+ fireEvent.click(screen.getByRole('button', { name: 'Show navigation' }));
+ expect(screen.getByRole('button', { name: 'Hide navigation' })).toBeTruthy();
+ split.unmount();
+ const reopened = render(() => <InSplit app="email" first={false} />);
+ expect(screen.getByRole('button', { name: 'Show navigation' })).toBeTruthy();
+ reopened.unmount();
+ render(() => <InSplit app="email" first />);
+ expect(screen.getByRole('button', { name: 'Hide 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.tsx
index 7f5b5d4092..232d1130b2 100644
--- a/apps/web/src/components/view-shell/ViewShell.tsx
+++ b/apps/web/src/components/view-shell/ViewShell.tsx
@@ -31,6 +31,7 @@ import {
Show,
Switch,
splitProps,
+ untrack,
useContext,
} from 'solid-js';
import { Portal } from 'solid-js/web';
@@ -131,7 +132,10 @@ export type ViewShellRootProps = Omit<
resizable?: boolean;
/** Set to false when the workspace has no navigation region. */
aside?: false | Partial<AsideLayout>;
- /** Sticky navigation visibility, scoped to this app type rather than an entry. */
+ /**
+ * Sticky navigation visibility, scoped to this app type rather than an entry.
+ * Only the first split uses it; other splits start collapsed.
+ */
asidePreferenceKey?: string;
/**
* Keep navigation open while true, e.g. while Main has nothing selected and
@@ -171,12 +175,20 @@ function Root(props: ViewShellRootProps) {
'onDetailOpenChange',
]);
- const [wideAsideCollapsed, setWideAsideCollapsed] = local.asidePreferenceKey
- ? usePreference(
- `macro:pref:view-sidebar:collapsed:${local.asidePreferenceKey}`,
- { default: false }
- )
- : createSignal(false);
+ const panel = useContext(SplitPanelContext);
+ // A view opened beside another split starts without navigation; 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
+ ? usePreference(
+ `macro:pref:view-sidebar:collapsed:${local.asidePreferenceKey}`,
+ { default: false }
+ )
+ : createSignal(secondarySplit);
const id = createUniqueId();
const [root, setRoot] = createSignal<HTMLDivElement>();
const animateSidebar = createSidebarMotion(root);
@@ -326,7 +338,6 @@ function Root(props: ViewShellRootProps) {
},
};
- const panel = useContext(SplitPanelContext);
const navigationSlot = useContext(ViewNavigationSlotContext);
if (panel) {
registerHotkey({