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: empty favorites sections (#6594)

Peter Chinman09c841d90715
diff --git a/apps/web/src/features/channels-view/components/rail/ChannelsRailSection.tsx b/apps/web/src/features/channels-view/components/rail/ChannelsRailSection.tsx
index d8ffb470c1..03cf24cf03 100644
--- a/apps/web/src/features/channels-view/components/rail/ChannelsRailSection.tsx
+++ b/apps/web/src/features/channels-view/components/rail/ChannelsRailSection.tsx
@@ -89,13 +89,26 @@ function SectionScrollArea(props: {
);
}
+/**
+ * How an open section claims height in its flex column.
+ *
+ * - `half`: natural height, capped at half the column and shrinkable. Two
+ * `half` siblings split the column; a third sibling is starved to zero
+ * once both hit the cap, so keep `half` sections in a column of their own.
+ * - `fill`: grows into whatever the column has left.
+ * - `content`: natural height, never shrunk below it, capped at a third of
+ * the column so a long list still leaves room for its siblings.
+ */
+type CollapsibleSectionSizing = 'half' | 'fill' | 'content';
+
function CollapsibleSectionRoot(props: {
open: boolean;
- fillAvailable?: boolean;
+ sizing?: CollapsibleSectionSizing;
class?: string;
children: JSX.Element;
}) {
let sectionRef: HTMLElement | undefined;
+ const sizing = () => props.sizing ?? 'half';
return (
<SectionContainerContext.Provider value={() => sectionRef}>
@@ -103,10 +116,12 @@ function CollapsibleSectionRoot(props: {
ref={sectionRef}
class={cn(
'group/sidebar-section flex min-h-0 flex-col gap-(--sidebar-section-content-gap)',
- props.open && props.fillAvailable && 'flex-1',
- props.open && !props.fillAvailable && 'shrink',
!props.open && 'shrink-0',
- props.open && !props.fillAvailable && 'max-h-[calc(50%_-_0.375rem)]',
+ props.open && sizing() === 'fill' && 'flex-1',
+ props.open &&
+ sizing() === 'half' &&
+ 'shrink max-h-[calc(50%_-_0.375rem)]',
+ props.open && sizing() === 'content' && 'shrink-0 max-h-1/3',
props.class
)}
>
diff --git a/apps/web/src/features/channels-view/components/rail/ExpandedChannelsRail.tsx b/apps/web/src/features/channels-view/components/rail/ExpandedChannelsRail.tsx
index 2b191edcfb..cd68511b54 100644
--- a/apps/web/src/features/channels-view/components/rail/ExpandedChannelsRail.tsx
+++ b/apps/web/src/features/channels-view/components/rail/ExpandedChannelsRail.tsx
@@ -268,7 +268,7 @@ function ExpandedFavoritesSection() {
return (
<Show when={section().items.length > 0}>
- <CollapsibleSection.Root open={section().open}>
+ <CollapsibleSection.Root open={section().open} sizing="content">
<CollapsibleSection.Header
focused={section().focused}
focusWithin={section().containsFocus}
@@ -474,7 +474,7 @@ function ExpandedGroupSection(props: { config: GroupConfig }) {
return (
<CollapsibleSection.Root
open={section().open}
- fillAvailable={section().fillAvailable}
+ sizing={section().fillAvailable ? 'fill' : 'half'}
>
<CollapsibleSection.Header
focused={section().focused}
@@ -596,9 +596,14 @@ function ExpandedBrowse() {
<Match when={true}>
<ViewSidebar.Content class="h-full overflow-hidden">
<ExpandedFavoritesSection />
- <For each={GROUPS}>
- {(config) => <ExpandedGroupSection config={config} />}
- </For>
+ {/* The groups split the height left after favorites between them.
+ Their half-height caps resolve against this column, not the
+ whole sidebar, so favorites is never squeezed out. */}
+ <div class="flex min-h-0 flex-1 flex-col gap-(--sidebar-section-gap)">
+ <For each={GROUPS}>
+ {(config) => <ExpandedGroupSection config={config} />}
+ </For>
+ </div>
</ViewSidebar.Content>
</Match>
</Switch>
diff --git a/apps/web/src/features/drive-view/drive-view.tsx b/apps/web/src/features/drive-view/drive-view.tsx
index bd89f9a902..c4ed6c35f4 100644
--- a/apps/web/src/features/drive-view/drive-view.tsx
+++ b/apps/web/src/features/drive-view/drive-view.tsx
@@ -389,9 +389,6 @@ function DriveViewContent(props: DriveViewProps) {
/>
)}
</For>
- <Show when={favorites().length === 0}>
- <p class="px-3 py-2 text-sm text-ink-extra-muted">No favorites yet</p>
- </Show>
</ViewSidebar.Nav>
);
@@ -545,6 +542,7 @@ function DriveViewContent(props: DriveViewProps) {
}
createMenu={CreateMenu}
favorites={Favorites}
+ hasFavorites={favorites().length > 0}
detail={
navigationStack.active() ? (
<DriveDetailView
diff --git a/apps/web/src/features/drive-view/views/drive-layout.tsx b/apps/web/src/features/drive-view/views/drive-layout.tsx
index 794915839f..cd34ba8737 100644
--- a/apps/web/src/features/drive-view/views/drive-layout.tsx
+++ b/apps/web/src/features/drive-view/views/drive-layout.tsx
@@ -50,6 +50,8 @@ export function DriveLayout(props: {
onTagsOpen: (open: boolean) => void;
createMenu: () => JSX.Element;
favorites: () => JSX.Element;
+ /** The favorites section is hidden entirely when the user has none. */
+ hasFavorites: boolean;
locationMenu: DriveLocationMenu;
detail?: JSX.Element;
children: JSX.Element;
@@ -77,18 +79,20 @@ export function DriveLayout(props: {
setNavigationOpen(false);
}}
/>
- <CollapsibleSection.Root
- open={props.state.favoritesOpen}
- onOpenChange={props.onFavoritesOpen}
- >
- <CollapsibleSection.Trigger>
- <span class="min-w-0 truncate">Favorites</span>
- <CollapsibleSection.Indicator />
- </CollapsibleSection.Trigger>
- <CollapsibleSection.Content>
- <props.favorites />
- </CollapsibleSection.Content>
- </CollapsibleSection.Root>
+ <Show when={props.hasFavorites}>
+ <CollapsibleSection.Root
+ open={props.state.favoritesOpen}
+ onOpenChange={props.onFavoritesOpen}
+ >
+ <CollapsibleSection.Trigger>
+ <span class="min-w-0 truncate">Favorites</span>
+ <CollapsibleSection.Indicator />
+ </CollapsibleSection.Trigger>
+ <CollapsibleSection.Content>
+ <props.favorites />
+ </CollapsibleSection.Content>
+ </CollapsibleSection.Root>
+ </Show>
<CollapsibleSection.Root
open={props.state.rootOpen}
onOpenChange={props.onRootOpen}
diff --git a/apps/web/src/features/tasks-view/components/TasksSidebar.tsx b/apps/web/src/features/tasks-view/components/TasksSidebar.tsx
index 6047f0c6e1..98d5c500ba 100644
--- a/apps/web/src/features/tasks-view/components/TasksSidebar.tsx
+++ b/apps/web/src/features/tasks-view/components/TasksSidebar.tsx
@@ -105,29 +105,26 @@ function TaskFavorites(props: {
};
return (
- <CollapsibleSection.Root
- open={props.open}
- onOpenChange={props.onOpenChange}
- >
- <CollapsibleSection.Trigger>
- <span class="min-w-0 truncate">Favorites</span>
- <CollapsibleSection.Indicator />
- </CollapsibleSection.Trigger>
- <CollapsibleSection.Content>
- <ViewSidebar.Nav aria-label="Favorite tasks">
- <For each={favorites()}>
- {(favorite) => (
- <FavoriteRow favorite={favorite} onOpen={openFavorite} />
- )}
- </For>
- <Show when={favorites().length === 0}>
- <p class="px-3 py-2 text-sm text-ink-extra-muted">
- No favorites yet
- </p>
- </Show>
- </ViewSidebar.Nav>
- </CollapsibleSection.Content>
- </CollapsibleSection.Root>
+ <Show when={favorites().length > 0}>
+ <CollapsibleSection.Root
+ open={props.open}
+ onOpenChange={props.onOpenChange}
+ >
+ <CollapsibleSection.Trigger>
+ <span class="min-w-0 truncate">Favorites</span>
+ <CollapsibleSection.Indicator />
+ </CollapsibleSection.Trigger>
+ <CollapsibleSection.Content>
+ <ViewSidebar.Nav aria-label="Favorite tasks">
+ <For each={favorites()}>
+ {(favorite) => (
+ <FavoriteRow favorite={favorite} onOpen={openFavorite} />
+ )}
+ </For>
+ </ViewSidebar.Nav>
+ </CollapsibleSection.Content>
+ </CollapsibleSection.Root>
+ </Show>
);
}