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.

Add Send email button to calendar event details (#6394)

Jacob Beckerman86cb23532bce
diff --git a/apps/web/src/features/block-calendar/components/SelectedEventDetails.tsx b/apps/web/src/features/block-calendar/components/SelectedEventDetails.tsx
index e8e3ee5ab0..f5b32e54ee 100644
--- a/apps/web/src/features/block-calendar/components/SelectedEventDetails.tsx
+++ b/apps/web/src/features/block-calendar/components/SelectedEventDetails.tsx
@@ -8,10 +8,16 @@ import {
type CalendarTimeFormat,
reminderCalendarIdOf,
} from '@app/features/calendar/types';
+import {
+ eventEmailRecipients,
+ guestEmails,
+} from '@app/features/calendar/utils/guest-emails';
import { MobileDrawer } from '@components/app/mobile/MobileDrawer';
import { toast } from '@core/component/Toast/Toast';
import { isMobile } from '@core/mobile/isMobile';
import { Popover } from '@kobalte/core/popover';
+import CopyIcon from '@phosphor/copy.svg';
+import EnvelopeIcon from '@phosphor/envelope.svg';
import ExclamationIcon from '@phosphor/exclamation-mark.svg';
import LinkIcon from '@phosphor/link.svg';
import PencilSimpleIcon from '@phosphor/pencil-simple.svg';
@@ -30,8 +36,10 @@ import {
} from '@ui';
import { type Accessor, createMemo, createSignal, Show } from 'solid-js';
import { copyCalendarEventMention } from '../copy-event-mention';
+import { copyGuestEmails } from '../copy-guest-emails';
import { EventRsvpSection } from './EventRsvpSection';
import { useOpenEventComposer } from './use-open-event-composer';
+import { useOpenEventEmail } from './use-open-event-email';
interface SelectedEventDetailsProps {
anchor: Accessor<HTMLElement | undefined>;
@@ -166,6 +174,50 @@ function EveryoneElseDeclinedNotice(props: {
);
}
+/**
+ * The guest-row actions Google Calendar users know: copy every guest's
+ * address, or start an email to the other guests (hidden when the viewer is
+ * the only one). Emailing closes the details first: closing hands focus back
+ * to the calendar chip, and the composer's To field has to win that exchange.
+ */
+function EventGuestActions(props: {
+ event: CalendarEvent;
+ closeDetails: () => void;
+}) {
+ const openEventEmail = useOpenEventEmail();
+
+ return (
+ <>
+ <Button
+ label="Copy guest emails"
+ variant="ghost"
+ size="icon-sm"
+ depth={3}
+ class="rounded-md text-ink-muted [&_svg]:size-4"
+ onClick={() => copyGuestEmails(guestEmails(props.event.attendees))}
+ >
+ <CopyIcon />
+ </Button>
+ <Show when={eventEmailRecipients(props.event).length > 0}>
+ <Button
+ label="Email guests"
+ variant="ghost"
+ size="icon-sm"
+ depth={3}
+ class="rounded-md text-ink-muted [&_svg]:size-4"
+ onClick={() => {
+ const event = props.event;
+ props.closeDetails();
+ openEventEmail(event);
+ }}
+ >
+ <EnvelopeIcon />
+ </Button>
+ </Show>
+ </>
+ );
+}
+
function EventDetailsDrawer(props: EventDetailsOverlayProps) {
const openEventComposer = useOpenEventComposer();
const deleteDialog = useDeleteEventDialog({
@@ -256,7 +308,15 @@ function EventDetailsDrawer(props: EventDetailsOverlayProps) {
defaultReminders={props.defaultReminders}
/>
</div>
- <EventAttendeesSection attendees={props.event.attendees} />
+ <EventAttendeesSection
+ attendees={props.event.attendees}
+ actions={
+ <EventGuestActions
+ event={props.event}
+ closeDetails={() => props.onOpenChange(false)}
+ />
+ }
+ />
<EventRsvpSection event={props.event} buttonSize="md" />
</MobileDrawer.ScrollBody>
</MobileDrawer.Content>
@@ -503,7 +563,15 @@ function EventDetailsPopover(props: EventDetailsPopoverProps) {
defaultReminders={props.defaultReminders}
/>
</div>
- <EventAttendeesSection attendees={props.event.attendees} />
+ <EventAttendeesSection
+ attendees={props.event.attendees}
+ actions={
+ <EventGuestActions
+ event={props.event}
+ closeDetails={() => props.onOpenChange(false)}
+ />
+ }
+ />
<EventRsvpSection event={props.event} />
</div>
</div>
diff --git a/apps/web/src/features/block-calendar/components/use-open-event-email.ts b/apps/web/src/features/block-calendar/components/use-open-event-email.ts
new file mode 100644
index 0000000000..a59f789084
--- /dev/null
+++ b/apps/web/src/features/block-calendar/components/use-open-event-email.ts
@@ -0,0 +1,31 @@
+import type { CalendarEvent } from '@app/features/calendar/types';
+import { eventEmailRecipients } from '@app/features/calendar/utils/guest-emails';
+import { EMAIL_COMPOSE_TO_INPUT_ID } from '@app/features/email-compose/core/constants';
+import { useSplitLayout } from '@components/app/split-layout/layout';
+import { triggerFocusInput } from '@core/directive/focusInput';
+
+/**
+ * Opens a new email addressed to the event's other guests. Desktop gets the
+ * composer in a split beside the calendar; on touch devices `openWithSplit`
+ * never inserts a split, so the composer takes over the screen instead.
+ * `preserveParams` keeps the recipients on the history entry the same way
+ * `mailto:` links do — the in-place replace path would otherwise drop them.
+ */
+export function useOpenEventEmail() {
+ const { openWithSplit } = useSplitLayout();
+
+ return (event: CalendarEvent) => {
+ // Focus the To field within this gesture so the iOS keyboard opens; the
+ // composer mounts asynchronously, so this waits for the input.
+ triggerFocusInput(() => document.getElementById(EMAIL_COMPOSE_TO_INPUT_ID));
+ openWithSplit(
+ {
+ type: 'component',
+ id: 'email-compose',
+ params: { initialTo: eventEmailRecipients(event) },
+ preserveParams: true,
+ },
+ { preferNewSplit: true }
+ );
+ };
+}
diff --git a/apps/web/src/features/block-calendar/copy-guest-emails.test.ts b/apps/web/src/features/block-calendar/copy-guest-emails.test.ts
new file mode 100644
index 0000000000..1e00e13ea8
--- /dev/null
+++ b/apps/web/src/features/block-calendar/copy-guest-emails.test.ts
@@ -0,0 +1,36 @@
+import { beforeEach, describe, expect, it, vi } from 'vitest';
+import { copyGuestEmails } from './copy-guest-emails';
+
+const writeClipboardData = vi.hoisted(() =>
+ vi.fn(async (_data: Record<string, string | undefined>) => true)
+);
+const toast = vi.hoisted(() => ({ success: vi.fn(), failure: vi.fn() }));
+
+vi.mock('@core/util/dataTransfer', () => ({ writeClipboardData }));
+vi.mock('@core/component/Toast/Toast', () => ({ toast }));
+
+describe('copyGuestEmails', () => {
+ beforeEach(() => {
+ writeClipboardData.mockClear();
+ toast.success.mockClear();
+ toast.failure.mockClear();
+ });
+
+ it('writes the addresses comma-separated as plain text', async () => {
+ await copyGuestEmails(['[email protected]', '[email protected]']);
+
+ expect(writeClipboardData).toHaveBeenCalledWith({
+ });
+ expect(toast.success).toHaveBeenCalledWith('Copied guest emails');
+ });
+
+ it('reports a clipboard that refused the write', async () => {
+ writeClipboardData.mockResolvedValueOnce(false);
+
+ await copyGuestEmails(['[email protected]']);
+
+ expect(toast.success).not.toHaveBeenCalled();
+ expect(toast.failure).toHaveBeenCalledWith('Failed to copy guest emails');
+ });
+});
diff --git a/apps/web/src/features/block-calendar/copy-guest-emails.ts b/apps/web/src/features/block-calendar/copy-guest-emails.ts
new file mode 100644
index 0000000000..719745965c
--- /dev/null
+++ b/apps/web/src/features/block-calendar/copy-guest-emails.ts
@@ -0,0 +1,15 @@
+import { toast } from '@core/component/Toast/Toast';
+import { writeClipboardData } from '@core/util/dataTransfer';
+
+/**
+ * Copies guest addresses comma-separated, ready to paste into any To field.
+ * Must be called from a user gesture.
+ */
+export async function copyGuestEmails(emails: string[]) {
+ const written = await writeClipboardData({ 'text/plain': emails.join(', ') });
+ if (written) {
+ toast.success('Copied guest emails');
+ } else {
+ toast.failure('Failed to copy guest emails');
+ }
+}
diff --git a/apps/web/src/features/calendar/components/EventDetails.tsx b/apps/web/src/features/calendar/components/EventDetails.tsx
index 51151d480d..85fb005784 100644
--- a/apps/web/src/features/calendar/components/EventDetails.tsx
+++ b/apps/web/src/features/calendar/components/EventDetails.tsx
@@ -631,9 +631,15 @@ export function EventDetails(props: {
);
}
-/** Displays attendees in a full-width collapsible popover section. */
+/**
+ * Displays attendees in a full-width collapsible popover section. `actions`
+ * are icon buttons for the header row's trailing edge — the copy-emails and
+ * email-guests pair Google Calendar puts there — rendered beside the
+ * disclosure trigger rather than inside it, since a button cannot nest one.
+ */
export function EventAttendeesSection(props: {
attendees: CalendarAttendee[];
+ actions?: JSX.Element;
}) {
return (
<Show when={props.attendees.length > 0}>
@@ -641,17 +647,20 @@ export function EventAttendeesSection(props: {
defaultOpen
class="border-edge-muted text-sm text-ink-muted sm:border-t sm:text-xs"
>
- <Collapsible.Trigger class="group flex w-full items-center gap-4 px-4 py-4 text-left hover:bg-hover hover:text-ink sm:gap-3">
- <UsersIcon class="size-5 shrink-0 text-ink-extra-muted sm:size-4" />
- <span>
- {props.attendees.length}{' '}
- {plural('attendee', props.attendees.length)}
- </span>
- <CaretDownIcon
- aria-hidden="true"
- class="ml-auto size-3 shrink-0 -rotate-90 text-ink-extra-muted transition-transform group-data-expanded:rotate-0"
- />
- </Collapsible.Trigger>
+ <div class="flex items-center pr-2">
+ <Collapsible.Trigger class="group flex min-w-0 flex-1 items-center gap-4 py-4 pl-4 pr-2 text-left hover:bg-hover hover:text-ink sm:gap-3">
+ <UsersIcon class="size-5 shrink-0 text-ink-extra-muted sm:size-4" />
+ <span>
+ {props.attendees.length}{' '}
+ {plural('attendee', props.attendees.length)}
+ </span>
+ <CaretDownIcon
+ aria-hidden="true"
+ class="size-3 shrink-0 -rotate-90 text-ink-extra-muted transition-transform group-data-expanded:rotate-0"
+ />
+ </Collapsible.Trigger>
+ <div class="flex shrink-0 items-center gap-1">{props.actions}</div>
+ </div>
<Collapsible.Content class="data-closed:hidden">
<div class="flex gap-4 pb-3 pl-4 pt-1.5 sm:gap-3">
<span aria-hidden="true" class="size-5 shrink-0 sm:size-4" />
diff --git a/apps/web/src/features/calendar/utils/guest-emails.test.ts b/apps/web/src/features/calendar/utils/guest-emails.test.ts
new file mode 100644
index 0000000000..88c67b40a8
--- /dev/null
+++ b/apps/web/src/features/calendar/utils/guest-emails.test.ts
@@ -0,0 +1,91 @@
+import type { CalendarAttendee } from '@service-storage/generated/schemas/calendarAttendee';
+import { describe, expect, it } from 'vitest';
+import type { CalendarEvent } from '../types';
+import { eventEmailRecipients, guestEmails } from './guest-emails';
+
+function attendee(
+ email: string,
+ overrides: Partial<CalendarAttendee> = {}
+): CalendarAttendee {
+ return {
+ email,
+ isOptional: false,
+ isOrganizer: false,
+ isSelf: false,
+ responseStatus: 'accepted',
+ ...overrides,
+ };
+}
+
+function event(attendees: CalendarAttendee[]): CalendarEvent {
+ return {
+ id: '["event","occurrence"]',
+ eventId: 'event',
+ occurrenceKey: 'occurrence',
+ isCancelled: false,
+ isReadOnly: false,
+ attendees,
+ recurrenceLines: [],
+ sourceCalendarIds: [],
+ title: 'Demo call',
+ start: '2026-09-14T19:00:00.000Z',
+ end: '2026-09-14T19:30:00.000Z',
+ allDay: false,
+ calendar: {
+ id: 'jacob-cal',
+ name: 'Jacob Beckerman',
+ color: 'orange',
+ emailAddress: '[email protected]',
+ isPrimary: true,
+ },
+ visibleCalendars: [],
+ };
+}
+
+describe('guestEmails', () => {
+ it('lists every guest, the viewer included, in guest-list order', () => {
+ expect(
+ guestEmails([
+ attendee('[email protected]'),
+ attendee('[email protected]', { isSelf: true }),
+ attendee('[email protected]', { isOptional: true }),
+ ])
+ });
+
+ it('lists an address once however it is cased or padded', () => {
+ expect(
+ guestEmails([
+ attendee('[email protected]'),
+ attendee(' [email protected] '),
+ attendee(''),
+ ])
+ ).toEqual(['[email protected]']);
+ });
+});
+
+describe('eventEmailRecipients', () => {
+ it('addresses every guest but the viewer', () => {
+ expect(
+ eventEmailRecipients(
+ event([
+ attendee('[email protected]'),
+ attendee('[email protected]', { isSelf: true }),
+ attendee('[email protected]', { isOrganizer: true }),
+ ])
+ )
+ });
+
+ it('is empty when the viewer is the only guest', () => {
+ expect(
+ eventEmailRecipients(
+ event([attendee('[email protected]', { isSelf: true })])
+ )
+ ).toEqual([]);
+ });
+
+ it('is empty for an event without guests', () => {
+ expect(eventEmailRecipients(event([]))).toEqual([]);
+ });
+});
diff --git a/apps/web/src/features/calendar/utils/guest-emails.ts b/apps/web/src/features/calendar/utils/guest-emails.ts
new file mode 100644
index 0000000000..c862b02549
--- /dev/null
+++ b/apps/web/src/features/calendar/utils/guest-emails.ts
@@ -0,0 +1,28 @@
+import type { CalendarAttendee } from '@service-storage/generated/schemas/calendarAttendee';
+import type { CalendarEvent } from '../types';
+
+/**
+ * Every guest's address once, in guest-list order, blanks dropped — what
+ * "Copy guest emails" puts on the clipboard.
+ */
+export function guestEmails(attendees: CalendarAttendee[]): string[] {
+ const seen = new Set<string>();
+ const emails: string[] = [];
+ for (const attendee of attendees) {
+ const email = attendee.email.trim();
+ const key = email.toLowerCase();
+ if (email === '' || seen.has(key)) continue;
+ seen.add(key);
+ emails.push(email);
+ }
+ return emails;
+}
+
+/**
+ * Who a new email about the event goes to: every guest except the viewer's
+ * own inboxes. Empty when the viewer is the only guest, so callers can hide
+ * the action instead of opening a composer addressed to nobody.
+ */
+export function eventEmailRecipients(event: CalendarEvent): string[] {
+ return guestEmails(event.attendees.filter((attendee) => !attendee.isSelf));
+}
diff --git a/docs/AGENT_GUIDE/surfaces.md b/docs/AGENT_GUIDE/surfaces.md
index 7af24c13bf..1f191dc71b 100644
--- a/docs/AGENT_GUIDE/surfaces.md
+++ b/docs/AGENT_GUIDE/surfaces.md
@@ -264,6 +264,11 @@ the copy Macro's alerts fire from and whose guest list and join link Macro recor
editor only lets them be changed there. Answering an invitation likewise addresses the
primary copy. The details popover and the editor act on the displayed copy, so editing or
deleting it targets that calendar's event at Google.
+As in Google Calendar, the guests row of the details popover (a bottom sheet on phones)
+carries `Copy guest emails` and `Email guests` icon buttons. Copying puts every guest's
+address on the clipboard, comma-separated. Emailing opens a new email addressed to every
+guest but you — in a split beside the calendar on desktop, as the full-screen composer on
+touch devices — and is hidden when you are the only guest.
With the `enable-calendar-team-ooo` flag on, teammates' Google Calendar out-of-office events
overlay the grid as read-only chips titled `<name>: <event title>`. The side panel's