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): 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.tsx
index 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.tsx
index 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.tsx
index 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 host
expect(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.tsx
index 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.tsx
index 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(
<CalendarInviteCard
invitation={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.tsx
index 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.md
index 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 on
desktop and mobile, including when the email uses `application/ics` or a
parameterized `text/calendar` MIME type. Opening the attachment of a message that shows a
card 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 card
stays put while the thread refreshes, and `Open in calendar` closes the dialog before the
calendar opens, including when Calendar is already open in another split. A calendar file with
no card (nothing Macro could read) downloads directly, and an Outlook cloud-reference `.ics`