Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
fix(email): stop the .ics dialog's card pointing back at its attachment (#8710)
gbirmanf6ec0dee89cb
diff --git a/apps/web/src/features/email-message/components/calendar-invite-card.test.tsx b/apps/web/src/features/email-message/components/calendar-invite-card.test.tsxindex 1168bc7f58..6fce113618 100644--- a/apps/web/src/features/email-message/components/calendar-invite-card.test.tsx+++ b/apps/web/src/features/email-message/components/calendar-invite-card.test.tsx@@ -129,6 +129,28 @@ describe('native invitation card', () => {).toBeNull();expect(screen.getAllByText('Cancelled').length).toBeGreaterThan(0);});+ it('points at the invitation attachment only from outside it', () => {+ const noMatch: InvitationResolution = { kind: 'no_match' };+ render(() => (+ <>+ <CalendarInviteCard+ invitation={invitationFixture}+ actions={{ resolution: noMatch }}+ />+ <CalendarInviteCard+ invitation={invitationFixture}+ actions={{ resolution: noMatch }}+ inCalendarFile+ />+ </>+ ));+ const [inline, inFile] = screen.getAllByText(/^Saved invitation\./);+ expect(inline.textContent).toBe(+ 'Saved invitation. Open the original email or invitation attachment for more options.'+ );+ expect(inFile.textContent).toBe('Saved invitation.');+ });+it('expands guest identities and descriptions explicitly', () => {render(() => <CalendarInviteCard invitation={invitationFixture} />);fireEvent.click(screen.getByRole('button', { name: '+3 more' }));diff --git a/apps/web/src/features/email-message/components/calendar-invite-card.tsx b/apps/web/src/features/email-message/components/calendar-invite-card.tsxindex 55b1f32317..34883e8000 100644--- a/apps/web/src/features/email-message/components/calendar-invite-card.tsx+++ b/apps/web/src/features/email-message/components/calendar-invite-card.tsx@@ -58,6 +58,8 @@ export function CalendarInviteCard(props: {actions?: CalendarInvitationActions;hour12?: boolean;timeZone?: string;+ /** Shown inside the calendar file it came from, so it must not point back at that file. */+ inCalendarFile?: boolean;}) {const [descriptionExpanded, setDescriptionExpanded] = createSignal(false);const [attendeesExpanded, setAttendeesExpanded] = createSignal(false);@@ -152,9 +154,10 @@ export function CalendarInviteCard(props: {? 'Waiting for your calendar to catch up. Responses are paused until it does.': 'Your connected calendar does not allow a response to this event.')- .otherwise(- () =>- 'Saved invitation. Open the original email or invitation attachment for more options.'+ .otherwise(() =>+ props.inCalendarFile+ ? 'Saved invitation.'+ : 'Saved invitation. Open the original email or invitation attachment for more options.');const lastResponse = () => {const response = resolved()?.response;diff --git a/apps/web/src/features/email-message/views/email-message.test.tsx b/apps/web/src/features/email-message/views/email-message.test.tsxindex 9ee3162187..b6f5b36d51 100644--- a/apps/web/src/features/email-message/views/email-message.test.tsx+++ b/apps/web/src/features/email-message/views/email-message.test.tsx@@ -114,6 +114,29 @@ it('opens a calendar file as the event it holds and other files through the hostexpect(onOpenAttachment).toHaveBeenCalledWith(pdfFile);});+it('tells the card when it is shown inside its calendar file', () => {+ render(() => (+ <EmailMessageView+ message={message([invitationFixture])}+ renderInvitation={(_message, invitation, options) => (+ <div data-testid="card">+ {options?.inCalendarFile ? 'in file' : 'inline'} {invitation.id}+ </div>+ )}+ onOpenAttachment={vi.fn()}+ onDownloadAttachment={vi.fn()}+ isTouch={false}+ isPersonal={false}+ isSelected={false}+ allowHover={false}+ isExpanded+ />+ ));+ expect(screen.getByTestId('card').textContent).toContain('inline');+ fireEvent.click(screen.getByRole('button', { name: 'Planning.ics' }));+ expect(screen.getByRole('dialog').textContent).toContain('in file');+});+it('hands a calendar file without a readable event to the host', () => {const onOpenAttachment = vi.fn();render(() => (diff --git a/apps/web/src/features/email-message/views/email-message.tsx b/apps/web/src/features/email-message/views/email-message.tsxindex c9b528c9b5..6ce604e334 100644--- a/apps/web/src/features/email-message/views/email-message.tsx+++ b/apps/web/src/features/email-message/views/email-message.tsx@@ -22,6 +22,8 @@ import { inlineContentIds, normalizeContentId } from '../core/inline-images';export interface InvitationRenderOptions {/** Called before a card action opens something else in the app. */onNavigate?: () => void;+ /** The card is shown inside the calendar file it came from. */+ inCalendarFile?: boolean;}export interface EmailMessageViewProps {@@ -93,7 +95,10 @@ export function EmailMessageView(props: EmailMessageViewProps) {props.renderInvitation ? (props.renderInvitation(props.message, invitation, options)) : (- <CalendarInviteCard invitation={invitation} />+ <CalendarInviteCard+ invitation={invitation}+ inCalendarFile={options?.inCalendarFile}+ />);const body = () => (<div class="ph-no-capture text-base text-ink pr-4 mobile:pr-0">@@ -318,6 +323,7 @@ export function EmailMessageView(props: EmailMessageViewProps) {{(group) =>renderInvitation(group().primary, {onNavigate: closeForNavigation,+ inCalendarFile: true,})}</Key>diff --git a/apps/web/src/features/email-thread/calendar-invitation.tsx b/apps/web/src/features/email-thread/calendar-invitation.tsxindex 506749ac92..410d20c5ea 100644--- a/apps/web/src/features/email-thread/calendar-invitation.tsx+++ b/apps/web/src/features/email-thread/calendar-invitation.tsx@@ -33,10 +33,16 @@ export function EmailCalendarInvitation(props: {openCalendar?: (target: CalendarInvitationOpenTarget) => void;/** Called before Open in calendar leaves the email. */onNavigate?: () => void;+ /** The card is shown inside the calendar file it came from. */+ inCalendarFile?: boolean;}) {const calendarEnabled = useCalendarUiFlag();const saved = () => (- <CalendarInviteCard invitation={props.invitation} hour12={props.hour12} />+ <CalendarInviteCard+ invitation={props.invitation}+ hour12={props.hour12}+ inCalendarFile={props.inCalendarFile}+ />);// Without the calendar UI, the saved invitation renders with no calendar lookup.return (@@ -105,6 +111,7 @@ function ConnectedInvitation(<CalendarInviteCardinvitation={props.invitation}hour12={props.hour12}+ inCalendarFile={props.inCalendarFile}actions={{get resolution() {return state();diff --git a/apps/web/src/features/email-thread/email-thread.tsx b/apps/web/src/features/email-thread/email-thread.tsxindex de8dcfc5c9..e44a1c6ff8 100644--- a/apps/web/src/features/email-thread/email-thread.tsx+++ b/apps/web/src/features/email-thread/email-thread.tsx@@ -132,6 +132,7 @@ export function EmailThread(props: EmailThreadProps) {hour12={calendarPreferences.timeFormat !== '24-hour'}openCalendar={props.openCalendar}onNavigate={options?.onNavigate}+ inCalendarFile={options?.inCalendarFile}/>),openAttachment: createEmailAttachmentOpener(),diff --git a/docs/agent-guide/calendar.md b/docs/agent-guide/calendar.mdindex 2008a4b0d2..01077719d5 100644--- a/docs/agent-guide/calendar.md+++ b/docs/agent-guide/calendar.md@@ -1253,7 +1253,10 @@ ICS attachments show a calendar icon in the attachment pill and file headers ondesktop and mobile, including when the email uses `application/ics` or aparameterized `text/calendar` MIME type. Opening the attachment of a message that shows acard opens a dialog (a drawer on phones) with the same card, so its RSVP or `Add to calendar`-works there, and `Download .ics`, which saves the file without adding it to Drive. The card+works there, and `Download .ics`, which saves the file without adding it to Drive. When the+card falls back to the saved invitation (the event matches nothing on your calendars, as with+a forwarded event), its status line reads `Saved invitation.` in the dialog; the card in the+email adds that the original email or invitation attachment has more options. The cardstays put while the thread refreshes, and `Open in calendar` closes the dialog before thecalendar opens, including when Calendar is already open in another split. A calendar file withno card (nothing Macro could read) downloads directly, and an Outlook cloud-reference `.ics`