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(calendar): explain a hidden guest list instead of counting it (#8643)
gbirmanb829d6e1e774
diff --git a/apps/web/src/features/block-calendar/components/EventComposerSplit.tsx b/apps/web/src/features/block-calendar/components/EventComposerSplit.tsxindex 7b26bae9fc..15f21ac8cc 100644--- a/apps/web/src/features/block-calendar/components/EventComposerSplit.tsx+++ b/apps/web/src/features/block-calendar/components/EventComposerSplit.tsx@@ -97,6 +97,7 @@ function EventComposerContent(disabledFields={editor.disabledFields()}addOnlyGuests={editor.addOnlyGuests()}guestsReadOnlyReason={editor.guestsReadOnlyReason()}+ guestListHidden={editor.guestListHidden()}guestPolicyEditable={editor.guestPolicyEditable()}detailsReadOnlyReason={editor.detailsReadOnlyReason()}showRecurringEditNotice={editor.showRecurringEditNotice()}diff --git a/apps/web/src/features/calendar-view/components/EventGuests.test.tsx b/apps/web/src/features/calendar-view/components/EventGuests.test.tsxindex dda1fce0b0..6435939680 100644--- a/apps/web/src/features/calendar-view/components/EventGuests.test.tsx+++ b/apps/web/src/features/calendar-view/components/EventGuests.test.tsx@@ -49,6 +49,8 @@ vi.mock('@queries/calendar/mutations', () => ({useInviteCalendarEventGuestsMutation: () => ({ mutateAsync: mocks.invite }),isGuestInviteRefused: (error: unknown) =>(error as { code?: string }).code === 'guests_cannot_invite',+ isGuestListHiddenRefusal: (error: unknown) =>+ (error as { code?: string }).code === 'guest_list_hidden',}));// The picker itself is the composer's and is tested there; this stand-in// offers every pool member it is not told to exclude.@@ -364,6 +366,50 @@ describe('adding guests from event details', () => {expect(mocks.success).not.toHaveBeenCalled();});+ it('says the organizer hid the guest list instead of counting the guests the viewer can see', () => {+ renderGuests(+ event({+ guestPolicy: {+ canModify: false,+ canInviteOthers: true,+ canSeeOtherGuests: false,+ },+ viewerCan: { ...MAY_INVITE, inviteGuests: false },+ attendees: [attendee({ email: '[email protected]', isSelf: true })],+ })+ );++ expect(screen.getByText('Guest list hidden')).toBeTruthy();+ expect(screen.queryByText('1 attendee')).toBeNull();+ expect(screen.queryByRole('button', { name: 'Add guests' })).toBeNull();+ expect(+ screen.getByText(+ 'Guests cannot be added while the organizer hides the guest list.'+ )+ ).toBeTruthy();+ expect(+ screen.queryByText('Only the organizer can invite guests.')+ ).toBeNull();+ });++ it('switches to the hidden-list explanation when the server finds the list hidden', async () => {+ mocks.invite.mockRejectedValue({ code: 'guest_list_hidden' });+ const user = userEvent.setup();+ renderGuests(event());++ await user.click(screen.getByRole('button', { name: 'Add guests' }));+ await user.click(+ screen.getByRole('button', { name: 'Suggest Ada Lovelace' })+ );+ await user.click(screen.getByRole('button', { name: 'Send invitations' }));++ const reason =+ 'Guests cannot be added while the organizer hides the guest list.';+ await waitFor(() => expect(mocks.failure).toHaveBeenCalledWith(reason));+ expect(screen.queryByRole('button', { name: 'Add guests' })).toBeNull();+ expect(screen.getByText(reason)).toBeTruthy();+ });+it('offers no guest addresses to copy or email when the viewer is the only guest', () => {renderGuests(event({diff --git a/apps/web/src/features/calendar-view/components/EventGuests.tsx b/apps/web/src/features/calendar-view/components/EventGuests.tsxindex f7e191354f..3f76d9a74f 100644--- a/apps/web/src/features/calendar-view/components/EventGuests.tsx+++ b/apps/web/src/features/calendar-view/components/EventGuests.tsx@@ -15,7 +15,7 @@ import type {GuestInviteController,} from '@app/features/calendar/hooks/create-guest-invite-controller';import type { CalendarEvent } from '@app/features/calendar/types';-import { GUEST_INVITES_RESTRICTED } from '@app/features/calendar/utils/event-guest-editing';+import { guestListHidden } from '@app/features/calendar/utils/event-guest-editing';import {eventEmailRecipients,guestEmails,@@ -282,7 +282,8 @@ export function EventGuests(props: {return (<EventAttendeesSectionattendees={props.event.attendees}- notice={props.invites.restricted() ? GUEST_INVITES_RESTRICTED : undefined}+ guestListHidden={guestListHidden(props.event)}+ notice={props.invites.restrictedReason()}actions={<EventGuestActionsevent={props.event}diff --git a/apps/web/src/features/calendar/components/EventDetails.tsx b/apps/web/src/features/calendar/components/EventDetails.tsxindex d0aba479bd..9339121381 100644--- a/apps/web/src/features/calendar/components/EventDetails.tsx+++ b/apps/web/src/features/calendar/components/EventDetails.tsx@@ -636,11 +636,14 @@ export function EventDetails(props: {* email-guests pair Google Calendar puts there — rendered beside the* disclosure trigger rather than inside it, since a button cannot nest one.* `notice` is a muted line above the list, such as why it cannot grow.+ * `guestListHidden` replaces the count, which would only count the guests+ * the organizer lets the viewer see.*/export function EventAttendeesSection(props: {attendees: CalendarAttendee[];actions?: JSX.Element;notice?: string;+ guestListHidden?: boolean;}) {return (<Show when={props.attendees.length > 0}>@@ -652,8 +655,9 @@ export function EventAttendeesSection(props: {<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)}+ {props.guestListHidden+ ? 'Guest list hidden'+ : `${props.attendees.length} ${plural('attendee', props.attendees.length)}`}</span><CaretDownIconaria-hidden="true"diff --git a/apps/web/src/features/calendar/components/composer/EventForm.tsx b/apps/web/src/features/calendar/components/composer/EventForm.tsxindex 49f3045efe..9d4f2ffd93 100644--- a/apps/web/src/features/calendar/components/composer/EventForm.tsx+++ b/apps/web/src/features/calendar/components/composer/EventForm.tsx@@ -46,6 +46,8 @@ export interface EventFormProps {addOnlyGuests?: boolean;/** Why a read-only guest list cannot change. */guestsReadOnlyReason?: string;+ /** The organizer hides the guest list, so the seeded guests are not all of them. */+ guestListHidden?: boolean;/** Whether the viewer may set what guests may do, as the organizer. */guestPolicyEditable?: boolean;/**@@ -324,6 +326,7 @@ export function EventForm(props: EventFormProps) {disabled={formIsDisabled()}readOnly={fieldIsReadOnly('guests')}readOnlyReason={props.guestsReadOnlyReason}+ guestListHidden={props.guestListHidden}currentGuests={props.addOnlyGuests ? controller.initialGuests() : undefined}diff --git a/apps/web/src/features/calendar/components/composer/EventPropertyPills.test.tsx b/apps/web/src/features/calendar/components/composer/EventPropertyPills.test.tsxindex d071e51649..020125bb31 100644--- a/apps/web/src/features/calendar/components/composer/EventPropertyPills.test.tsx+++ b/apps/web/src/features/calendar/components/composer/EventPropertyPills.test.tsx@@ -265,6 +265,30 @@ describe('EventComposerGuestsPill for a guest who may only add guests', () => {screen.getByText('Only the organizer can invite guests.')).toBeTruthy();});++ it('names a hidden guest list instead of claiming there are no guests', async () => {+ const user = userEvent.setup();+ render(() => (+ <EventComposerGuestsPill+ options={() => []}+ selected={[]}+ onChange={vi.fn()}+ readOnly+ readOnlyReason="Guests cannot be added while the organizer hides the guest list."+ guestListHidden+ />+ ));++ const pill = screen.getByRole('button', { name: 'Guest list hidden' });+ expect(pill.textContent).toContain('Guest list hidden');+ await user.click(pill);+ expect(+ screen.getByText(+ 'Guests cannot be added while the organizer hides the guest list.'+ )+ ).toBeTruthy();+ expect(screen.queryByText('No guests')).toBeNull();+ });});describe('EventComposerConferencePill', () => {diff --git a/apps/web/src/features/calendar/components/composer/EventPropertyPills.tsx b/apps/web/src/features/calendar/components/composer/EventPropertyPills.tsxindex af132945a3..27a641a23d 100644--- a/apps/web/src/features/calendar/components/composer/EventPropertyPills.tsx+++ b/apps/web/src/features/calendar/components/composer/EventPropertyPills.tsx@@ -85,6 +85,11 @@ export interface EventComposerGuestsPillProps {readOnly?: boolean;/** Why a read-only guest list cannot change, shown as a tooltip. */readOnlyReason?: string;+ /**+ * The organizer hides the guest list, so `selected` holds only the guests+ * the viewer may see and the pill names the list hidden instead.+ */+ guestListHidden?: boolean;/*** The event's current guests when the viewer may add guests but not remove* them; they stay in `selected` and the editor only adds to them.@@ -117,7 +122,7 @@ function ReadOnlyEventComposerGuestsPill(props: EventComposerGuestsPillProps) {><Popover.Triggerdisabled={props.disabled}- aria-label="Guests"+ aria-label={props.guestListHidden ? 'Guest list hidden' : 'Guests'}aria-readonly="true"aria-description={props.readOnlyReason}class={cn(PROPERTY_TRIGGER_CLASS, 'max-w-48 overflow-hidden')}@@ -134,7 +139,9 @@ function ReadOnlyEventComposerGuestsPill(props: EventComposerGuestsPillProps) {: 'text-ink-extra-muted')}>- {guestPropertyLabel(props.selected)}+ {props.guestListHidden+ ? 'Guest list hidden'+ : guestPropertyLabel(props.selected)}</span><CaretDownIcon class="size-3 shrink-0 text-ink-extra-muted" /></Popover.Trigger>@@ -151,9 +158,11 @@ function ReadOnlyEventComposerGuestsPill(props: EventComposerGuestsPillProps) {<Showwhen={props.selected.length > 0}fallback={- <p class="px-2 py-4 text-center text-sm text-ink-muted">- No guests- </p>+ <Show when={!props.guestListHidden}>+ <p class="px-2 py-4 text-center text-sm text-ink-muted">+ No guests+ </p>+ </Show>}><div class="flex max-h-64 flex-col overflow-y-auto">diff --git a/apps/web/src/features/calendar/hooks/create-guest-invite-controller.ts b/apps/web/src/features/calendar/hooks/create-guest-invite-controller.tsindex 204ac55d2d..b25f5dd4c4 100644--- a/apps/web/src/features/calendar/hooks/create-guest-invite-controller.ts+++ b/apps/web/src/features/calendar/hooks/create-guest-invite-controller.ts@@ -3,6 +3,7 @@ import { fireAndForget } from '@core/util/fireAndForget';import {type InviteCalendarEventGuestsArgs,isGuestInviteRefused,+ isGuestListHiddenRefusal,useInviteCalendarEventGuestsMutation,} from '@queries/calendar/mutations';import type { CalendarInviteScope } from '@service-email/client';@@ -11,7 +12,8 @@ import { type Accessor, createSignal } from 'solid-js';import type { CalendarEvent } from '../types';import {GUEST_INVITES_RESTRICTED,- guestInvitesRestricted,+ GUEST_LIST_HIDDEN,+ guestInvitesRestrictedReason,} from '../utils/event-guest-editing';/** Guests an editor sends an invitation to, with the names its toast uses. */@@ -30,15 +32,15 @@ export function invitationSentMessage(guests: readonly { name: string }[]) {* Inviting guests from event details. The editor closes as soon as the* invitation goes out, while the mutation shows the new guests as unanswered.* The outcome is announced once the provider answers, since that takes- * seconds. A refusal means the organizer does not let guests invite, which- * switches the details to their explanation.+ * seconds. A refusal means the organizer does not let guests invite, or+ * hides the guest list, which switches the details to that explanation.*/export function createGuestInviteController(event: Accessor<CalendarEvent>,enabled: Accessor<boolean>) {const [editorOpen, setEditorOpen] = createSignal(false);- const [refused, setRefused] = createSignal(false);+ const [refusal, setRefusal] = createSignal<string>();const mutation = useInviteCalendarEventGuestsMutation();const deliver = async (@@ -57,9 +59,14 @@ export function createGuestInviteController(toast.success(sentMessage);return;}- if (isGuestInviteRefused(result.error)) {- setRefused(true);- toast.failure(GUEST_INVITES_RESTRICTED);+ const refusedWith = isGuestInviteRefused(result.error)+ ? GUEST_INVITES_RESTRICTED+ : isGuestListHiddenRefusal(result.error)+ ? GUEST_LIST_HIDDEN+ : undefined;+ if (refusedWith) {+ setRefusal(refusedWith);+ toast.failure(refusedWith);return;}toast.failure('Could not send invitations', {@@ -74,14 +81,15 @@ export function createGuestInviteController(const current = event();return (enabled() &&- !refused() &&+ !refusal() &&!current.isReadOnly &&!current.isCancelled &&!current.teamProjection &¤t.viewerCan.inviteGuests);},- restricted: () => refused() || guestInvitesRestricted(event()),+ /** Why the viewer cannot add guests, shown above the guest list. */+ restrictedReason: () => refusal() ?? guestInvitesRestrictedReason(event()),send: (invitation: GuestInvitation) => {if (invitation.guests.length === 0) return;if (!navigator.onLine) {diff --git a/apps/web/src/features/calendar/hooks/use-event-editor.ts b/apps/web/src/features/calendar/hooks/use-event-editor.tsindex bfe57a0675..8338319488 100644--- a/apps/web/src/features/calendar/hooks/use-event-editor.ts+++ b/apps/web/src/features/calendar/hooks/use-event-editor.ts@@ -43,10 +43,10 @@ import {type EventGuestEditing,eventGuestEditing,GUEST_EDITS_RESTRICTED,- GUEST_INVITES_RESTRICTED,guestEditsRestricted,- guestInvitesRestricted,+ guestInvitesRestrictedReason,guestListChanged,+ guestListHidden,viewerReplacesGuests,} from '../utils/event-guest-editing';import {@@ -202,9 +202,7 @@ export function useEventEditor(props: UseEventEditorProps) {});const guestsReadOnlyReason = () => {const event = props.event();- return event && guestInvitesRestricted(event)- ? GUEST_INVITES_RESTRICTED- : undefined;+ return event && guestInvitesRestrictedReason(event);};// A refusal means the stored guest policy was newer than the event shown,// so the details lock without waiting for the refetch.@@ -512,6 +510,10 @@ export function useEventEditor(props: UseEventEditorProps) {disabledFields,addOnlyGuests: () => guestEditing() === 'add',guestsReadOnlyReason,+ guestListHidden: () => {+ const event = props.event();+ return event !== undefined && guestListHidden(event);+ },/** The organizer sets what guests may do; a new event is the viewer's own. */guestPolicyEditable: () =>(props.guestInvitesEnabled?.() ?? false) &&diff --git a/apps/web/src/features/calendar/utils/event-guest-editing.test.ts b/apps/web/src/features/calendar/utils/event-guest-editing.test.tsindex 584b8bd9bf..b3fc668b2d 100644--- a/apps/web/src/features/calendar/utils/event-guest-editing.test.ts+++ b/apps/web/src/features/calendar/utils/event-guest-editing.test.ts@@ -4,8 +4,12 @@ import type { CalendarEvent } from '../types';import {addedGuestEmails,eventGuestEditing,+ GUEST_INVITES_RESTRICTED,+ GUEST_LIST_HIDDEN,guestInvitesRestricted,+ guestInvitesRestrictedReason,guestListChanged,+ guestListHidden,} from './event-guest-editing';function attendee(overrides: Partial<CalendarAttendee>): CalendarAttendee {@@ -164,6 +168,88 @@ describe('guestInvitesRestricted', () => {});});+describe('guestInvitesRestrictedReason', () => {+ const policy = (+ canSeeOtherGuests: boolean,+ canInviteOthers: boolean,+ canModify = false+ ) => ({ canModify, canInviteOthers, canSeeOtherGuests });+ // Google gives a guest's copy of a hidden list only the guest, and the+ // server lets no guest add to it.+ const hiddenFrom = (guestPolicy: CalendarEvent['guestPolicy']) =>+ event({+ guestPolicy,+ viewerCan: GUEST,+ attendees: [attendee({ email: '[email protected]', isSelf: true })],+ });++ it('blames the hidden guest list when the organizer lets guests invite or modify', () => {+ expect(guestInvitesRestrictedReason(hiddenFrom(policy(false, true)))).toBe(+ GUEST_LIST_HIDDEN+ );+ expect(+ guestInvitesRestrictedReason(hiddenFrom(policy(false, true, true)))+ ).toBe(GUEST_LIST_HIDDEN);+ });++ it('names the organizer when guests may not invite, hidden list or not', () => {+ expect(guestInvitesRestrictedReason(hiddenFrom(policy(false, false)))).toBe(+ GUEST_INVITES_RESTRICTED+ );+ expect(+ guestInvitesRestrictedReason({+ ...invited(GUEST),+ guestPolicy: policy(true, false),+ })+ ).toBe(GUEST_INVITES_RESTRICTED);+ });++ it('says nothing to a guest who may invite', () => {+ expect(guestInvitesRestrictedReason(invited(INVITING_GUEST))).toBe(+ undefined+ );+ });+});++describe('guestListHidden', () => {+ const hidden = {+ canModify: false,+ canInviteOthers: true,+ canSeeOtherGuests: false,+ };++ it('holds for a guest on their own copy of a hidden list', () => {+ expect(guestListHidden({ ...invited(GUEST), guestPolicy: hidden })).toBe(+ true+ );+ });++ it('does not hold for the organizer, who sees every guest', () => {+ expect(+ guestListHidden({ ...invited(ORGANIZER), guestPolicy: hidden })+ ).toBe(false);+ });++ it('does not hold for someone else’s copy or a snapshot', () => {+ expect(+ guestListHidden(+ event({+ viewerCan: GUEST,+ guestPolicy: hidden,+ attendees: [attendee({ email: '[email protected]' })],+ })+ )+ ).toBe(false);+ expect(+ guestListHidden({+ ...invited({ ...GUEST, rsvp: false }),+ guestPolicy: hidden,+ isSnapshot: true,+ })+ ).toBe(false);+ });+});+describe('addedGuestEmails', () => {const current = invited(INVITING_GUEST);diff --git a/apps/web/src/features/calendar/utils/event-guest-editing.ts b/apps/web/src/features/calendar/utils/event-guest-editing.tsindex ca37c8deb3..6eb4b1c918 100644--- a/apps/web/src/features/calendar/utils/event-guest-editing.ts+++ b/apps/web/src/features/calendar/utils/event-guest-editing.ts@@ -4,6 +4,13 @@ import type { CalendarEvent } from '../types';/** Shown where a guest would add guests when the organizer does not allow it. */export const GUEST_INVITES_RESTRICTED = 'Only the organizer can invite guests.';+/**+ * Shown where a guest would add guests when the organizer allows inviting+ * but hides the guest list; the server refuses with the same words.+ */+export const GUEST_LIST_HIDDEN =+ 'Guests cannot be added while the organizer hides the guest list.';+/** Shown where a guest would change the event when the organizer does not allow it. */export const GUEST_EDITS_RESTRICTED ='Only the organizer can change this event.';@@ -94,6 +101,35 @@ export function guestInvitesRestricted(event: CalendarEvent): boolean {);}+/**+ * Whether the organizer hides the guest list from the viewer, a guest on+ * their own copy. Google then gives that copy only the viewer and perhaps the+ * organizer, so its attendees are not the real guest list.+ */+export function guestListHidden(event: CalendarEvent): boolean {+ return (+ !event.isSnapshot &&+ !event.viewerCan.organize &&+ !event.guestPolicy.canSeeOtherGuests &&+ event.attendees.some((attendee) => attendee.isSelf)+ );+}++/**+ * Why the viewer's guest list cannot grow, when it is worth saying. Google+ * would let a guest the organizer lets invite add guests to a hidden list,+ * but Macro cannot, since a guest's copy of that list is incomplete.+ */+export function guestInvitesRestrictedReason(+ event: CalendarEvent+): string | undefined {+ if (!guestInvitesRestricted(event)) return undefined;+ const policy = event.guestPolicy;+ return guestListHidden(event) && (policy.canInviteOthers || policy.canModify)+ ? GUEST_LIST_HIDDEN+ : GUEST_INVITES_RESTRICTED;+}+/*** Whether a submitted guest list differs from the event's current one.* Attendee updates replace the whole list and notify every guest, so thediff --git a/apps/web/src/lib/queries/calendar/mutations.ts b/apps/web/src/lib/queries/calendar/mutations.tsindex aa2a49ca63..de3aae0616 100644--- a/apps/web/src/lib/queries/calendar/mutations.ts+++ b/apps/web/src/lib/queries/calendar/mutations.ts@@ -406,6 +406,14 @@ export function isGuestInviteRefused(error: unknown): boolean {);}+/** Whether an invitation failed because the organizer hides the guest list from the viewer. */+export function isGuestListHiddenRefusal(error: unknown): boolean {+ return hasCalendarMutationCode(+ error,+ CalendarMutationErrorCode.guest_list_hidden+ );+}+/** Whether a write failed because the organizer does not let the viewer change the event. */export function isGuestEditRefused(error: unknown): boolean {return hasCalendarMutationCode(@@ -458,7 +466,8 @@ async function inviteCalendarEventGuests(span.setAttr('calendar.invite.outcome', 'sent');return 'sent';} catch (error) {- const refused = isGuestInviteRefused(error);+ const refused =+ isGuestInviteRefused(error) || isGuestListHiddenRefusal(error);span.setAttr('calendar.invite.outcome', refused ? 'refused' : 'failed');// Provider messages can quote addresses; record only the category.span.error(diff --git a/docs/agent-guide/calendar.md b/docs/agent-guide/calendar.mdindex 31d6df0d5b..9b6fe02a49 100644--- a/docs/agent-guide/calendar.md+++ b/docs/agent-guide/calendar.md@@ -471,8 +471,13 @@ while a guest who may invite gets an add-only guests pill whose additions are seinvitation on save (other edits are saved first); a guest who may not invite keeps aread-only pill that explains why. A guest on an event whose organizer hides the guest listmay not invite either (`viewerCan.inviteGuests` is false; the route answers 403-`guest_list_hidden`). To check the refusal state without a Google account, answer-`POST /events/{id}/guests` with HTTP 403 and code `guests_cannot_invite`.+`guest_list_hidden`), since that guest's copy lists only themselves and perhaps the organizer:+the guests row reads `Guest list hidden` instead of a count (so does the editor's read-only+guests pill), and when the organizer does let guests invite, the explanation reads `Guests+cannot be added while the organizer hides the guest list.` instead. To check the refusal+states without a Google account, answer `POST /events/{id}/guests` with HTTP 403 and code+`guests_cannot_invite` or `guest_list_hidden`; each switches the guest list to its own+explanation and toast.An event that reached several connected inboxes shows one chip per inbox (overlapping;tell them apart by calendar color), and each copy answers only for its own inbox: aguest copy stays a guest copy, marked `(you)` on that inbox's row alone, even when