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): ui improvements (#4565)
dev-rbda663d4665fa
diff --git a/js/app/packages/app/component/next-soup/soup-view/date-group-header.tsx b/js/app/packages/app/component/next-soup/soup-view/date-group-header.tsxnew file mode 100644index 0000000000..a08cb82e33--- /dev/null+++ b/js/app/packages/app/component/next-soup/soup-view/date-group-header.tsx@@ -0,0 +1,21 @@+import type { GroupHeaderProps } from '@app/component/next-soup/create-soup-state';+import ChevronRightIcon from '@phosphor/caret-right.svg';+import { cn } from '@ui';++export const DateGroupHeader = (props: GroupHeaderProps) => {+ return (+ <button+ type="button"+ onClick={() => props.group.toggle()}+ class="flex w-full items-center gap-1.5 px-4 py-4 text-sm font-medium text-ink-extra-muted hover:bg-active data-highlighted:bg-active"+ data-highlighted={props.highlighted || undefined}+ >+ <ChevronRightIcon+ class={cn('size-4 shrink-0 transition-transform', {+ 'rotate-90': props.group.isExpanded(),+ })}+ />+ <span class="truncate">{props.group.label}</span>+ </button>+ );+};diff --git a/js/app/packages/app/component/next-soup/soup-view/empty-states.tsx b/js/app/packages/app/component/next-soup/soup-view/empty-states.tsxindex e7425c02eb..fcd2e06c3e 100644--- a/js/app/packages/app/component/next-soup/soup-view/empty-states.tsx+++ b/js/app/packages/app/component/next-soup/soup-view/empty-states.tsx@@ -108,12 +108,20 @@ export function EmptyState(props: {</EmptyStatePanel></Match>- <Match- when={- (props.listView === 'inbox' || props.listView === 'mail') &&- !emailActive()- }- >+ <Match when={props.listView === 'inbox' && !emailActive()}>+ <EmptyStatePanel+ graphic={EmptyStateInboxTrayGraphic}+ title="Your inbox is empty"+ description="Bring your inbox into Macro to triage signal from noise, reply faster, and let agents work alongside your mail."+ primaryAction={{+ label: 'Connect email',+ onClick: onConnectEmail,+ }}+ documentationUrl={`${DOCS_BASE}/product/inbox`}+ />+ </Match>++ <Match when={props.listView === 'mail' && !emailActive()}><EmptyStatePanelgraphic={EmptyStateEmailGraphic}title="Connect your email"diff --git a/js/app/packages/app/component/next-soup/soup-view/group-by-date.ts b/js/app/packages/app/component/next-soup/soup-view/group-by-date.tsindex 721a60663a..ee29ac8d22 100644--- a/js/app/packages/app/component/next-soup/soup-view/group-by-date.ts+++ b/js/app/packages/app/component/next-soup/soup-view/group-by-date.ts@@ -1,11 +1,17 @@-import { format, isSameWeek, isSameYear, isToday, isYesterday } from 'date-fns';+import {+ differenceInCalendarDays,+ isSameMonth,+ isToday,+ isYesterday,+ subMonths,+} from 'date-fns';export type DateBucket = { key: string; label: string };/**- * Bucket a timestamp into a relative section: Today, Yesterday, This week, then- * by month within the current year, and by year for anything older. The `key`- * is stable/collapsible; the `label` is the section header text.+ * Bucket a timestamp into a relative section: Today, Yesterday, Last 7 days,+ * Earlier this month, Last month, then Older. The `key` is stable/collapsible;+ * the `label` is the section header text.** Generic and client-side — used to group soup rows by date without relying on* backend grouping.@@ -15,13 +21,18 @@ export function dateBucket(value: unknown, now = new Date()): DateBucket {value == null ? undefined : new Date(value as string | number | Date);if (!date || Number.isNaN(date.getTime())) {- return { key: 'unknown', label: 'Earlier' };+ return { key: 'older', label: 'Older' };}if (isToday(date)) return { key: 'today', label: 'Today' };if (isYesterday(date)) return { key: 'yesterday', label: 'Yesterday' };- if (isSameWeek(date, now)) return { key: 'this-week', label: 'This week' };- if (isSameYear(date, now)) {- return { key: format(date, 'yyyy-MM'), label: format(date, 'MMMM') };+ if (differenceInCalendarDays(now, date) < 7) {+ return { key: 'last-7-days', label: 'Last 7 days' };}- return { key: format(date, 'yyyy'), label: format(date, 'yyyy') };+ if (isSameMonth(date, now)) {+ return { key: 'earlier-this-month', label: 'Earlier this month' };+ }+ if (isSameMonth(date, subMonths(now, 1))) {+ return { key: 'last-month', label: 'Last month' };+ }+ return { key: 'older', label: 'Older' };}diff --git a/js/app/packages/app/component/next-soup/soup-view/soup-view-context.tsx b/js/app/packages/app/component/next-soup/soup-view/soup-view-context.tsxindex e61b5ef359..6354f1bd5e 100644--- a/js/app/packages/app/component/next-soup/soup-view/soup-view-context.tsx+++ b/js/app/packages/app/component/next-soup/soup-view/soup-view-context.tsx@@ -20,6 +20,7 @@ import {} from '@app/component/next-soup/filters/filter-store/query-store';import { createGroupedSoupQueries } from '@app/component/next-soup/soup-view/create-grouped-soup-queries';import { createSearchState } from '@app/component/next-soup/soup-view/create-search-state';+import { DateGroupHeader } from '@app/component/next-soup/soup-view/date-group-header';import { dateBucket } from '@app/component/next-soup/soup-view/group-by-date';import {INBOX_FILTER_ENTRY_KEY,@@ -817,6 +818,7 @@ export const SoupViewContextProvider: FlowComponent<count: group.entities.length,isExpanded: () => soup.grouping.isExpanded(key),toggle: () => soup.grouping.toggle(key),+ renderHeader: DateGroupHeader,};dateRows.push(soup.buildRow({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 1d41caa84d..547f01e87c 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@@ -624,6 +624,10 @@ export const SoupView = (props: SoupViewProps) => {},});+ const { paneVisible } = usePreviewPaneVisiblity();++ const isNewInboxEnabled = useIsNewInboxEnabled();+return (<SplitPanelContext.Providervalue={{@@ -640,7 +644,7 @@ export const SoupView = (props: SoupViewProps) => {// In preview the separating border sits below this region, so it// ends up under the active-filters bar when shown, otherwise right// under the toolbar (the wrapper collapses to zero height).- 'border-b border-edge-muted': !isMobile() && !!soup.previewEntity(),+ 'border-b border-edge-muted': !isMobile() && paneVisible(),})}><SplitHeaderLeft>@@ -787,7 +791,11 @@ export const SoupView = (props: SoupViewProps) => {</div></div><Suspense>- <Show when={ENABLE_UNIFIED_LIST_AI_INPUT && !isMobile()}>+ <Show+ when={+ ENABLE_UNIFIED_LIST_AI_INPUT && !isMobile() && !isNewInboxEnabled()+ }+ ><SoupChatInput /></Show></Suspense>@@ -795,7 +803,7 @@ export const SoupView = (props: SoupViewProps) => {);};-export const useIsNewInboxEnabled = () => {+export function useIsNewInboxEnabled() {const panel = useSplitPanelOrThrow();const currentView = () => {@@ -812,7 +820,42 @@ export const useIsNewInboxEnabled = () => {currentView() === 'inbox' && newInboxFlag().enabled;return isNewInboxEnabled;-};+}++export function usePreviewPaneVisiblity() {+ const panel = useSplitPanelOrThrow();++ const { soup, rows } = useSoupView();++ const isNewInboxEnabled = useIsNewInboxEnabled();++ const isWideSplitPanel = createMemo(() => {+ return (panel.panelSize.width ?? 0) > WIDE_SPLIT_PANEL_BREAKPOINT;+ });++ const previewVisible = createMemo(+ () =>+ isWideSplitPanel() &&+ (!!soup.previewEntity() || panel.previewState[0]()) &&+ !!soup.focus.item()+ );++ // Placeholder display only for new inbox where the preview panel is open by default+ // Only open while no items are focused+ const previewPlaceholderVisible = createMemo(() => {+ return isWideSplitPanel() && isNewInboxEnabled() && !soup.focus.item();+ });++ const previewPaneVisible = createMemo(+ () => rows().length > 0 && (previewVisible() || previewPlaceholderVisible())+ );++ return {+ paneVisible: previewPaneVisible,+ placeholderVisible: previewPlaceholderVisible,+ previewVisible,+ };+}interface SoupViewListProps {customScrollbarHidden?: boolean;@@ -854,6 +897,8 @@ export const SoupViewList = (props: SoupViewListProps) => {return isListViewID(id) ? id : undefined;});+ const { paneVisible, placeholderVisible, previewVisible } =+ usePreviewPaneVisiblity();// On desktop the calls view defaults to a gallery of call cards instead of// list rows (toggleable from the header). The gallery only renders while// the list column is wide enough for at least two card columns and while@@ -961,7 +1006,7 @@ export const SoupViewList = (props: SoupViewListProps) => {// The calls view has no preview button in its chrome, so never auto-open// the pane there — only keep an already-open pane (Space) in sync.- if (currentView() !== 'calls' || soup.previewEntity()) {+ if (paneVisible() && (currentView() !== 'calls' || soup.previewEntity())) {soup.setPreviewEntity(result?.row.id);}@@ -1127,7 +1172,7 @@ export const SoupViewList = (props: SoupViewListProps) => {}if (- previewPlaceholderVisible() ||+ placeholderVisible() ||(previewVisible() && soup.previewEntity() && type === 'entity')) {if (args.rowIndex !== undefined) soup.focus.setIndex(args.rowIndex);@@ -1337,25 +1382,6 @@ export const SoupViewList = (props: SoupViewListProps) => {return (panel.panelSize.width ?? 0) > WIDE_SPLIT_PANEL_BREAKPOINT;});- const previewVisible = createMemo(- () =>- isWideSplitPanel() &&- (!!soup.previewEntity() || panel.previewState[0]()) &&- !!soup.focus.item()- );-- // On first load the new inbox doesn't auto-select a row, so reserve the- // preview pane with a placeholder until the user picks something. Only for- // that initial state — after the first selection, an empty selection- // collapses the pane as before.- const previewPlaceholderVisible = createMemo(() => {- return isWideSplitPanel() && isNewInboxEnabled() && !soup.focus.item();- });-- const previewPaneVisible = createMemo(- () => previewVisible() || previewPlaceholderVisible()- );-createEffect(() => {const hasPreviewEntity = !!soup.previewEntity();const [getPreview, setPreview] = panel.previewState;@@ -1389,14 +1415,13 @@ export const SoupViewList = (props: SoupViewListProps) => {<Resize.Panelid="soup-list"minSize={200}- maxSize={previewPaneVisible() ? 840 : undefined}+ maxSize={paneVisible() ? 840 : undefined}><divref={setListColumnRef}class={cn('@container/u-list size-full unified-list-root flex flex-col relative',- soup.previewEntity() !== undefined &&- 'border-r border-edge-muted'+ paneVisible() && 'border-r border-edge-muted')}><Show when={isMobile() && source.isPlaceholderData()}>@@ -1759,7 +1784,7 @@ export const SoupViewList = (props: SoupViewListProps) => {</StaticMarkdownContext></div></Resize.Panel>- <Show when={previewPaneVisible()}>+ <Show when={paneVisible()}><Resize.Panelid="soup-preview"minSize={500}@@ -1778,11 +1803,10 @@ export const SoupViewList = (props: SoupViewListProps) => {when={soup.focus.item()}fallback={<EmptyStatePanel- graphic={(iconProps) => (- <EmptyStatePreviewIcon {...iconProps} />- )}+ graphic={EmptyStatePreviewIcon}title="Nothing selected"description="Select an item from your inbox to preview it here."+ centered/>}>@@ -1891,7 +1915,7 @@ const SoupList = (props: SoupListProps) => {<divref={setTopSpacerRef}aria-hidden- class="h-0 mobile:h-(--mobile-content-inset-top)"+ class="h-0 block sm:hidden mobile:h-(--mobile-content-inset-top)"/><Virtualizercache={props.cache}