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
import { DOCS_BASE } from '@app/constants/docs-links';
import { useAddInboxFlow, useEmailLinksStatus } from '@core/email-link';
import { fireAndForget } from '@core/util/fireAndForget';
import EmptyStateEmailGraphic from '@design/empty-state-email.svg';
import EmptyStateInboxTrayGraphic from '@design/empty-state-inbox-tray.svg';
import EmptyStateNoFilterMatchGraphic from '@design/empty-state-no-filter-match.svg';
import EmptyStateNoSearchMatchGraphic from '@design/empty-state-no-search-match.svg';
import { FOCUS_WINDOW_DAYS } from '@queries/email/focus';
import { EmptyStatePanel, FilteredHiddenBanner } from '@ui';
import { Match, Switch } from 'solid-js';
import { match } from 'ts-pattern';
import { canSearchEmailTab } from '../constants';
import { useEmailView } from '../email-view-context';
import type { EmailTab } from '../types';
const EMAIL_DOCS_URL = `${DOCS_BASE}/product/email`;
function tabCopy(tab: EmailTab): { title: string; description: string } {
return match(tab)
.with('important', () => ({
title: 'Inbox zero',
description:
"You're all caught up. New email will appear here as it arrives.",
}))
.with('noise', () => ({
title: 'No noise',
description:
'Low-priority email like newsletters and notifications collects here. Nothing to clear right now.',
}))
.with('favorites', () => ({
title: 'No favorite emails',
description: 'Star an email to keep it here for easy access.',
}))
.with('sent', () => ({
title: 'No sent email',
description: 'Email you send will appear here.',
}))
.with('scheduled', () => ({
title: 'No scheduled email',
description: 'Email you schedule to send later will appear here.',
}))
.with('reminders', () => ({
title: 'No email reminders',
description: 'Use Remind me on an email to return to it later.',
}))
.with('calendar', () => ({
title: 'No calendar email',
description: 'Invitations and event updates will appear here.',
}))
.with('drafts', () => ({
title: 'No drafts',
description: "Email you start but haven't sent will appear here.",
}))
.with('shared', () => ({
title: 'No shared email',
description: 'Threads teammates share with you will appear here.',
}))
.with('archived', () => ({
title: 'No archived email',
description: 'Email you archive will appear here.',
}))
.with('focus', () => ({
title: "You're caught up",
description: `Email worth your attention from the last ${FOCUS_WINDOW_DAYS} days appears here.`,
}))
.with('spam', () => ({
title: 'No spam',
description:
'Email marked as spam or junk in your connected inboxes appears here.',
}))
.with('trash', () => ({
title: 'Trash is empty',
description:
'Deleted email from your connected inboxes appears here until it is permanently removed.',
}))
.with('all', () => ({
title: 'No email yet',
description: 'Everything in your inbox will appear here as it arrives.',
}))
.exhaustive();
}
export function EmailEmptyState() {
const { state, setFacets, setInboxIds, setTab } = useEmailView();
const emailActive = useEmailLinksStatus();
const startAddInbox = useAddInboxFlow();
// Scheduled has no search or filters; text typed on another tab stays behind.
const searchText = () =>
canSearchEmailTab(state.tab) ? state.search.trim() : '';
const noInboxesSelected = () => state.inboxIds?.length === 0;
const hasActiveFilters = () =>
Object.values(state.facets).some((optionIds) => optionIds.length > 0);
return (
<Switch>
<Match when={!emailActive()}>
<EmptyStatePanel
graphic={EmptyStateEmailGraphic}
title="Connect your email"
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: () => fireAndForget(startAddInbox(), 'add-inbox'),
}}
documentationUrl={EMAIL_DOCS_URL}
/>
</Match>
<Match when={noInboxesSelected()}>
<EmptyStatePanel
centered
graphic={EmptyStateInboxTrayGraphic}
title="No inboxes selected"
description="Pick at least one inbox to see its email."
primaryAction={{
label: 'Show all inboxes',
onClick: () => setInboxIds(undefined),
}}
/>
</Match>
<Match when={searchText()}>
{(search) => (
<EmptyStatePanel
centered
graphic={EmptyStateNoSearchMatchGraphic}
title={`No results for "${search()}"`}
description={
state.tab === 'focus'
? 'Focus search covers subjects, senders, and previews. Try a different query.'
: 'Search across subjects, senders, and message content. Try a different query.'
}
documentationUrl={`${DOCS_BASE}/product/search`}
/>
)}
</Match>
<Match when={hasActiveFilters()}>
<EmptyStatePanel
centered
graphic={EmptyStateNoFilterMatchGraphic}
title="No email matching the filters"
description="Try adjusting or clearing your filters to see more results."
>
<FilteredHiddenBanner
hasHiddenItems={false}
onClearFilters={() => setFacets({})}
/>
</EmptyStatePanel>
</Match>
<Match when={tabCopy(state.tab)}>
{(copy) => (
<EmptyStatePanel
graphic={EmptyStateInboxTrayGraphic}
title={copy().title}
description={copy().description}
primaryAction={
state.tab === 'focus'
? {
label: 'See the rest of your inbox',
onClick: () => setTab('important'),
}
: undefined
}
documentationUrl={EMAIL_DOCS_URL}
/>
)}
</Match>
</Switch>
);
}