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
feat(email): add email hover actions and a Favorites view (#7036)
teo84d57e420973
diff --git a/apps/web/src/features/email-view/components/EmailEmptyState.tsx b/apps/web/src/features/email-view/components/EmailEmptyState.tsxindex 4429150973..081e9b8b67 100644--- a/apps/web/src/features/email-view/components/EmailEmptyState.tsx+++ b/apps/web/src/features/email-view/components/EmailEmptyState.tsx@@ -24,6 +24,10 @@ function tabCopy(tab: EmailTab): { title: string; description: string } {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.',diff --git a/apps/web/src/features/email-view/components/EmailList.tsx b/apps/web/src/features/email-view/components/EmailList.tsxindex 0a0b166f33..4b4648cfc8 100644--- a/apps/web/src/features/email-view/components/EmailList.tsx+++ b/apps/web/src/features/email-view/components/EmailList.tsx@@ -1,5 +1,6 @@import '@entity/composed/ListEntity.css';import { type ListActivation, useListInteractions } from '@app/components/list';+import { CommandState } from '@app/features/command/state';import {resolveEntityActionViewContext,toEntityActionListState,@@ -58,6 +59,7 @@ import type { EmailDataSourceItem } from '../queries/use-email-query';import { useEmailListHotkeys } from '../use-email-list-hotkeys';import { EmailDateGroupHeader } from './EmailDateGroupHeader';import { EmailEmptyState } from './EmailEmptyState';+import { EmailRowActions, EmailStarAction } from './EmailRowActions';type EmailActionRow = {entity: WithNotification<EntityData>;@@ -129,7 +131,7 @@ export function EmailList(props: EmailListProps) {registerListActivationHandler(onActivate);- const { buildActionGroups } = createSoupEntityActions();+ const { buildActionGroups, isFavorited } = createSoupEntityActions();const entityActionViewContext = () =>resolveEntityActionViewContext({activeListView: panel.handle.content().id,@@ -286,6 +288,54 @@ export function EmailList(props: EmailListProps) {list.selection.setAnchor(row.rowId);}+ const [isRowActionPending, setRowActionPending] = createSignal(false);++ async function runRowAction(+ row: EmailActionRow,+ actionId: 'favorite' | 'mark-done' | 'mark-not-done'+ ) {+ if (isRowActionPending()) return;+ const action = actionGroupsFor(row)+ .flatMap((group) => group.items)+ .find((item) => item.id === actionId);+ if (!action || action.disabled) return;++ focusActionRow(row);+ setRowActionPending(true);+ try {+ await action.onClick();+ } catch {+ // Entity actions own their rollback and failure notification.+ } finally {+ setRowActionPending(false);+ grid()?.focus();+ }+ }++ function RowActions(props: { row: EmailActionRow }) {+ const archived = () =>+ props.row.entity.type === 'email' && props.row.entity.done;++ return (+ <EmailRowActions+ archived={archived()}+ canArchive={entityActionViewContext().supportsMarkDone}+ pending={isRowActionPending()}+ onFocus={() => focusActionRow(props.row)}+ onArchive={() =>+ void runRowAction(+ props.row,+ archived() ? 'mark-not-done' : 'mark-done'+ )+ }+ onCommands={() => {+ focusActionRow(props.row);+ CommandState.openForEntityAction([props.row.entity]);+ }}+ />+ );+ }+let restoredScroll = false;function registerVirtualizer(handle?: VirtualizerHandle) {setVirtualizer(handle);@@ -512,6 +562,41 @@ export function EmailList(props: EmailListProps) {<div role="gridcell"><ListEntityentity={entityRow().entity}+ leadingAction={+ <Show when={!isTouchDevice()}>+ <EmailStarAction+ starred={isFavorited(+ entityRow().entity+ )}+ pending={isRowActionPending()}+ onFocus={() =>+ focusActionRow({+ entity: entityRow().entity,+ rowId: entityRow().id,+ })+ }+ onStar={() =>+ void runRowAction(+ {+ entity: entityRow().entity,+ rowId: entityRow().id,+ },+ 'favorite'+ )+ }+ />+ </Show>+ }+ actions={+ <Show when={!isTouchDevice()}>+ <RowActions+ row={{+ entity: entityRow().entity,+ rowId: entityRow().id,+ }}+ />+ </Show>+ }checked={list.selection.isSelected(entityRow().id)}diff --git a/apps/web/src/features/email-view/components/EmailRowActions.test.tsx b/apps/web/src/features/email-view/components/EmailRowActions.test.tsxnew file mode 100644index 0000000000..3b8b3ceca6--- /dev/null+++ b/apps/web/src/features/email-view/components/EmailRowActions.test.tsx@@ -0,0 +1,133 @@+import { cleanup, fireEvent, render, screen } from '@solidjs/testing-library';+import { type ComponentProps, createSignal } from 'solid-js';+import { afterEach, describe, expect, it, vi } from 'vitest';+import { EmailRowActions, EmailStarAction } from './EmailRowActions';++vi.mock('@ui', async () => ({+ Button: (await import('@app/components/ui/components/Button')).Button,+ cn: (await import('@app/components/ui/utils/classname')).cn,+}));++afterEach(cleanup);++function Actions(+ props: ComponentProps<typeof EmailStarAction> &+ ComponentProps<typeof EmailRowActions>+) {+ return (+ <>+ <EmailStarAction {...props} />+ <EmailRowActions {...props} />+ </>+ );+}++describe('email row actions', () => {+ it('runs the clicked action without activating or dragging the row', () => {+ const openThread = vi.fn();+ const startDrag = vi.fn();+ const onStar = vi.fn();+ const onArchive = vi.fn();+ const onCommands = vi.fn();+ render(() => (+ <div+ onClick={openThread}+ onPointerDown={startDrag}+ onMouseDown={startDrag}+ >+ <Actions+ starred={false}+ archived={false}+ canArchive+ pending={false}+ onStar={onStar}+ onArchive={onArchive}+ onCommands={onCommands}+ onFocus={() => {}}+ />+ </div>+ ));++ for (const name of ['Star email', 'Archive email', 'Open command menu']) {+ const button = screen.getByRole('button', { name });+ fireEvent.pointerDown(button);+ fireEvent.mouseDown(button);+ fireEvent.click(button);+ }+ expect(onStar).toHaveBeenCalledOnce();+ expect(onArchive).toHaveBeenCalledOnce();+ expect(onCommands).toHaveBeenCalledOnce();+ expect(openThread).not.toHaveBeenCalled();+ expect(startDrag).not.toHaveBeenCalled();+ });++ it('reflects star/archive changes and disables unavailable or pending writes', () => {+ const [starred, setStarred] = createSignal(false);+ const [archived, setArchived] = createSignal(false);+ const [pending, setPending] = createSignal(false);+ const [canArchive, setCanArchive] = createSignal(true);+ render(() => (+ <Actions+ starred={starred()}+ archived={archived()}+ canArchive={canArchive()}+ pending={pending()}+ onStar={() => setStarred(!starred())}+ onArchive={() => setArchived(!archived())}+ onCommands={() => {}}+ onFocus={() => {}}+ />+ ));++ fireEvent.click(screen.getByRole('button', { name: 'Star email' }));+ expect(+ screen+ .getByRole('button', { name: 'Unstar email' })+ .getAttribute('aria-pressed')+ ).toBe('true');+ fireEvent.click(screen.getByRole('button', { name: 'Archive email' }));+ const archive = screen.getByRole('button', { name: 'Unarchive email' });+ setCanArchive(false);+ expect(archive.hasAttribute('disabled')).toBe(true);+ setCanArchive(true);+ setPending(true);+ expect(archive.hasAttribute('disabled')).toBe(true);+ expect(+ screen+ .getByRole('button', { name: 'Unstar email' })+ .hasAttribute('disabled')+ ).toBe(true);+ expect(+ screen+ .getByRole('button', { name: 'Open command menu' })+ .hasAttribute('disabled')+ ).toBe(false);+ });++ it('isolates button activation keys while preserving list navigation keys', () => {+ const onListKey = vi.fn();+ const onFocus = vi.fn();+ render(() => (+ <div onKeyDown={onListKey}>+ <Actions+ starred={false}+ archived={false}+ canArchive+ pending={false}+ onStar={() => {}}+ onArchive={() => {}}+ onCommands={() => {}}+ onFocus={onFocus}+ />+ </div>+ ));+ const button = screen.getByRole('button', { name: 'Open command menu' });+ fireEvent.focusIn(button);+ expect(onFocus).toHaveBeenCalledOnce();+ fireEvent.keyDown(button, { key: 'Enter' });+ fireEvent.keyDown(button, { key: ' ' });+ expect(onListKey).not.toHaveBeenCalled();+ fireEvent.keyDown(button, { key: 'ArrowDown' });+ expect(onListKey).toHaveBeenCalledOnce();+ });+});diff --git a/apps/web/src/features/email-view/components/EmailRowActions.tsx b/apps/web/src/features/email-view/components/EmailRowActions.tsxnew file mode 100644index 0000000000..56c0a9f258--- /dev/null+++ b/apps/web/src/features/email-view/components/EmailRowActions.tsx@@ -0,0 +1,98 @@+import ArrowCounterClockwiseIcon from '@phosphor/arrow-counter-clockwise.svg';+import CheckIcon from '@phosphor/check.svg';+import LightningIcon from '@phosphor/lightning.svg';+import StarIcon from '@phosphor/star.svg';+import StarFillIcon from '@phosphor-icons/core/fill/star-fill.svg?component-solid';+import { Button, cn } from '@ui';+import { type ParentProps, Show } from 'solid-js';++function EmailActionGroup(+ props: ParentProps<{+ onFocus: () => void;+ class?: string;+ }>+) {+ return (+ <div+ role="group"+ aria-label="Email actions"+ class={cn('flex items-center gap-1', props.class)}+ onPointerDown={(event) => event.stopPropagation()}+ onMouseDown={(event) => event.stopPropagation()}+ onClick={(event) => event.stopPropagation()}+ onKeyDown={(event) => {+ if (event.key === 'Enter' || event.key === ' ') event.stopPropagation();+ }}+ onFocusIn={props.onFocus}+ >+ {props.children}+ </div>+ );+}++export function EmailStarAction(props: {+ starred: boolean;+ pending: boolean;+ onStar: () => void;+ onFocus: () => void;+}) {+ return (+ <EmailActionGroup+ onFocus={props.onFocus}+ class={cn(+ 'group-hover/entity:opacity-100 group-hover/entity:pointer-events-auto group-focus-within/entity:opacity-100 group-focus-within/entity:pointer-events-auto',+ !props.starred && 'opacity-0 pointer-events-none'+ )}+ >+ <Button+ variant="plain"+ size="icon-sm"+ label={props.starred ? 'Unstar email' : 'Star email'}+ class={props.starred ? 'text-ink-muted' : 'text-ink-extra-muted'}+ tooltip={props.starred ? 'Remove from favorites' : 'Add to favorites'}+ aria-pressed={props.starred}+ disabled={props.pending}+ onClick={props.onStar}+ >+ <Show when={props.starred} fallback={<StarIcon class="size-4" />}>+ <StarFillIcon class="size-4" />+ </Show>+ </Button>+ </EmailActionGroup>+ );+}++export function EmailRowActions(props: {+ archived: boolean;+ canArchive: boolean;+ pending: boolean;+ onArchive: () => void;+ onCommands: () => void;+ onFocus: () => void;+}) {+ return (+ <EmailActionGroup onFocus={props.onFocus}>+ <Button+ variant="plain"+ size="icon-sm"+ label={props.archived ? 'Unarchive email' : 'Archive email'}+ class="text-ink-extra-muted"+ disabled={!props.canArchive || props.pending}+ onClick={props.onArchive}+ >+ <Show when={props.archived} fallback={<CheckIcon class="size-4" />}>+ <ArrowCounterClockwiseIcon class="size-4" />+ </Show>+ </Button>+ <Button+ variant="plain"+ size="icon-sm"+ label="Open command menu"+ class="text-ink-extra-muted"+ onClick={props.onCommands}+ >+ <LightningIcon class="size-4" />+ </Button>+ </EmailActionGroup>+ );+}diff --git a/apps/web/src/features/email-view/components/EmailSidebar.tsx b/apps/web/src/features/email-view/components/EmailSidebar.tsxindex f3e689f253..9501891380 100644--- a/apps/web/src/features/email-view/components/EmailSidebar.tsx+++ b/apps/web/src/features/email-view/components/EmailSidebar.tsx@@ -8,6 +8,7 @@ import ClockIcon from '@phosphor/clock.svg';import EnvelopeIcon from '@phosphor/envelope.svg';import FileIcon from '@phosphor/file.svg';import PaperPlaneTiltIcon from '@phosphor/paper-plane-tilt.svg';+import StarIcon from '@phosphor/star.svg';import UsersThreeIcon from '@phosphor/users-three.svg';import SignalIcon from '@phosphor/wave-sine.svg';import NoiseIcon from '@phosphor/waveform.svg';@@ -24,6 +25,7 @@ import { EmailInboxList } from './EmailInboxSelector';const TAB_ICONS: Record<EmailTab, Component<{ class?: string }>> = {important: SignalIcon,noise: NoiseIcon,+ favorites: StarIcon,sent: PaperPlaneTiltIcon,scheduled: ClockIcon,calendar: CalendarBlankIcon,diff --git a/apps/web/src/features/email-view/constants.ts b/apps/web/src/features/email-view/constants.tsindex 2a7f4e598e..7e8214cf13 100644--- a/apps/web/src/features/email-view/constants.ts+++ b/apps/web/src/features/email-view/constants.ts@@ -8,6 +8,7 @@ export type EmailTabItem = {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: 'calendar', label: 'Calendar' },diff --git a/apps/web/src/features/email-view/email-route.ts b/apps/web/src/features/email-view/email-route.tsindex f9289f328f..f2fdc3c835 100644--- a/apps/web/src/features/email-view/email-route.ts+++ b/apps/web/src/features/email-view/email-route.ts@@ -8,6 +8,7 @@ export const emailTabSearch = {tab: z.enum(['important','noise',+ 'favorites','sent','scheduled','calendar',diff --git a/apps/web/src/features/email-view/persistence.ts b/apps/web/src/features/email-view/persistence.tsindex cadfe6981d..a4fc84fe58 100644--- a/apps/web/src/features/email-view/persistence.ts+++ b/apps/web/src/features/email-view/persistence.ts@@ -25,6 +25,7 @@ const emailTabSchema = z.enum(['important','noise',+ 'favorites','sent','scheduled','calendar',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.tsindex c71f971754..a6015d025c 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@@ -43,6 +43,7 @@ const NIL = '00000000-0000-0000-0000-000000000000';const TABS: EmailTab[] = ['important','noise',+ 'favorites','sent','scheduled','calendar',@@ -79,6 +80,42 @@ const TAG_SETS = [] as TagSetResponse[];describe('buildEmailQuery', () => {+ it('filters favorites on the server in both Soup transports, including inbox and read scope', () => {+ const args = buildEmailQuery(+ contextFor({+ tab: 'favorites',+ favoriteThreadIds: ['starred-a', 'starred-b'],+ inboxIds: ['inbox-a'],+ facets: { read: ['unread'] },+ })+ );+ expect(args.transport).toBeUndefined();+ expect(args.body.emailView).toBe('all');+ expect(serialize(args.body.ef)).toContain(+ serialize({ l: { ThreadId: 'starred-a' } })+ );+ const input = makeGraphqlSoupInput(args);+ expect(input.initial?.emailView).toBe('ALL');+ const filter = serialize(input.initial?.filters?.emailFilter);+ expect(filter).toContain(serialize({ literal: { threadId: 'starred-a' } }));+ expect(filter).toContain(serialize({ literal: { threadId: 'starred-b' } }));+ expect(filter).toContain(serialize({ literal: { owner: 'inbox-a' } }));+ expect(filter).toContain(serialize({ literal: { read: false } }));+ expect(filter).not.toContain('inboxVisible');+ });++ it('matches no email when favorites are empty or unresolved', () => {+ for (const favoriteThreadIds of [undefined, []]) {+ const args = buildEmailQuery(+ contextFor({ tab: 'favorites', favoriteThreadIds })+ );+ expect(args.body.ef).toEqual({ l: { ThreadId: NIL } });+ expect(makeGraphqlSoupInput(args).initial?.filters?.emailFilter).toEqual({+ tree: { literal: { threadId: NIL } },+ });+ }+ });+it('keeps a full admission batch below REST and GraphQL ingress recursion limits', () => {const ids = Array.from({ length: 100 },@@ -104,6 +141,7 @@ describe('buildEmailQuery', () => {expect(TABS.map((tab) => [tab, emailViewForTab(tab)])).toEqual([['important', 'inbox'],['noise', 'inbox'],+ ['favorites', 'all'],['sent', 'sent'],['scheduled', 'drafts'],['calendar', 'all'],@@ -264,6 +302,28 @@ describe('buildEmailSearchRequest', () => {expect(body.filters.email_filters).toEqual({});});+ it('restricts search and retained results to current favorites before pagination', () => {+ const context = contextFor({+ tab: 'favorites',+ favoriteThreadIds: ['starred-a', 'starred-b'],+ inboxIds: ['inbox-a'],+ });+ expect(+ buildEmailSearchRequest(context, search).body.filters?.email_filters+ ).toEqual({+ email_thread_ids: ['starred-a', 'starred-b'],+ link_ids: ['inbox-a'],+ });+ expect(+ buildEmailSearchRequest(context, search, ['starred-b', 'removed']).body+ .filters?.email_filters?.email_thread_ids+ ).toEqual(['starred-b']);+ expect(+ requestFor({ tab: 'favorites', favoriteThreadIds: [] }).filters+ .email_filters?.email_thread_ids+ ).toEqual([NIL]);+ });+it('mirrors the tab scoping the list applies', () => {const filtersFor = (tab: EmailTab) =>requestFor({ tab }).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.tsindex 85049ab2ea..b8716e33cf 100644--- a/apps/web/src/features/email-view/queries/email-query.ts+++ b/apps/web/src/features/email-view/queries/email-query.ts@@ -19,6 +19,8 @@ export type EmailQueryContext = {inboxIds: string[] | undefined;facets: FacetSelection;facetContext: EmailFacetContext;+ /** Macro favorites, resolved before listing or searching the Favorites tab. */+ favoriteThreadIds?: readonly string[];};/**@@ -33,27 +35,28 @@ 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('calendar', 'shared', 'all', () => 'all')+ .with('favorites', 'calendar', 'shared', 'all', () => 'all').exhaustive();const anyThread = (): TargetExpr => clause.not(clause.eq('threadId', NIL_UUID));// Preserve a shallow tree through both the REST and GraphQL AST compilers.// A flat 100-way clause.or becomes a linear tree and exceeds JSON ingress depth.-function admittedThreads(ids: readonly string[]): TargetExpr {+function threadIdsClause(ids: readonly string[]): TargetExpr {if (ids.length < 2) return clause.eq('threadId', ids[0] ?? NIL_UUID);const middle = Math.floor(ids.length / 2);return clause.or(- admittedThreads(ids.slice(0, middle)),- admittedThreads(ids.slice(middle))+ threadIdsClause(ids.slice(0, middle)),+ threadIdsClause(ids.slice(middle)));}// Deliberately no `!isDraft` exclusion here: `isDraft` is thread-level, so// excluding it hid whole conversations the moment a reply draft saved (#5940).-function tabClause(tab: EmailTab): TargetExpr {+function tabClause(context: EmailQueryContext): TargetExpr {return (- match(tab)+ match(context.tab)+ .with('favorites', () => threadIdsClause(context.favoriteThreadIds ?? [])).with('important', () =>clause.and(clause.eq('emailImportance', true),@@ -98,9 +101,9 @@ export function buildEmailQuery(context: EmailQueryContext,admittedIds?: readonly string[]): SoupAstItemsQueryArgs {- const expressions = [tabClause(context.tab)];+ const expressions = [tabClause(context)];if (admittedIds) {- expressions.push(admittedThreads(admittedIds));+ expressions.push(threadIdsClause(admittedIds));}const inbox = inboxClause(context.inboxIds);if (inbox) expressions.push(inbox);diff --git a/apps/web/src/features/email-view/queries/email-search.ts b/apps/web/src/features/email-view/queries/email-search.tsindex 82d048c217..90437c35a8 100644--- a/apps/web/src/features/email-view/queries/email-search.ts+++ b/apps/web/src/features/email-view/queries/email-search.ts@@ -37,7 +37,7 @@ function tabFilters(tab: EmailTab): EmailFilters {shared: 'exclude' as const,})).with('shared', () => ({ shared: 'only' as const }))- .with('drafts', 'scheduled', 'sent', 'all', () => ({}))+ .with('favorites', 'drafts', 'scheduled', 'sent', 'all', () => ({})).exhaustive();}@@ -75,13 +75,20 @@ export function buildEmailSearchRequest(search: SoupSearchRequest,admittedIds?: readonly string[]): SearchSoupQueryArgs {+ // Both discovery and retained unread results must stay within favorites.+ const threadIds =+ context.tab === 'favorites'+ ? (context.favoriteThreadIds ?? []).filter(+ (id) => admittedIds === undefined || admittedIds.includes(id)+ )+ : admittedIds;const emailFilters: EmailFilters = {...tabFilters(context.tab),...facetFilters(admittedIds ? { ...context.facets, read: [] } : context.facets),- ...(admittedIds- ? { email_thread_ids: admittedIds.length ? [...admittedIds] : [NIL_UUID] }+ ...(threadIds+ ? { email_thread_ids: threadIds.length ? [...threadIds] : [NIL_UUID] }: {}),};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.tsindex 8c1272c410..73e69bbe4a 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@@ -16,6 +16,10 @@ import {} from './use-email-query';const searchQueryMock = vi.hoisted(() => vi.fn());+const favoritesQueryMock = vi.hoisted(() => vi.fn());+vi.mock('@queries/favorites/favorites', () => ({+ useFavoritesQuery: favoritesQueryMock,+}));const scheduledRows = vi.hoisted(() => ({current: [] as EmailDataSourceItem[],}));@@ -113,6 +117,27 @@ function mount(search = '') {const [placeholder, setPlaceholder] = createSignal(false);const [fetching, setFetching] = createSignal(false);const [tagSetsReady, setTagSetsReady] = createSignal(true);+ const [favoriteIds, setFavoriteIds] = createSignal<string[] | undefined>(+ []+ );+ const [favoritesError, setFavoritesError] = createSignal<Error>();+ favoritesQueryMock.mockReturnValue({+ get isSuccess() {+ return favoriteIds() !== undefined && !favoritesError();+ },+ get isError() {+ return !!favoritesError();+ },+ get error() {+ return favoritesError();+ },+ get data() {+ if (favoriteIds() === undefined)+ throw new Error('Read pending favorites');+ return { favorites: favoriteIds()!.map((entityId) => ({ entityId })) };+ },+ refetch: vi.fn(async () => {}),+ });const [searchEntities, setSearchDiscoveryEntities] = createSignal([email('search'),]);@@ -218,6 +243,8 @@ function mount(search = '') {setPlaceholder,setFetching,setTagSetsReady,+ setFavoriteIds,+ setFavoritesError,searchEntities,setSearchEntities,setSearchDiscoveryEntities,@@ -231,10 +258,57 @@ function mount(search = '') {describe('Email list query transitions', () => {beforeEach(() => {vi.clearAllMocks();+ favoritesQueryMock.mockReturnValue({+ isSuccess: true,+ isError: false,+ data: { favorites: [] },+ error: null,+ refetch: vi.fn(async () => {}),+ });scheduledRows.current = [];});afterEach(() => dispose?.());+ it('waits for favorites and uses only their IDs in the Soup query', () => {+ const { source, setState, setEntities, setFavoriteIds } = mount();+ setFavoriteIds(undefined);+ setState('tab', 'favorites');+ setEntities([email('starred'), email('ordinary')]);+ expect(source.isLoading()).toBe(true);+ expect(ids(source)).toEqual([]);+ expect(vi.mocked(useSoupAstItemsQuery).mock.calls[0][1]?.().enabled).toBe(+ false+ );+ setFavoriteIds(['starred']);+ expect(source.isLoading()).toBe(false);+ expect(ids(source)).toEqual(['starred']);+ expect(vi.mocked(useSoupAstItemsQuery).mock.calls[0][1]?.().enabled).toBe(+ true+ );+ expect(+ vi.mocked(useSoupAstItemsQuery).mock.calls[0][0]().transport+ ).toBeUndefined();+ expect(+ JSON.stringify(vi.mocked(useSoupAstItemsQuery).mock.calls[0][0]().body.ef)+ ).toContain('starred');+ expect(favoritesQueryMock).toHaveBeenCalledWith({+ entityType: ['email_thread'],+ });+ setFavoriteIds([]);+ expect(ids(source)).toEqual([]);+ });++ it('surfaces a favorites failure without an endless loading state', () => {+ const { source, setState, setFavoriteIds, setFavoritesError } = mount();+ setFavoriteIds(undefined);+ setState('tab', 'favorites');+ const error = new Error('Favorites unavailable');+ setFavoritesError(error);+ expect(source.error()).toBe(error);+ expect(source.isLoading()).toBe(false);+ expect(ids(source)).toEqual([]);+ });+it('lists the scheduled source on the Scheduled tab instead of soup rows', () => {scheduledRows.current = [{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.tsindex 888a12812c..b3cee4ded8 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@@ -20,6 +20,7 @@ import {isEmailEntity,type WithNotification,} from '@entity';+import { useFavoritesQuery } from '@queries/favorites/favorites';import { useSoupAstItemsQuery } from '@queries/soup/items';import { useSearchSoupQuery } from '@queries/soup/search';import type { TagSetResponse } from '@service-properties/generated/schemas/tagSetResponse';@@ -67,6 +68,7 @@ function emailMatchesTab(.with('important','noise',+ 'favorites','sent','scheduled','calendar',@@ -94,6 +96,20 @@ export function useEmailDataSource(const userId = useUserId();const scheduled = useScheduledEmailSource(state);const showsScheduled = () => state.tab === 'scheduled';+ const showsFavorites = () => state.tab === 'favorites';+ // Uses GraphQL favorites with enable-graphql-soup, REST otherwise. Guard+ // the data read so a pending favorites request cannot suspend the view.+ const favorites = useFavoritesQuery({ entityType: ['email_thread'] });+ const favoriteThreadIds = createMemo(() =>+ favorites.isSuccess+ ? [+ ...new Set(+ favorites.data?.favorites.map((favorite) => favorite.entityId) ?? []+ ),+ ].sort()+ : undefined+ );+ const favoriteIds = createMemo(() => new Set(favoriteThreadIds()));const facetContext = createMemo((): EmailFacetContext => createTagFacetContext(options.tagSets())@@ -105,21 +121,23 @@ export function useEmailDataSource(inboxIds: state.inboxIds === undefined ? undefined : [...state.inboxIds],facets: state.facets,facetContext: facetContext(),+ ...(showsFavorites() ? { favoriteThreadIds: favoriteThreadIds() } : {}),}));// Discovery must apply read status before pagination, not scan through// pages of read mail to find an unread thread.const queryArgs = createMemo(() => buildEmailQuery(queryContext()));- // A restored tag selection waits for the tag sets rather than listing the- // whole mailbox and then narrowing.- const facetsReady = () => tagFacetReady(state.facets, options.tagSetsReady());- const sourceEnabled = () => facetsReady() && state.tab !== 'scheduled';+ // Resolve tags and favorite membership before either list or search fetches.+ const filtersReady = () =>+ tagFacetReady(state.facets, options.tagSetsReady()) &&+ (!showsFavorites() || favoriteThreadIds() !== undefined);+ const sourceEnabled = () => filtersReady() && state.tab !== 'scheduled';const query = useSoupAstItemsQuery(queryArgs, () => ({enabled: sourceEnabled(),}));const isListPending = () =>- !facetsReady() || query.isLoading || query.isPlaceholderData;+ !filtersReady() || query.isLoading || query.isPlaceholderData;const selectEmails = (entities: EntityData[]): EmailEntity[] => {const context = queryContext();@@ -127,6 +145,7 @@ export function useEmailDataSource(for (const entity of entities) {if (!isEmailEntity(entity)) continue;if (!emailMatchesTab(entity, context.tab, userId())) continue;+ if (showsFavorites() && !favoriteIds().has(entity.id)) continue;selected.push(entity);}@@ -137,8 +156,7 @@ export function useEmailDataSource(// every search result comes from the search service.const search = createSearchState({text: () => state.search,- // Held back with the list query so a tag selection is not stripped from- // the request before the sets that resolve it have loaded.+ // Wait for the same tag and favorites scope as the list query.enabled: sourceEnabled,disableLocalSearch: () => true,buildRequest: (request) => buildEmailSearchRequest(queryContext(), request),@@ -146,7 +164,7 @@ export function useEmailDataSource(const rawEntities = createMemo<EntityData[]>(() => {// Disabled searches can retain placeholder data for the previous facets.- if (!facetsReady()) return [];+ if (!filtersReady()) return [];if (!search.isSearching()) {// Previous-tab/inbox rows are not valid results for the new query.@@ -209,7 +227,7 @@ export function useEmailDataSource();const admissionBatches = createMemo(- () => (facetsReady() ? emailAdmissionBatches(admitted().items) : []),+ () => (filtersReady() ? emailAdmissionBatches(admitted().items) : []),[],{equals: (left, right) =>@@ -220,7 +238,7 @@ export function useEmailDataSource(const retainedQueries = indexArray(admissionBatches, (ids) => {const list = useSoupAstItemsQuery(() => buildEmailQuery(queryContext(), ids()),- () => ({ enabled: facetsReady() && !search.isSearching() })+ () => ({ enabled: filtersReady() && !search.isSearching() }));const searchQuery = useSearchSoupQuery(() =>@@ -232,7 +250,7 @@ export function useEmailDataSource(},ids()),- () => ({ enabled: facetsReady() && search.usesServiceSearch() })+ () => ({ enabled: filtersReady() && search.usesServiceSearch() }));return {ids,@@ -255,7 +273,7 @@ export function useEmailDataSource(const publication = createMemo<RetainedEmailPublication>((previous) => {const currentScope = scope();- if (!facetsReady() || (!search.isSearching() && isListPending())) {+ if (!filtersReady() || (!search.isSearching() && isListPending())) {return { scope: currentScope, items: [], resolved: new Map() };}if (!hasReadFilter()) {@@ -305,6 +323,7 @@ export function useEmailDataSource(const usesServiceSearch = search.usesServiceSearch;const hasMore = () => {+ if (!filtersReady()) return false;if (usesServiceSearch()) return search.hasNextPage();return !isListPending() && query.hasNextPage;};@@ -334,7 +353,8 @@ export function useEmailDataSource(});const isLoading = () => {- if (!facetsReady()) return true;+ if (showsFavorites() && favorites.isError) return false;+ if (!filtersReady()) return true;if (!search.isSearching()) {// A query held back for the tag sets is loading, not empty.return isListPending();@@ -355,6 +375,7 @@ export function useEmailDataSource(error: () => {if (showsScheduled()) return scheduled.error();return (+ (showsFavorites() ? favorites.error : undefined) ??(usesServiceSearch() ? search.error() : query.error) ??retainedQueries().map((lookup) => lookup.error())@@ -377,6 +398,7 @@ export function useEmailDataSource(await scheduled.refresh();return;}+ if (showsFavorites()) await favorites.refetch();await Promise.all([usesServiceSearch() ? search.refetch() : query.refresh(),...retainedQueries().map((lookup) => lookup.refresh()),diff --git a/apps/web/src/features/email-view/types.ts b/apps/web/src/features/email-view/types.tsindex 7147ad5d96..63d41f918f 100644--- a/apps/web/src/features/email-view/types.ts+++ b/apps/web/src/features/email-view/types.ts@@ -1,13 +1,13 @@import type { FacetSelection } from '@app/features/soup';/**- * Tab ids match the legacy mail view's `VIEW_TAB_LISTS.mail` values (`important`- * is the Signal tab) so entity actions keyed on `${view}-${tab}` — mark done,- * the sender-policy bucket — keep working unchanged.+ * 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'| 'calendar'diff --git a/apps/web/src/features/entity/composed/ListEntity.tsx b/apps/web/src/features/entity/composed/ListEntity.tsxindex 3c4218859f..9142fbf2c3 100644--- a/apps/web/src/features/entity/composed/ListEntity.tsx+++ b/apps/web/src/features/entity/composed/ListEntity.tsx@@ -21,6 +21,7 @@ import {import { mergeRefs } from '@solid-primitives/refs';import { cn } from '@ui';import {+ children,createEffect,createMemo,createSignal,@@ -93,6 +94,8 @@ export function MaybeEntityRow(props: {export function ListEntity(props: ListEntityProps) {// Legacy Soup callers do not pass row behavior explicitly yet.const soupView = useMaybeSoupView();+ const rowActions = children(() => props.actions);+ const leadingAction = children(() => props.leadingAction);const unread = () => unreadFilterFn(props.entity);const isShared = useIsShared(props.entity);@@ -148,6 +151,8 @@ export function ListEntity(props: ListEntityProps) {const layoutProps = (): LayoutProps => ({entity: props.entity,+ actions: !isTouchDevice() ? rowActions() : undefined,+ leadingAction: !isTouchDevice() ? leadingAction() : undefined,authorDisplayName: props.authorDisplayName,checked: props.checked,hideCheckbox: props.hideCheckbox,@@ -219,6 +224,8 @@ export function ListEntity(props: ListEntityProps) {props.highlighted && !props.checked && !isTouchDevice(),'hover:bg-list-hover':!props.highlighted && !props.checked && !isTouchDevice(),+ 'focus-within:bg-list-hover':+ !!rowActions() && !props.highlighted && !props.checked,})}onMouseMove={props.onMouseMove}diff --git a/apps/web/src/features/entity/composed/list-entity/narrow-layout.tsx b/apps/web/src/features/entity/composed/list-entity/narrow-layout.tsxindex 8d9255e0f8..c5b49b5795 100644--- a/apps/web/src/features/entity/composed/list-entity/narrow-layout.tsx+++ b/apps/web/src/features/entity/composed/list-entity/narrow-layout.tsx@@ -16,6 +16,7 @@ import {} from './channel';import { EmailInboxChip } from './email';import { GithubAuthorBadge } from './foreign';+import { RowEnd } from './row-end';import { SOUP_ROW_CLASS } from './row-geometry';import { type LayoutProps, RowIndicator } from './shared';@@ -104,18 +105,20 @@ export function NarrowLayout(props: LayoutProps) {placement="timestamp"class="text-xs text-right text-ink-extra-muted font-light">- <Show- when={!isTaskEntity(props.entity)}- fallback={- <Entity.Properties- entity={props.entity}- maxUserStackUsers={0}- showCaret={false}- />- }- >- <Entity.Timestamp entity={props.entity} />- </Show>+ <RowEnd actions={props.actions} leadingAction={props.leadingAction}>+ <Show+ when={!isTaskEntity(props.entity)}+ fallback={+ <Entity.Properties+ entity={props.entity}+ maxUserStackUsers={0}+ showCaret={false}+ />+ }+ >+ <Entity.Timestamp entity={props.entity} />+ </Show>+ </RowEnd></Entity.Slot></Show></Entity.Layout>diff --git a/apps/web/src/features/entity/composed/list-entity/row-end.tsx b/apps/web/src/features/entity/composed/list-entity/row-end.tsxnew file mode 100644index 0000000000..a87c203149--- /dev/null+++ b/apps/web/src/features/entity/composed/list-entity/row-end.tsx@@ -0,0 +1,31 @@+import { cn } from '@ui';+import { type JSX, Show } from 'solid-js';++/** Only the persistent action adds width; quick actions reuse the date's space. */+export function RowEnd(props: {+ actions?: JSX.Element;+ leadingAction?: JSX.Element;+ children: JSX.Element;+}) {+ return (+ <div class="flex items-center justify-end gap-1">+ {props.leadingAction}+ <div class="grid items-center justify-items-end">+ <div+ class={cn(+ '[grid-area:1/1]',+ props.actions &&+ 'group-hover/entity:invisible group-focus-within/entity:invisible'+ )}+ >+ {props.children}+ </div>+ <Show when={props.actions}>+ <div class="[grid-area:1/1] opacity-0 pointer-events-none group-hover/entity:opacity-100 group-hover/entity:pointer-events-auto group-focus-within/entity:opacity-100 group-focus-within/entity:pointer-events-auto">+ {props.actions}+ </div>+ </Show>+ </div>+ </div>+ );+}diff --git a/apps/web/src/features/entity/composed/list-entity/shared.tsx b/apps/web/src/features/entity/composed/list-entity/shared.tsxindex 47a1a1af3b..f9a3166043 100644--- a/apps/web/src/features/entity/composed/list-entity/shared.tsx+++ b/apps/web/src/features/entity/composed/list-entity/shared.tsx@@ -28,6 +28,10 @@ export interface BaseListEntityProps<E extends EntityData = EntityData> {checked?: boolean;highlighted?: boolean;hovered?: boolean;+ /** Caller-owned quick actions, revealed on pointer hover or keyboard focus. */+ actions?: JSX.Element;+ /** Persistent status/action immediately before the timestamp. */+ leadingAction?: JSX.Element;hideContentHits?: boolean;/** Resolved app display name for a linked GitHub PR author, when available. */authorDisplayName?: string;@@ -58,6 +62,8 @@ const WIDE_BREAKPOINT = 512; // @lg container query = 32remexport interface LayoutProps {entity: WithNotification<EntityData>;+ actions?: JSX.Element;+ leadingAction?: JSX.Element;checked?: boolean;authorDisplayName?: string;hideCheckbox?: boolean;diff --git a/apps/web/src/features/entity/composed/list-entity/wide-layout.tsx b/apps/web/src/features/entity/composed/list-entity/wide-layout.tsxindex aaba5d9627..cbc5febc6b 100644--- a/apps/web/src/features/entity/composed/list-entity/wide-layout.tsx+++ b/apps/web/src/features/entity/composed/list-entity/wide-layout.tsx@@ -43,6 +43,7 @@ import {GithubPullRequestPills,} from './foreign';import { ReminderWideContent } from './reminder';+import { RowEnd } from './row-end';import { SOUP_ROW_CLASS } from './row-geometry';import type { LayoutProps } from './shared';@@ -79,7 +80,8 @@ export function WideLayout(props: LayoutProps) {// Drop the indicator column entirely when the checkbox is hidden so the// content isn't indented by an empty gutter.// A scheduled send's badge is wider than a date, so it sizes its column.- isEmailEntity(props.entity) && props.entity.scheduledSendTime+ props.actions ||+ (isEmailEntity(props.entity) && props.entity.scheduledSendTime)? props.hideCheckbox? 'grid-cols-[1fr_auto_auto]': 'grid-cols-[var(--soup-row-indicator-width)_1fr_auto_auto]'@@ -309,21 +311,23 @@ export function WideLayout(props: LayoutProps) {placement="timestamp"class="text-xs text-right text-ink-extra-muted font-medium">- <Show- when={- !props.hasNotifications &&- !(isChannelEntity(props.entity) && isSearchEntity(props.entity))- }- >- <Switch fallback={<Entity.Timestamp entity={props.entity} />}>- {/* The event's own date, not its sync time. */}- <Match- when={props.entity.type === 'calendar_event' && props.entity}- >- {(entity) => <CalendarStamp entity={entity()} />}- </Match>- </Switch>- </Show>+ <RowEnd actions={props.actions} leadingAction={props.leadingAction}>+ <Show+ when={+ !props.hasNotifications &&+ !(isChannelEntity(props.entity) && isSearchEntity(props.entity))+ }+ >+ <Switch fallback={<Entity.Timestamp entity={props.entity} />}>+ {/* The event's own date, not its sync time. */}+ <Match+ when={props.entity.type === 'calendar_event' && props.entity}+ >+ {(entity) => <CalendarStamp entity={entity()} />}+ </Match>+ </Switch>+ </Show>+ </RowEnd></Entity.Slot></Entity.Layout>);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.tsindex c9af4ab134..2c958c51f6 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@@ -118,7 +118,14 @@ function createAction() {describe('canExecuteMarkDoneOnView', () => {it('allows mark done on every thread-listing mail tab', () => {- for (const tab of ['important', 'noise', 'calendar', 'shared', 'all']) {+ for (const tab of [+ 'important',+ 'noise',+ 'favorites',+ 'calendar',+ 'shared',+ 'all',+ ]) {expect(canExecuteMarkDoneOnView('mail', tab)).toBe(true);}});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.tsindex 47fe57a45f..67866fb9ce 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@@ -37,6 +37,7 @@ const VALID_MARK_DONE_LIST_VIEWS: `${ListView}-${string}`[] = ['mail-important','mail-all','mail-noise',+ 'mail-favorites',// Calendar lists invite threads from the "all" email view, so done rows// stay in place and flip to the done state exactly like mail "All".'mail-calendar',diff --git a/apps/web/src/features/soup/createSoupEntityActions.ts b/apps/web/src/features/soup/createSoupEntityActions.tsindex 73f5ac404b..00e1424c4f 100644--- a/apps/web/src/features/soup/createSoupEntityActions.ts+++ b/apps/web/src/features/soup/createSoupEntityActions.ts@@ -91,6 +91,7 @@ export const viewedProjectIdFromContent = (content: {export function createSoupEntityActions(): {buildActionGroups: BuildActionGroups;+ isFavorited: (entity: EntityData) => boolean;} {const analytics = useAnalytics();const userId = useUserId();@@ -521,5 +522,5 @@ export function createSoupEntityActions(): {.map((items) => ({ items }));};- return { buildActionGroups };+ return { buildActionGroups, isFavorited: favoriteAction.isFavorited };}diff --git a/docs/AGENT_GUIDE/surfaces.md b/docs/AGENT_GUIDE/surfaces.mdindex fecf8b4215..b94b4d7daf 100644--- a/docs/AGENT_GUIDE/surfaces.md+++ b/docs/AGENT_GUIDE/surfaces.md@@ -304,11 +304,31 @@ Email's Tags sidebar uses the same [nested tag tree as Tasks](tasks.md#nested-siCarets and folder-only parents expand branches; actual tags select their exact IDand switch the mailbox to All. Parent selection does not include descendant tags.-Full email client. Tabs: `Signal` / `Noise` / `Sent` / `Calendar` / `Drafts` / `Shared` /+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 itshows `Connect your email` (Gmail/Google Workspace OAuth) — most functionality needs aconnected account. Search is `Ctrl+F` within the surface.+`Favorites`, directly below Noise, lists starred Macro emails across Signal,+Noise, and archived mail. It respects the selected inboxes and filters; search+within the tab is also restricted to favorites. Removing a star removes the row+from this view. The tab persists across reloads. With `enable-graphql-soup` on,+favorite membership comes from the filtered GraphQL favorites query, then thread+IDs scope the paginated GraphQL Soup query. With the flag off, the same scope+uses the REST queries. An empty favorites list shows `No favorite emails`.++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+**Open command menu** for that email. The star stays in place; archive and commands+replace the timestamp within its existing space. Archived rows offer+**Unarchive email**; the archive control is disabled in tabs that do not support+Mark Done. The icons also appear when a button receives keyboard focus. Clicking+an icon neither opens the thread nor applies the action to other selected rows.+Touch devices retain the swipe actions.+Search results use the same reserved column, with actions aligned to the first+line; snippets, highlighted matches, and expanded hits remain unobstructed.+When switching email tabs or inboxes, the list shows current-query cached resultsor a scoped `Loading email` spinner until they arrive—not the previous tab's rowsunder the new heading. Active searches also hide retained results and show loading