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.

fix(email): address Outlook QA findings from dev (#8713)

teo7b47f9165e07
diff --git a/apps/web/src/features/calendar-team/components/team-sharing-settings.tsx b/apps/web/src/features/calendar-team/components/team-sharing-settings.tsx
index 6269ad5c9e..c975ff45ef 100644
--- a/apps/web/src/features/calendar-team/components/team-sharing-settings.tsx
+++ b/apps/web/src/features/calendar-team/components/team-sharing-settings.tsx
@@ -49,7 +49,7 @@ export function TeamSharingSettings(props: {
<>
<SettingsSection
title="Team sharing"
- description="What teammates can see in Macro. Google Calendar permissions stay the same."
+ description="What teammates can see in Macro. Sharing in Google Calendar or Outlook stays the same."
>
<SettingsCard>
<Show
diff --git a/apps/web/src/features/calendar/components/connected-calendars.tsx b/apps/web/src/features/calendar/components/connected-calendars.tsx
index 5a8c333aa4..3d7927e020 100644
--- a/apps/web/src/features/calendar/components/connected-calendars.tsx
+++ b/apps/web/src/features/calendar/components/connected-calendars.tsx
@@ -48,7 +48,7 @@ export function ConnectedCalendars(props: {
>
<SettingsCard>
<SettingsRow
- label="Google Calendar"
+ label="Calendar accounts"
description={
<Show
when={accountNeedingPermission()}
diff --git a/apps/web/src/features/email-message/core/email-user.test.ts b/apps/web/src/features/email-message/core/email-user.test.ts
new file mode 100644
index 0000000000..16373ca833
--- /dev/null
+++ b/apps/web/src/features/email-message/core/email-user.test.ts
@@ -0,0 +1,19 @@
+import { describe, expect, it } from 'vitest';
+import { getRecipientDisplayName } from './email-user';
+
+describe('getRecipientDisplayName', () => {
+ it("names the viewer's own address Me whatever its case", () => {
+ expect(
+ getRecipientDisplayName(
+ { email: '[email protected]', name: 'Viewer Person' },
+ )
+ ).toBe('Me');
+ });
+
+ it('does not call an addressless recipient Me while the viewer is unknown', () => {
+ expect(getRecipientDisplayName({ name: 'Alex Doe' }, undefined)).toBe(
+ 'Alex'
+ );
+ });
+});
diff --git a/apps/web/src/features/email-message/core/email-user.ts b/apps/web/src/features/email-message/core/email-user.ts
index 353ffda143..6e68c4722a 100644
--- a/apps/web/src/features/email-message/core/email-user.ts
+++ b/apps/web/src/features/email-message/core/email-user.ts
@@ -2,17 +2,12 @@ import type { EmailMessage } from '@app/features/email-message/core/email-messag
import { getFirstName } from './name';
-/**
- * Check if a message is from the current user
- */
-function isMessageFromCurrentUser(
- message: EmailMessage,
- currentUserEmail?: string
+export function isViewerAddress(
+ address: string | null | undefined,
+ viewerEmail: string | undefined
): boolean {
- if (!currentUserEmail) return false;
- const fromEmail = message.from?.email?.toLowerCase();
- const userEmail = currentUserEmail.toLowerCase();
- return fromEmail !== undefined && fromEmail === userEmail;
+ if (!address || !viewerEmail) return false;
+ return address.toLowerCase() === viewerEmail.toLowerCase();
}
/**
@@ -22,7 +17,7 @@ export function getSenderDisplayName(
message: EmailMessage,
currentUserEmail?: string
): string {
- if (isMessageFromCurrentUser(message, currentUserEmail)) {
+ if (isViewerAddress(message.from?.email, currentUserEmail)) {
return 'Me';
}
const from = message.from;
@@ -53,7 +48,7 @@ export function getRecipientDisplayName(
recipient: Recipient,
currentUserEmail?: string
): string {
- if (recipient.email === currentUserEmail) return 'Me';
+ if (isViewerAddress(recipient.email, currentUserEmail)) return 'Me';
return recipient.name
? getFirstName(recipient.name)
: (recipient.email?.split('@')[0] ?? '');
diff --git a/apps/web/src/features/email-thread/core/thread-messages.test.ts b/apps/web/src/features/email-thread/core/thread-messages.test.ts
index 6d74541c2d..2c844d6c36 100644
--- a/apps/web/src/features/email-thread/core/thread-messages.test.ts
+++ b/apps/web/src/features/email-thread/core/thread-messages.test.ts
@@ -56,6 +56,20 @@ describe('thread message selection', () => {
).toBeUndefined();
expect(selectThreadSender(thread([]))).toBeUndefined();
});
+ it('targets no sender while the viewer is unknown, so a sender action cannot hit the viewer', () => {
+ const own = message('own', {
+ from: { email: '[email protected]' },
+ internal_date_ts: '2026-09-01T00:00:00Z',
+ });
+ const reply = message('reply', {
+ from: { email: '[email protected]' },
+ internal_date_ts: '2026-09-02T00:00:00Z',
+ });
+ expect(selectThreadSender(thread([own, reply]))).toBeUndefined();
+ expect(selectThreadSender(thread([own, reply]), '[email protected]')).toBe(
+ );
+ });
it('never offers a deleted draft as the reply draft or the draft to edit', () => {
const parent = message('parent');
const live = message('live', {
diff --git a/apps/web/src/features/email-thread/core/thread-messages.ts b/apps/web/src/features/email-thread/core/thread-messages.ts
index 6927c3e034..08cc1b8807 100644
--- a/apps/web/src/features/email-thread/core/thread-messages.ts
+++ b/apps/web/src/features/email-thread/core/thread-messages.ts
@@ -1,12 +1,12 @@
import type { EmailMessage } from '../../email-message/core/email-message';
+import { isViewerAddress } from '../../email-message/core/email-user';
import type { EmailThread } from './email-thread';
-/** Sender actions historically target the earliest sender other than the viewer. */
export function selectThreadSender(thread: EmailThread, viewerEmail?: string) {
- const viewer = viewerEmail?.toLowerCase();
+ if (!viewerEmail) return undefined;
return selectThreadMessages(thread).messages.find(
(message) =>
- message.from?.email && message.from.email.toLowerCase() !== viewer
+ message.from?.email && !isViewerAddress(message.from.email, viewerEmail)
)?.from?.email;
}
diff --git a/apps/web/src/features/email-thread/email-thread.test.tsx b/apps/web/src/features/email-thread/email-thread.test.tsx
index 74db6273ff..e167d634a4 100644
--- a/apps/web/src/features/email-thread/email-thread.test.tsx
+++ b/apps/web/src/features/email-thread/email-thread.test.tsx
@@ -1,11 +1,12 @@
import { cleanup, fireEvent, render, screen } from '@solidjs/testing-library';
-import { createSignal } from 'solid-js';
+import { createSignal, type ParentProps } from 'solid-js';
import { afterEach, describe, expect, it, vi } from 'vitest';
import type { EmailComposeContextOptions } from '../email-compose/compose-adapter';
import { createComposeContext } from '../email-compose/tests/capabilities';
+import { useEmailThreadViewContext } from './context/email-thread-view-context';
import { EmailThread } from './email-thread';
import { createThreadContext, message, thread } from './tests/fixtures';
-import type { EmailThreadSurfaceProps } from './views/email-thread-surface';
+import { EmailParticipants } from './views/email-participants';
const mocks = vi.hoisted(() => ({
query: vi.fn(),
@@ -14,6 +15,10 @@ const mocks = vi.hoisted(() => ({
composeOptions: vi.fn<(options: EmailComposeContextOptions) => void>(),
started: [] as Promise<void>[],
}));
+vi.mock('@core/component/UserIcon', () => ({ UserIcon: () => <span /> }));
+vi.mock('@app/features/email-message/components/email-user-tooltip', () => ({
+ EmailUserTooltip: (props: ParentProps) => <>{props.children}</>,
+}));
vi.mock('@property/tags', () => ({ InlineFetchedEntityTagsPill: () => null }));
vi.mock('@queries/email/thread', () => ({ useThreadQuery: mocks.query }));
vi.mock('@queries/email/draft-cache', () => ({
@@ -30,6 +35,27 @@ vi.mock('@core/context/user', () => ({
useUserContext: () => ({ isLoading: () => false }),
}));
vi.mock('@core/user', () => ({ useContacts: () => () => [] }));
+const [linksLoaded, setLinksLoaded] = createSignal(true);
+vi.mock('@queries/email/link', () => ({
+ useEmailLinksQuery: () => ({
+ get isPending() {
+ return !linksLoaded();
+ },
+ get isLoading() {
+ return !linksLoaded();
+ },
+ get data() {
+ return linksLoaded()
+ ? {
+ links: [
+ { id: 'primary', email_address: '[email protected]' },
+ { id: 'inbox', email_address: '[email protected]' },
+ ],
+ }
+ : undefined;
+ },
+ }),
+}));
vi.mock('../email-compose/compose-adapter', () => ({
createEmailComposeContext: (options: EmailComposeContextOptions) => {
mocks.composeOptions(options);
@@ -54,12 +80,13 @@ vi.mock('./calendar-invitation', () => ({
vi.mock('./thread-action-adapter', () => ({
createThreadActionAdapter: vi.fn(),
}));
-vi.mock('./views/email-thread-surface', () => ({
- EmailThreadSurface: (props: EmailThreadSurfaceProps) => {
- const source = props.context.thread.source;
+vi.mock('./views/email-thread', () => ({
+ EmailThreadView: () => {
+ const source = useEmailThreadViewContext().thread.source;
mocks.source(source);
return (
<div>
+ <EmailParticipants />
<span data-testid="body">
{source.thread()?.messages[0]?.body_text}
</span>
@@ -76,6 +103,7 @@ vi.mock('./views/email-thread-surface', () => ({
afterEach(() => {
cleanup();
+ setLinksLoaded(true);
vi.clearAllMocks();
mocks.started.length = 0;
});
@@ -129,4 +157,32 @@ describe('email thread query ownership', () => {
expect(mocks.clearDraft).toHaveBeenCalledWith('thread');
await Promise.all(mocks.started);
});
+
+ it("labels the thread's inbox address, not the Macro login, as Me", () => {
+ setLinksLoaded(false);
+ const source = createThreadContext({
+ thread: () =>
+ thread([
+ message('first', {
+ from: { email: '[email protected]' },
+ to: [{ email: '[email protected]' }],
+ }),
+ ]),
+ }).source;
+ render(() => (
+ <EmailThread
+ title="Subject"
+ threadId={source.id}
+ source={source}
+ threadTransport={() => 'graphql'}
+ />
+ ));
+ expect(screen.queryByText('Me')).toBeNull();
+ setLinksLoaded(true);
+ const participants = screen
+ .getAllByRole('listitem')
+ .map((node) => node.textContent)
+ .filter(Boolean);
+ expect(participants).toEqual(['viewer', 'Me']);
+ });
});
diff --git a/apps/web/src/features/email-thread/email-thread.tsx b/apps/web/src/features/email-thread/email-thread.tsx
index e44a1c6ff8..9a60b04e0b 100644
--- a/apps/web/src/features/email-thread/email-thread.tsx
+++ b/apps/web/src/features/email-thread/email-thread.tsx
@@ -1,11 +1,12 @@
import { useGlobalNotificationSource } from '@components/app/GlobalAppState';
-import { useEmail, useUserContext } from '@core/context/user';
+import { useUserContext } from '@core/context/user';
import { isTouchDevice } from '@core/mobile/isTouchDevice';
import { useContacts } from '@core/user';
import { fireAndForget } from '@core/util/fireAndForget';
import { createEffectOnEntityTypeNotification } from '@notifications';
import { InlineFetchedEntityTagsPill } from '@property/tags';
import { clearSavedDraftThreadCache } from '@queries/email/draft-cache';
+import { useInboxEmail } from '@queries/email/inbox-email';
import type { ThreadQueryTransport } from '@queries/email/thread';
import {
type Accessor,
@@ -64,12 +65,12 @@ export function EmailThread(props: EmailThreadProps) {
// mounting the body does not start a second disk read/network request.
const [calendarPreferences] = useCalendarPreferences();
const contacts = useContacts();
- const viewerEmail = useEmail();
const user = useUserContext();
const compose = createEmailComposeContext({
threadTransport: props.threadTransport,
});
const source = createOptimisticThreadSend(props.source, compose);
+ const viewerEmail = useInboxEmail(() => source.thread()?.link_id);
const threadContext: EmailThreadContext = {
source,
viewerEmail,
diff --git a/apps/web/src/features/email-thread/thread-action-adapter.tsx b/apps/web/src/features/email-thread/thread-action-adapter.tsx
index 68bc595869..5ece4a4ead 100644
--- a/apps/web/src/features/email-thread/thread-action-adapter.tsx
+++ b/apps/web/src/features/email-thread/thread-action-adapter.tsx
@@ -1,5 +1,5 @@
-import { useEmail } from '@core/context/user';
import { fireAndForget } from '@core/util/fireAndForget';
+import { useInboxEmail } from '@queries/email/inbox-email';
import { useNonPrimaryEmailLinkIdHeader } from '@queries/email/link';
import {
blockSenderWithToast,
@@ -23,11 +23,11 @@ export function createThreadActionAdapter(
toHeaderLinkId
);
const read = createThreadReadAdapter(threadId, threadSource, toHeaderLinkId);
- const currentUserEmail = useEmail();
+ const viewerEmail = useInboxEmail(() => threadSource()?.link_id);
const getSenderEmail = (): string | undefined => {
const thread = threadSource();
- return thread ? selectThreadSender(thread, currentUserEmail()) : undefined;
+ return thread ? selectThreadSender(thread, viewerEmail()) : undefined;
};
const blockSender = () => {
diff --git a/apps/web/src/features/email-thread/views/email-participants.test.tsx b/apps/web/src/features/email-thread/views/email-participants.test.tsx
index 29fec2a75d..528bf040d8 100644
--- a/apps/web/src/features/email-thread/views/email-participants.test.tsx
+++ b/apps/web/src/features/email-thread/views/email-participants.test.tsx
@@ -13,6 +13,45 @@ vi.mock('@app/features/email-message/components/email-user-tooltip', () => ({
EmailUserTooltip: (props: ParentProps) => <>{props.children}</>,
}));
+const renderParticipants = (
+ messages: ReturnType<typeof message>[],
+ viewerEmail: () => string | undefined
+) =>
+ render(() => {
+ const context = {
+ ...createThreadContext({ thread: () => thread(messages) }),
+ viewerEmail,
+ };
+ return (
+ <EmailThreadViewProvider
+ value={{
+ thread: context,
+ compose: createComposeContext(),
+ rendering: {},
+ }}
+ >
+ <EmailThreadStateProvider value={createEmailThreadState(context)}>
+ <EmailParticipants />
+ </EmailThreadStateProvider>
+ </EmailThreadViewProvider>
+ );
+ });
+
+it("labels the viewer's address as Me whatever its case", () => {
+ const view = renderParticipants(
+ [
+ message('sent', {
+ from: { email: '[email protected]', name: 'Sender' },
+ to: [{ email: '[email protected]' }],
+ }),
+ ],
+ );
+ expect(view.getAllByRole('listitem').map((node) => node.textContent)).toEqual(
+ ['Sender', 'Me']
+ );
+});
+
it('keeps participant order and nodes through draft creation, deletion and refetches', () => {
const sent = message('sent', {
from: { email: '[email protected]', name: 'Sender' },
diff --git a/apps/web/src/features/email-thread/views/email-participants.tsx b/apps/web/src/features/email-thread/views/email-participants.tsx
index d5e16075b6..86044d07d6 100644
--- a/apps/web/src/features/email-thread/views/email-participants.tsx
+++ b/apps/web/src/features/email-thread/views/email-participants.tsx
@@ -1,4 +1,5 @@
import { EmailUserTooltip } from '@app/features/email-message/components/email-user-tooltip';
+import { isViewerAddress } from '@app/features/email-message/core/email-user';
import { UserIcon, type UserIconProps } from '@core/component/UserIcon';
import { emailToMacroId } from '@core/user/macroId';
import { Key } from '@solid-primitives/keyed';
@@ -65,7 +66,7 @@ export function EmailParticipants() {
);
const getDisplayName = (p: Participant) => {
- if (p.email === currentUserEmail()) return 'Me';
+ if (isViewerAddress(p.email, currentUserEmail())) return 'Me';
if (p.name) return p.name.split(' ')[0];
return p.email.split('@')[0];
};
diff --git a/apps/web/src/features/entity/extractors/entity-email-participants.tsx b/apps/web/src/features/entity/extractors/entity-email-participants.tsx
index 420b7e3ad5..607b1c542d 100644
--- a/apps/web/src/features/entity/extractors/entity-email-participants.tsx
+++ b/apps/web/src/features/entity/extractors/entity-email-participants.tsx
@@ -1,9 +1,9 @@
+import { isViewerAddress } from '@app/features/email-message/core/email-user';
import { HoverCard } from '@core/component/HoverCard';
import { StaticMarkdown } from '@core/component/LexicalMarkdown/component/core/StaticMarkdown';
import { unifiedListMarkdownTheme } from '@core/component/LexicalMarkdown/theme';
import { toast } from '@core/component/Toast/Toast';
import { UserTooltip } from '@core/component/UserTooltip';
-import { useEmail } from '@core/context/user';
import { emailToMacroId, getDisplayName } from '@core/user';
import {
highlightTermsInText,
@@ -11,6 +11,7 @@ import {
} from '@core/util/searchHighlight';
import CopyIcon from '@icon/system/regular/copy.svg';
import { Telemetry } from '@macro-inc/observability';
+import { useInboxEmail } from '@queries/email/inbox-email';
import { Surface } from '@ui';
import { createSignal, For, Show } from 'solid-js';
import type { EmailEntity, EmailThreadParticipants } from '../types/entity';
@@ -98,11 +99,11 @@ function ParticipantWithTooltip(props: {
/**
* Resolves participants into display-ready objects, handling the "me" case
- * and filtering out the current user.
+ * and filtering out the viewer.
*/
function resolveParticipants(
participants: EmailThreadParticipants | undefined,
- userEmail: string | undefined,
+ viewerEmail: string | undefined,
getMacroDisplayName: (email: string) => string | undefined
): ResolvedParticipant[] {
if (!participants || participants.length === 0) return [];
@@ -112,7 +113,7 @@ function resolveParticipants(
for (const participant of participants) {
if (!participant.email) continue;
- if (userEmail && participant.email === userEmail) continue;
+ if (isViewerAddress(participant.email, viewerEmail)) continue;
const macroDisplayName = getMacroDisplayName(participant.email);
const displayName = resolveParticipantName(participant, macroDisplayName);
@@ -123,10 +124,12 @@ function resolveParticipants(
result.push({ participant, displayName });
}
- // Every participant was the current user (self-to-self threads, or
+ // Every participant was the viewer (self-to-self threads, or
// duplicate own-address rows from multi-inbox accounts) — show "me".
if (result.length === 0) {
- const self = participants.find((p) => userEmail && p.email === userEmail);
+ const self = participants.find((p) =>
+ isViewerAddress(p.email, viewerEmail)
+ );
if (self) return [{ participant: self, displayName: 'me' }];
}
@@ -187,7 +190,7 @@ function HiddenParticipantsTooltip(props: { hidden: ResolvedParticipant[] }) {
/** Get a nicely formatted list of participants from an email entity. */
export function EntityEmailParticipants(props: { entity: EmailEntity }) {
- const userEmail = useEmail();
+ const viewerEmail = useInboxEmail(() => props.entity.linkId);
const fetchDisplayName = (email: string) =>
getDisplayName(emailToMacroId(email));
@@ -195,7 +198,7 @@ export function EntityEmailParticipants(props: { entity: EmailEntity }) {
abbreviateParticipants(
resolveParticipants(
props.entity.participants,
- userEmail(),
+ viewerEmail(),
fetchDisplayName
)
);
@@ -203,7 +206,7 @@ export function EntityEmailParticipants(props: { entity: EmailEntity }) {
const allResolved = () =>
resolveParticipants(
props.entity.participants,
- userEmail(),
+ viewerEmail(),
fetchDisplayName
);
diff --git a/apps/web/src/features/entity/tests/entity-email-participants.test.tsx b/apps/web/src/features/entity/tests/entity-email-participants.test.tsx
index 58043838e6..694a9e9e37 100644
--- a/apps/web/src/features/entity/tests/entity-email-participants.test.tsx
+++ b/apps/web/src/features/entity/tests/entity-email-participants.test.tsx
@@ -17,6 +17,14 @@ vi.mock('@core/user', () => ({
vi.mock('@core/context/user', () => ({
useEmail: () => () => '[email protected]',
}));
+vi.mock('@queries/email/link', () => ({
+ useEmailLinksQuery: () => ({
+ isPending: false,
+ data: {
+ links: [{ id: 'outlook', email_address: '[email protected]' }],
+ },
+ }),
+}));
vi.mock('@core/component/HoverCard', () => ({
HoverCard: (props: { trigger: unknown }) => <>{props.trigger}</>,
}));
@@ -39,13 +47,15 @@ vi.mock('@core/component/LexicalMarkdown/theme', () => ({
afterEach(cleanup);
const emailEntity = (
- participants: NonNullable<EmailEntity['participants']>
+ participants: NonNullable<EmailEntity['participants']>,
+ linkId?: string
): EmailEntity =>
({
id: 'thread-1',
type: 'email',
name: 'Subject',
participants,
+ linkId,
}) as unknown as EmailEntity;
describe('EntityEmailParticipants', () => {
@@ -105,4 +115,33 @@ describe('EntityEmailParticipants', () => {
expect(container.textContent).toBe('Nathan Flurry');
});
+
+ it("treats the row's inbox address, not the Macro login, as me", () => {
+ const { container } = render(() => (
+ <EntityEmailParticipants
+ entity={emailEntity(
+ [{ email: '[email protected]', name: 'Riley Park' }],
+ 'outlook'
+ )}
+ />
+ ));
+
+ expect(container.textContent).toBe('me');
+ });
+
+ it("recognizes the row's inbox address whatever its case", () => {
+ const { container } = render(() => (
+ <EntityEmailParticipants
+ entity={emailEntity(
+ [
+ { email: '[email protected]', name: 'Riley Park' },
+ { email: '[email protected]' },
+ ],
+ 'outlook'
+ )}
+ />
+ ));
+
+ expect(container.textContent).toBe('Wolf Ryan');
+ });
});
diff --git a/apps/web/src/features/settings/browser-test/fixture.tsx b/apps/web/src/features/settings/browser-test/fixture.tsx
index 3ceba9afac..fb8a8e21b2 100644
--- a/apps/web/src/features/settings/browser-test/fixture.tsx
+++ b/apps/web/src/features/settings/browser-test/fixture.tsx
@@ -104,7 +104,7 @@ function Fixture() {
>
<SettingsSection
title="Accounts"
- description="Connect Gmail accounts and manage their sync with Macro."
+ description="Connect email accounts and manage their sync with Macro."
>
<SettingsCard>
@@ -123,7 +123,7 @@ function Fixture() {
</For>
<SettingsRow
label="Add another inbox"
- description="Connect more Gmail accounts."
+ description="Connect Gmail, Outlook.com, or Microsoft 365."
>
<Button variant="secondary" size="md">
Add account
diff --git a/apps/web/src/features/settings/email-settings.tsx b/apps/web/src/features/settings/email-settings.tsx
index ebffdc8166..c3e8da0164 100644
--- a/apps/web/src/features/settings/email-settings.tsx
+++ b/apps/web/src/features/settings/email-settings.tsx
@@ -77,7 +77,7 @@ export function EmailSettings() {
<SettingsRow
stackOnNarrow
label="Calendars"
- description="Manage the calendars connected to your Google accounts."
+ description="Manage the calendars connected to your email accounts."
>
<Button
variant="ghost"
diff --git a/apps/web/src/lib/core/component/RecipientSelector.test.tsx b/apps/web/src/lib/core/component/RecipientSelector.test.tsx
new file mode 100644
index 0000000000..a141e29592
--- /dev/null
+++ b/apps/web/src/lib/core/component/RecipientSelector.test.tsx
@@ -0,0 +1,109 @@
+import type { WithCustomUserInput } from '@core/user';
+import {
+ cleanup,
+ fireEvent,
+ render,
+ screen,
+ waitFor,
+} from '@solidjs/testing-library';
+import userEvent from '@testing-library/user-event';
+import { createSignal, type JSX } from 'solid-js';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+import { RecipientSelector } from './RecipientSelector';
+
+vi.mock('@core/context/user', () => ({
+ useEmail: () => () => '[email protected]',
+ useUserId: () => () => 'macro|[email protected]',
+}));
+vi.mock('@core/user/dmActivity', () => ({
+ useAugmentUserWithDmActivity: () => (user: unknown) => user,
+}));
+vi.mock('@core/component/HoverCard', () => ({
+ HoverCard: (props: { trigger: JSX.Element }) => <>{props.trigger}</>,
+}));
+vi.mock('@core/component/UserIcon', () => ({ UserIcon: () => null }));
+
+beforeEach(() => {
+ vi.stubGlobal(
+ 'ResizeObserver',
+ class {
+ observe() {}
+ unobserve() {}
+ disconnect() {}
+ }
+ );
+ Object.defineProperty(HTMLElement.prototype, 'scrollIntoView', {
+ configurable: true,
+ value: vi.fn(),
+ });
+});
+afterEach(() => {
+ cleanup();
+ vi.unstubAllGlobals();
+});
+
+function renderSelector() {
+ const [selected, setSelected] = createSignal<WithCustomUserInput[]>([]);
+ render(() => (
+ <RecipientSelector
+ options={() => []}
+ selectedOptions={selected()}
+ setSelectedOptions={setSelected}
+ />
+ ));
+ const emails = () =>
+ selected().map((option) =>
+ option.kind === 'custom' ? option.data.email : option.kind
+ );
+ return {
+ input: screen.getByRole<HTMLInputElement>('combobox'),
+ emails,
+ };
+}
+
+describe('RecipientSelector typed addresses', () => {
+ it('turns an address ended by a comma into a recipient and clears the input', () => {
+ const { input, emails } = renderSelector();
+ fireEvent.input(input, { target: { value: '[email protected],' } });
+ expect(emails()).toEqual(['[email protected]']);
+ expect(screen.getByText('[email protected]')).toBeTruthy();
+ expect(input.value).toBe('');
+ });
+
+ it('adds every address in a pasted list once', () => {
+ const { input, emails } = renderSelector();
+ fireEvent.input(input, {
+ });
+ expect(emails()).toEqual(['[email protected]', '[email protected]']);
+ });
+
+ it('clears an address that is already a recipient', () => {
+ const { input, emails } = renderSelector();
+ fireEvent.input(input, { target: { value: '[email protected];' } });
+ fireEvent.input(input, { target: { value: '[email protected];' } });
+ expect(emails()).toEqual(['[email protected]']);
+ expect(input.value).toBe('');
+ });
+
+ it('keeps an address typed straight after picking a suggestion', async () => {
+ const user = userEvent.setup();
+ const { input, emails } = renderSelector();
+ await user.type(input, '[email protected]');
+ await screen.findByRole('listbox');
+ await user.keyboard('{Enter}[email protected],');
+ await waitFor(() =>
+ expect(emails()).toEqual(['[email protected]', '[email protected]'])
+ );
+ expect(input.value).toBe('');
+ });
+
+ it('leaves text until a separator ends a complete address', () => {
+ const { input, emails } = renderSelector();
+ fireEvent.input(input, {
+ target: { value: '[email protected], [email protected]' },
+ });
+ fireEvent.input(input, { target: { value: '[email protected], b@exa,' } });
+ expect(emails()).toEqual([]);
+ });
+});
diff --git a/apps/web/src/lib/core/component/RecipientSelector.tsx b/apps/web/src/lib/core/component/RecipientSelector.tsx
index fff3c5db82..d86a38ed83 100644
--- a/apps/web/src/lib/core/component/RecipientSelector.tsx
+++ b/apps/web/src/lib/core/component/RecipientSelector.tsx
@@ -724,8 +724,60 @@ export function RecipientSelector<K extends CombinedRecipientKind>(
let contentEl: HTMLElement | undefined;
+ // Committing changes the selection, and Kobalte clears the input when it does.
+ const commitSeparatedEmails = (input: string) => {
+ if (!/[,;]\s*$/.test(input)) return false;
+ const emails = input
+ .split(/[,;]/)
+ .map((part) => part.trim())
+ .filter(Boolean)
+ .filter(
+ (email, index, all) =>
+ all.findIndex(
+ (other) => other.toLowerCase() === email.toLowerCase()
+ ) === index
+ );
+ if (emails.length === 0 || !emails.every((e) => EmailValidator.validate(e)))
+ return false;
+ const known = recipients().raw;
+ const findKnown = (email: string) =>
+ known.find(
+ (option) =>
+ getRecipientOptionEmail(option)?.toLowerCase() === email.toLowerCase()
+ );
+ const pending = emails.filter(
+ (email) => !selectedEmails().has(email.toLowerCase())
+ );
+ // Every address is already a recipient: setting the same selection again
+ // still makes Kobalte clear the text instead of leaving it in the field.
+ if (pending.length === 0) {
+ handleChange([...(props.selectedOptions as CombinedRecipientItem[])]);
+ return true;
+ }
+ if (props.allowCustomRecipients === false && !pending.every(findKnown))
+ return false;
+ const added = pending.map(
+ (email) =>
+ findKnown(email) ??
+ recipientEntityMapper('custom')({
+ id: emailToId(email),
+ email,
+ invalid: false,
+ })
+ );
+ handleChange([
+ ...(props.selectedOptions as CombinedRecipientItem[]),
+ ...added,
+ ]);
+ return true;
+ };
+
const onInputChange = (next: string) => {
props.onInputChange?.(next);
+ if (commitSeparatedEmails(next)) {
+ setInputValue('');
+ return;
+ }
const previous = inputValue();
setInputValue(next);
if (next !== previous) {
diff --git a/apps/web/src/lib/queries/email/inbox-email.test.tsx b/apps/web/src/lib/queries/email/inbox-email.test.tsx
new file mode 100644
index 0000000000..cf78a3b00f
--- /dev/null
+++ b/apps/web/src/lib/queries/email/inbox-email.test.tsx
@@ -0,0 +1,143 @@
+import type { Link as EmailLink } from '@service-email/generated/schemas';
+import { cleanup, render, screen } from '@solidjs/testing-library';
+import { onlineManager } from '@tanstack/query-core';
+import { QueryClient, QueryClientProvider } from '@tanstack/solid-query';
+import { err, type Ok, ok } from 'neverthrow';
+import { createSignal } from 'solid-js';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+import { useInboxEmail } from './inbox-email';
+import { emailKeys } from './keys';
+
+const getLinksMock = vi.hoisted(() => vi.fn());
+
+vi.mock('@service-email/client', () => ({
+ emailClient: { getLinks: getLinksMock },
+}));
+vi.mock('@queries/calendar/sync', () => ({ invalidateCalendarViews: vi.fn() }));
+vi.mock('@queries/auth/user-info', () => ({ invalidateUserInfo: vi.fn() }));
+vi.mock('@queries/soup/normalized-cache', () => ({
+ invalidateAllSoup: vi.fn(),
+}));
+vi.mock('@core/context/user', () => ({
+ useEmail: () => () => '[email protected]',
+ useIsAuthenticated: () => () => true,
+}));
+
+let client: QueryClient;
+vi.mock('../client', () => ({
+ get queryClient() {
+ return client;
+ },
+}));
+
+const outlook = {
+ id: 'outlook',
+ email_address: '[email protected]',
+} as unknown as EmailLink;
+
+function Viewer(props: { linkId: () => string | undefined }) {
+ const viewer = useInboxEmail(props.linkId);
+ return <output>{viewer() ?? 'unknown'}</output>;
+}
+
+const mount = (linkId: string | undefined) => {
+ const [id, setId] = createSignal(linkId);
+ render(() => (
+ <QueryClientProvider client={client}>
+ <Viewer linkId={id} />
+ </QueryClientProvider>
+ ));
+ return { viewer: () => screen.getByRole('status').textContent, setId };
+};
+
+beforeEach(() => {
+ client = new QueryClient({ defaultOptions: { queries: { retry: false } } });
+});
+
+afterEach(() => {
+ cleanup();
+ onlineManager.setOnline(true);
+ client.clear();
+ vi.clearAllMocks();
+});
+
+describe('useInboxEmail', () => {
+ it("is the owning inbox's address once inboxes load", async () => {
+ getLinksMock.mockResolvedValue(ok({ links: [outlook] }));
+ const { viewer } = mount('outlook');
+ await vi.waitFor(() => expect(viewer()).toBe('[email protected]'));
+ });
+
+ it('is unknown while inboxes are still loading', async () => {
+ const request = Promise.withResolvers<Ok<{ links: EmailLink[] }, never>>();
+ getLinksMock.mockReturnValue(request.promise);
+ const { viewer } = mount('outlook');
+ await vi.waitFor(() => expect(getLinksMock).toHaveBeenCalledOnce());
+ expect(viewer()).toBe('unknown');
+ request.resolve(ok({ links: [outlook] }));
+ await vi.waitFor(() => expect(viewer()).toBe('[email protected]'));
+ });
+
+ it('is unknown, not the Macro login, while offline with no cached inboxes', async () => {
+ onlineManager.setOnline(false);
+ getLinksMock.mockResolvedValue(ok({ links: [outlook] }));
+ const { viewer } = mount('outlook');
+ expect(viewer()).toBe('unknown');
+ expect(getLinksMock).not.toHaveBeenCalled();
+ onlineManager.setOnline(true);
+ await vi.waitFor(() => expect(viewer()).toBe('[email protected]'));
+ });
+
+ it('is unknown, not the Macro login, when the inbox list fails to load', async () => {
+ getLinksMock.mockResolvedValue(
+ err([{ code: 'HTTP_ERROR' as const, message: 'unavailable' }])
+ );
+ const { viewer } = mount('outlook');
+ await vi.waitFor(() => expect(getLinksMock).toHaveBeenCalledOnce());
+ await vi.waitFor(() =>
+ expect(client.getQueryState(emailKeys.links.queryKey)?.status).toBe(
+ 'error'
+ )
+ );
+ expect(viewer()).toBe('unknown');
+ });
+
+ it('keeps the address when a later inbox refresh fails', async () => {
+ getLinksMock.mockResolvedValueOnce(ok({ links: [outlook] }));
+ const { viewer } = mount('outlook');
+ await vi.waitFor(() => expect(viewer()).toBe('[email protected]'));
+ getLinksMock.mockResolvedValue(
+ err([{ code: 'HTTP_ERROR' as const, message: 'unavailable' }])
+ );
+ await client.refetchQueries({ queryKey: emailKeys.links.queryKey });
+ expect(client.getQueryState(emailKeys.links.queryKey)?.status).toBe(
+ 'error'
+ );
+ expect(viewer()).toBe('[email protected]');
+ });
+
+ it("is unknown until the mail's inbox is known, then follows it", async () => {
+ getLinksMock.mockResolvedValue(ok({ links: [outlook] }));
+ const { viewer, setId } = mount(undefined);
+ await vi.waitFor(() => expect(getLinksMock).toHaveBeenCalledOnce());
+ await vi.waitFor(() =>
+ expect(client.getQueryState(emailKeys.links.queryKey)?.status).toBe(
+ 'success'
+ )
+ );
+ expect(viewer()).toBe('unknown');
+ setId('outlook');
+ expect(viewer()).toBe('[email protected]');
+ });
+
+ it("is unknown for an inbox that is not one of the user's", async () => {
+ getLinksMock.mockResolvedValue(ok({ links: [outlook] }));
+ const { viewer } = mount('shared-inbox');
+ await vi.waitFor(() =>
+ expect(client.getQueryState(emailKeys.links.queryKey)?.status).toBe(
+ 'success'
+ )
+ );
+ expect(viewer()).toBe('unknown');
+ });
+});
diff --git a/apps/web/src/lib/queries/email/inbox-email.ts b/apps/web/src/lib/queries/email/inbox-email.ts
new file mode 100644
index 0000000000..cc1711f7e7
--- /dev/null
+++ b/apps/web/src/lib/queries/email/inbox-email.ts
@@ -0,0 +1,14 @@
+import type { Accessor } from 'solid-js';
+import { queryReadyGate } from '../gate';
+import { useEmailLinksQuery } from './link';
+
+export function useInboxEmail(
+ linkId: Accessor<string | undefined>
+): Accessor<string | undefined> {
+ const links = useEmailLinksQuery();
+ return () => {
+ const id = linkId();
+ if (!id || !queryReadyGate(links)) return undefined;
+ return links.data.links.find((link) => link.id === id)?.email_address;
+ };
+}
diff --git a/crates/email_api_client/src/outbound/outlook/messages.rs b/crates/email_api_client/src/outbound/outlook/messages.rs
index 5d81f23f1c..168ed6ad50 100644
--- a/crates/email_api_client/src/outbound/outlook/messages.rs
+++ b/crates/email_api_client/src/outbound/outlook/messages.rs
@@ -305,6 +305,25 @@ fn contact(recipient: wire::Recipient) -> ContactInfo {
}
}
+/// Graph's `bodyPreview` length.
+const SNIPPET_CHARS: usize = 255;
+
+fn reply_snippet(subject: Option<&str>, html: Option<&str>, text: Option<&str>) -> Option<String> {
+ let reply = email_utils::body_replyless::compute_body_replyless(subject, html, text)?;
+ let reply = match html {
+ Some(_) => email_utils::body_parsed::html_to_plaintext(&reply)?,
+ None => reply,
+ };
+ let snippet: String = reply
+ .split_whitespace()
+ .collect::<Vec<_>>()
+ .join(" ")
+ .chars()
+ .take(SNIPPET_CHARS)
+ .collect();
+ (!snippet.is_empty()).then_some(snippet)
+}
+
pub(super) fn normalize(
source: wire::Message,
attachments: Vec<Attachment>,
@@ -339,6 +358,12 @@ pub(super) fn normalize(
Some(body) => (Some(body.content), None),
None => (None, None),
};
+ let snippet = reply_snippet(
+ source.subject.as_deref(),
+ body_html_sanitized.as_deref(),
+ body_text.as_deref(),
+ )
+ .or(source.body_preview);
let headers =
serde_json::to_value(source.internet_message_headers).map_err(|_| invalid_response())?;
let now = Utc::now();
@@ -351,7 +376,7 @@ pub(super) fn normalize(
global_id: source.internet_message_id,
link_id,
subject: source.subject,
- snippet: source.body_preview,
+ snippet,
provider_history_id: None,
internal_date_ts: source.received_date_time.or(source.sent_date_time),
sent_at: source.sent_date_time,
diff --git a/crates/email_api_client/src/outbound/outlook/test.rs b/crates/email_api_client/src/outbound/outlook/test.rs
index a30bd9d231..1707ed54ad 100644
--- a/crates/email_api_client/src/outbound/outlook/test.rs
+++ b/crates/email_api_client/src/outbound/outlook/test.rs
@@ -615,6 +615,39 @@ fn folder_subtrees_inherit_trash_without_becoming_move_destinations() {
);
}
+#[test]
+fn reply_snippets_leave_out_the_quoted_message() {
+ let snippet = |body: serde_json::Value| {
+ let source = serde_json::from_value(json!({
+ "id":"m","conversationId":"c","subject":"RE: Hello",
+ "bodyPreview":"Preview with quoted history","body":body
+ }))
+ .unwrap();
+ super::messages::normalize(source, Vec::new(), Uuid::new_v4(), &[])
+ .unwrap()
+ .content
+ .message
+ .snippet
+ };
+ assert_eq!(
+ snippet(json!({"contentType":"html","content":concat!(
+ "<html><body><div>Tell gab I said\nhello</div>",
+ "<div id=\"appendonsend\"></div><hr><div id=\"divRplyFwdMsg\">",
+ "<b>From:</b> Teo<br><b>Sent:</b> Tuesday<br><b>To:</b> Gab<br>",
+ "<b>Subject:</b> Hello</div><div>Original message</div></body></html>"
+ )}))
+ .as_deref(),
+ Some("Tell gab I said hello")
+ );
+ assert_eq!(
+ snippet(json!({"contentType":"text","content":
+ "Me too\n\nOn Tue, Oct 20, 2026 at 3:00 PM Teo <[email protected]> wrote:\n> God I love outlook"
+ }))
+ .as_deref(),
+ Some("Me too")
+ );
+}
+
#[tokio::test]
async fn cloud_reference_attachments_preserve_provider_open_without_download_bytes() {
let (server, api, token) = setup().await;
diff --git a/docs/agent-guide/calendar.md b/docs/agent-guide/calendar.md
index d4da70be00..3e0528ec8d 100644
--- a/docs/agent-guide/calendar.md
+++ b/docs/agent-guide/calendar.md
@@ -259,8 +259,8 @@ Connected calendars offers Connect account (pick Gmail or Outlook / Microsoft 36
then consent), Connect calendar for accounts missing calendar permission (consent
again for that account at its own provider with its address preselected, as
Settings → Email's Enable calendar does), and Disconnect with confirmation. When
-the only linked account lacks calendar permission, the Google
-Calendar row shows just a filled Connect button for it, with no account list or
+the only linked account lacks calendar permission, the Calendar accounts row
+shows just a filled Connect button for it, with no account list or
visibility note. Disconnect removes calendar access/data, not the Gmail connection.
Settings → Calendar lists only the viewer's own inboxes. The **Enable calendar**
toast (behind `enable-calendar-prompt-web` and `enable-calendar-prompt-mobile`)
diff --git a/docs/agent-guide/email.md b/docs/agent-guide/email.md
index f952885708..fc4ef3a799 100644
--- a/docs/agent-guide/email.md
+++ b/docs/agent-guide/email.md
@@ -73,6 +73,11 @@ draft exactly like its trash button, `Cmd+Shift+U` opens the attach picker, and
list and quote. Check discard from both a reply (the reply closes) and
standalone compose (the view goes back), with focus in the body.
+Recipient fields turn complete addresses into chips when the typed or pasted
+text ends in a comma or semicolon, so `[email protected], [email protected],` adds both.
+Enter or a click picks the highlighted suggestion. Type, paste, or Tab straight
+after picking one and check that both recipients stay and the input is empty.
+
Outlook connections support personal Outlook.com and individual Microsoft 365
inboxes. Choose the inbox explicitly when testing mixed-provider accounts. The
same thread, search, Signal/Noise, draft, and schedule surfaces apply to both