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.

feat(email-view): add Archived tab (#7555)

teoc9ac175e8a47
diff --git a/apps/web/src/features/email-view/components/EmailEmptyState.tsx b/apps/web/src/features/email-view/components/EmailEmptyState.tsx
index 9871dc14dc..afe670fedf 100644
--- a/apps/web/src/features/email-view/components/EmailEmptyState.tsx
+++ b/apps/web/src/features/email-view/components/EmailEmptyState.tsx
@@ -52,6 +52,10 @@ function tabCopy(tab: EmailTab): { title: string; description: string } {
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('all', () => ({
title: 'No email yet',
description: 'Everything in your inbox will appear here as it arrives.',
diff --git a/apps/web/src/features/email-view/components/EmailSidebar.tsx b/apps/web/src/features/email-view/components/EmailSidebar.tsx
index c275fc14f4..8e0d7db7b3 100644
--- a/apps/web/src/features/email-view/components/EmailSidebar.tsx
+++ b/apps/web/src/features/email-view/components/EmailSidebar.tsx
@@ -5,6 +5,7 @@ import { useSplitLayout } from '@components/app/split-layout/layout';
import { useSplitPanelOrThrow } from '@components/app/split-layout/layoutUtils';
import { enableReminders } from '@core/constant/featureFlags';
import { isTouchDevice } from '@core/mobile/isTouchDevice';
+import ArchiveIcon from '@phosphor/archive.svg';
import BellIcon from '@phosphor/bell-simple.svg';
import CalendarBlankIcon from '@phosphor/calendar-blank.svg';
import ClockIcon from '@phosphor/clock.svg';
@@ -37,6 +38,7 @@ const TAB_ICONS: Record<EmailTab, Component<{ class?: string }>> = {
calendar: CalendarBlankIcon,
drafts: FileIcon,
shared: UsersThreeIcon,
+ archived: ArchiveIcon,
all: EnvelopeIcon,
};
diff --git a/apps/web/src/features/email-view/constants.ts b/apps/web/src/features/email-view/constants.ts
index a04846f5e0..35b88556fd 100644
--- a/apps/web/src/features/email-view/constants.ts
+++ b/apps/web/src/features/email-view/constants.ts
@@ -1,23 +1,45 @@
-import type { EmailTab } from './types';
+/**
+ * Existing tab ids match the legacy mail view (`important` is Signal).
+ * Favorites extends that list; entity action capabilities use `${view}-${tab}`.
+ */
+export const EMAIL_TAB_IDS = [
+ 'important',
+ 'noise',
+ 'favorites',
+ 'sent',
+ 'scheduled',
+ 'reminders',
+ 'calendar',
+ 'drafts',
+ 'shared',
+ 'archived',
+ 'all',
+] as const;
+
+export type EmailTab = (typeof EMAIL_TAB_IDS)[number];
+
+const EMAIL_TAB_LABELS = {
+ important: 'Signal',
+ noise: 'Noise',
+ favorites: 'Favorites',
+ sent: 'Sent',
+ scheduled: 'Scheduled',
+ reminders: 'Reminders',
+ calendar: 'Calendar',
+ drafts: 'Drafts',
+ shared: 'Shared',
+ archived: 'Archived',
+ all: 'All',
+} as const satisfies Record<EmailTab, string>;
export type EmailTabItem = {
id: EmailTab;
label: string;
};
-export const EMAIL_TABS: EmailTabItem[] = [
- { id: 'important', label: 'Signal' },
- { id: 'noise', label: 'Noise' },
- { id: 'favorites', label: 'Favorites' },
- { id: 'sent', label: 'Sent' },
- { id: 'scheduled', label: 'Scheduled' },
- { id: 'reminders', label: 'Reminders' },
- { id: 'calendar', label: 'Calendar' },
- { id: 'drafts', label: 'Drafts' },
- { id: 'shared', label: 'Shared' },
- { id: 'all', label: 'All' },
-];
-
-export const EMAIL_TAB_IDS: EmailTab[] = EMAIL_TABS.map((tab) => tab.id);
+export const EMAIL_TABS: readonly EmailTabItem[] = EMAIL_TAB_IDS.map((id) => ({
+ id,
+ label: EMAIL_TAB_LABELS[id],
+}));
export const DEFAULT_EMAIL_TAB: EmailTab = 'important';
diff --git a/apps/web/src/features/email-view/email-route.ts b/apps/web/src/features/email-view/email-route.ts
index 38781dd50b..027fb36cb2 100644
--- a/apps/web/src/features/email-view/email-route.ts
+++ b/apps/web/src/features/email-view/email-route.ts
@@ -1,24 +1,11 @@
import { createSearchParamsCodec } from '@app/lib/split-router';
import { z } from 'zod';
-import type { EmailTab } from './types';
+import { DEFAULT_EMAIL_TAB, EMAIL_TAB_IDS } from './constants';
export const emailTabSearch = {
namespace: 'mail',
- schema: z.object({
- tab: z.enum([
- 'important',
- 'noise',
- 'favorites',
- 'sent',
- 'scheduled',
- 'reminders',
- 'calendar',
- 'drafts',
- 'shared',
- 'all',
- ]),
- }),
- defaults: { tab: 'important' as EmailTab },
+ schema: z.object({ tab: z.enum(EMAIL_TAB_IDS) }),
+ defaults: { tab: DEFAULT_EMAIL_TAB },
};
export const emailTabSearchCodec = createSearchParamsCodec(emailTabSearch);
diff --git a/apps/web/src/features/email-view/persistence.test.ts b/apps/web/src/features/email-view/persistence.test.ts
new file mode 100644
index 0000000000..c934326d61
--- /dev/null
+++ b/apps/web/src/features/email-view/persistence.test.ts
@@ -0,0 +1,54 @@
+import type { EntryPersistenceHandle } from '@components/app/split-layout/entry-persistence';
+import { describe, expect, it, vi } from 'vitest';
+import { createEmailViewPersistence } from './persistence';
+import type { EmailViewState } from './types';
+
+// The soup barrel persistence imports opens real sockets at module scope.
+vi.mock('@service-storage/websocket', () => ({
+ storageWS: { reconnectIfDisconnected: vi.fn() },
+ createWebSocketJob: vi.fn(),
+}));
+vi.mock('@service-connection/websocket', () => ({
+ ws: { addEventListener: vi.fn(), send: vi.fn() },
+ state: () => 'closed',
+ createConnectionBlockWebsocketEffect: vi.fn(),
+ createConnectionWebsocketEffect: vi.fn(),
+}));
+
+const current = (): EmailViewState => ({
+ tab: 'important',
+ search: '',
+ inboxIds: undefined,
+ facets: {},
+ collapsedSidebarSectionIds: [],
+});
+
+describe('createEmailViewPersistence', () => {
+ it('restores a stored archived tab', () => {
+ const handle: EntryPersistenceHandle = {
+ currentEntryState: () => ({
+ 'email.view': {
+ version: 1,
+ tab: 'archived',
+ search: '',
+ facets: {},
+ },
+ }),
+ registerEntryStateCaptor: () => () => {},
+ };
+ const { storages } = createEmailViewPersistence({
+ handle,
+ userId: () => undefined,
+ restoreLocalState: false,
+ restorePreferences: false,
+ });
+ const list = Array.isArray(storages) ? storages : [storages];
+ let state = current();
+ for (const storage of list) {
+ const next = storage.restore(state);
+ if (next !== undefined) state = next;
+ }
+
+ expect(state.tab).toBe('archived');
+ });
+});
diff --git a/apps/web/src/features/email-view/persistence.ts b/apps/web/src/features/email-view/persistence.ts
index 5ec947559e..1ae2f22983 100644
--- a/apps/web/src/features/email-view/persistence.ts
+++ b/apps/web/src/features/email-view/persistence.ts
@@ -12,6 +12,7 @@ import {
import { createUserScopedStorage } from '@core/util/userScopedStorage';
import type { Accessor } from 'solid-js';
import { z } from 'zod';
+import { DEFAULT_EMAIL_TAB, EMAIL_TAB_IDS } from './constants';
import { normalizeInboxSelection } from './inbox-selection';
import type { EmailViewState } from './types';
@@ -21,26 +22,13 @@ const emailLocalStateStorage = createUserScopedStorage(
'macro:email:view-state:v1'
);
-const emailTabSchema = z
- .enum([
- 'important',
- 'noise',
- 'favorites',
- 'sent',
- 'scheduled',
- 'reminders',
- 'calendar',
- 'drafts',
- 'shared',
- 'all',
- ])
- .catch('important');
+const emailTabSchema = z.enum(EMAIL_TAB_IDS).catch(DEFAULT_EMAIL_TAB);
const emailFacetsSchema = z.record(z.string(), z.array(z.string()));
const emailEntryStateSchemaWithDefaults = z.object({
version: z.literal(1).default(1),
- tab: emailTabSchema.default('important'),
+ tab: emailTabSchema.default(DEFAULT_EMAIL_TAB),
search: z.string().default(''),
facets: emailFacetsSchema.default({}),
});
@@ -117,7 +105,7 @@ function createEmailEntryStorage(options: {
// text remains deliberately scoped to one visit.
const emailLocalStateSchemaWithDefaults = z.object({
version: z.literal(1).default(1),
- tab: emailTabSchema.default('important'),
+ tab: emailTabSchema.default(DEFAULT_EMAIL_TAB),
inboxIds: inboxIdsEntrySchema,
facets: emailFacetsSchema.default({}),
});
diff --git a/apps/web/src/features/email-view/queries/email-query.test.ts b/apps/web/src/features/email-view/queries/email-query.test.ts
index 5d18618d8b..e06392c332 100644
--- a/apps/web/src/features/email-view/queries/email-query.test.ts
+++ b/apps/web/src/features/email-view/queries/email-query.test.ts
@@ -6,6 +6,7 @@ import type { EntityData, WithNotification } from '@entity';
import { makeGraphqlSoupInput } from '@queries/soup/graphql/ast';
import type { TagSetResponse } from '@service-properties/generated/schemas/tagSetResponse';
import { describe, expect, it, vi } from 'vitest';
+import { EMAIL_TAB_IDS } from '../constants';
import type { EmailTab } from '../types';
import {
buildEmailQuery,
@@ -40,17 +41,6 @@ vi.mock('@service-connection/websocket', () => ({
}));
const NIL = '00000000-0000-0000-0000-000000000000';
-const TABS: EmailTab[] = [
- 'important',
- 'noise',
- 'favorites',
- 'sent',
- 'scheduled',
- 'calendar',
- 'drafts',
- 'shared',
- 'all',
-];
const serialize = (value: unknown) => JSON.stringify(value);
@@ -141,19 +131,21 @@ describe('buildEmailQuery', () => {
});
it('lists the server view each tab reads from', () => {
- expect(TABS.map((tab) => [tab, emailViewForTab(tab)])).toEqual([
+ expect(EMAIL_TAB_IDS.map((tab) => [tab, emailViewForTab(tab)])).toEqual([
['important', 'inbox'],
['noise', 'inbox'],
['favorites', 'all'],
['sent', 'sent'],
['scheduled', 'drafts'],
+ ['reminders', 'all'],
['calendar', 'all'],
['drafts', 'drafts'],
['shared', 'all'],
+ ['archived', 'all'],
['all', 'all'],
]);
- for (const tab of TABS) {
+ for (const tab of EMAIL_TAB_IDS) {
expect(buildEmailQuery(contextFor({ tab })).body.emailView).toBe(
emailViewForTab(tab)
);
@@ -201,6 +193,26 @@ describe('buildEmailQuery', () => {
expect(shared).toEqual({ l: { Shared: 'only' } });
});
+ it('lists archived mail on the All view, done and unshared', () => {
+ const args = buildEmailQuery(contextFor({ tab: 'archived' }));
+
+ expect(args.body.emailView).toBe('all');
+ const ef = serialize(args.body.ef);
+ expect(ef).toContain(serialize({ l: { InboxVisible: false } }));
+ expect(ef).toContain(serialize({ l: { Shared: 'exclude' } }));
+
+ const input = makeGraphqlSoupInput(args);
+ expect(input.initial?.emailView).toBe('ALL');
+ expect(input.initial?.filters?.emailFilter).toEqual({
+ tree: {
+ and: {
+ left: { literal: { inboxVisible: false } },
+ right: { literal: { shared: 'EXCLUDE' } },
+ },
+ },
+ });
+ });
+
it('leaves the inbox unscoped when every inbox is selected', () => {
const { body } = buildEmailQuery(contextFor());
@@ -357,6 +369,13 @@ describe('buildEmailSearchRequest', () => {
expect(filtersFor('sent')).toEqual({});
});
+ it('excludes shared threads from archived search', () => {
+ const filtersFor = (tab: EmailTab) =>
+ requestFor({ tab }).filters.email_filters;
+
+ expect(filtersFor('archived')).toEqual({ shared: 'exclude' });
+ });
+
it('restricts to the selected inboxes', () => {
const selected = requestFor({ inboxIds: ['link-a'] }).filters.email_filters;
const none = requestFor({ inboxIds: [] }).filters.email_filters;
diff --git a/apps/web/src/features/email-view/queries/email-query.ts b/apps/web/src/features/email-view/queries/email-query.ts
index cee5c3a0cf..85c66f44c9 100644
--- a/apps/web/src/features/email-view/queries/email-query.ts
+++ b/apps/web/src/features/email-view/queries/email-query.ts
@@ -35,7 +35,15 @@ export const emailViewForTab = (tab: EmailTab): string =>
// Soup source on drafts so its query shape remains valid while disabled.
.with('scheduled', () => 'drafts')
.with('sent', () => 'sent')
- .with('favorites', 'calendar', 'shared', 'all', 'reminders', () => 'all')
+ .with(
+ 'favorites',
+ 'calendar',
+ 'shared',
+ 'all',
+ 'reminders',
+ 'archived',
+ () => 'all'
+ )
.exhaustive();
const anyThread = (): TargetExpr => clause.not(clause.eq('threadId', NIL_UUID));
@@ -75,6 +83,12 @@ function tabClause(context: EmailQueryContext): TargetExpr {
)
)
.with('shared', () => clause.eq('emailShared', 'only'))
+ .with('archived', () =>
+ clause.and(
+ clause.eq('emailDone', true),
+ clause.eq('emailShared', 'exclude')
+ )
+ )
// Sent and Drafts are scoped entirely by `emailView`; the server's sent
// view already covers every linked inbox, so no sender filter is needed.
.with(
diff --git a/apps/web/src/features/email-view/queries/email-search.ts b/apps/web/src/features/email-view/queries/email-search.ts
index 5ded41501a..3060516278 100644
--- a/apps/web/src/features/email-view/queries/email-search.ts
+++ b/apps/web/src/features/email-view/queries/email-search.ts
@@ -27,7 +27,8 @@ const nonEmailFilters: EntityFilters = {
};
// Search has no draft/sent scoping, so those tabs (like All) search the
-// user's own threads — the same reach the legacy mail search had.
+// user's own threads — the same reach the legacy mail search had. It cannot
+// filter archive state either, so `emailMatchesTab` trims Archived hits.
function tabFilters(tab: EmailTab): EmailFilters {
return match(tab)
.with('important', () => ({ importance: true, shared: 'exclude' as const }))
@@ -37,6 +38,7 @@ function tabFilters(tab: EmailTab): EmailFilters {
shared: 'exclude' as const,
}))
.with('shared', () => ({ shared: 'only' as const }))
+ .with('archived', () => ({ shared: 'exclude' as const }))
.with(
'favorites',
'drafts',
diff --git a/apps/web/src/features/email-view/queries/use-email-query.test.ts b/apps/web/src/features/email-view/queries/use-email-query.test.ts
index 3f10ff31b1..be07b8ca14 100644
--- a/apps/web/src/features/email-view/queries/use-email-query.test.ts
+++ b/apps/web/src/features/email-view/queries/use-email-query.test.ts
@@ -355,6 +355,38 @@ describe('Email list query transitions', () => {
expect(ids(source)).toEqual(['noise']);
});
+ it('lists done rows on Archived and drops a row when it is unarchived', () => {
+ const { source, setState, setEntities } = mount();
+ const archived = { ...email('archived'), done: true };
+ const active = { ...email('active'), done: false };
+ batch(() => {
+ setState('tab', 'archived');
+ setEntities([archived, active]);
+ });
+ expect(ids(source)).toEqual(['archived']);
+ expect(source.isLoading()).toBe(false);
+
+ setEntities([{ ...archived, done: false }, active]);
+ expect(ids(source)).toEqual([]);
+ expect(source.isLoading()).toBe(false);
+ });
+
+ it('trims archived search results to done threads', () => {
+ const { source, setState, setSearchEntities } = mount('invoice');
+ const archived = { ...email('archived'), done: true };
+ const active = { ...email('active'), done: false };
+ batch(() => {
+ setState('tab', 'archived');
+ setSearchEntities([archived, active]);
+ });
+ expect(ids(source)).toEqual(['archived']);
+ expect(source.isLoading()).toBe(false);
+
+ setSearchEntities([{ ...archived, done: false }, active]);
+ expect(ids(source)).toEqual([]);
+ expect(source.isLoading()).toBe(false);
+ });
+
it('does not suspend on pending native data while its fetch is paused', () => {
const { source, setPaused, setEntities, query } = mount();
expect(() => setPaused(true)).not.toThrow();
diff --git a/apps/web/src/features/email-view/queries/use-email-query.ts b/apps/web/src/features/email-view/queries/use-email-query.ts
index 14de2554cb..a74ad4056b 100644
--- a/apps/web/src/features/email-view/queries/use-email-query.ts
+++ b/apps/web/src/features/email-view/queries/use-email-query.ts
@@ -69,6 +69,7 @@ function emailMatchesTab(
): boolean {
return match(tab)
.with('drafts', () => entity.isDraft)
+ .with('archived', () => entity.done === true)
.with('shared', () => userId !== undefined && entity.ownerId !== userId)
.with(
'important',
diff --git a/apps/web/src/features/email-view/types.ts b/apps/web/src/features/email-view/types.ts
index 285fa4ce17..05e90c54a3 100644
--- a/apps/web/src/features/email-view/types.ts
+++ b/apps/web/src/features/email-view/types.ts
@@ -1,20 +1,7 @@
import type { FacetSelection } from '@app/features/soup';
+import type { EmailTab } from './constants';
-/**
- * Existing tab ids match the legacy mail view (`important` is Signal).
- * Favorites extends that list; entity action capabilities use `${view}-${tab}`.
- */
-export type EmailTab =
- | 'important'
- | 'noise'
- | 'favorites'
- | 'sent'
- | 'scheduled'
- | 'reminders'
- | 'calendar'
- | 'drafts'
- | 'shared'
- | 'all';
+export type { EmailTab };
export type EmailFilterGroupId =
| 'read'
diff --git a/apps/web/src/features/next-soup/actions/make-mark-done-action.test.ts b/apps/web/src/features/next-soup/actions/make-mark-done-action.test.ts
index 731ec5df79..94037efc00 100644
--- a/apps/web/src/features/next-soup/actions/make-mark-done-action.test.ts
+++ b/apps/web/src/features/next-soup/actions/make-mark-done-action.test.ts
@@ -134,6 +134,10 @@ describe('canExecuteMarkDoneOnView', () => {
expect(canExecuteMarkDoneOnView('mail', 'drafts')).toBe(false);
expect(canExecuteMarkDoneOnView('mail', 'sent')).toBe(false);
});
+
+ it('allows mark done on the archived tab', () => {
+ expect(canExecuteMarkDoneOnView('mail', 'archived')).toBe(true);
+ });
});
describe('makeMarkDoneAction', () => {
diff --git a/apps/web/src/features/next-soup/actions/make-mark-done-action.ts b/apps/web/src/features/next-soup/actions/make-mark-done-action.ts
index 6785925268..6f1efe202f 100644
--- a/apps/web/src/features/next-soup/actions/make-mark-done-action.ts
+++ b/apps/web/src/features/next-soup/actions/make-mark-done-action.ts
@@ -44,6 +44,7 @@ const VALID_MARK_DONE_LIST_VIEWS: `${ListView}-${string}`[] = [
// stay in place and flip to the done state exactly like mail "All".
'mail-calendar',
'mail-shared',
+ 'mail-archived',
'reminders-all',
];
diff --git a/docs/AGENT_GUIDE/surfaces.md b/docs/AGENT_GUIDE/surfaces.md
index b4dc8308ec..9f1ae9bd52 100644
--- a/docs/AGENT_GUIDE/surfaces.md
+++ b/docs/AGENT_GUIDE/surfaces.md
@@ -407,7 +407,7 @@ Carets and folder-only parents expand branches; actual tags select their exact I
and switch the mailbox to All. Parent selection does not include descendant tags.
Full email client. Tabs: `Signal` / `Noise` / `Favorites` / `Sent` / `Scheduled` / `Calendar` / `Drafts` / `Shared` /
-`All`. Compose via the `Email` button (or `Create` → `Email E`). On a fresh local user it
+`Archived` / `All`. Compose via the `Email` button (or `Create` → `Email E`). On a fresh local user it
shows `Connect your email` (Gmail/Google Workspace OAuth) — most functionality needs a
connected account. Search is `Ctrl+F` within the surface.
@@ -420,6 +420,14 @@ REST Soup uses `favorites_only: true`. Starring changes membership without
changing the list query. Text search still resolves favorite IDs for the search
service. An empty favorites list shows `No favorite emails`.
+`Archived`, directly before All, lists your own archived (Mail Done) threads: the
+All mailbox with Done applied, excluding threads teammates shared with you. It
+respects the selected inboxes and filters. The search service cannot filter
+archive state, so search within the tab keeps only archived hits on the client.
+Rows offer **Unarchive email**;
+unarchiving removes the row at once. The tab persists across reloads. An empty
+list shows `No archived email`.
+
On desktop, a favorited email keeps a filled, muted star just before its
timestamp. Other rows reserve only that small star slot. Hovering reveals
**Star email** (Macro favorites), **Archive email** (Mark Done, with Undo), and
@@ -551,7 +559,7 @@ All, Signal, Noise, Drafts, Sent, Calendar, and Shared support tab changes and n
filter combinations while offline: account selection
(including delegated inboxes), read/unread, and archive-based Done/Not Done. Mail Done
means `inboxVisible = false`; it is **not** notification lifecycle state. Signal/Noise
-retain their Inbox scope, so archived mail is found using All + Done.
+retain their Inbox scope, so archived mail is found in Archived (All + Done).
A `Showing cached mail` notice identifies results over synchronized metadata, not a
claim of complete mailbox coverage. These lists paginate locally beyond the first