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(inbox): various fixes (#4434)
dev-rb93bc21553f69
diff --git a/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx b/js/app/packages/app/component/next-soup/soup-view/soup-view.tsxindex 775e480ecb..45efb347cb 100644--- a/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx+++ b/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx@@ -136,6 +136,8 @@ import { SoupEntitySelectionToolbar } from './soup-entity-selection-toolbar';import { useSoupNavigationHotkeys } from './use-soup-navigation-hotkeys';import { useSoupViewHotkeys } from './use-soup-view-hotkeys';+const WIDE_SPLIT_PANEL_BREAKPOINT = 512;+export const SoupSectionHeader = (props: {children: JSX.Element;onClick?: () => void;@@ -1145,6 +1147,10 @@ export const SoupViewList = (props: SoupViewListProps) => {// otherwise it stays stale-true and the entity's toolbar keeps the border.onCleanup(() => panel.previewState[1](false));+ const isWideSplitPanel = createMemo(() => {+ return (panel.panelSize.width ?? 0) > WIDE_SPLIT_PANEL_BREAKPOINT;+ });+return (<MaybeSoupEntityActionDrawerManager><div@@ -1161,7 +1167,14 @@ export const SoupViewList = (props: SoupViewListProps) => {data-soup-viewdata-soup-view-id={panel.handle.id + (previewPanel ? '-preview' : '')}>- <Resize.Zone direction="horizontal" gutter={0}>+ <Resize.Zone+ direction={+ !isNewInboxEnabled() || isWideSplitPanel()+ ? 'horizontal'+ : 'vertical'+ }+ gutter={0}+ ><Resize.Panelid="soup-list"minSize={200}@@ -1515,17 +1528,24 @@ export const SoupViewList = (props: SoupViewListProps) => {minSize={300}target={{kind: 'percent',- percent: isNewInboxEnabled() ? 50 : 70,+ percent: isNewInboxEnabled() ? 80 : 70,}}>- <PreviewPanel- selectedEntity={soup.focus.item()}- orchestrator={orchestrator}- splitPanelContext={panel}- onFocusOut={() => {- soupViewRef()?.focus();- }}- />+ <div+ class={cn(+ 'size-full',+ !isWideSplitPanel() && 'border-t border-t-edge-muted'+ )}+ >+ <PreviewPanel+ selectedEntity={soup.focus.item()}+ orchestrator={orchestrator}+ splitPanelContext={panel}+ onFocusOut={() => {+ soupViewRef()?.focus();+ }}+ />+ </div></Resize.Panel></Show></Resize.Zone>diff --git a/js/app/packages/app/component/next-soup/soup-view/views/inbox/InboxCard.tsx b/js/app/packages/app/component/next-soup/soup-view/views/inbox/InboxCard.tsxindex 27fe66c9af..091695425b 100644--- a/js/app/packages/app/component/next-soup/soup-view/views/inbox/InboxCard.tsx+++ b/js/app/packages/app/component/next-soup/soup-view/views/inbox/InboxCard.tsx@@ -47,7 +47,7 @@ function Root(props: RootProps): JSX.Element {props.highlighted && !props.selected && !isTouchDevice(),'hover:bg-hover/30':!props.highlighted && !props.selected && !isTouchDevice(),- 'opacity-65': props.dimmed,+ 'opacity-75': props.dimmed,},props.class)}diff --git a/js/app/packages/app/component/next-soup/soup-view/views/inbox/InboxListEntity.tsx b/js/app/packages/app/component/next-soup/soup-view/views/inbox/InboxListEntity.tsxindex 963f82ba0e..1d22e6d4eb 100644--- a/js/app/packages/app/component/next-soup/soup-view/views/inbox/InboxListEntity.tsx+++ b/js/app/packages/app/component/next-soup/soup-view/views/inbox/InboxListEntity.tsx@@ -1,4 +1,3 @@-import { useSoup } from '@app/component/next-soup/soup-context';import { useChannelsContext } from '@core/context/channels';import { MaybeEntityRow } from '@entity';import type { BaseListEntityProps } from '@entity/composed/list-entity/shared';@@ -18,7 +17,6 @@ import { scopeThreadNotifications } from './utils';* view); without a provider the card falls back to its own local state.*/export function InboxListEntity(props: BaseListEntityProps) {- const soup = useSoup();const expansion = useInboxExpansion();const channels = useChannelsContext();@@ -32,16 +30,13 @@ export function InboxListEntity(props: BaseListEntityProps) {});const item = createMemo(() => toInboxCardDisplayItem(entity()));- // The preview follows the focused row, so the selected row is the focused one- // (preview target and focus can diverge from `previewEntity` after a click).- const selected = () => soup.focus.id() === props.entity.id;return (<div class="mx-1" ref={props.ref} onMouseMove={props.onMouseMove}><MaybeEntityRow entityId={props.entity.id} config={props.entityRowConfig}><InboxCardLayoutitem={item()}- selected={selected()}+ selected={props.checked}highlighted={props.highlighted}onClick={props.onClick}expanded={diff --git a/js/app/packages/app/component/next-soup/soup-view/views/inbox/inbox-card-layouts.tsx b/js/app/packages/app/component/next-soup/soup-view/views/inbox/inbox-card-layouts.tsxindex 26ad196b88..3d7a9e1567 100644--- a/js/app/packages/app/component/next-soup/soup-view/views/inbox/inbox-card-layouts.tsx+++ b/js/app/packages/app/component/next-soup/soup-view/views/inbox/inbox-card-layouts.tsx@@ -74,13 +74,22 @@ const isUnreadNotification = (notification?: Notification) =>notification ? !notification.viewed_at : false;const getGithubSender = (entity: EntityData, notification?: Notification) => {- const content = notification?.notification_metadata.content as- | { senderGithubLogin?: string | null }- | undefined;- const pr =- entity.type === 'foreign' && entity.foreignSource === 'github_pull_request'- ? entity.metadata- : undefined;+ const meta = notification?.notification_metadata;+ if (+ meta &&+ meta.tag !== 'github_pr_status_changed' &&+ meta.tag !== 'github_review_requested' &&+ meta.tag !== 'github_pr_comment' &&+ meta.tag !== 'github_pr_mention' &&+ meta.tag !== 'github_pr_review' &&+ meta.tag !== 'github_pr_check_run'+ )+ return;++ const content = meta?.content;++ const pr = isGithubPrEntity(entity) ? entity.metadata : undefined;+const login = content?.senderGithubLogin ?? pr?.authorLogin ?? undefined;let imageUrl: string | undefined;if (content?.senderGithubLogin) {@@ -193,7 +202,15 @@ function Avatar(props: {}><Match when={props.imageUrl}>- {(url) => <img src={url()} alt="" class="size-full object-cover" />}+ {(url) => (+ <img+ src={url()}+ alt=""+ class="size-full object-cover"+ crossorigin="anonymous"+ referrerpolicy="no-referrer"+ />+ )}</Match><Match when={isMacroAgent()}><MacroLogo class="m-auto size-1/2 text-accent" />@@ -223,22 +240,22 @@ const tagBubbleIcon = (tag: NotificationTag) =></span>)).with('channel_mention', 'mentioned_in_document_comment', () => () => (- <AtIcon class="size-3" />+ <AtIcon class="size-4" />))- .with('document_mention', () => () => <FilesIcon class="size-3" />)+ .with('document_mention', () => () => <FilesIcon class="size-4" />).with('channel_message_reply','replied_to_document_comment_thread',- () => () => <ArrowBendUpLeftIcon class="size-3" />+ () => () => <ArrowBendUpLeftIcon class="size-4" />).with('commented_on_document', () => () => (- <ChatCircleIcon class="size-3" />+ <ChatCircleIcon class="size-4" />))- .with('channel_message_send', () => () => <ChatTextIcon class="size-3" />)+ .with('channel_message_send', () => () => <ChatTextIcon class="size-4" />).with('channel_invite', 'invite_to_team', () => () => (- <UserPlusIcon class="size-3" />+ <UserPlusIcon class="size-4" />))- .with('call_started', () => () => <PhoneIcon class="size-3" />)+ .with('call_started', () => () => <PhoneIcon class="size-4" />).with('github_pr_status_changed','github_pr_check_run',@@ -246,11 +263,11 @@ const tagBubbleIcon = (tag: NotificationTag) =>'github_pr_comment','github_pr_mention','github_pr_review',- () => () => <GithubIcon class="size-3" />+ () => () => <GithubIcon class="size-4" />).with(P.when((value) => value?.startsWith('github_') ?? false),- () => () => <GithubIcon class="size-3" />+ () => () => <GithubIcon class="size-4" />).otherwise(() => undefined);@@ -272,7 +289,7 @@ function ActionBubble(props: { tag: NotificationTag }) {function Badge(props: { unread: boolean }) {return (<Show when={props.unread}>- <span class="ml-auto flex shrink-0 items-center">+ <span class="flex shrink-0 items-center"><span class="size-2 rounded-full bg-accent" /></span></Show>@@ -436,8 +453,10 @@ function BaseCard(props: {{props.leading}<InboxCard.Body><InboxCard.Header>- <InboxCard.Title>{props.title}</InboxCard.Title>- <Badge unread={props.unread} />+ <InboxCard.Title class="flex items-center gap-1">+ <Badge unread={props.unread} />+ {props.title}+ </InboxCard.Title></InboxCard.Header><Show when={props.preview?.trim()}>@@ -526,9 +545,20 @@ export function ChannelCardLayout(props: InboxCardLayoutProps) {const senderId = () => {const value = props.item.entity;- return value.type === 'channel'- ? value.latestRootMessage?.senderId- : undefined;++ if (value.type !== 'channel') return;++ const latestSender = value.latestRootMessage?.senderId;++ if (value.channelType === 'direct_message') {+ const otherParticipant = value.participantIds?.filter(+ (i) => i !== value.ownerId+ )?.[0];++ return latestSender ?? otherParticipant ?? 'Unknown';+ }++ return latestSender;};const senderName = createSenderDisplayName(senderId);@@ -542,15 +572,13 @@ export function ChannelCardLayout(props: InboxCardLayoutProps) {const location = channelLocation(entity());const tag = getNotificationTag(props.item.notification);- let sender;+ let sender = isDM() ? entity().name || senderName() : '';let action = '';if (tag === 'document_mention' && isDM()) {action = 'shared a document with you';- sender = senderName();- } else if (tag === 'channel_message_send') {+ } else if (tag === 'channel_message_send' && isDM()) {action = 'sent you a message';- sender = senderName();}const content = itemContent(entity(), props.item.notification);@@ -583,7 +611,7 @@ export function ChannelCardLayout(props: InboxCardLayoutProps) {<InboxCard.Iconfallback={<EntityIcon- class="size-3"+ class="size-5"targetType={getEntityIconType(entity())}size="fill"theme="monochrome"@@ -593,13 +621,15 @@ export function ChannelCardLayout(props: InboxCardLayoutProps) {</Show><InboxCard.Body><InboxCard.Header>- <InboxCard.Title>{text().title}</InboxCard.Title>- <Badge unread={props.item.unread} />+ <InboxCard.Title class="flex items-center gap-1">+ <Badge unread={props.item.unread} />+ {text().title}+ </InboxCard.Title></InboxCard.Header><div class="flex items-center gap-1"><Show when={!isDM()}>- <span class="flex gap-1 items-center text-xs">+ <span class="flex gap-1 items-center text-sm whitespace-nowrap"><Show when={senderId()}>{(id) => (<UserIcon@@ -911,20 +941,9 @@ export function ChannelThreadCardLayout(props: InboxCardLayoutProps) {unread={props.item.unread}timestamp={props.item.timestamp}leading={- <Show- when={isLatestNotificationReply()}- fallback={- <InboxCard.Icon fallback={<Avatar senderId={senderId()} />}>- <ActionBubble- tag={getNotificationTag(props.item.notification)}- />- </InboxCard.Icon>- }- >- <InboxCard.Icon- fallback={<ChatTextIcon class="size-4 shrink-0" />}- />- </Show>+ <InboxCard.Icon fallback={<Avatar senderId={senderId()} />}>+ <ActionBubble tag={getNotificationTag(props.item.notification)} />+ </InboxCard.Icon>}title={text().title}preview={text().content}@@ -1099,7 +1118,11 @@ export function TaskCardLayout(props: InboxCardLayoutProps) {<Showwhen={props.item.notification}fallback={- <EntityIcon targetType={getEntityIconType(props.item.entity)} />+ <EntityIcon+ class="size-5"+ size="fill"+ targetType={getEntityIconType(props.item.entity)}+ />}><Avatar@@ -1165,7 +1188,11 @@ export function AiCardLayout(props: InboxCardLayoutProps) {<Showwhen={props.item.notification}fallback={- <EntityIcon targetType={getEntityIconType(props.item.entity)} />+ <EntityIcon+ class="size-5"+ targetType={getEntityIconType(props.item.entity)}+ size="fill"+ />}><Avatar@@ -1202,12 +1229,7 @@ export function EmailCardLayout(props: InboxCardLayoutProps) {const senderName = createSenderDisplayName(senderId, senderFallbackName);const text = createMemo(() => {- const metadata = props.item.notification?.notification_metadata;- const content = itemContent(props.item.entity, props.item.notification);- let subject: string | undefined;- if (metadata?.tag === 'new_email') {- subject = metadata.content.subject;- }+ const subject = props.item.entity.name;let entitySnippet: string | undefined;if (props.item.entity.type === 'email') {@@ -1217,9 +1239,9 @@ export function EmailCardLayout(props: InboxCardLayoutProps) {return {title: buildActionLabel({sender: senderName(),- action: 'sent an email',+ action: `— ${subject || 'sent an email'}`,}),- content: subject || entitySnippet || props.item.entity.name || content,+ content: entitySnippet,};});@@ -1251,10 +1273,10 @@ export function GithubCardLayout(props: InboxCardLayoutProps) {getGithubSender(props.item.entity, props.item.notification));- const senderId = () => sender().id;- const senderFallbackName = () => sender().fallbackName;+ const senderId = () => sender()?.id;+ const senderFallbackName = () => sender()?.fallbackName;- const avatarUrl = () => sender().imageUrl;+ const avatarUrl = () => sender()?.imageUrl;const senderName = createSenderDisplayName(senderId, senderFallbackName);@@ -1310,7 +1332,7 @@ export function GithubCardLayout(props: InboxCardLayoutProps) {<InboxCard.Iconfallback={<EntityIcon- class="size-3"+ class="size-5"targetType="githubPullRequest"size="fill"theme="monochrome"@@ -1399,7 +1421,7 @@ export function CallCardLayout(props: InboxCardLayoutProps) {<InboxCard.Iconfallback={<EntityIcon- class="size-3"+ class="size-5"targetType="call"size="fill"theme="monochrome"@@ -1432,7 +1454,7 @@ export function GenericCardLayout(props: InboxCardLayoutProps) {<InboxCard.Iconfallback={<EntityIcon- class="size-3"+ class="size-5"targetType={getEntityIconType(props.item.entity)}size="fill"theme="monochrome"diff --git a/js/app/packages/core/component/Resize/Resize.tsx b/js/app/packages/core/component/Resize/Resize.tsxindex 584ab9c899..de44a04fb3 100644--- a/js/app/packages/core/component/Resize/Resize.tsx+++ b/js/app/packages/core/component/Resize/Resize.tsx@@ -6,8 +6,8 @@ import {createMemo,createSignal,Index,+ on,onCleanup,- onMount,type ParentProps,Show,useContext,@@ -70,8 +70,7 @@ type ZoneProps = {* ```*/function Zone(props: ParentProps<ZoneProps>) {- // NOT REACTIVE on direction on purpose.- const { direction } = props;+ const direction = () => props.direction;const gutterPx = () => props.gutter ?? 0;const minSize = () => props.minSize ?? 0;@@ -79,13 +78,15 @@ function Zone(props: ParentProps<ZoneProps>) {const [root, setRoot] = createSignal<HTMLDivElement>();const rootSize = createElementSize(root);const zoneSize = createMemo(() => {- return direction === 'horizontal'+ return direction() === 'horizontal'? (rootSize.width ?? 0): (rootSize.height ?? 0);});const solver = createResizeSolver({- direction,+ // The solver is axis-agnostic (shares are dimensionless), so it only needs+ // the current axis to store; reactivity lives on `ctx.direction`.+ direction: props.direction,gutter: gutterPx,size: zoneSize,panels: [],@@ -255,18 +256,24 @@ function Panel(props: ParentProps<PanelProps>) {return props.target;};- onMount(() => {- if (props.collapsed?.() === false) return;- ctx.register(- {- id: props.id,- minSize: props.minSize,- maxSize: props.maxSize ?? Infinity,- target: getTarget(),- },- props.index- );- });+ let registered = false;+ createEffect(+ on(ctx.size, (size) => {+ if (size <= 0 || registered || props.collapsed?.() === false) return;++ registered = true;++ ctx.register(+ {+ id: props.id,+ minSize: props.minSize,+ maxSize: props.maxSize ?? Infinity,+ target: getTarget(),+ },+ props.index+ );+ })+ );createEffect(() => {ctx.update(props.id, {@@ -326,7 +333,7 @@ function Panel(props: ParentProps<PanelProps>) {const size = createMemo(ctx.sizeOf(props.id));const styles = createMemo(() => {- if (ctx.direction === 'horizontal') {+ if (ctx.direction() === 'horizontal') {return {top: '0px',bottom: '0px',@@ -378,7 +385,7 @@ type GutterProps = {function Gutter(props: GutterProps) {const ctx = useContext(ResizeZoneContext)!;const styles = createMemo(() => {- if (ctx.direction === 'horizontal') {+ if (ctx.direction() === 'horizontal') {return {top: '0px',bottom: '0px',@@ -406,16 +413,16 @@ function Gutter(props: GutterProps) {const rect = root.getBoundingClientRect();const visualSize =- ctx.direction === 'horizontal' ? rect.width : rect.height;+ ctx.direction() === 'horizontal' ? rect.width : rect.height;const layoutSize =- ctx.direction === 'horizontal' ? root.offsetWidth : root.offsetHeight;+ ctx.direction() === 'horizontal' ? root.offsetWidth : root.offsetHeight;if (visualSize <= 0 || layoutSize <= 0) return 1;return visualSize / layoutSize;}function eventPosition(ev: PointerEvent) {- return ctx.direction === 'horizontal' ? ev.clientX : ev.clientY;+ return ctx.direction() === 'horizontal' ? ev.clientX : ev.clientY;}function onPointerDown(ev: PointerEvent) {@@ -448,7 +455,7 @@ function Gutter(props: GutterProps) {}function onKeyDown(ev: KeyboardEvent) {- if (ctx?.direction === 'horizontal') {+ if (ctx?.direction() === 'horizontal') {if (ev.key !== 'ArrowLeft' && ev.key !== 'ArrowRight') return;} else {if (ev.key !== 'ArrowUp' && ev.key !== 'ArrowDown') return;@@ -459,7 +466,7 @@ function Gutter(props: GutterProps) {ev.stopImmediatePropagation();const step = ev.shiftKey ? 100 : 20;- if (ctx?.direction === 'horizontal') {+ if (ctx?.direction() === 'horizontal') {const sign = ev.key === 'ArrowLeft' ? -1 : 1;props.nudge(props.index, sign * step);} else {@@ -473,13 +480,13 @@ function Gutter(props: GutterProps) {class="group"role="separator"aria-orientation={- ctx.direction === 'horizontal' ? 'vertical' : 'horizontal'+ ctx.direction() === 'horizontal' ? 'vertical' : 'horizontal'}tabIndex={0}aria-label={`resize at ${props.index}`}style={{position: 'absolute',- cursor: ctx.direction === 'horizontal' ? 'col-resize' : 'row-resize',+ cursor: ctx.direction() === 'horizontal' ? 'col-resize' : 'row-resize',...styles(),}}onPointerDown={onPointerDown}@@ -492,12 +499,12 @@ function Gutter(props: GutterProps) {ptrDown() && 'opacity-100')}style={{- left: ctx.direction === 'horizontal' ? '50%' : '0',- top: ctx.direction === 'vertical' ? '50%' : '0',- width: ctx.direction === 'horizontal' ? '2px' : '100%',- height: ctx.direction === 'vertical' ? '2px' : '100%',+ left: ctx.direction() === 'horizontal' ? '50%' : '0',+ top: ctx.direction() === 'vertical' ? '50%' : '0',+ width: ctx.direction() === 'horizontal' ? '2px' : '100%',+ height: ctx.direction() === 'vertical' ? '2px' : '100%',transform:- ctx.direction === 'horizontal'+ ctx.direction() === 'horizontal'? 'translateX(-50%)': 'translateY(-50%)',}}diff --git a/js/app/packages/core/component/Resize/types.ts b/js/app/packages/core/component/Resize/types.tsindex d0a4b6ed34..8869edd9ba 100644--- a/js/app/packages/core/component/Resize/types.ts+++ b/js/app/packages/core/component/Resize/types.ts@@ -1,3 +1,5 @@+import type { Accessor } from 'solid-js';+export type PanelId = string;const _HORIZONTAL = 'horizontal' as const;@@ -33,7 +35,7 @@ export type LayoutResult = {};export type ResizeZoneCtx = {- direction: 'horizontal' | 'vertical';+ direction: Accessor<'horizontal' | 'vertical'>;register: (panel: PanelConfig, index?: number) => void;unregister: (id: PanelId) => void;update: (id: PanelId, config: { minSize?: number; maxSize?: number }) => void;