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
fix(sidebar): better dm icon size, add preview to favorited channels (#4709)
Seamus46bd0e99c98e
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.tsxindex 2f0d990928..6efa3de045 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@@ -18,6 +18,7 @@ import {MenuItem,MenuSeparator,} from '@core/component/ContextMenu';+import { EntityIcon } from '@core/component/EntityIcon';import { UserIcon } from '@core/component/UserIcon';import { isTouchDevice } from '@core/mobile/isTouchDevice';import { compareDateDesc } from '@core/util/date';@@ -27,7 +28,7 @@ import { openNotification } from '@notifications';import { isChannelNotification } from '@notifications/notification-helpers';import { getChannelNotificationParams } from '@notifications/notification-navigation';import type { UnifiedNotification } from '@notifications/types';-import { Avatar, cn, Dropdown, NavRow, Surface, Tooltip } from '@ui';+import { cn, Dropdown, NavRow, Surface, Tooltip } from '@ui';import {createEffect,createMemo,@@ -65,36 +66,6 @@ interface ChannelGroup {latestSenderId: string | null;}-function computeChannelLetters(groups: ChannelGroup[]): Map<string, string> {- const result = new Map<string, string>();- const firstLetterCount = new Map<string, number>();-- for (const group of groups) {- if (group.isDM || !group.channelName) continue;- const first = group.channelName[0]?.toUpperCase() ?? '';- firstLetterCount.set(first, (firstLetterCount.get(first) ?? 0) + 1);- }-- for (const group of groups) {- if (group.isDM || !group.channelName) continue;- const name = group.channelName;- const first = name[0]?.toUpperCase() ?? '';- const needsTwo = (firstLetterCount.get(first) ?? 0) > 1 && name.length > 1;- const letters = needsTwo ? first + name[1].toUpperCase() : first;- result.set(group.entityId, letters);- }-- return result;-}--function ChannelLetterIcon(props: { letters: string; slim?: boolean }) {- return (- <Avatar size="sm" class="size-3.5 bg-ink-extra-muted/15 text-ink-muted">- <Avatar.Fallback>{props.letters}</Avatar.Fallback>- </Avatar>- );-}-function groupByChannel(notifications: UnifiedNotification[]): Map<string, ChannelGroup> {@@ -228,7 +199,6 @@ function ChannelGroupItem(props: {group: ChannelGroup;animate?: boolean;isSlim?: boolean;- channelLetters?: string;onFloatingOpenChange?: (open: boolean) => void;}) {const notificationSource = useGlobalNotificationSource();@@ -252,9 +222,7 @@ function ChannelGroupItem(props: {if (props.group.isDM) {return senderName() ?? 'Direct Message';}- return props.group.channelName- ? `#${props.group.channelName}`- : 'Unknown Channel';+ return props.group.channelName ?? 'Unknown Channel';};const latestNotification = () => props.group.notifications[0];@@ -319,10 +287,7 @@ function ChannelGroupItem(props: {<Showwhen={isDM() && senderId()}fallback={- <ChannelLetterIcon- letters={props.channelLetters ?? '?'}- slim={isSlim()}- />+ <EntityIcon targetType="channel" size="xs" class="size-3.5" />}><UserIcon@@ -409,17 +374,12 @@ function filterUnreadNotDone(notifications: UnifiedNotification[]) {return notifications.filter((n) => !n.viewed_at && !n.done);}-function ChannelGroupDropdownItem(props: {- group: ChannelGroup;- channelLetters?: string;-}) {+function ChannelGroupDropdownItem(props: { group: ChannelGroup }) {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';+ return props.group.channelName ?? 'Unknown Channel';};const latestNotification = () => props.group.notifications[0];@@ -433,7 +393,9 @@ function ChannelGroupDropdownItem(props: {><Showwhen={props.group.isDM && props.group.latestSenderId}- fallback={<ChannelLetterIcon letters={props.channelLetters ?? '?'} />}+ fallback={+ <EntityIcon targetType="channel" size="xs" class="size-3.5" />+ }><UserIconid={props.group.latestSenderId!}@@ -494,10 +456,6 @@ export const ChannelsUnreadWidget = (props: {.filter((g): g is ChannelGroup => g != null);});- const channelLettersMap = createMemo(() =>- computeChannelLetters(channelGroups())- );-const isSlim = () => props.sidebarState === 'slim';const SLIM_MAX = 4;const slimVisible = () => channelGroups().slice(0, SLIM_MAX);@@ -509,16 +467,10 @@ export const ChannelsUnreadWidget = (props: {<ChannelGroupItemgroup={group}animate={false}- channelLetters={channelLettersMap().get(group.entityId)}onFloatingOpenChange={props.onDropdownOpenChange}/>),- dropdown: () => (- <ChannelGroupDropdownItem- group={group}- channelLetters={channelLettersMap().get(group.entityId)}- />- ),+ dropdown: () => <ChannelGroupDropdownItem group={group} />,})));@@ -542,12 +494,7 @@ export const ChannelsUnreadWidget = (props: {<section class="w-full py-1.5 flex flex-col items-start gap-0.5"><For each={slimVisible()}>{(group) => (- <ChannelGroupItem- group={group}- animate={false}- isSlim- channelLetters={channelLettersMap().get(group.entityId)}- />+ <ChannelGroupItem group={group} animate={false} isSlim />)}</For><Show when={slimOverflow() > 0}>diff --git a/js/app/packages/app/component/app-sidebar/favorites-section.tsx b/js/app/packages/app/component/app-sidebar/favorites-section.tsxindex 444eea4ae4..60e39769c4 100644--- a/js/app/packages/app/component/app-sidebar/favorites-section.tsx+++ b/js/app/packages/app/component/app-sidebar/favorites-section.tsx@@ -1,6 +1,9 @@import type { SidebarState } from '@app/component/app-sidebar/sidebar';import { FavoriteIcon } from '@app/component/FavoriteIcon';-import { useGlobalNotificationSource } from '@app/component/GlobalAppState';+import {+ useGlobalBlockOrchestrator,+ useGlobalNotificationSource,+} from '@app/component/GlobalAppState';import { useSplitLayout } from '@app/component/split-layout/layout';import { globalSplitManager } from '@app/signal/splitLayout';import {@@ -9,6 +12,8 @@ import {useFavoriteDisplayName,useFavoriteDmRecipientId,} from '@app/util/favorites';+import { navigateToChannelMessage } from '@block-channel/utils/link';+import { ReadonlyThread } from '@channel/StandaloneThread';import {ContextMenuContent,MenuGroup,@@ -16,8 +21,11 @@ import {MenuSeparator,} from '@core/component/ContextMenu';import type { EntityIconSelector } from '@core/component/EntityIcon';+import { isTouchDevice } from '@core/mobile/isTouchDevice';import { ContextMenu } from '@kobalte/core/context-menu';+import { Tooltip as KobalteTooltip } from '@kobalte/core/tooltip';import { isChannelNotification } from '@notifications/notification-helpers';+import { getChannelNotificationParams } from '@notifications/notification-navigation';import type { UnifiedNotification } from '@notifications/types';import CaretDownIcon from '@phosphor/caret-down.svg';import {@@ -33,8 +41,16 @@ import {SortableProvider,useDragDropContext,} from '@thisbeyond/solid-dnd';-import { cn, NavRow } from '@ui';-import { type Accessor, createMemo, createSignal, For, Show } from 'solid-js';+import { cn, NavRow, Surface } from '@ui';+import {+ type Accessor,+ createEffect,+ createMemo,+ createSignal,+ For,+ type ParentProps,+ Show,+} from 'solid-js';/*** Drag data carried by favorite row sortables. Distinct from `EntityDragData`@@ -52,6 +68,106 @@ export type FavoriteDragData = {isDropTargetDisabled: () => boolean;};+const HOVER_PREVIEW_COUNT = 3;++function getPreviewThreadRoots(notifications: UnifiedNotification[]): string[] {+ const roots: string[] = [];+ const seen = new Set<string>();+ for (const notification of notifications) {+ const { messageId, threadId } = getChannelNotificationParams(notification);+ const rootId = threadId ?? messageId;+ if (!rootId || seen.has(rootId)) continue;+ seen.add(rootId);+ roots.push(rootId);+ }+ return roots;+}++function FavoriteChannelHoverPreview(props: {+ channelId: string;+ notifications: UnifiedNotification[];+}) {+ const orchestrator = useGlobalBlockOrchestrator();+ const roots = () => getPreviewThreadRoots(props.notifications);+ const visible = () => roots().slice(0, HOVER_PREVIEW_COUNT).reverse();+ const hiddenCount = () => roots().length - visible().length;++ return (+ <div class="w-90 min-h-12 max-h-96 overflow-y-auto overscroll-contain flex flex-col py-1">+ <Show when={hiddenCount() > 0}>+ <span class="px-3 py-1 text-xs text-ink-extra-muted">+ +{hiddenCount()} earlier+ </span>+ </Show>+ <For each={visible()}>+ {(rootMessageId) => (+ <ReadonlyThread+ channelId={props.channelId}+ messageId={rootMessageId}+ onClickMessage={(clickedMessageId, e) => {+ e.stopPropagation();+ const isReply = clickedMessageId !== rootMessageId;+ navigateToChannelMessage(+ orchestrator,+ props.channelId,+ clickedMessageId,+ isReply ? rootMessageId : undefined+ );+ }}+ />+ )}+ </For>+ </div>+ );+}++function FavoriteChannelHoverCard(+ props: ParentProps<{+ channelId: string;+ notifications: UnifiedNotification[];+ 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+ open={open()}+ onOpenChange={setHovered}+ placement="right"+ overflowPadding={16}+ fitViewport={true}+ closeDelay={250}+ openDelay={1000}+ flip={true}+ gutter={4}+ >+ <KobalteTooltip.Trigger+ class="inline-flex items-center w-full"+ as="div"+ >+ {props.children}+ </KobalteTooltip.Trigger>+ <KobalteTooltip.Portal>+ <KobalteTooltip.Content class="z-tool-tip max-w-[calc(100vw-32px)] menu-open-animation">+ <Surface depth={3}>+ <FavoriteChannelHoverPreview+ channelId={props.channelId}+ notifications={props.notifications}+ />+ </Surface>+ </KobalteTooltip.Content>+ </KobalteTooltip.Portal>+ </KobalteTooltip>+ </Show>+ );+}+/*** Linear-style favorites for the expanded sidebar: a collapsible "Favorites"* list of the user's favorited entities. Rows navigate like other sidebar rows@@ -288,6 +404,44 @@ const FavoriteRow = (props: {});};+ const isUnreadChannelFavorite = () =>+ props.favorite.entityType === 'channel' && props.notifications().length > 0;+ const [contextMenuOpen, setContextMenuOpen] = createSignal(false);+ const [hoverPreviewOpen, setHoverPreviewOpen] = createSignal(false);++ createEffect(() => {+ props.onContextMenuOpenChange?.(contextMenuOpen() || hoverPreviewOpen());+ });++ const row = (+ <NavRow+ draggable={false}+ disabled={props.disabled}+ data-sidebar-favorite={favoriteEntityKey(+ props.favorite.entityType,+ props.favorite.entityId+ )}+ data-active={isActive() ? '' : undefined}+ active={isActive()}+ class="h-7"+ fullWidth+ onClick={open}+ >+ <div class="size-5 shrink-0 flex items-center justify-center">+ <FavoriteIcon+ favorite={props.favorite}+ class={dmRecipientId() ? 'size-[18px]' : '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>+ );+return (<divref={sortable}@@ -300,31 +454,18 @@ const FavoriteRow = (props: {sortable.isActiveDraggable && 'opacity-40')}>- <ContextMenu onOpenChange={props.onContextMenuOpenChange}>+ <ContextMenu onOpenChange={setContextMenuOpen}><ContextMenu.Trigger class="w-full h-7">- <NavRow- draggable={false}- disabled={props.disabled}- data-sidebar-favorite={favoriteEntityKey(- props.favorite.entityType,- props.favorite.entityId- )}- data-active={isActive() ? '' : undefined}- active={isActive()}- class="h-7"- fullWidth- onClick={open}- >- <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>+ <Show when={isUnreadChannelFavorite()} fallback={row}>+ <FavoriteChannelHoverCard+ channelId={props.favorite.entityId}+ notifications={props.notifications()}+ disabled={contextMenuOpen()}+ onOpenChange={setHoverPreviewOpen}+ >+ {row}+ </FavoriteChannelHoverCard>+ </Show></ContextMenu.Trigger><ContextMenu.Portal>