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.

style(sidebar): new sidebar collapse logic and layout (#4681)

Seamusbb181e5c312d
diff --git a/js/app/packages/app/component/Layout.tsx b/js/app/packages/app/component/Layout.tsx
index 1a0a64d5e1..9184105ce2 100644
--- a/js/app/packages/app/component/Layout.tsx
+++ b/js/app/packages/app/component/Layout.tsx
@@ -1,3 +1,4 @@
+import { SidebarActiveCallWidget } from '@app/component/app-sidebar/active-call-widget';
import {
AppSidebar,
GoToHotkeys,
@@ -5,11 +6,13 @@ import {
} from '@app/component/app-sidebar/sidebar';
import {
isSidebarVisible,
+ SidebarCollapseContext,
SidebarVisibilityContext,
} from '@app/component/sidebarVisibility';
import { ROUTER_BASE_CONCAT } from '@app/constants/routerBase';
import { mountGlobalFocusListener } from '@app/signal/focus';
import { AutomationComposer } from '@block-automation/component';
+import { InCallPanel, useCallContextOptional } from '@channel/Call';
import { useIsAuthenticated } from '@core/auth';
import { usePaywallState } from '@core/constant/PaywallState';
import { isSoloSettings } from '@core/constant/SettingsState';
@@ -25,6 +28,7 @@ import {
createEffect,
createMemo,
createSignal,
+ onCleanup,
onMount,
Show,
Suspense,
@@ -86,7 +90,14 @@ export function Layout(props: RouteSectionProps) {
return (
<SidebarVisibilityContext.Provider value={sidebarVisible}>
- <LayoutInner {...props} />
+ <SidebarCollapseContext.Provider
+ value={{
+ isCollapsed: () => sidebarVisible() && sidebarState() === 'slim',
+ expand: () => setSidebarState('expanded'),
+ }}
+ >
+ <LayoutInner {...props} />
+ </SidebarCollapseContext.Provider>
</SidebarVisibilityContext.Provider>
);
}
@@ -95,6 +106,43 @@ function LayoutInner(props: RouteSectionProps) {
const isAuthenticated = useIsAuthenticated();
const { paywallOpen, showPaywall } = usePaywallState();
const location = useLocation();
+ const [sidebarOverlayOpen, setSidebarOverlayOpen] = createSignal(false);
+ const [sidebarOverlayTriggerHovered, setSidebarOverlayTriggerHovered] =
+ createSignal(false);
+ const callCtx = useCallContextOptional();
+ const sidebarCollapsed = createMemo(
+ () => isSidebarVisible() && sidebarState() === 'slim'
+ );
+ let sidebarOverlayCloseTimer: ReturnType<typeof setTimeout> | undefined;
+
+ const clearSidebarOverlayCloseTimer = () => {
+ if (sidebarOverlayCloseTimer === undefined) return;
+ clearTimeout(sidebarOverlayCloseTimer);
+ sidebarOverlayCloseTimer = undefined;
+ };
+
+ const setSidebarOverlayOpenGuarded = (open: boolean) => {
+ clearSidebarOverlayCloseTimer();
+ if (open) {
+ setSidebarOverlayOpen(true);
+ return;
+ }
+
+ sidebarOverlayCloseTimer = setTimeout(() => {
+ sidebarOverlayCloseTimer = undefined;
+ if (!sidebarOverlayTriggerHovered()) setSidebarOverlayOpen(false);
+ }, 120);
+ };
+
+ createEffect(() => {
+ if (!sidebarCollapsed()) {
+ clearSidebarOverlayCloseTimer();
+ setSidebarOverlayTriggerHovered(false);
+ setSidebarOverlayOpen(false);
+ }
+ });
+
+ onCleanup(clearSidebarOverlayCloseTimer);
useAppSquishHandlers();
@@ -180,6 +228,8 @@ function LayoutInner(props: RouteSectionProps) {
<Show when={isSidebarVisible()}>
<AppSidebar
sidebarState={sidebarState()}
+ overlayOpen={sidebarOverlayOpen()}
+ onOverlayOpenChange={setSidebarOverlayOpenGuarded}
onOpenChange={(open) => {
if (!open) {
setSidebarState(isMobile() ? 'hidden' : 'slim');
@@ -190,12 +240,43 @@ function LayoutInner(props: RouteSectionProps) {
}}
/>
</Show>
+ <Show when={sidebarCollapsed()}>
+ <div
+ class="fixed left-0 inset-y-0 z-modal-content w-[8px]"
+ onPointerEnter={() => {
+ setSidebarOverlayTriggerHovered(true);
+ setSidebarOverlayOpenGuarded(true);
+ }}
+ onPointerLeave={() => {
+ setSidebarOverlayTriggerHovered(false);
+ setSidebarOverlayOpenGuarded(false);
+ }}
+ />
+ </Show>
<div class="flex-1 w-full min-h-0 font-sans text-ink caret-accent">
{props.children}
</div>
</ItemDndProvider>
</div>
+ <Show when={isSidebarVisible()}>
+ <div
+ class="fixed bottom-3 z-page-overlay w-64 flex flex-col gap-2 transition-[left] duration-[120ms] ease-in-out"
+ style={{
+ left: sidebarState() === 'expanded' ? '15.75rem' : '0.75rem',
+ }}
+ >
+ <Show when={callCtx?.isInCall()}>
+ <div data-ui="in-call-panel">
+ <InCallPanel isSlim={() => false} />
+ </div>
+ </Show>
+ <SidebarActiveCallWidget
+ sidebarState="expanded"
+ class="rounded-xl border border-edge-muted bg-surface shadow-menu p-1"
+ />
+ </div>
+ </Show>
<Show
when={
isMobile() &&
diff --git a/js/app/packages/app/component/app-sidebar/active-call-widget.tsx b/js/app/packages/app/component/app-sidebar/active-call-widget.tsx
index d0def3f3fc..1d98768394 100644
--- a/js/app/packages/app/component/app-sidebar/active-call-widget.tsx
+++ b/js/app/packages/app/component/app-sidebar/active-call-widget.tsx
@@ -179,7 +179,10 @@ const IncomingCallContextMenu: FlowComponent<IncomingCallContextMenuProps> = (
);
};
-export function SidebarActiveCallWidget(props: { sidebarState: SidebarState }) {
+export function SidebarActiveCallWidget(props: {
+ sidebarState: SidebarState;
+ class?: string;
+}) {
const channelsCtx = useChannelsContext();
const callCtx = useCallContextOptional();
const userId = useUserId();
@@ -313,7 +316,9 @@ export function SidebarActiveCallWidget(props: { sidebarState: SidebarState }) {
<Show
when={!isSlim()}
fallback={
- <section class="w-full p-2 flex flex-col items-center">
+ <section
+ class={cn('w-full p-2 flex flex-col items-center', props.class)}
+ >
<For each={slimVisible()}>
{(call) => {
const channel = () =>
@@ -366,7 +371,12 @@ export function SidebarActiveCallWidget(props: { sidebarState: SidebarState }) {
</section>
}
>
- <section class="size-full flex flex-col justify-center px-2 py-1.5">
+ <section
+ class={cn(
+ 'size-full flex flex-col justify-center px-2 py-1.5',
+ props.class
+ )}
+ >
<header class="text-xs font-medium text-ink-muted ml-2 mb-1 whitespace-nowrap">
<h1>Incoming calls</h1>
</header>
diff --git a/js/app/packages/app/component/app-sidebar/channels-unread-widget.tsx b/js/app/packages/app/component/app-sidebar/channels-unread-widget.tsx
index 0f13c5342a..2f0d990928 100644
--- a/js/app/packages/app/component/app-sidebar/channels-unread-widget.tsx
+++ b/js/app/packages/app/component/app-sidebar/channels-unread-widget.tsx
@@ -1,13 +1,23 @@
+import {
+ CollapsibleSidebarSection,
+ type CollapsibleSidebarSectionItem,
+} from '@app/component/app-sidebar/collapsible-sidebar-section';
import type { SidebarState } from '@app/component/app-sidebar/sidebar';
import { useSenderName } from '@app/component/app-sidebar/utils';
import {
useGlobalBlockOrchestrator,
useGlobalNotificationSource,
} from '@app/component/GlobalAppState';
+import { useSplitLayout } from '@app/component/split-layout/layout';
import { globalSplitManager } from '@app/signal/splitLayout';
import { navigateToChannelMessage } from '@block-channel/utils/link';
import { ReadonlyThread } from '@channel/StandaloneThread';
-import { ContextMenuContent, MenuItem } from '@core/component/ContextMenu';
+import {
+ ContextMenuContent,
+ MenuGroup,
+ MenuItem,
+ MenuSeparator,
+} from '@core/component/ContextMenu';
import { UserIcon } from '@core/component/UserIcon';
import { isTouchDevice } from '@core/mobile/isTouchDevice';
import { compareDateDesc } from '@core/util/date';
@@ -17,15 +27,13 @@ import { openNotification } from '@notifications';
import { isChannelNotification } from '@notifications/notification-helpers';
import { getChannelNotificationParams } from '@notifications/notification-navigation';
import type { UnifiedNotification } from '@notifications/types';
-import { createElementSize } from '@solid-primitives/resize-observer';
-import { Avatar, cn, NavRow, Surface, Tooltip } from '@ui';
+import { Avatar, cn, Dropdown, NavRow, Surface, Tooltip } from '@ui';
import {
createEffect,
createMemo,
createSignal,
For,
on,
- onCleanup,
onMount,
type ParentProps,
Show,
@@ -81,7 +89,7 @@ function computeChannelLetters(groups: ChannelGroup[]): Map<string, string> {
function ChannelLetterIcon(props: { letters: string; slim?: boolean }) {
return (
- <Avatar size="md" class="bg-ink-extra-muted/15 text-ink-muted">
+ <Avatar size="sm" class="size-3.5 bg-ink-extra-muted/15 text-ink-muted">
<Avatar.Fallback>{props.letters}</Avatar.Fallback>
</Avatar>
);
@@ -174,11 +182,17 @@ function GroupHoverPreview(props: { group: ChannelGroup }) {
}
function UnreadHoverCard(
- props: ParentProps<{ group: ChannelGroup; disabled?: boolean }>
+ props: ParentProps<{
+ group: ChannelGroup;
+ disabled?: boolean;
+ onOpenChange?: (open: boolean) => void;
+ }>
) {
const [hovered, setHovered] = createSignal(false);
const open = () => hovered() && !props.disabled;
+ createEffect(() => props.onOpenChange?.(open()));
+
return (
<Show when={!isTouchDevice()} fallback={props.children}>
<KobalteTooltip
@@ -215,6 +229,7 @@ function ChannelGroupItem(props: {
animate?: boolean;
isSlim?: boolean;
channelLetters?: string;
+ onFloatingOpenChange?: (open: boolean) => void;
}) {
const notificationSource = useGlobalNotificationSource();
const [isVisible, setIsVisible] = createSignal(!props.animate);
@@ -271,7 +286,7 @@ function ChannelGroupItem(props: {
void notificationSource.bulkMarkAsRead(props.group.notifications);
};
- const _openFullscreen = () => {
+ const openFullscreen = () => {
const { params } = getChannelNotificationParams(latestNotification());
globalSplitManager()?.createPopoverSplit({
content: {
@@ -286,9 +301,7 @@ function ChannelGroupItem(props: {
const ButtonContent = () => (
<NavRow
- class={cn(
- 'transition-[opacity,transform] justify-start gap-2 w-full h-8 p-1.25'
- )}
+ class="transition-[opacity,transform] justify-start w-full h-7"
draggable={false}
classList={{
'opacity-0 -translate-y-2': !isVisible(),
@@ -314,9 +327,10 @@ function ChannelGroupItem(props: {
>
<UserIcon
id={senderId()!}
- size={'md'}
+ size="sm"
suppressClick
showTooltip={false}
+ class="size-3.5"
/>
</Show>
<Show when={isSlim()}>
@@ -337,6 +351,11 @@ function ChannelGroupItem(props: {
);
const [contextMenuOpen, setContextMenuOpen] = createSignal(false);
+ const [hoverCardOpen, setHoverCardOpen] = createSignal(false);
+
+ createEffect(() => {
+ props.onFloatingOpenChange?.(contextMenuOpen() || hoverCardOpen());
+ });
return (
<ContextMenu onOpenChange={setContextMenuOpen}>
@@ -351,7 +370,11 @@ function ChannelGroupItem(props: {
</Tooltip>
}
>
- <UnreadHoverCard group={props.group} disabled={contextMenuOpen()}>
+ <UnreadHoverCard
+ group={props.group}
+ disabled={contextMenuOpen()}
+ onOpenChange={setHoverCardOpen}
+ >
<ButtonContent />
</UnreadHoverCard>
</Show>
@@ -359,16 +382,23 @@ function ChannelGroupItem(props: {
<ContextMenu.Portal>
<ContextMenuContent class="text-xs text-ink-muted">
- <MenuItem
- text="Open in new split"
- onClick={openInNewSplit}
- disabled={!canOpenInNewSplit()}
- />
- {/* FIXME: this doesn't work yet */}
- {/* <MenuItem text="Open fullscreen" onClick={openFullscreen} /> */}
- <MenuItem text="Open in current split" onClick={openInCurrentSplit} />
- <MenuItem text="Mark all as read" onClick={markAllAsRead} />
- <MenuItem text="Mark all as done" onClick={markAllAsDone} />
+ <MenuGroup>
+ <MenuItem
+ text="Open in new split"
+ onClick={openInNewSplit}
+ disabled={!canOpenInNewSplit()}
+ />
+ <MenuItem text="Open fullscreen" onClick={openFullscreen} />
+ <MenuItem
+ text="Open in current split"
+ onClick={openInCurrentSplit}
+ />
+ </MenuGroup>
+ <MenuSeparator />
+ <MenuGroup>
+ <MenuItem text="Mark all as read" onClick={markAllAsRead} />
+ <MenuItem text="Mark all as done" onClick={markAllAsDone} />
+ </MenuGroup>
</ContextMenuContent>
</ContextMenu.Portal>
</ContextMenu>
@@ -379,8 +409,54 @@ function filterUnreadNotDone(notifications: UnifiedNotification[]) {
return notifications.filter((n) => !n.viewed_at && !n.done);
}
-export const ChannelsUnreadWidget = (props: { sidebarState: SidebarState }) => {
+function ChannelGroupDropdownItem(props: {
+ group: ChannelGroup;
+ channelLetters?: string;
+}) {
+ const senderName = useSenderName(props.group.latestSenderId);
+ const count = () => props.group.notifications.length;
+ const displayName = () => {
+ if (props.group.isDM) return senderName() ?? 'Direct Message';
+ return props.group.channelName
+ ? `#${props.group.channelName}`
+ : 'Unknown Channel';
+ };
+ const latestNotification = () => props.group.notifications[0];
+
+ return (
+ <Dropdown.Item
+ class="min-h-8 gap-2 px-2.5 text-[13px]"
+ onSelect={() => {
+ const manager = globalSplitManager();
+ if (manager) openNotification(latestNotification(), manager, false);
+ }}
+ >
+ <Show
+ when={props.group.isDM && props.group.latestSenderId}
+ fallback={<ChannelLetterIcon letters={props.channelLetters ?? '?'} />}
+ >
+ <UserIcon
+ id={props.group.latestSenderId!}
+ size="md"
+ suppressClick
+ showTooltip={false}
+ />
+ </Show>
+ <span class="min-w-0 flex-1 truncate text-ink">{displayName()}</span>
+ <span class="shrink-0 min-w-5 h-5 px-1.5 flex items-center justify-center text-xs font-medium bg-ink/6 text-ink-muted rounded-md">
+ {count()}
+ </span>
+ </Dropdown.Item>
+ );
+}
+
+export const ChannelsUnreadWidget = (props: {
+ sidebarState: SidebarState;
+ onSectionOpenChange?: () => void;
+ onDropdownOpenChange?: (open: boolean) => void;
+}) => {
const notificationSource = useGlobalNotificationSource();
+ const layout = useSplitLayout();
const allNotifications = () => [...notificationSource.notifications()];
const filteredNotifications = () => filterUnreadNotDone(allNotifications());
@@ -426,78 +502,37 @@ export const ChannelsUnreadWidget = (props: { sidebarState: SidebarState }) => {
const SLIM_MAX = 4;
const slimVisible = () => channelGroups().slice(0, SLIM_MAX);
const slimOverflow = () => Math.max(0, channelGroups().length - SLIM_MAX);
- const [hasOverflowTop, setHasOverflowTop] = createSignal(false);
- const [hasOverflowBottom, setHasOverflowBottom] = createSignal(false);
- const [scrollRef, setScrollRef] = createSignal<HTMLDivElement>();
- const [scrollFrameRef, setScrollFrameRef] = createSignal<HTMLDivElement>();
- const scrollSize = createElementSize(scrollRef);
- const scrollFrameSize = createElementSize(scrollFrameRef);
- let scrollShadowFrame: number | undefined;
- let detachScrollShadowObservers: VoidFunction | undefined;
-
- const updateScrollShadows = () => {
- const el = scrollRef();
- if (!el) return;
- const maxScrollTop = el.scrollHeight - el.clientHeight;
- setHasOverflowTop(el.scrollTop > 1);
- setHasOverflowBottom(maxScrollTop - el.scrollTop > 1);
- };
-
- const scheduleScrollShadowUpdate = () => {
- if (scrollShadowFrame !== undefined) {
- cancelAnimationFrame(scrollShadowFrame);
- }
- scrollShadowFrame = requestAnimationFrame(() => {
- scrollShadowFrame = undefined;
- updateScrollShadows();
- });
- };
-
- const detachScrollObservers = () => {
- detachScrollShadowObservers?.();
- detachScrollShadowObservers = undefined;
- };
-
- const attachScrollEl = (el: HTMLDivElement) => {
- detachScrollObservers();
- setScrollRef(el);
-
- const mutationObserver = new MutationObserver(scheduleScrollShadowUpdate);
- const sidebarRoot = el.closest('[data-expanded]');
-
- mutationObserver.observe(sidebarRoot ?? el, {
- childList: true,
- subtree: true,
- characterData: true,
- });
-
- scheduleScrollShadowUpdate();
-
- detachScrollShadowObservers = () => {
- mutationObserver.disconnect();
- };
- };
-
- onCleanup(() => {
- detachScrollObservers();
- if (scrollShadowFrame !== undefined) {
- cancelAnimationFrame(scrollShadowFrame);
- }
- });
-
- createEffect(
- on(channelGroups, () => {
- scheduleScrollShadowUpdate();
- })
+ const sectionItems = createMemo<CollapsibleSidebarSectionItem[]>(() =>
+ channelGroups().map((group) => ({
+ id: group.entityId,
+ visible: () => (
+ <ChannelGroupItem
+ group={group}
+ animate={false}
+ channelLetters={channelLettersMap().get(group.entityId)}
+ onFloatingOpenChange={props.onDropdownOpenChange}
+ />
+ ),
+ dropdown: () => (
+ <ChannelGroupDropdownItem
+ group={group}
+ channelLetters={channelLettersMap().get(group.entityId)}
+ />
+ ),
+ }))
);
- createEffect(() => {
- scrollSize.width;
- scrollSize.height;
- scrollFrameSize.width;
- scrollFrameSize.height;
- scheduleScrollShadowUpdate();
- });
+ const openChannels = () => {
+ layout.openWithSplit(
+ { type: 'component', id: 'channels' },
+ {
+ allowDuplicate: true,
+ mergeHistory: false,
+ referredFrom: 'sidebar',
+ }
+ );
+ globalSplitManager()?.returnFocus();
+ };
return (
<Show when={channelGroups().length > 0}>
@@ -523,41 +558,22 @@ export const ChannelsUnreadWidget = (props: { sidebarState: SidebarState }) => {
</section>
}
>
- <section class="size-full min-h-0 flex flex-col px-0 py-1.5">
- <header class="shrink-0 text-xs font-medium text-ink-extra-muted/50 my-1 px-1">
- <h1>Unread</h1>
- </header>
-
- <div ref={setScrollFrameRef} class="relative min-h-0 flex-1">
- <div
- ref={attachScrollEl}
- onScroll={updateScrollShadows}
- class="size-full overflow-y-auto overscroll-contain flex flex-col gap-0.5 pr-1 -mr-1"
+ <CollapsibleSidebarSection
+ label="Unread"
+ items={sectionItems()}
+ visibleCount={3}
+ dropdownMax={10}
+ onOpenChange={() => props.onSectionOpenChange?.()}
+ onDropdownOpenChange={props.onDropdownOpenChange}
+ dropdownFooter={() => (
+ <Dropdown.Item
+ class="min-h-8 gap-2 px-2.5 text-[13px]"
+ onSelect={openChannels}
>
- <For each={channelGroups()}>
- {(group) => (
- <ChannelGroupItem
- group={group}
- animate={false}
- channelLetters={channelLettersMap().get(group.entityId)}
- />
- )}
- </For>
- </div>
- <div
- class={cn(
- 'pointer-events-none absolute inset-x-0 top-0 h-3 transition-opacity bg-gradient-to-b from-surface to-transparent',
- hasOverflowTop() ? 'opacity-100' : 'opacity-0'
- )}
- />
- <div
- class={cn(
- 'pointer-events-none absolute inset-x-0 bottom-0 h-3 transition-opacity bg-gradient-to-t from-surface to-transparent',
- hasOverflowBottom() ? 'opacity-100' : 'opacity-0'
- )}
- />
- </div>
- </section>
+ <span class="flex-1 text-ink">Go to channels</span>
+ </Dropdown.Item>
+ )}
+ />
</Show>
</Show>
);
diff --git a/js/app/packages/app/component/app-sidebar/collapsible-sidebar-section.tsx b/js/app/packages/app/component/app-sidebar/collapsible-sidebar-section.tsx
new file mode 100644
index 0000000000..392aead49a
--- /dev/null
+++ b/js/app/packages/app/component/app-sidebar/collapsible-sidebar-section.tsx
@@ -0,0 +1,126 @@
+import CaretDownIcon from '@phosphor/caret-down.svg';
+import DotsIcon from '@phosphor/dots-three.svg';
+import { cn, Dropdown, NavRow } from '@ui';
+import { createSignal, For, type JSX, onCleanup, Show } from 'solid-js';
+
+export type CollapsibleSidebarSectionItem = {
+ id: string;
+ visible: () => JSX.Element;
+ dropdown: () => JSX.Element;
+};
+
+export function CollapsibleSidebarSection(props: {
+ label: string;
+ items: readonly CollapsibleSidebarSectionItem[];
+ visibleCount: number;
+ dropdownMax?: number;
+ dropdownFooter?: () => JSX.Element;
+ defaultOpen?: boolean;
+ onOpenChange?: (open: boolean) => void;
+ onDropdownOpenChange?: (open: boolean) => void;
+ dropdownInteractionDisabled?: boolean;
+}) {
+ const [open, setOpen] = createSignal(props.defaultOpen ?? true);
+ let openChangeTimer: ReturnType<typeof setTimeout> | undefined;
+ const visibleItems = () => props.items.slice(0, props.visibleCount);
+ const overflowItems = () => {
+ const items = props.items.slice(props.visibleCount);
+ return props.dropdownMax === undefined
+ ? items
+ : items.slice(0, props.dropdownMax);
+ };
+
+ onCleanup(() => {
+ if (openChangeTimer !== undefined) clearTimeout(openChangeTimer);
+ });
+
+ const toggleOpen = () => {
+ const next = !open();
+ setOpen(next);
+ props.onOpenChange?.(next);
+ if (openChangeTimer !== undefined) clearTimeout(openChangeTimer);
+ openChangeTimer = setTimeout(() => {
+ openChangeTimer = undefined;
+ props.onOpenChange?.(next);
+ }, 130);
+ };
+
+ return (
+ <section class="w-full flex flex-col">
+ <header>
+ <button
+ type="button"
+ class="group/section flex h-7 w-full items-center justify-start gap-1 rounded-md px-2 text-left text-[13px] font-medium text-ink-extra-muted/60 transition-colors hover:bg-ink/3 hover:text-ink-muted"
+ aria-expanded={open()}
+ onClick={toggleOpen}
+ >
+ <span class="min-w-0 truncate">{props.label}</span>
+ <CaretDownIcon
+ class={cn(
+ 'size-3 shrink-0 transition-transform duration-[120ms] ease-in-out',
+ !open() && '-rotate-90'
+ )}
+ />
+ </button>
+ </header>
+ <div
+ class={cn('grid overflow-hidden', !open() && 'pointer-events-none')}
+ aria-hidden={!open()}
+ style={{
+ 'grid-template-rows': open() ? '1fr' : '0fr',
+ 'margin-top': open() ? '0.125rem' : '0',
+ opacity: open() ? '1' : '0',
+ visibility: open() ? 'visible' : 'hidden',
+ transition: open()
+ ? 'grid-template-rows 120ms ease-in-out, margin-top 120ms ease-in-out, opacity 120ms ease-in-out, visibility 0ms linear 0ms'
+ : 'grid-template-rows 120ms ease-in-out, margin-top 120ms ease-in-out, opacity 120ms ease-in-out, visibility 0ms linear 120ms',
+ }}
+ >
+ <div class="min-h-0 overflow-hidden flex flex-col gap-0.5">
+ <For each={visibleItems()}>
+ {(item) => <div class="w-full">{item.visible()}</div>}
+ </For>
+ <Show when={overflowItems().length > 0}>
+ <Dropdown
+ placement="right-start"
+ gutter={8}
+ onOpenChange={props.onDropdownOpenChange}
+ >
+ <Dropdown.Trigger
+ as={NavRow}
+ class="h-7 border-0! text-[13px] focus-visible:bg-transparent focus-visible:ring-0 focus-visible:ring-offset-0"
+ fullWidth
+ label={`${props.label} more`}
+ tooltipPlacement="right"
+ onMouseDown={(e: MouseEvent) => {
+ if (e.button !== 0) return;
+ e.preventDefault();
+ }}
+ >
+ <div class="size-5 shrink-0 flex items-center justify-center">
+ <DotsIcon class="size-3.5" />
+ </div>
+ <span class="whitespace-nowrap">More</span>
+ </Dropdown.Trigger>
+ <Dropdown.Content
+ class={cn(
+ 'min-w-52 shadow-menu',
+ props.dropdownInteractionDisabled &&
+ 'pointer-events-none [&_[data-highlighted]]:bg-transparent!'
+ )}
+ inert={props.dropdownInteractionDisabled || undefined}
+ >
+ <Dropdown.Group>
+ <For each={overflowItems()}>{(item) => item.dropdown()}</For>
+ <Show when={props.dropdownFooter}>
+ {(footer) => footer()()}
+ </Show>
+ </Dropdown.Group>
+ </Dropdown.Content>
+ </Dropdown>
+ </Show>
+ </div>
+ </div>
+ </section>
+ );
+}
diff --git a/js/app/packages/app/component/app-sidebar/favorites-section.tsx b/js/app/packages/app/component/app-sidebar/favorites-section.tsx
index 46c3eafd29..444eea4ae4 100644
--- a/js/app/packages/app/component/app-sidebar/favorites-section.tsx
+++ b/js/app/packages/app/component/app-sidebar/favorites-section.tsx
@@ -1,5 +1,6 @@
import type { SidebarState } from '@app/component/app-sidebar/sidebar';
import { FavoriteIcon } from '@app/component/FavoriteIcon';
+import { useGlobalNotificationSource } from '@app/component/GlobalAppState';
import { useSplitLayout } from '@app/component/split-layout/layout';
import { globalSplitManager } from '@app/signal/splitLayout';
import {
@@ -8,10 +9,17 @@ import {
useFavoriteDisplayName,
useFavoriteDmRecipientId,
} from '@app/util/favorites';
-import { ContextMenuContent, MenuItem } from '@core/component/ContextMenu';
+import {
+ ContextMenuContent,
+ MenuGroup,
+ MenuItem,
+ MenuSeparator,
+} from '@core/component/ContextMenu';
import type { EntityIconSelector } from '@core/component/EntityIcon';
import { ContextMenu } from '@kobalte/core/context-menu';
-import CaretRightIcon from '@phosphor/caret-right.svg';
+import { isChannelNotification } from '@notifications/notification-helpers';
+import type { UnifiedNotification } from '@notifications/types';
+import CaretDownIcon from '@phosphor/caret-down.svg';
import {
favoriteEntityKey,
useFavoritesData,
@@ -26,7 +34,7 @@ import {
useDragDropContext,
} from '@thisbeyond/solid-dnd';
import { cn, NavRow } from '@ui';
-import { createMemo, createSignal, For, Show } from 'solid-js';
+import { type Accessor, createMemo, createSignal, For, Show } from 'solid-js';
/**
* Drag data carried by favorite row sortables. Distinct from `EntityDragData`
@@ -50,20 +58,45 @@ export type FavoriteDragData = {
* and are drag-reorderable. Hidden entirely in slim mode and when the user has
* no favorites.
*/
-export const FavoritesSection = (props: { sidebarState: SidebarState }) => {
+export const FavoritesSection = (props: {
+ sidebarState: SidebarState;
+ onContextMenuOpenChange?: (open: boolean) => void;
+}) => {
// Non-suspending accessor: a pending or failed favorites query must not
// suspend or crash the sidebar; the section just stays hidden until loaded.
const favoritesData = useFavoritesData();
+ const notificationSource = useGlobalNotificationSource();
const favorites = () => favoritesData()?.favorites ?? [];
+ const unreadNotificationsByChannel = createMemo(() => {
+ const notificationsByChannel = new Map<string, UnifiedNotification[]>();
+ for (const notification of notificationSource.notifications()) {
+ if (
+ !isChannelNotification(notification) ||
+ notification.viewed_at ||
+ notification.done
+ ) {
+ continue;
+ }
+ const notifications = notificationsByChannel.get(notification.entity_id);
+ if (notifications) {
+ notifications.push(notification);
+ } else {
+ notificationsByChannel.set(notification.entity_id, [notification]);
+ }
+ }
+ return notificationsByChannel;
+ });
return (
<Show when={props.sidebarState === 'expanded' && favorites().length > 0}>
- <div class="w-full shrink-0 max-h-[40%] overflow-y-auto overscroll-contain">
+ <div class="w-full shrink-0">
<FavoritesGroup
label="Favorites"
favorites={favorites()}
persistKey="sidebar-favorites-expanded"
+ onContextMenuOpenChange={props.onContextMenuOpenChange}
+ unreadNotificationsByChannel={unreadNotificationsByChannel}
/>
</div>
</Show>
@@ -74,6 +107,10 @@ const FavoritesGroup = (props: {
label: string;
favorites: Favorite[];
persistKey: string;
+ onContextMenuOpenChange?: (open: boolean) => void;
+ unreadNotificationsByChannel: Accessor<
+ ReadonlyMap<string, UnifiedNotification[]>
+ >;
}) => {
const [expanded, setExpanded] = makePersisted(createSignal(true), {
name: props.persistKey,
@@ -86,6 +123,10 @@ const FavoritesGroup = (props: {
favoriteEntityKey(favorite.entityType, favorite.entityId)
)
);
+ const notificationsForFavorite = (favorite: Favorite) => () =>
+ favorite.entityType === 'channel'
+ ? (props.unreadNotificationsByChannel().get(favorite.entityId) ?? [])
+ : [];
// The sidebar lives inside the app-wide DragDropProvider (ItemDndProvider);
// register on its events rather than mounting a nested provider.
@@ -113,19 +154,19 @@ const FavoritesGroup = (props: {
});
return (
- <section class="w-full py-1.5">
- <header class="shrink-0 my-1 px-1">
+ <section class="w-full flex flex-col">
+ <header>
<button
type="button"
- class="w-full flex items-center gap-1 text-xs font-medium text-ink-extra-muted/50 hover:text-ink-muted transition-colors"
+ class="group/section flex h-7 w-full items-center justify-start gap-1 rounded-md px-2 text-left text-[13px] font-medium text-ink-extra-muted/60 transition-colors hover:bg-ink/3 hover:text-ink-muted"
aria-expanded={expanded()}
onClick={() => setExpanded(!expanded())}
>
- <h1>{props.label}</h1>
- <CaretRightIcon
+ <span class="min-w-0 truncate">{props.label}</span>
+ <CaretDownIcon
class={cn(
- 'size-3 transition-transform duration-200',
- expanded() && 'rotate-90'
+ 'size-3 shrink-0 transition-transform duration-[120ms] ease-in-out',
+ !expanded() && '-rotate-90'
)}
/>
</button>
@@ -138,7 +179,7 @@ const FavoritesGroup = (props: {
<ul class="min-h-0 overflow-hidden flex flex-col gap-0.5">
<SortableProvider ids={keys()}>
<For each={props.favorites}>
- {(favorite, index) => (
+ {(favorite) => (
<li
class={cn(
'w-full transition-[opacity,transform] duration-200 ease-out',
@@ -146,13 +187,13 @@ const FavoritesGroup = (props: {
? 'opacity-100 translate-y-0'
: 'opacity-0 -translate-y-2'
)}
- style={{
- 'transition-delay': expanded()
- ? `${index() * 30}ms`
- : '0ms',
- }}
>
- <FavoriteRow favorite={favorite} disabled={!expanded()} />
+ <FavoriteRow
+ favorite={favorite}
+ disabled={!expanded()}
+ onContextMenuOpenChange={props.onContextMenuOpenChange}
+ notifications={notificationsForFavorite(favorite)}
+ />
</li>
)}
</For>
@@ -163,8 +204,14 @@ const FavoritesGroup = (props: {
);
};
-const FavoriteRow = (props: { favorite: Favorite; disabled: boolean }) => {
+const FavoriteRow = (props: {
+ favorite: Favorite;
+ disabled: boolean;
+ onContextMenuOpenChange?: (open: boolean) => void;
+ notifications: Accessor<UnifiedNotification[]>;
+}) => {
const layout = useSplitLayout();
+ const notificationSource = useGlobalNotificationSource();
const removeMutation = useRemoveFavoriteMutation();
const [dndState] = useDragDropContext() ?? [];
@@ -209,13 +256,29 @@ const FavoriteRow = (props: { favorite: Favorite; disabled: boolean }) => {
);
};
- const open = (e: MouseEvent) => {
- layout.openWithSplit(content(), {
+ const openFavorite = (preferNewSplit: boolean) => {
+ const split = layout.openWithSplit(content(), {
referredFrom: 'sidebar',
activate: true,
- preferNewSplit: e.shiftKey,
+ preferNewSplit,
});
globalSplitManager()?.returnFocus();
+ return split;
+ };
+
+ const open = (e: MouseEvent) => openFavorite(e.shiftKey);
+ const canOpenInNewSplit = () =>
+ globalSplitManager()?.canAppendSplit() ?? false;
+ const openInCurrentSplit = () => openFavorite(false);
+ const openInNewSplit = () => {
+ if (canOpenInNewSplit()) openFavorite(true);
+ };
+ const openFullscreen = () => layout.popoverSplit(content());
+ const markAllAsRead = () => {
+ void notificationSource.bulkMarkAsRead(props.notifications());
+ };
+ const markAllAsDone = () => {
+ void notificationSource.bulkMarkAsDone(props.notifications());
};
const removeFromFavorites = () => {
@@ -237,8 +300,8 @@ const FavoriteRow = (props: { favorite: Favorite; disabled: boolean }) => {
sortable.isActiveDraggable && 'opacity-40'
)}
>
- <ContextMenu>
- <ContextMenu.Trigger class="w-full h-8">
+ <ContextMenu onOpenChange={props.onContextMenuOpenChange}>
+ <ContextMenu.Trigger class="w-full h-7">
<NavRow
draggable={false}
disabled={props.disabled}
@@ -248,21 +311,50 @@ const FavoriteRow = (props: { favorite: Favorite; disabled: boolean }) => {
)}
data-active={isActive() ? '' : undefined}
active={isActive()}
- class="h-8"
+ class="h-7"
fullWidth
onClick={open}
>
- <FavoriteIcon favorite={props.favorite} />
- <span class="truncate">{displayName()}</span>
+ <div class="size-5 shrink-0 flex items-center justify-center">
+ <FavoriteIcon favorite={props.favorite} class="size-3.5" />
+ </div>
+ <span class="min-w-0 truncate">{displayName()}</span>
+ <Show when={props.notifications().length > 0}>
+ <span class="ml-auto shrink-0 min-w-5 h-5 px-1.5 flex items-center justify-center text-xs font-medium bg-ink/6 text-ink-muted rounded-md">
+ {props.notifications().length}
+ </span>
+ </Show>
</NavRow>
</ContextMenu.Trigger>
<ContextMenu.Portal>
<ContextMenuContent class="text-xs text-ink-muted">
- <MenuItem
- text="Remove from favorites"
- onClick={removeFromFavorites}
- />
+ <MenuGroup>
+ <MenuItem
+ text="Open in new split"
+ onClick={openInNewSplit}
+ disabled={!canOpenInNewSplit()}
+ />
+ <MenuItem text="Open fullscreen" onClick={openFullscreen} />
+ <MenuItem
+ text="Open in current split"
+ onClick={openInCurrentSplit}
+ />
+ </MenuGroup>
+ <Show when={props.notifications().length > 0}>
+ <MenuSeparator />
+ <MenuGroup>
+ <MenuItem text="Mark all as read" onClick={markAllAsRead} />
+ <MenuItem text="Mark all as done" onClick={markAllAsDone} />
+ </MenuGroup>
+ </Show>
+ <MenuSeparator />
+ <MenuGroup>
+ <MenuItem
+ text="Remove from favorites"
+ onClick={removeFromFavorites}
+ />
+ </MenuGroup>
</ContextMenuContent>
</ContextMenu.Portal>
</ContextMenu>
diff --git a/js/app/packages/app/component/app-sidebar/sidebar-create-menu.tsx b/js/app/packages/app/component/app-sidebar/sidebar-create-menu.tsx
index bef22b4edf..89043e3eda 100644
--- a/js/app/packages/app/component/app-sidebar/sidebar-create-menu.tsx
+++ b/js/app/packages/app/component/app-sidebar/sidebar-create-menu.tsx
@@ -12,11 +12,15 @@ import { setActiveScope } from '@core/hotkey/state';
import { TOKENS } from '@core/hotkey/tokens';
import { activateClosestDOMScope } from '@core/hotkey/utils';
import PlusIcon from '@phosphor/plus.svg';
-import { cn, Dropdown, Hotkey, NavRow } from '@ui';
-import { createMemo, createSignal, For, Show } from 'solid-js';
+import { Button, cn, Dropdown, Hotkey, NavRow } from '@ui';
+import { createMemo, createSignal, For, onCleanup, Show } from 'solid-js';
import { Dynamic } from 'solid-js/web';
-export const SidebarCreateMenu = (props: { isSlim: () => boolean }) => {
+export const SidebarCreateMenu = (props: {
+ isSlim: () => boolean;
+ variant?: 'row' | 'icon';
+ onMenuOpenChange?: (open: boolean) => void;
+}) => {
const analytics = useAnalytics();
const [open, setOpen] = createSignal(false);
const [focusedIndex, setFocusedIndex] = createSignal(-1);
@@ -35,6 +39,7 @@ export const SidebarCreateMenu = (props: { isSlim: () => boolean }) => {
analytics.track('create_menu_open', { from: 'sidebar' });
}
setOpen(nextOpen);
+ props.onMenuOpenChange?.(nextOpen);
if (nextOpen) {
setActiveScope(CREATE_MENU_COMMAND_SCOPE);
} else {
@@ -42,6 +47,8 @@ export const SidebarCreateMenu = (props: { isSlim: () => boolean }) => {
}
};
+ onCleanup(() => props.onMenuOpenChange?.(false));
+
useHotkeyInterceptor((context) => {
if (!open() || context.eventType !== 'keydown') return false;
@@ -77,31 +84,55 @@ export const SidebarCreateMenu = (props: { isSlim: () => boolean }) => {
placement="right-start"
gutter={8}
>
- <Dropdown.Trigger
- as={NavRow}
- class="center h-8 bg-ink/4"
- fullWidth
- tooltipPlacement="right"
- tooltipDisabled={!props.isSlim()}
- label="Create"
- hotkey={TOKENS.global.createCommand}
- onMouseDown={(e: MouseEvent) => {
- if (e.button !== 0) return;
- e.preventDefault();
- }}
+ <Show
+ when={props.variant === 'icon'}
+ fallback={
+ <Dropdown.Trigger
+ as={NavRow}
+ class="center h-8 bg-ink/4 text-[13px]"
+ fullWidth
+ tooltipPlacement="right"
+ tooltipDisabled={!props.isSlim()}
+ label="Create"
+ hotkey={TOKENS.global.createCommand}
+ onMouseDown={(e: MouseEvent) => {
+ if (e.button !== 0) return;
+ e.preventDefault();
+ }}
+ >
+ <div class="size-4 shrink-0">
+ <PlusIcon class="size-4" />
+ </div>
+ <span class="whitespace-nowrap group-data-[slim=true]/sidebar:hidden">
+ Create
+ </span>
+ <Show when={open()}>
+ <div class="text-xxs text-ink-extra-muted/50 rounded-sm ml-auto border border-ink/5 px-1.5 py-px -my-1 group-data-[slim=true]/sidebar:hidden">
+ <Hotkey
+ token={TOKENS.global.createCommand}
+ class="flex gap-1"
+ />
+ </div>
+ </Show>
+ </Dropdown.Trigger>
+ }
>
- <div class="size-4 shrink-0">
- <PlusIcon class="size-4" />
- </div>
- <span class="whitespace-nowrap group-data-[slim=true]/sidebar:hidden">
- Create
- </span>
- <Show when={open()}>
- <div class="text-xxs text-ink-extra-muted/50 rounded-sm ml-auto border border-ink/5 px-1.5 py-px -my-1 group-data-[slim=true]/sidebar:hidden">
- <Hotkey token={TOKENS.global.createCommand} class="flex gap-1" />
- </div>
- </Show>
- </Dropdown.Trigger>
+ <Dropdown.Trigger
+ as={Button}
+ variant="base"
+ size="icon-sm"
+ depth={1}
+ class="size-[26px] rounded-full bg-surface shadow-md shadow-drop-shadow [&_svg]:size-4!"
+ label="Create"
+ hotkey={TOKENS.global.createCommand}
+ onMouseDown={(e: MouseEvent) => {
+ if (e.button !== 0) return;
+ e.preventDefault();
+ }}
+ >
+ <PlusIcon />
+ </Dropdown.Trigger>
+ </Show>
<Dropdown.Content class="min-w-52 shadow-menu">
<Dropdown.Group>
<For each={blocks()}>
diff --git a/js/app/packages/app/component/app-sidebar/sidebar.tsx b/js/app/packages/app/component/app-sidebar/sidebar.tsx
index 7518c6ee61..a2b83691e4 100644
--- a/js/app/packages/app/component/app-sidebar/sidebar.tsx
+++ b/js/app/packages/app/component/app-sidebar/sidebar.tsx
@@ -1,6 +1,9 @@
import { useAnalytics } from '@app/component/analytics-context';
-import { SidebarActiveCallWidget } from '@app/component/app-sidebar/active-call-widget';
import { ChannelsUnreadWidget } from '@app/component/app-sidebar/channels-unread-widget';
+import {
+ CollapsibleSidebarSection,
+ type CollapsibleSidebarSectionItem,
+} from '@app/component/app-sidebar/collapsible-sidebar-section';
import { FavoritesSection } from '@app/component/app-sidebar/favorites-section';
import {
InviteModal,
@@ -20,7 +23,6 @@ import {
requestInboxFilter,
} from '@app/component/next-soup/soup-view/inbox-filter-controllers';
import { requestSearchFocus } from '@app/component/next-soup/soup-view/search-controllers';
-import { setAllSidePanelsOpen } from '@app/component/side-panel/registry';
import { useSplitLayout } from '@app/component/split-layout/layout';
import type {
ReferredFrom,
@@ -32,8 +34,6 @@ import { LIST_VIEW_PATHS, type ListView } from '@app/constants/list-views';
import { useFeatureFlag } from '@app/lib/analytics/posthog';
import { useHotkeyInterceptor } from '@app/signal/hotkeyRoot';
import { globalSplitManager } from '@app/signal/splitLayout';
-import { InCallPanel } from '@channel/Call';
-import { useCallContextOptional } from '@channel/Call/CallContext';
import { useHasPaidAccess } from '@core/auth';
import { useLogout } from '@core/auth/logout';
import { ContextMenuContent, MenuItem } from '@core/component/ContextMenu';
@@ -42,7 +42,6 @@ import { UserIcon } from '@core/component/UserIcon';
import {
ENABLE_CALLS,
ENABLE_CRM,
- ENABLE_HOME_OVERRIDE,
ENABLE_NEW_PRICING_OVERRIDE,
} from '@core/constant/featureFlags';
import {
@@ -60,7 +59,6 @@ import { type HotkeyToken, TOKENS } from '@core/hotkey/tokens';
import type { ValidHotkey } from '@core/hotkey/types';
import { activateClosestDOMScope } from '@core/hotkey/utils';
import LogoIcon from '@icon/macro-logo.svg';
-import { AnimatedSquareSidebarIcon } from '@icon/square-sidebar';
import { AnimatedCallIcon } from '@icon/wide-call';
import { AnimatedChannelIcon } from '@icon/wide-channel';
import { AnimatedCompanyIcon } from '@icon/wide-company';
@@ -75,14 +73,19 @@ import CaretRightIcon from '@phosphor/caret-right.svg';
import CaretUpIcon from '@phosphor/caret-up.svg';
import GearIcon from '@phosphor/gear.svg';
import HomeIcon from '@phosphor/house.svg';
+import MagnifyingGlassIcon from '@phosphor/magnifying-glass.svg';
import SignOutIcon from '@phosphor/sign-out.svg';
+import UsersThreeIcon from '@phosphor/users-three.svg';
import { useEmailLinksQuery } from '@queries/email/link';
+import { useCurrentTeamQuery } from '@queries/team/teams';
+import { createElementSize } from '@solid-primitives/resize-observer';
import { debounce } from '@solid-primitives/scheduled';
import { makePersisted } from '@solid-primitives/storage';
import { useLocation } from '@solidjs/router';
import { Button, cn, Dropdown, Hotkey, NavRow } from '@ui';
import {
type Component,
+ type ComponentProps,
createEffect,
createMemo,
createSignal,
@@ -127,6 +130,7 @@ const SIDEBAR_LINKS = [
hotkey: '/',
hotkeyToken: TOKENS.sidebar.goTo.search,
standaloneHotkey: true,
+ hiddenFromSidebar: true,
},
{
id: 'agents',
@@ -178,17 +182,17 @@ const SIDEBAR_LINKS = [
},
{
id: 'channels',
- label: 'Channels',
+ label: 'Messages',
href: LIST_VIEW_PATHS.channels,
icon: AnimatedChannelIcon,
- hotkey: 'c',
+ hotkey: 'm',
hotkeyToken: TOKENS.sidebar.goTo.channels,
},
...(ENABLE_CRM
? ([
{
id: 'companies',
- label: 'Customers',
+ label: 'Companies',
href: LIST_VIEW_PATHS.companies,
icon: AnimatedCompanyIcon,
hotkey: 'o',
@@ -202,85 +206,18 @@ export type SidebarState = 'hidden' | 'expanded' | 'slim';
/** Root sidebar `max-width` transition (see `SIDEBAR_MAX_WIDTH_TRANSITION_STYLE`). */
const SIDEBAR_MAX_WIDTH_TRANSITION_MS = 120;
-const SIDEBAR_MAX_WIDTH_TRANSITION_STYLE = `max-width ease-in-out ${SIDEBAR_MAX_WIDTH_TRANSITION_MS}ms`;
-
-/**
- * InCallPanel stays in slim layout until the sidebar shell finishes widening.
- * Uses `transitionend` on that element’s `max-width` (no timer on the happy path);
- * a short fallback timeout covers reduced-motion / no-op layout.
- */
-function createInCallPanelSlimToggle(args: {
- initialSlim: boolean;
- parentOnOpenChange: (open: boolean) => void;
- getShell: () => HTMLDivElement | undefined;
-}) {
- const [panelIsSlim, setPanelIsSlim] = createSignal(args.initialSlim);
- let shellEl: HTMLDivElement | undefined;
- let onMaxWidthEnd: ((e: TransitionEvent) => void) | undefined;
- let fallbackTimer: ReturnType<typeof setTimeout> | undefined;
-
- const detachExpandTracking = () => {
- const el = shellEl;
- const handler = onMaxWidthEnd;
- shellEl = undefined;
- onMaxWidthEnd = undefined;
- if (el && handler) {
- el.removeEventListener('transitionend', handler);
- }
- if (fallbackTimer !== undefined) {
- globalThis.clearTimeout(fallbackTimer);
- fallbackTimer = undefined;
- }
- };
-
- const finishExpand = () => {
- detachExpandTracking();
- setPanelIsSlim(false);
- };
-
- onCleanup(detachExpandTracking);
-
- return {
- panelIsSlim,
- handleSidebarOpenChange(open: boolean) {
- detachExpandTracking();
-
- if (!open) {
- setPanelIsSlim(true);
- args.parentOnOpenChange(open);
- return;
- }
-
- args.parentOnOpenChange(open);
-
- requestAnimationFrame(() => {
- const el = args.getShell();
- if (!el) {
- setPanelIsSlim(false);
- return;
- }
-
- const onEnd = (e: TransitionEvent) => {
- if (e.propertyName !== 'max-width' || e.target !== el) return;
- finishExpand();
- };
-
- shellEl = el;
- onMaxWidthEnd = onEnd;
- el.addEventListener('transitionend', onEnd);
-
- fallbackTimer = globalThis.setTimeout(
- finishExpand,
- SIDEBAR_MAX_WIDTH_TRANSITION_MS + 80
- );
- });
- },
- } as const;
-}
+const SIDEBAR_MAX_WIDTH_TRANSITION_STYLE = [
+ `max-width ease-in-out ${SIDEBAR_MAX_WIDTH_TRANSITION_MS}ms`,
+ `width ease-in-out ${SIDEBAR_MAX_WIDTH_TRANSITION_MS}ms`,
+ `opacity ease-in-out ${SIDEBAR_MAX_WIDTH_TRANSITION_MS}ms`,
+ `transform ease-in-out ${SIDEBAR_MAX_WIDTH_TRANSITION_MS}ms`,
+].join(', ');
type AppSidebarProps = {
sidebarState?: SidebarState;
onOpenChange: (open: boolean) => void;
+ overlayOpen?: boolean;
+ onOverlayOpenChange?: (open: boolean) => void;
};
type SidebarHotkeyDeps = {
@@ -355,13 +292,12 @@ const registerSidebarHotkeys = ({
hotkey: 'cmd+.',
scopeId: 'global',
hotkeyToken: TOKENS.global.toggleSidebar,
- description: 'Toggle sidebar and side panels',
+ description: 'Toggle sidebar',
runWithInputFocused: true,
keyDownHandler: (e) => {
e?.preventDefault();
const show = isSlim();
onOpenChange(show);
- setAllSidePanelsOpen(show);
return true;
},
});
@@ -404,13 +340,7 @@ export const GoToHotkeys = () => {
},
});
- const homeViewEnabled = useFeatureFlag('enable-home-view', {
- enabledOverride: ENABLE_HOME_OVERRIDE,
- });
-
- const links = createMemo((): SidebarItem[] =>
- buildSidebarLinks(homeViewEnabled().enabled)
- );
+ const links = createMemo((): SidebarItem[] => buildSidebarLinks());
const debounceResetHotkeysState = debounce(resetGoToHotkeysState, 2000);
const debounceSetHotkeyVisible = debounce(
@@ -551,7 +481,7 @@ const SidebarShortcutLink = (props: SidebarShortcutLinkProps) => {
return (
<NavRow
draggable={false}
- class="h-8"
+ class="h-7"
fullWidth
tooltipPlacement="right"
label={props.isSlim() ? props.label : undefined}
@@ -563,7 +493,7 @@ const SidebarShortcutLink = (props: SidebarShortcutLinkProps) => {
props.onClick();
}}
>
- <div class="relative shrink-0 [&_svg]:size-4">
+ <div class="relative size-5 shrink-0 flex items-center justify-center [&_svg]:size-3.5">
<Dynamic component={props.icon} triggerAnimation={isHovering()} />
</div>
@@ -574,32 +504,144 @@ const SidebarShortcutLink = (props: SidebarShortcutLinkProps) => {
);
};
-/**
- * Compact icon-only button for the sidebar header row. Encapsulates the hover
- * signal so animated icons play on hover, mirroring `SidebarActionButton`.
- */
-const SidebarHeaderIconButton = (props: {
- icon: Component<{ triggerAnimation?: boolean; class?: string }>;
- label: string;
- hotkey?: HotkeyToken | HotkeyToken[];
- disabled?: boolean;
- onClick: (event: MouseEvent) => void;
- onMouseDown?: (event: MouseEvent) => void;
-}) => {
- const [hovering, setHovering] = createSignal(false);
+const SidebarDropdownLink = (
+ props: SidebarItem & {
+ onContextMenuOpenChange?: (open: boolean) => void;
+ }
+) => {
+ const analytics = useAnalytics();
+ const layout = useSplitLayout();
+ const location = useLocation();
+ const [isHovering, setIsHovering] = createSignal(false);
+ let contextMenuOpen = false;
+
+ const isActive = () => {
+ const activeContent = globalSplitManager()?.activeSplit()?.content();
+ if (!activeContent) {
+ return location.pathname.split('/').filter(Boolean).includes(props.id);
+ }
+ return activeContent.id === props.id;
+ };
+
+ const handleContextMenuOpenChange = (open: boolean) => {
+ contextMenuOpen = open;
+ props.onContextMenuOpenChange?.(open);
+ };
+
+ onCleanup(() => {
+ if (contextMenuOpen) props.onContextMenuOpenChange?.(false);
+ });
+
+ const open = (newSplit = false) => {
+ analytics.track('sidebar_click', { view: props.id });
+ const handle = navigateToSidebarView({
+ viewId: props.id,
+ params: props.params,
+ shiftKey: newSplit,
+ activeSplit: globalSplitManager()?.activeSplit(),
+ openWithSplit: layout.openWithSplit,
+ referredFrom: 'sidebar',
+ });
+ if (props.id === 'search' && handle) requestSearchFocus(handle.id);
+ globalSplitManager()?.returnFocus();
+ return handle;
+ };
+
+ const canOpenInNewSplit = () =>
+ globalSplitManager()?.canAppendSplit() ?? false;
+ const openInNewSplit = () => {
+ if (canOpenInNewSplit()) open(true);
+ };
+ const openInCurrentSplit = () => open(false);
+ const openFullscreen = () => open(false)?.toggleSpotlight(true);
+
+ const ContextMenuTriggerItem = (
+ triggerProps: ComponentProps<typeof ContextMenu.Trigger>
+ ) => (
+ <ContextMenu onOpenChange={handleContextMenuOpenChange}>
+ <ContextMenu.Trigger {...triggerProps} />
+ <ContextMenu.Portal>
+ <ContextMenuContent class="z-tool-tip! text-xs text-ink-muted">
+ <MenuItem
+ text="Open in new split"
+ onClick={openInNewSplit}
+ disabled={!canOpenInNewSplit()}
+ />
+ <MenuItem text="Open fullscreen" onClick={openFullscreen} />
+ <MenuItem text="Open in current split" onClick={openInCurrentSplit} />
+ </ContextMenuContent>
+ </ContextMenu.Portal>
+ </ContextMenu>
+ );
+
+ return (
+ <Dropdown.Item
+ as={ContextMenuTriggerItem}
+ class={cn(
+ 'min-h-8 gap-2 px-2.5 text-[13px]',
+ isActive() &&
+ 'bg-ink/6 text-ink hover:bg-ink/6 data-highlighted:bg-ink/6'
+ )}
+ data-active={isActive() ? '' : undefined}
+ onMouseEnter={() => setIsHovering(true)}
+ onMouseLeave={() => setIsHovering(false)}
+ onSelect={openInCurrentSplit}
+ >
+ <Show when={props.icon}>
+ <div class="shrink-0 [&_svg]:size-3.5">
+ <Dynamic component={props.icon} triggerAnimation={isHovering()} />
+ </div>
+ </Show>
+ <span class="min-w-0 flex-1 truncate text-ink">{props.label}</span>
+ <Hotkey token={props.hotkeyToken} theme="subtle" class="ml-6" />
+ </Dropdown.Item>
+ );
+};
+
+const SidebarHeaderSearchButton = (props: { link: SidebarItem }) => {
+ const analytics = useAnalytics();
+ const layout = useSplitLayout();
+
+ const openSearch = (event: MouseEvent) => {
+ analytics.track('sidebar_click', { view: props.link.id });
+ let currentContentHandle = globalSplitManager()?.activeSplit();
+ const content = currentContentHandle?.content();
+
+ if (
+ currentContentHandle &&
+ content?.type === 'component' &&
+ content.id === 'search'
+ ) {
+ requestSearchFocus(currentContentHandle.id);
+ globalSplitManager()?.returnFocus();
+ return;
+ }
+
+ currentContentHandle = navigateToSidebarView({
+ viewId: props.link.id,
+ params: props.link.params,
+ shiftKey: event.shiftKey,
+ activeSplit: currentContentHandle,
+ openWithSplit: layout.openWithSplit,
+ referredFrom: 'sidebar',
+ });
+ if (currentContentHandle) requestSearchFocus(currentContentHandle.id);
+ globalSplitManager()?.returnFocus();
+ };
+
return (
<Button
- class="rounded-md p-1 text-ink-extra-muted size-8 [&_svg]:size-4"
size="icon-sm"
- label={props.label}
- hotkey={props.hotkey}
- disabled={props.disabled}
- onClick={props.onClick}
- onMouseDown={props.onMouseDown}
- onMouseEnter={() => setHovering(true)}
- onMouseLeave={() => setHovering(false)}
+ class="[&_svg]:size-4!"
+ label="Search"
+ hotkey={props.link.hotkeyToken}
+ onMouseDown={(e) => {
+ if (e.button !== 0) return;
+ e.preventDefault();
+ }}
+ onClick={openSearch}
>
- <Dynamic component={props.icon} triggerAnimation={hovering()} />
+ <MagnifyingGlassIcon />
</Button>
);
};
@@ -607,6 +649,7 @@ const SidebarHeaderIconButton = (props: {
type SidebarSettingsWidgetProps = {
isSlim: () => boolean;
onSelect: (tab: SettingsTab) => void;
+ onMenuOpenChange?: (open: boolean) => void;
};
const SidebarSettingsWidget = (props: SidebarSettingsWidgetProps) => {
@@ -616,7 +659,11 @@ const SidebarSettingsWidget = (props: SidebarSettingsWidgetProps) => {
const logout = useLogout();
return (
- <Dropdown placement="top-start" gutter={6}>
+ <Dropdown
+ placement="top-start"
+ gutter={6}
+ onOpenChange={props.onMenuOpenChange}
+ >
<Dropdown.Trigger
variant="ghost"
class={cn(
@@ -740,20 +787,16 @@ const DASHBOARD_LINK: SidebarItem = {
};
/**
- * Assemble the ordered sidebar link list: the static links plus the flag-gated
- * Home and Calls entries in their correct positions. Shared by the rendered
+ * Assemble the ordered sidebar link list: the static links plus Home and the
+ * flag-gated Calls entry in their correct positions. Shared by the rendered
* sidebar (`AppSidebar.visibleLinks`) and the always-mounted `GoToHotkeys`
* registrar so their link sets can't drift. Call from a reactive context — it
- * reads `ENABLE_CALLS()`; `homeEnabled` is passed in so the caller tracks the
- * feature-flag read. `visibleLinks` additionally drops `hiddenFromSidebar`
+ * reads `ENABLE_CALLS()`. Rendered sections additionally drop
+ * `hiddenFromSidebar`
* entries, which have hotkeys but no sidebar row.
*/
-const buildSidebarLinks = (homeEnabled: boolean): SidebarItem[] => {
- let links: SidebarItem[] = [...SIDEBAR_LINKS];
-
- if (homeEnabled) {
- links = [DASHBOARD_LINK, ...links];
- }
+const buildSidebarLinks = (): SidebarItem[] => {
+ let links: SidebarItem[] = [DASHBOARD_LINK, ...SIDEBAR_LINKS];
if (ENABLE_CALLS()) {
const idx = links.findIndex((l) => l.id === 'channels');
@@ -763,25 +806,10 @@ const buildSidebarLinks = (homeEnabled: boolean): SidebarItem[] => {
return links;
};
-/**
- * Settings tabs surfaced as always-visible quick links above the settings
- * widget. Label/icon come from the settings tab config (see
- * `getSettingsTabItem`); this list only decides which tabs to promote.
- */
-const PROMOTED_SETTINGS_TABS: SettingsTab[] = [
- 'Mobile App',
- 'Connected',
- 'Team',
-];
-
export const AppSidebar = (props: AppSidebarProps) => {
const { openSettings, selectTab, settingsOpen } = useSettingsState();
const isTabAvailable = useSettingsTabAvailable();
- const callCtx = useCallContextOptional();
-
- const homeViewEnabled = useFeatureFlag('enable-home-view', {
- enabledOverride: ENABLE_HOME_OVERRIDE,
- });
+ const currentTeamQuery = useCurrentTeamQuery();
const hasPaidAccess = useHasPaidAccess();
@@ -795,11 +823,7 @@ export const AppSidebar = (props: AppSidebarProps) => {
enabledOverride: ENABLE_NEW_PRICING_OVERRIDE,
});
- const visibleLinks = createMemo((): SidebarItem[] =>
- buildSidebarLinks(homeViewEnabled().enabled).filter(
- (link) => !link.hiddenFromSidebar
- )
- );
+ const allLinks = createMemo((): SidebarItem[] => buildSidebarLinks());
const openSettingsTab = (tab: SettingsTab) => {
if (!isTabAvailable(tab)) return;
@@ -811,183 +835,417 @@ export const AppSidebar = (props: AppSidebarProps) => {
};
const isExpanded = () => props.sidebarState === 'expanded';
- const isSlim = () => props.sidebarState === 'slim';
+ const isCollapsed = () => props.sidebarState === 'slim';
+ const overlayOpen = () => props.overlayOpen === true;
+ const isOverlayExpanded = () => isCollapsed() && overlayOpen();
+ const isExpandedView = () => isExpanded() || isOverlayExpanded();
+ const isSlim = () => isCollapsed() && !isOverlayExpanded();
+ const sidebarDisplayState = (): SidebarState =>
+ isExpandedView() ? 'expanded' : (props.sidebarState ?? 'expanded');
+ const currentTeamName = () => currentTeamQuery.data?.team.name?.trim();
+
+ const [hasOverflowTop, setHasOverflowTop] = createSignal(false);
+ const [hasOverflowBottom, setHasOverflowBottom] = createSignal(false);
+ const [middleScrollRef, setMiddleScrollRef] = createSignal<HTMLDivElement>();
+ const middleScrollSize = createElementSize(middleScrollRef);
+ const [overlayPointerInside, setOverlayPointerInside] = createSignal(false);
+ const [overlayDropdownOpen, setOverlayDropdownOpen] = createSignal(false);
+ const [workspaceContextMenuOpen, setWorkspaceContextMenuOpen] =
+ createSignal(false);
+ let middleScrollFrame: number | undefined;
+ let middleScrollObserver: MutationObserver | undefined;
+ let overlayCloseTimer: ReturnType<typeof setTimeout> | undefined;
+ let overlayDropdownCloseTimer: ReturnType<typeof setTimeout> | undefined;
+
+ const cancelOverlayClose = () => {
+ if (overlayCloseTimer !== undefined) {
+ clearTimeout(overlayCloseTimer);
+ overlayCloseTimer = undefined;
+ }
+ };
- let sidebarShell: HTMLDivElement | undefined;
- const { panelIsSlim, handleSidebarOpenChange } = createInCallPanelSlimToggle({
- initialSlim: isSlim(),
- parentOnOpenChange: props.onOpenChange,
- getShell: () => sidebarShell,
+ const requestOverlayClose = () => {
+ if (!isCollapsed()) return;
+ cancelOverlayClose();
+ overlayCloseTimer = setTimeout(() => {
+ overlayCloseTimer = undefined;
+ if (!overlayPointerInside() && !overlayDropdownOpen()) {
+ props.onOverlayOpenChange?.(false);
+ }
+ }, SIDEBAR_MAX_WIDTH_TRANSITION_MS);
+ };
+
+ const handleOverlayDropdownOpenChange = (open: boolean) => {
+ if (!isCollapsed()) return;
+ if (overlayDropdownCloseTimer !== undefined) {
+ clearTimeout(overlayDropdownCloseTimer);
+ overlayDropdownCloseTimer = undefined;
+ }
+
+ if (open) {
+ setOverlayDropdownOpen(true);
+ props.onOverlayOpenChange?.(true);
+ cancelOverlayClose();
+ return;
+ }
+
+ overlayDropdownCloseTimer = setTimeout(() => {
+ overlayDropdownCloseTimer = undefined;
+ setOverlayDropdownOpen(false);
+ if (!overlayPointerInside()) requestOverlayClose();
+ }, SIDEBAR_MAX_WIDTH_TRANSITION_MS);
+ };
+
+ const handleWorkspaceContextMenuOpenChange = (open: boolean) => {
+ setWorkspaceContextMenuOpen(open);
+ handleOverlayDropdownOpenChange(open);
+ };
+
+ const updateMiddleScrollShadows = () => {
+ const el = middleScrollRef();
+ if (!el) return;
+ const maxScrollTop = el.scrollHeight - el.clientHeight;
+ setHasOverflowTop(el.scrollTop > 1);
+ setHasOverflowBottom(maxScrollTop - el.scrollTop > 1);
+ };
+
+ const scheduleMiddleScrollUpdate = () => {
+ if (middleScrollFrame !== undefined)
+ cancelAnimationFrame(middleScrollFrame);
+ middleScrollFrame = requestAnimationFrame(() => {
+ middleScrollFrame = undefined;
+ updateMiddleScrollShadows();
+ });
+ };
+
+ const attachMiddleScrollRef = (el: HTMLDivElement) => {
+ middleScrollObserver?.disconnect();
+ setMiddleScrollRef(el);
+ middleScrollObserver = new MutationObserver(scheduleMiddleScrollUpdate);
+ middleScrollObserver.observe(el, {
+ childList: true,
+ subtree: true,
+ characterData: true,
+ attributes: true,
+ });
+ scheduleMiddleScrollUpdate();
+ };
+
+ onCleanup(() => {
+ middleScrollObserver?.disconnect();
+ if (middleScrollFrame !== undefined)
+ cancelAnimationFrame(middleScrollFrame);
+ if (overlayCloseTimer !== undefined) clearTimeout(overlayCloseTimer);
+ if (overlayDropdownCloseTimer !== undefined) {
+ clearTimeout(overlayDropdownCloseTimer);
+ }
+ });
+
+ const findLink = (id: SidebarItem['id']) =>
+ allLinks().find((link) => link.id === id && !link.hiddenFromSidebar);
+ const searchLink = () => allLinks().find((link) => link.id === 'search');
+
+ const renderSidebarLink = (link: SidebarItem) => (
+ <Dynamic
+ component={link.id === 'mail' ? SidebarMailLink : SidebarLink}
+ {...link}
+ sidebarState={sidebarDisplayState()}
+ hotkeyVisible={goToHotkeyVisible()}
+ onContextMenuOpenChange={handleOverlayDropdownOpenChange}
+ />
+ );
+
+ const toSectionItem = (link: SidebarItem): CollapsibleSidebarSectionItem => ({
+ id: String(link.id),
+ visible: () => renderSidebarLink(link),
+ dropdown: () => (
+ <SidebarDropdownLink
+ {...link}
+ onContextMenuOpenChange={handleWorkspaceContextMenuOpenChange}
+ />
+ ),
+ });
+
+ const topLinks = createMemo(() =>
+ ['home', 'inbox']
+ .map((id) => findLink(id))
+ .filter((link): link is SidebarItem => link !== undefined)
+ );
+
+ const workspaceItems = createMemo(() =>
+ ['mail', 'documents', 'channels', 'tasks', 'calls', 'agents']
+ .map((id) => findLink(id))
+ .filter((link): link is SidebarItem => link !== undefined)
+ .map(toSectionItem)
+ );
+
+ const tryItems = createMemo<CollapsibleSidebarSectionItem[]>(() => {
+ const items: CollapsibleSidebarSectionItem[] = [];
+ const connected = getSettingsTabItem('Connected');
+ if (connected && isTabAvailable('Connected')) {
+ items.push({
+ id: 'connect',
+ visible: () => (
+ <SidebarShortcutLink
+ label="Connect"
+ isSlim={isSlim}
+ onClick={() => openSettingsTab('Connected')}
+ icon={connected.icon}
+ />
+ ),
+ dropdown: () => (
+ <SidebarShortcutLink
+ label="Connect"
+ isSlim={isSlim}
+ onClick={() => openSettingsTab('Connected')}
+ icon={connected.icon}
+ />
+ ),
+ });
+ }
+
+ items.push({
+ id: 'invite',
+ visible: () => (
+ <SidebarShortcutLink
+ label="Invite"
+ isSlim={isSlim}
+ onClick={() => setInviteModalOpen(true)}
+ icon={UsersThreeIcon}
+ />
+ ),
+ dropdown: () => (
+ <SidebarShortcutLink
+ label="Invite"
+ isSlim={isSlim}
+ onClick={() => setInviteModalOpen(true)}
+ icon={UsersThreeIcon}
+ />
+ ),
+ });
+
+ const mobile = getSettingsTabItem('Mobile App');
+ if (mobile && isTabAvailable('Mobile App')) {
+ items.push({
+ id: 'mobile',
+ visible: () => (
+ <SidebarShortcutLink
+ label="Mobile"
+ isSlim={isSlim}
+ onClick={() => openSettingsTab('Mobile App')}
+ icon={mobile.icon}
+ />
+ ),
+ dropdown: () => (
+ <SidebarShortcutLink
+ label="Mobile"
+ isSlim={isSlim}
+ onClick={() => openSettingsTab('Mobile App')}
+ icon={mobile.icon}
+ />
+ ),
+ });
+ }
+ return items;
+ });
+
+ createEffect(() => {
+ middleScrollSize.width;
+ middleScrollSize.height;
+ workspaceItems().length;
+ tryItems().length;
+ props.overlayOpen;
+ scheduleMiddleScrollUpdate();
+ });
+
+ createEffect(() => {
+ if (isCollapsed() && !overlayOpen()) {
+ cancelOverlayClose();
+ setOverlayPointerInside(false);
+ setOverlayDropdownOpen(false);
+ setWorkspaceContextMenuOpen(false);
+ }
});
registerSidebarHotkeys({
- isSlim,
- onOpenChange: handleSidebarOpenChange,
+ isSlim: isCollapsed,
+ onOpenChange: props.onOpenChange,
});
return (
<div
- ref={(el) => {
- sidebarShell = el ?? undefined;
- }}
class={cn(
- 'group/sidebar h-full p-3 flex flex-col gap-0 mobile:absolute mobile:z-modal-content overflow-hidden',
- isExpanded() &&
- 'max-w-52 w-full mobile:max-w-2/3 translate-x-0 opacity-100',
+ 'group/sidebar flex flex-col gap-0 overflow-hidden bg-surface px-3 pb-3 pt-4 text-[13px]',
+ isExpanded() && 'relative h-full shrink-0 max-w-60 w-60 opacity-100',
props.sidebarState === 'hidden' &&
- '-translate-x-full overflow-hidden opacity-0',
-
- isSlim() && 'max-w-14 w-full mobile:max-w-2/3 translate-x-0 opacity-100'
+ 'fixed left-0 top-0 bottom-0 h-full -translate-x-full max-w-0 w-0 opacity-0 pointer-events-none',
+ isCollapsed() && 'fixed z-modal-content',
+ isCollapsed() &&
+ !overlayOpen() &&
+ 'left-0 inset-y-0 h-full max-w-0 w-0 opacity-0 pointer-events-none -translate-x-2',
+ isOverlayExpanded() &&
+ 'left-0 inset-y-0 h-full max-w-60 w-60 opacity-100 translate-x-0 rounded-r-xl shadow-menu ring-1 ring-edge-muted'
)}
- data-expanded={isExpanded()}
+ data-expanded={isExpandedView()}
data-slim={isSlim()}
style={{ transition: SIDEBAR_MAX_WIDTH_TRANSITION_STYLE }}
+ onPointerEnter={() => {
+ if (!isCollapsed()) return;
+ setOverlayPointerInside(true);
+ props.onOverlayOpenChange?.(true);
+ cancelOverlayClose();
+ }}
+ onPointerLeave={() => {
+ if (!isCollapsed()) return;
+ setOverlayPointerInside(false);
+ requestOverlayClose();
+ }}
>
- <div class="flex items-center justify-between w-full relative group/logo-area">
- <div class="text-accent group-data-[slim=true]/sidebar:opacity-0 group-data-[slim=true]/sidebar:max-w-0 min-w-0 pl-1 group-data-[slim=true]/sidebar:pl-0 transition-[opacity,padding]">
- <LogoIcon class="size-6 translate-x-1" />
+ <div class="shrink-0 flex items-center justify-between w-full relative group/logo-area">
+ <div class="text-accent min-w-0 flex flex-1 items-center gap-2 pl-2">
+ <div class="size-5 shrink-0 flex items-center justify-center">
+ <LogoIcon class="size-4" />
+ </div>
+ <Show when={currentTeamName()}>
+ {(teamName) => (
+ <span class="min-w-0 truncate text-[13px] font-medium text-ink">
+ {teamName()}
+ </span>
+ )}
+ </Show>
+ </div>
+ <div class="flex shrink-0 items-center gap-1">
+ <Show when={searchLink()}>
+ {(link) => <SidebarHeaderSearchButton link={link()} />}
+ </Show>
+ <SidebarCreateMenu
+ isSlim={isSlim}
+ variant="icon"
+ onMenuOpenChange={handleOverlayDropdownOpenChange}
+ />
</div>
- <SidebarHeaderIconButton
- label={isExpanded() ? 'Shrink Sidebar' : 'Expand Sidebar'}
- hotkey={TOKENS.global.toggleSidebar}
- onMouseDown={(e) => {
- if (e.button !== 0) return;
- e.preventDefault();
- }}
- onClick={() => {
- handleSidebarOpenChange(!isExpanded());
- globalSplitManager()?.returnFocus();
- }}
- icon={AnimatedSquareSidebarIcon}
- />
- </div>
-
- <div class="w-full my-2.5">
- <SidebarCreateMenu isSlim={isSlim} />
</div>
- <nav>
+ <nav class="shrink-0 mt-2">
<ul class="size-full flex flex-col gap-0.5">
- <For each={visibleLinks()}>
+ <For each={topLinks()}>
{(link) => (
<li class="flex flex-col items-center justify-center">
- <Dynamic
- component={link.id === 'mail' ? SidebarMailLink : SidebarLink}
- {...link}
- sidebarState={props.sidebarState ?? 'expanded'}
- hotkeyVisible={goToHotkeyVisible()}
- />
+ {renderSidebarLink(link)}
</li>
)}
</For>
</ul>
</nav>
- <div class="px-2">
- <hr class="border-transparent my-2" />
- </div>
-
- <Suspense>
- <FavoritesSection sidebarState={props.sidebarState ?? 'expanded'} />
- </Suspense>
-
- <div class="min-h-0 flex-1 overflow-hidden">
- <ChannelsUnreadWidget sidebarState={props.sidebarState ?? 'expanded'} />
- </div>
+ <div class="relative min-h-0 flex-1 my-3">
+ <div
+ ref={attachMiddleScrollRef}
+ onScroll={updateMiddleScrollShadows}
+ class="size-full overflow-y-auto flex flex-col gap-3"
+ >
+ <CollapsibleSidebarSection
+ label="Workspace"
+ items={workspaceItems()}
+ visibleCount={3}
+ onOpenChange={scheduleMiddleScrollUpdate}
+ onDropdownOpenChange={handleOverlayDropdownOpenChange}
+ dropdownInteractionDisabled={workspaceContextMenuOpen()}
+ />
- <div class="mt-auto">
- <Show when={ENABLE_CALLS()}>
- <div class="block max-h-[clamp(10%,60%,20rem)]">
- <SidebarActiveCallWidget
- sidebarState={props.sidebarState ?? 'expanded'}
+ <Suspense>
+ <FavoritesSection
+ sidebarState={sidebarDisplayState()}
+ onContextMenuOpenChange={handleOverlayDropdownOpenChange}
/>
- </div>
- </Show>
-
- <Show when={callCtx?.isInCall()}>
- <div class="my-3" data-ui="in-call-panel">
- <InCallPanel isSlim={panelIsSlim} />
- </div>
- </Show>
- </div>
-
- <div class="px-2 w-full">
- <hr class="border-transparent mb-2" />
- </div>
+ </Suspense>
- <Show
- when={
- !hasPaidAccess() &&
- !isSlim() &&
- !premiumCardDismissed() &&
- newPricingFF().enabled
- }
- >
- <div class="w-full px-2 mb-2">
- <SidebarPromoCard
- label="Upgrade to Premium"
- description="Unlock MCP integrations, better AI models, and team collaboration."
- onDismiss={() => {
- setPremiumCardDismissed(true);
- setPremiumHintVisible(true);
- }}
- primaryAction={{
- label: 'Upgrade',
- onClick: () => openSettingsTab('Billing'),
- }}
- secondaryAction={{
- label: 'Later',
- onClick: () => {
- setPremiumCardDismissed(true);
- setPremiumHintVisible(true);
- },
- }}
+ <ChannelsUnreadWidget
+ sidebarState={sidebarDisplayState()}
+ onSectionOpenChange={scheduleMiddleScrollUpdate}
+ onDropdownOpenChange={handleOverlayDropdownOpenChange}
/>
- </div>
- </Show>
- <Show
- when={
- !hasPaidAccess() &&
- !isSlim() &&
- premiumHintVisible() &&
- premiumCardDismissed() &&
- newPricingFF().enabled
- }
- >
- <div class="w-full px-2 mb-2">
- <SidebarPromoHint
- title="Maybe later"
- message="You can upgrade anytime from Account settings."
- onDone={() => setPremiumHintVisible(false)}
- secondaryAction={{
- label: 'Take me there',
- onClick: () => openSettingsTab('Account'),
- }}
+
+ <CollapsibleSidebarSection
+ label="Try"
+ items={tryItems()}
+ visibleCount={3}
+ onOpenChange={scheduleMiddleScrollUpdate}
+ onDropdownOpenChange={handleOverlayDropdownOpenChange}
/>
- </div>
- </Show>
- <div class="w-full flex flex-col gap-0.5 mb-1">
- <For each={PROMOTED_SETTINGS_TABS}>
- {(tab) => (
- <Show
- when={isTabAvailable(tab) ? getSettingsTabItem(tab) : undefined}
- >
- {(item) => (
- <SidebarShortcutLink
- label={item().label}
- isSlim={isSlim}
- onClick={() => openSettingsTab(tab)}
- icon={item().icon}
- />
- )}
- </Show>
+ <Show
+ when={
+ !hasPaidAccess() &&
+ isExpandedView() &&
+ !premiumCardDismissed() &&
+ newPricingFF().enabled
+ }
+ >
+ <div class="w-full px-2">
+ <SidebarPromoCard
+ label="Upgrade to Premium"
+ description="Unlock MCP integrations, better AI models, and team collaboration."
+ onDismiss={() => {
+ setPremiumCardDismissed(true);
+ setPremiumHintVisible(true);
+ }}
+ primaryAction={{
+ label: 'Upgrade',
+ onClick: () => openSettingsTab('Billing'),
+ }}
+ secondaryAction={{
+ label: 'Later',
+ onClick: () => {
+ setPremiumCardDismissed(true);
+ setPremiumHintVisible(true);
+ },
+ }}
+ />
+ </div>
+ </Show>
+ <Show
+ when={
+ !hasPaidAccess() &&
+ isExpandedView() &&
+ premiumHintVisible() &&
+ premiumCardDismissed() &&
+ newPricingFF().enabled
+ }
+ >
+ <div class="w-full px-2">
+ <SidebarPromoHint
+ title="Maybe later"
+ message="You can upgrade anytime from Account settings."
+ onDone={() => setPremiumHintVisible(false)}
+ secondaryAction={{
+ label: 'Take me there',
+ onClick: () => openSettingsTab('Account'),
+ }}
+ />
+ </div>
+ </Show>
+ </div>
+ <div
+ class={cn(
+ 'pointer-events-none absolute inset-x-0 top-0 h-3 transition-opacity bg-gradient-to-b from-surface to-transparent',
+ hasOverflowTop() ? 'opacity-100' : 'opacity-0'
)}
- </For>
+ />
+ <div
+ class={cn(
+ 'pointer-events-none absolute inset-x-0 bottom-0 h-3 transition-opacity bg-gradient-to-t from-surface to-transparent',
+ hasOverflowBottom() ? 'opacity-100' : 'opacity-0'
+ )}
+ />
</div>
- <div class="w-full">
- <SidebarSettingsWidget isSlim={isSlim} onSelect={openSettingsTab} />
+ <div class="shrink-0 w-full pt-2">
+ <SidebarSettingsWidget
+ isSlim={isSlim}
+ onSelect={openSettingsTab}
+ onMenuOpenChange={handleOverlayDropdownOpenChange}
+ />
</div>
<InviteModal />
</div>
@@ -997,6 +1255,7 @@ export const AppSidebar = (props: AppSidebarProps) => {
interface SidebarLinkProps extends SidebarItem {
sidebarState: SidebarState;
hotkeyVisible: boolean;
+ onContextMenuOpenChange?: (open: boolean) => void;
/**
* Skip the active background/text even when the view is active — used when
* a nested row (e.g. a single selected inbox) carries the highlight instead.
@@ -1071,14 +1330,14 @@ const SidebarLink = (props: SidebarLinkProps) => {
};
return (
- <ContextMenu>
- <ContextMenu.Trigger class="w-full h-8">
+ <ContextMenu onOpenChange={props.onContextMenuOpenChange}>
+ <ContextMenu.Trigger class="w-full h-7">
<NavRow
draggable={false}
data-sidebar-link={props.id}
data-active={isActive() ? '' : undefined}
active={isActive() && !props.suppressActiveStyle}
- class="h-8"
+ class="h-7"
fullWidth
tooltipPlacement="right"
onMouseEnter={() => setIsHovering(true)}
@@ -1125,7 +1384,7 @@ const SidebarLink = (props: SidebarLinkProps) => {
}}
>
<Show when={props.icon}>
- <div class="shrink-0 [&_svg]:size-3.5">
+ <div class="size-5 shrink-0 flex items-center justify-center [&_svg]:size-3.5">
<Dynamic component={props.icon} triggerAnimation={isHovering()} />
</div>
</Show>
@@ -1337,7 +1596,7 @@ const SidebarMailLink = (props: SidebarLinkProps) => {
data-sidebar-mail-account={link.email_address}
data-active={onlySelectedId() === link.id ? '' : undefined}
active={onlySelectedId() === link.id}
- class="h-8 pl-6 pr-2"
+ class="h-7 pl-6 pr-2"
onMouseDown={(e) => {
if (e.button !== 0) return;
e.preventDefault();
diff --git a/js/app/packages/app/component/sidebarVisibility.ts b/js/app/packages/app/component/sidebarVisibility.ts
index 799bc6e23b..b930c55a26 100644
--- a/js/app/packages/app/component/sidebarVisibility.ts
+++ b/js/app/packages/app/component/sidebarVisibility.ts
@@ -4,3 +4,16 @@ export const SidebarVisibilityContext = createContext<() => boolean>(
() => false
);
export const isSidebarVisible = () => useContext(SidebarVisibilityContext)();
+
+export type SidebarCollapseContextValue = {
+ isCollapsed: () => boolean;
+ expand: () => void;
+};
+
+export const SidebarCollapseContext =
+ createContext<SidebarCollapseContextValue>({
+ isCollapsed: () => false,
+ expand: () => {},
+ });
+
+export const useSidebarCollapse = () => useContext(SidebarCollapseContext);
diff --git a/js/app/packages/app/component/split-layout/SplitLayout.tsx b/js/app/packages/app/component/split-layout/SplitLayout.tsx
index daead312f3..e22443a02a 100644
--- a/js/app/packages/app/component/split-layout/SplitLayout.tsx
+++ b/js/app/packages/app/component/split-layout/SplitLayout.tsx
@@ -1,5 +1,8 @@
import { useGlobalBlockOrchestrator } from '@app/component/GlobalAppState';
-import { isSidebarVisible } from '@app/component/sidebarVisibility';
+import {
+ isSidebarVisible,
+ useSidebarCollapse,
+} from '@app/component/sidebarVisibility';
import { activeElement } from '@app/signal/focus';
import { Resize } from '@core/component/Resize';
import { splitContainerSelector } from '@core/dom-selectors';
@@ -307,6 +310,7 @@ export function SplitLayoutContainer(props: SplitLayoutContainerProps) {
const blockOrchestrator = useGlobalBlockOrchestrator();
const splitManager = createSplitLayout(blockOrchestrator, decodedPairs());
const [, setTabTitle] = tabTitleSignal;
+ const sidebar = useSidebarCollapse();
// Create the mobile swipe layout once on mobile devices.
const mobileSwipeLayout: MobileSwipeLayout | undefined =
@@ -345,7 +349,9 @@ export function SplitLayoutContainer(props: SplitLayoutContainerProps) {
return (
<SplitLayoutContext.Provider value={{ manager: splitManager }}>
<div
- class={cn('size-full p-2 mobile:p-0', { 'pl-0': isSidebarVisible() })}
+ class={cn('size-full p-2 mobile:p-0', {
+ 'pl-0': isSidebarVisible() && !sidebar.isCollapsed(),
+ })}
>
<Show
when={isNativeMobilePlatform() && mobileSwipeLayout}
diff --git a/js/app/packages/app/component/split-layout/components/SplitHeader.tsx b/js/app/packages/app/component/split-layout/components/SplitHeader.tsx
index 6f5d79ff40..34df498065 100644
--- a/js/app/packages/app/component/split-layout/components/SplitHeader.tsx
+++ b/js/app/packages/app/component/split-layout/components/SplitHeader.tsx
@@ -1,5 +1,6 @@
import { useSoup } from '@app/component/next-soup/soup-context';
import { openEntityInSplitFromUnifiedList } from '@app/component/next-soup/utils';
+import { useSidebarCollapse } from '@app/component/sidebarVisibility';
import { isListViewID, LIST_VIEW_ID } from '@app/constants/list-views';
import type { BlockName } from '@core/block';
import {
@@ -13,6 +14,7 @@ import { TOKENS } from '@core/hotkey/tokens';
import { isMobile } from '@core/mobile/isMobile';
import { isNativeMobilePlatform } from '@core/mobile/isNativeMobilePlatform';
import type { EntityDragEvent } from '@entity';
+import { AnimatedSquareSidebarIcon } from '@icon/square-sidebar';
import SplitIcon from '@icon/wide-newSplit.svg';
import { ContextMenu } from '@kobalte/core/context-menu';
import ArrowClockwise from '@phosphor/arrow-clockwise.svg';
@@ -29,6 +31,7 @@ import { createDroppable, useDragDropContext } from '@thisbeyond/solid-dnd';
import { Button, cn } from '@ui';
import {
createMemo,
+ createSignal,
type ParentProps,
type Setter,
Show,
@@ -104,6 +107,43 @@ function SplitForwardButton() {
);
}
+function SidebarExpandButton() {
+ const panel = useContext(SplitPanelContext);
+ const layout = useContext(SplitLayoutContext);
+ const sidebar = useSidebarCollapse();
+ const [hovering, setHovering] = createSignal(false);
+
+ const isLeftmostSplit = () =>
+ layout?.manager.splits()[0]?.id === panel?.handle.id;
+ const visible = () => sidebar.isCollapsed() && isLeftmostSplit();
+
+ return (
+ <div
+ class={cn(
+ 'overflow-hidden transition-[width,opacity,margin] duration-[120ms] ease-in-out',
+ visible() ? 'w-8 opacity-100 mr-1' : 'w-0 opacity-0 mr-0'
+ )}
+ aria-hidden={!visible()}
+ >
+ <Button
+ class="p-1 rounded-lg"
+ label="Expand Sidebar"
+ hotkey={TOKENS.global.toggleSidebar}
+ disabled={!visible()}
+ tabindex={visible() ? undefined : -1}
+ onClick={() => sidebar.expand()}
+ onMouseEnter={() => setHovering(true)}
+ onMouseLeave={() => setHovering(false)}
+ >
+ <AnimatedSquareSidebarIcon
+ class="size-4"
+ triggerAnimation={hovering()}
+ />
+ </Button>
+ </div>
+ );
+}
+
function _SplitSpotlightButton() {
const context = useContext(SplitPanelContext);
const layout = useContext(SplitLayoutContext);
@@ -444,6 +484,7 @@ export function SplitHeader(props: { ref: Setter<HTMLDivElement | null> }) {
when={isMobile()}
fallback={
<div class="relative flex items-center pl-2 h-full">
+ <SidebarExpandButton />
<SplitCloseButton />
<SplitBackButton />
<SplitForwardButton />