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(calendar): reachable events from AI tools, and copyable event links (#5822)

gbirman1e2a9fb2074f
diff --git a/apps/docs/AI/mcp/tools/update-calendar-event.mdx b/apps/docs/AI/mcp/tools/update-calendar-event.mdx
index 4130d1f839..273fe60120 100644
--- a/apps/docs/AI/mcp/tools/update-calendar-event.mdx
+++ b/apps/docs/AI/mcp/tools/update-calendar-event.mdx
@@ -1,6 +1,6 @@
---
title: UpdateCalendarEvent
-description: "Update an existing calendar event. Only the supplied fields change; omitted fields keep their current values. The change is written to Google immediately and attendees are notified of it, so confirm details with the user first. Get the `eventId` from ListCalendarEvents. `scope` picks how much of a recurring series changes and is always required: \"this_event\" edits one occurrence (pass the occurrence's `recurrenceId` from ListCalendarEvents) and leaves the rest of the series alone; \"all\" edits the series itself — with `time` that MOVES EVERY OCCURRENCE, so never use \"all\" to reschedule a single occurrence. Non-recurring events use \"all\". There is no this-and-following update: end the series with DeleteCalendarEvent's \"this_and_following\" and create a new event instead. Passing `attendees` replaces the full attendee list — include everyone who should remain, not just additions. An empty string for `description` or `location` clears it. Fails on events from calendars the user cannot edit."
+description: "Update an existing calendar event. Only the supplied fields change; omitted fields keep their current values. The change is written to Google immediately and attendees are notified of it, so confirm details with the user first. Get the `eventId` from ListCalendarEvents. `scope` picks how much of a recurring series changes and is always required: \"this_event\" edits one occurrence (pass the occurrence's `recurrenceId` from ListCalendarEvents) and leaves the rest of the series alone; \"all\" edits the series itself — with `time` that MOVES EVERY OCCURRENCE, so never use \"all\" to reschedule a single occurrence. Non-recurring events use \"all\". There is no this-and-following update: end the series with DeleteCalendarEvent's \"this_and_following\" and create a new event instead. Passing `attendees` replaces the full attendee list — include everyone who should remain, not just additions. An empty string for `description` or `location` clears it. Fails on events from calendars the user cannot edit. `rsvp` sets the user's own response to an invitation and is independent of the field edits — it can be the only thing this call changes. It applies at the same `scope` as the rest of the call, and only works on events the user is actually an attendee of."
---
# UpdateCalendarEvent
@@ -11,6 +11,8 @@ Update an existing calendar event. Only the supplied fields change; omitted fiel
Passing `attendees` replaces the full attendee list — include everyone who should remain, not just additions. An empty string for `description` or `location` clears it. Fails on events from calendars the user cannot edit.
+`rsvp` sets the user's own response to an invitation and is independent of the field edits — it can be the only thing this call changes. It applies at the same `scope` as the rest of the call, and only works on events the user is actually an attendee of.
+
## Parameters
| Parameter | Type | Required | Description |
@@ -25,3 +27,5 @@ Passing `attendees` replaces the full attendee list — include everyone who sho
| `attendees` | AttendeeInput[] | No | Replacement attendee list — replaces all current attendees, so include everyone who should remain. Omit to leave attendees unchanged. |
| `recurrenceLines` | string[] | No | Replacement RFC 5545 recurrence lines. An empty list makes the event one-off; omit to keep the current recurrence. Only valid with scope "all". |
| `conference` | `"google_meet"` \| `"remove"` | No | Change the event's video conference: "google_meet" attaches a fresh Google Meet, "remove" detaches the current conference. Omit to leave it untouched. |
+| `reminders` | EventRemindersInput | No | Replacement notification reminders. `useDefault: true` follows the calendar's own defaults; otherwise `overrides` replaces the whole list with entries of `method` "popup" (a Macro notification) or "email" and `minutes` before the start — an empty list silences the event. Omit to keep the current reminders. |
+| `rsvp` | `"accepted"` \| `"declined"` \| `"tentative"` | No | Set the user's own response to the invitation: "accepted", "declined", or "tentative". Omit to leave their response alone. |
diff --git a/apps/web/src/features/block-calendar/copy-event-mention.test.ts b/apps/web/src/features/block-calendar/copy-event-mention.test.ts
new file mode 100644
index 0000000000..7baa3554ad
--- /dev/null
+++ b/apps/web/src/features/block-calendar/copy-event-mention.test.ts
@@ -0,0 +1,71 @@
+import { beforeEach, describe, expect, it, vi } from 'vitest';
+import { copyCalendarEventMentionTarget } from './copy-event-mention';
+
+const writeClipboardData = vi.hoisted(() =>
+ vi.fn(async (_data: Record<string, string | undefined>) => true)
+);
+
+vi.mock('@core/util/dataTransfer', () => ({ writeClipboardData }));
+vi.mock('@core/component/Toast/Toast', () => ({
+ toast: { success: vi.fn(), failure: vi.fn() },
+}));
+
+const written = () => writeClipboardData.mock.calls[0]?.[0];
+
+describe('copyCalendarEventMentionTarget', () => {
+ beforeEach(() => writeClipboardData.mockClear());
+
+ it('writes a mention span an editor can import', async () => {
+ await copyCalendarEventMentionTarget({
+ eventId: 'event-1',
+ title: 'Smart Macro Discussion',
+ });
+
+ const html = written()?.['text/html'];
+ expect(html).toContain('data-document-mention="true"');
+ expect(html).toContain('data-document-id="event-1"');
+ expect(html).toContain('data-block-name="calendar"');
+ expect(html).not.toContain('data-block-params');
+ });
+
+ it('pins the occurrence when one is given', async () => {
+ await copyCalendarEventMentionTarget({
+ eventId: 'event-1',
+ title: 'Standup',
+ occurrenceKey: '2026-08-21T18:00:00+00:00',
+ });
+
+ expect(written()?.['text/html']).toContain(
+ `data-block-params="${JSON.stringify({ occurrenceKey: '2026-08-21T18:00:00+00:00' }).replaceAll('"', '&quot;')}"`
+ );
+ });
+
+ // `importDOM` reads the title back off the attribute, so a title carrying
+ // quotes or angle brackets has to survive the round trip intact.
+ it('round-trips a title that could break the markup', async () => {
+ const title = 'Q3 "<review>" & retro';
+ await copyCalendarEventMentionTarget({ eventId: 'event-1', title });
+
+ const html = written()?.['text/html'] ?? '';
+ const span = new DOMParser()
+ .parseFromString(html, 'text/html')
+ .querySelector('span');
+ expect(span?.getAttribute('data-document-name')).toBe(title);
+ expect(span?.textContent).toBe(title);
+ });
+
+ it('falls back to a deep link for the plain flavor', async () => {
+ await copyCalendarEventMentionTarget({
+ eventId: 'event-1',
+ title: 'Standup',
+ occurrenceKey: '2026-08-21T18:00:00+00:00',
+ });
+
+ const plain = written()?.['text/plain'] ?? '';
+ expect(plain).toContain('/app/calendar/');
+ expect(plain).toContain('eventId=event-1');
+ expect(plain).toContain(
+ `occurrenceKey=${encodeURIComponent('2026-08-21T18:00:00+00:00')}`
+ );
+ });
+});
diff --git a/apps/web/src/features/block-calendar/copy-event-mention.ts b/apps/web/src/features/block-calendar/copy-event-mention.ts
index 7cb9720671..4baaee0431 100644
--- a/apps/web/src/features/block-calendar/copy-event-mention.ts
+++ b/apps/web/src/features/block-calendar/copy-event-mention.ts
@@ -3,6 +3,14 @@ import { toast } from '@core/component/Toast/Toast';
import { writeClipboardData } from '@core/util/dataTransfer';
import { CALENDAR_BLOCK_ID } from './types';
+/** What a copied event needs to come back as a mention or a deep link. */
+export type CalendarMentionTarget = {
+ eventId: string;
+ title: string;
+ /** Pins one instance of a recurring series; absent for a series mention. */
+ occurrenceKey?: string;
+};
+
function isRecurring(event: CalendarEvent): boolean {
return event.recurrenceLines.length > 0 || event.recurrenceId !== undefined;
}
@@ -13,19 +21,19 @@ function isRecurring(event: CalendarEvent): boolean {
* `importDOM`. A series mention names the whole event; an instance of a
* recurring event pins its occurrence key.
*/
-function mentionHtml(event: CalendarEvent): string {
+function mentionHtml(target: CalendarMentionTarget): string {
const span = document.createElement('span');
span.setAttribute('data-document-mention', 'true');
- span.setAttribute('data-document-id', event.eventId);
- span.setAttribute('data-document-name', event.title);
+ span.setAttribute('data-document-id', target.eventId);
+ span.setAttribute('data-document-name', target.title);
span.setAttribute('data-block-name', 'calendar');
- if (isRecurring(event)) {
+ if (target.occurrenceKey) {
span.setAttribute(
'data-block-params',
- JSON.stringify({ occurrenceKey: event.occurrenceKey })
+ JSON.stringify({ occurrenceKey: target.occurrenceKey })
);
}
- span.textContent = event.title;
+ span.textContent = target.title;
return span.outerHTML;
}
@@ -52,13 +60,12 @@ export function calendarEventDeepLink(target: {
* Copy an event to the clipboard as a calendar mention (rich flavor) with a
* deep link fallback (plain flavor). Must be called from a user gesture.
*/
-export async function copyCalendarEventMention(event: CalendarEvent) {
+export async function copyCalendarEventMentionTarget(
+ target: CalendarMentionTarget
+) {
const written = await writeClipboardData({
- 'text/html': mentionHtml(event),
- 'text/plain': calendarEventDeepLink({
- eventId: event.eventId,
- occurrenceKey: isRecurring(event) ? event.occurrenceKey : undefined,
- }),
+ 'text/html': mentionHtml(target),
+ 'text/plain': calendarEventDeepLink(target),
});
if (written) {
toast.success('Copied event to clipboard');
@@ -66,3 +73,12 @@ export async function copyCalendarEventMention(event: CalendarEvent) {
toast.failure('Failed to copy event');
}
}
+
+/** Copy a calendar-grid event, pinning the instance when it repeats. */
+export async function copyCalendarEventMention(event: CalendarEvent) {
+ await copyCalendarEventMentionTarget({
+ eventId: event.eventId,
+ title: event.title,
+ occurrenceKey: isRecurring(event) ? event.occurrenceKey : undefined,
+ });
+}
diff --git a/apps/web/src/features/entity/extractors-notification/notification-copy-link.ts b/apps/web/src/features/entity/extractors-notification/notification-copy-link.ts
new file mode 100644
index 0000000000..cc88407f86
--- /dev/null
+++ b/apps/web/src/features/entity/extractors-notification/notification-copy-link.ts
@@ -0,0 +1,36 @@
+import { copyCalendarEventMentionTarget } from '@block-calendar/copy-event-mention';
+import { toast } from '@core/component/Toast/Toast';
+import { buildSimpleEntityUrl } from '@core/util/url';
+import {
+ getChannelNotificationParams,
+ type UnifiedNotification,
+} from '@notifications';
+
+/**
+ * Copy the link to whatever a notification points at.
+ *
+ * The calendar is a singleton block, so an event has no `/app/calendar_event`
+ * route to address it by id — a reminder copies the calendar's deep link for
+ * the occurrence it fired for, with the mention flavor behind it so a paste
+ * into an editor stays a live mention.
+ */
+export async function copyNotificationLink(notification: UnifiedNotification) {
+ const metadata = notification.notification_metadata;
+ if (metadata.tag === 'calendar_event_reminder') {
+ await copyCalendarEventMentionTarget({
+ eventId: metadata.content.eventId,
+ title: metadata.content.title,
+ occurrenceKey: metadata.content.occurrenceKey,
+ });
+ return;
+ }
+
+ const { params } = getChannelNotificationParams(notification);
+ await navigator.clipboard.writeText(
+ buildSimpleEntityUrl(
+ { type: notification.entity_type, id: notification.entity_id },
+ params
+ )
+ );
+ toast.success('Link copied to clipboard');
+}
diff --git a/apps/web/src/features/entity/extractors-notification/notification-row.tsx b/apps/web/src/features/entity/extractors-notification/notification-row.tsx
index e282336a00..47a855f66f 100644
--- a/apps/web/src/features/entity/extractors-notification/notification-row.tsx
+++ b/apps/web/src/features/entity/extractors-notification/notification-row.tsx
@@ -2,15 +2,9 @@ import { globalSplitManager } from '@app/signal/splitLayout';
import { useGlobalNotificationSource } from '@components/app/GlobalAppState';
import { useSplitPanel } from '@components/app/split-layout/layoutUtils';
import { ContextMenuContent, MenuItem } from '@core/component/ContextMenu';
-import { toast } from '@core/component/Toast/Toast';
import type { NotificationType } from '@core/types';
-import { buildSimpleEntityUrl } from '@core/util/url';
import { ContextMenu } from '@kobalte/core/context-menu';
-import {
- getChannelNotificationParams,
- openNotification,
- type UnifiedNotification,
-} from '@notifications';
+import { openNotification, type UnifiedNotification } from '@notifications';
import CheckIcon from '@phosphor/check.svg';
import { Button, cn } from '@ui';
import { type JSX, Match, Show, Switch } from 'solid-js';
@@ -22,19 +16,12 @@ import {
DocumentMentionPill,
NotificationContent,
} from './notification-content';
+import { copyNotificationLink } from './notification-copy-link';
import { NotificationDescription } from './notification-description';
import { NotificationIcon } from './notification-icon';
import { NotificationSenderIcon } from './notification-sender-icon';
import { NotificationTimestamp } from './notification-timestamp';
-function getNotificationUrl(notification: UnifiedNotification): string {
- const { params } = getChannelNotificationParams(notification);
- return buildSimpleEntityUrl(
- { type: notification.entity_type, id: notification.entity_id },
- params
- );
-}
-
/**
* Per-type content renderer for a single, unstacked notification.
*
@@ -344,11 +331,7 @@ export function NotificationRow(props: NotificationRowProps) {
await markAsRead();
};
- const handleCopyLink = async () => {
- const url = getNotificationUrl(props.notification);
- await navigator.clipboard.writeText(url);
- toast.success('Link copied to clipboard');
- };
+ const handleCopyLink = () => copyNotificationLink(props.notification);
const bodyProps = (): BodyProps => ({
notification: props.notification,
diff --git a/apps/web/src/features/entity/extractors-notification/notification-stacks.tsx b/apps/web/src/features/entity/extractors-notification/notification-stacks.tsx
index 080d5d0de0..b5a04b0c8e 100644
--- a/apps/web/src/features/entity/extractors-notification/notification-stacks.tsx
+++ b/apps/web/src/features/entity/extractors-notification/notification-stacks.tsx
@@ -2,12 +2,8 @@ import { globalSplitManager } from '@app/signal/splitLayout';
import { useGlobalNotificationSource } from '@components/app/GlobalAppState';
import { useSplitPanel } from '@components/app/split-layout/layoutUtils';
import { ContextMenuContent, MenuItem } from '@core/component/ContextMenu';
-import { toast } from '@core/component/Toast/Toast';
-import { buildSimpleEntityUrl } from '@core/util/url';
import { ContextMenu } from '@kobalte/core/context-menu';
-import type { UnifiedNotification } from '@notifications';
import {
- getChannelNotificationParams,
getMostRecentNotification,
type NotificationStack,
openNotification,
@@ -27,6 +23,7 @@ import {
} from '../utils/notification';
import { useNotificationStackActions } from './notification-actions';
import { NotificationContent } from './notification-content';
+import { copyNotificationLink } from './notification-copy-link';
import { NotificationDescription } from './notification-description';
import { NotificationIcon } from './notification-icon';
import { NotificationSenderIcon } from './notification-sender-icon';
@@ -34,14 +31,6 @@ import { NotificationTimestamp } from './notification-timestamp';
const DEFAULT_VISIBLE_COUNT = 3;
-function getNotificationUrl(notification: UnifiedNotification): string {
- const { params } = getChannelNotificationParams(notification);
- return buildSimpleEntityUrl(
- { type: notification.entity_type, id: notification.entity_id },
- params
- );
-}
-
interface NotificationStacksProps {
entity: WithNotification<EntityData>;
onClick?: (e: PointerEvent | MouseEvent | KeyboardEvent) => void;
@@ -100,12 +89,8 @@ export function NotificationStackRow(props: {
await markStackAsRead();
};
- const handleCopyLink = async () => {
- const mostRecent = getMostRecentNotification(props.stack);
- const url = getNotificationUrl(mostRecent);
- await navigator.clipboard.writeText(url);
- toast.success('Link copied to clipboard');
- };
+ const handleCopyLink = () =>
+ copyNotificationLink(getMostRecentNotification(props.stack));
return (
<ContextMenu>
diff --git a/apps/web/src/features/next-soup/actions/make-copy-link-action.ts b/apps/web/src/features/next-soup/actions/make-copy-link-action.ts
index 85b7dcdddb..ddca6548f5 100644
--- a/apps/web/src/features/next-soup/actions/make-copy-link-action.ts
+++ b/apps/web/src/features/next-soup/actions/make-copy-link-action.ts
@@ -1,9 +1,11 @@
+import { copyCalendarEventMentionTarget } from '@block-calendar/copy-event-mention';
import { getChannelParams } from '@block-channel/utils/link';
import { toast } from '@core/component/Toast/Toast';
import { fileTypeToBlockName } from '@core/constant/allBlocks';
import { buildSimpleEntityUrl } from '@core/util/url';
import { type EntityData, isGithubPrEntity } from '@entity';
import type { SoupState } from '../create-soup-state';
+import { calendarEventLinkTarget } from '../utils';
/**
* Get the URL type/path segment for an entity
@@ -61,6 +63,17 @@ export const makeCopyLinkAction = () => {
const entity = entities[0];
if (!entity) return;
+ // The calendar is a singleton block, so there is no /app/calendar_event
+ // route to link an event by id. Events copy the deep link the calendar's
+ // own action writes, with the mention flavor behind it.
+ if (entity.type === 'calendar_event') {
+ await copyCalendarEventMentionTarget({
+ ...calendarEventLinkTarget(entity),
+ title: entity.name || '(No title)',
+ });
+ return;
+ }
+
const url = getEntityUrl(entity);
await navigator.clipboard.writeText(url);
diff --git a/apps/web/src/features/next-soup/utils.ts b/apps/web/src/features/next-soup/utils.ts
index 65a330516f..335fdeaa37 100644
--- a/apps/web/src/features/next-soup/utils.ts
+++ b/apps/web/src/features/next-soup/utils.ts
@@ -758,6 +758,17 @@ export function markReminderSeenOnOpen(
}
/** Build the singleton block params for an event row's target occurrence. */
+/**
+ * The event and instance a calendar row points at, resolved exactly as the
+ * open path resolves it so a copied link lands where a click would.
+ */
+export function calendarEventLinkTarget(
+ entity: Extract<EntityData, { type: 'calendar_event' }>
+): { eventId: string; occurrenceKey?: string } {
+ const { eventId, occurrenceKey } = calendarBlockParamsForEntity(entity);
+ return { eventId: eventId ?? entity.id, occurrenceKey };
+}
+
function calendarBlockParamsForEntity(
entity: Extract<EntityData, { type: 'calendar_event' }>
): CalendarBlockProps {
diff --git a/apps/web/src/lib/core/component/AI/component/tool/CalendarTools.tsx b/apps/web/src/lib/core/component/AI/component/tool/CalendarTools.tsx
index 7b03087328..8a435dac08 100644
--- a/apps/web/src/lib/core/component/AI/component/tool/CalendarTools.tsx
+++ b/apps/web/src/lib/core/component/AI/component/tool/CalendarTools.tsx
@@ -1,12 +1,19 @@
+import type { CalendarBlockEventTime } from '@block-calendar/calendar-range';
import CalendarBlank from '@phosphor-icons/core/regular/calendar-blank.svg';
import CalendarDots from '@phosphor-icons/core/regular/calendar-dots.svg';
import CalendarPlus from '@phosphor-icons/core/regular/calendar-plus.svg';
import CalendarX from '@phosphor-icons/core/regular/calendar-x.svg';
+import VideoCamera from '@phosphor-icons/core/regular/video-camera.svg';
import type { NamedTool } from '@service-cognition/generated/tools/tool';
import { format, isSameDay, subDays } from 'date-fns';
import { createSignal, For, Match, Show, Switch } from 'solid-js';
import { BaseTool } from './BaseTool';
import { CalendarChatCompose } from './calendar/ChatCompose';
+import {
+ openToolCalendarEvent,
+ type ToolCalendarEvent,
+ toolInputOpenTime,
+} from './calendar/open-tool-event';
import { Tool } from './Tool';
import { createToolRenderer } from './ToolRenderer';
@@ -15,7 +22,6 @@ type CalendarEventListItem = NamedTool<
'response'
>['data']['events'][number];
-type ToolCalendarEvent = NamedTool<'UpdateCalendarEvent', 'response'>['data'];
type CreateCalendarEventResponse = NamedTool<
'CreateCalendarEvent',
'response'
@@ -45,46 +51,59 @@ const formatEventTime = (
return `${format(startsAt, 'EEE MMM d, h:mm a')} – ${format(endsAt, 'EEE MMM d, h:mm a')}`;
};
-const EventDetails = (props: { event: ToolCalendarEvent }) => (
+const EventDetails = (props: {
+ event: ToolCalendarEvent;
+ onOpen: () => void;
+}) => (
<Tool.List>
- <Tool.ListItem icon={<CalendarBlank class="size-4" />}>
- <div class="flex min-w-0 flex-col gap-0.5">
- <span class="truncate text-xs text-ink">{props.event.title}</span>
- <span class="text-xs text-ink-extra-muted">
- {formatEventTime(
- props.event.start,
- props.event.end,
- props.event.isAllDay
- )}
- </span>
- <Show when={props.event.location}>
- <span class="truncate text-xs text-ink-extra-muted">
- {props.event.location}
- </span>
- </Show>
- <Show when={props.event.attendeeCount > 0}>
- <span class="truncate text-xs text-ink-extra-muted">
- {props.event.attendeeCount === 1
- ? '1 attendee'
- : `${props.event.attendeeCount} attendees`}
- {': '}
- {props.event.attendees.map((attendee) => attendee.email).join(', ')}
+ <button
+ type="button"
+ class="block w-full text-left hover:bg-hover"
+ onClick={props.onOpen}
+ >
+ <Tool.ListItem icon={<CalendarBlank class="size-4" />}>
+ <div class="flex min-w-0 flex-col gap-0.5">
+ <span class="truncate text-xs text-ink">{props.event.title}</span>
+ <span class="text-xs text-ink-extra-muted">
+ {formatEventTime(
+ props.event.start,
+ props.event.end,
+ props.event.isAllDay
+ )}
</span>
- </Show>
- <Show when={props.event.conferenceUrl}>
- {(url) => (
- <a
- class="truncate text-xs text-accent hover:underline"
- href={url()}
- rel="noreferrer"
- target="_blank"
- >
- {url()}
- </a>
- )}
- </Show>
- </div>
- </Tool.ListItem>
+ <Show when={props.event.location}>
+ <span class="truncate text-xs text-ink-extra-muted">
+ {props.event.location}
+ </span>
+ </Show>
+ <Show when={props.event.attendeeCount > 0}>
+ <span class="truncate text-xs text-ink-extra-muted">
+ {props.event.attendeeCount === 1
+ ? '1 attendee'
+ : `${props.event.attendeeCount} attendees`}
+ {': '}
+ {props.event.attendees
+ .map((attendee) => attendee.email)
+ .join(', ')}
+ </span>
+ </Show>
+ </div>
+ </Tool.ListItem>
+ </button>
+ <Show when={props.event.conferenceUrl}>
+ {(url) => (
+ <Tool.ListItem icon={<VideoCamera class="size-4" />}>
+ <a
+ class="block truncate text-xs text-accent hover:underline"
+ href={url()}
+ rel="noreferrer"
+ target="_blank"
+ >
+ {url()}
+ </a>
+ </Tool.ListItem>
+ )}
+ </Show>
</Tool.List>
);
@@ -102,6 +121,10 @@ function CalendarMutationCard(props: {
event?: ToolCalendarEvent;
icon: typeof CalendarPlus;
label: string;
+ /** Instance the call targeted, for occurrence-scoped mutations. */
+ occurrenceKey?: string;
+ /** Locator timing to use instead of the returned event's own. */
+ openTime?: CalendarBlockEventTime;
renderContext: Parameters<typeof BaseTool>[0]['renderContext'];
status?: string;
title?: string;
@@ -109,6 +132,15 @@ function CalendarMutationCard(props: {
const [isExpanded, setIsExpanded] = createSignal(false);
const title = () => props.event?.title ?? props.title;
+ const openEvent = () => {
+ const event = props.event;
+ if (!event) return;
+ openToolCalendarEvent(event, {
+ occurrenceKey: props.occurrenceKey,
+ time: props.openTime,
+ });
+ };
+
return (
<BaseTool
icon={props.icon}
@@ -116,7 +148,7 @@ function CalendarMutationCard(props: {
type="call"
response={
props.event && isExpanded() ? (
- <EventDetails event={props.event} />
+ <EventDetails event={props.event} onOpen={openEvent} />
) : undefined
}
>
@@ -197,15 +229,26 @@ export const updateCalendarEventHandler = createToolRenderer({
name: 'UpdateCalendarEvent',
render: (ctx) => {
const scope = () => ctx.tool.data.scope;
+ const isOccurrence = () => scope() === 'this_event';
+ // An occurrence-scoped update answers with the refreshed series, so the
+ // instance has to be located from the call's own occurrence and timing.
+ const movedTime = () => {
+ const time = ctx.tool.data.time;
+ return time ? toolInputOpenTime(time) : undefined;
+ };
return (
<CalendarMutationCard
event={ctx.response?.data}
icon={CalendarDots}
label={
- scope() === 'this_event'
+ isOccurrence()
? 'Update calendar event occurrence'
: 'Update calendar event'
}
+ occurrenceKey={
+ isOccurrence() ? (ctx.tool.data.recurrenceId ?? undefined) : undefined
+ }
+ openTime={isOccurrence() ? movedTime() : undefined}
renderContext={ctx.renderContext}
title={ctx.tool.data.title ?? undefined}
/>
diff --git a/apps/web/src/lib/core/component/AI/component/tool/calendar/ChatCompose.tsx b/apps/web/src/lib/core/component/AI/component/tool/calendar/ChatCompose.tsx
index 99001a7fe0..8ed247d82f 100644
--- a/apps/web/src/lib/core/component/AI/component/tool/calendar/ChatCompose.tsx
+++ b/apps/web/src/lib/core/component/AI/component/tool/calendar/ChatCompose.tsx
@@ -23,6 +23,7 @@ import {
createCalendarEventToEditorInitialValues,
editorSubmitValuesToCreateCalendarEvent,
} from './event-form-adapter';
+import { openToolCalendarEvent } from './open-tool-event';
type CreateCalendarEventResponse = NamedTool<
'CreateCalendarEvent',
@@ -279,7 +280,9 @@ function CalendarChatComposeContent(props: CalendarChatComposeProps) {
setOperation(undefined);
updateLocalResponse(result.value as CreateCalendarEventResponse, args);
void invalidateCalendarOccurrences();
- toast.success('Calendar event created');
+ toast.success('Calendar event created', {
+ actions: [{ label: 'Open', onClick: () => openToolCalendarEvent(event) }],
+ });
}
async function handleCancel() {
diff --git a/apps/web/src/lib/core/component/AI/component/tool/calendar/open-tool-event.test.ts b/apps/web/src/lib/core/component/AI/component/tool/calendar/open-tool-event.test.ts
new file mode 100644
index 0000000000..9206be00f4
--- /dev/null
+++ b/apps/web/src/lib/core/component/AI/component/tool/calendar/open-tool-event.test.ts
@@ -0,0 +1,117 @@
+import { beforeEach, describe, expect, it, vi } from 'vitest';
+import {
+ openToolCalendarEvent,
+ type ToolCalendarEvent,
+ toolInputOpenTime,
+} from './open-tool-event';
+
+const openCalendarEventSplit = vi.hoisted(() => vi.fn());
+
+vi.mock('@block-calendar/open-calendar-event', () => ({
+ openCalendarEventSplit,
+}));
+
+const timedEvent: ToolCalendarEvent = {
+ eventId: 'event-1',
+ title: 'Standup',
+ start: '2026-08-21T16:30:00+00:00',
+ end: '2026-08-21T18:30:00+00:00',
+ isAllDay: false,
+ status: 'confirmed',
+ isRecurring: false,
+ recurrenceLines: [],
+ attendees: [],
+ attendeeCount: 0,
+ isReadOnly: false,
+};
+
+describe('openToolCalendarEvent', () => {
+ beforeEach(() => openCalendarEventSplit.mockClear());
+
+ it('locates a timed event by its own span', () => {
+ openToolCalendarEvent(timedEvent);
+
+ expect(openCalendarEventSplit).toHaveBeenCalledWith({
+ eventId: 'event-1',
+ occurrenceKey: undefined,
+ time: {
+ kind: 'timed',
+ startsAt: '2026-08-21T16:30:00+00:00',
+ endsAt: '2026-08-21T18:30:00+00:00',
+ },
+ });
+ });
+
+ it('locates an all-day event by its dates', () => {
+ openToolCalendarEvent({
+ ...timedEvent,
+ isAllDay: true,
+ start: '2026-08-21',
+ end: '2026-08-22',
+ });
+
+ expect(openCalendarEventSplit).toHaveBeenCalledWith({
+ eventId: 'event-1',
+ occurrenceKey: undefined,
+ time: { kind: 'allDay', startDate: '2026-08-21', endDate: '2026-08-22' },
+ });
+ });
+
+ // An occurrence-scoped call answers with the refreshed series, so the
+ // series' own span would aim at the master rather than the instance.
+ it('lets an occurrence key anchor the range on its own', () => {
+ openToolCalendarEvent(timedEvent, {
+ occurrenceKey: '2026-08-28T16:30:00+00:00',
+ });
+
+ expect(openCalendarEventSplit).toHaveBeenCalledWith({
+ eventId: 'event-1',
+ occurrenceKey: '2026-08-28T16:30:00+00:00',
+ time: undefined,
+ });
+ });
+
+ it('prefers supplied timing over the event span', () => {
+ openToolCalendarEvent(timedEvent, {
+ occurrenceKey: '2026-08-28T16:30:00+00:00',
+ time: { kind: 'timed', startsAt: '2026-09-04T16:30:00Z' },
+ });
+
+ expect(openCalendarEventSplit).toHaveBeenCalledWith({
+ eventId: 'event-1',
+ occurrenceKey: '2026-08-28T16:30:00+00:00',
+ time: { kind: 'timed', startsAt: '2026-09-04T16:30:00Z' },
+ });
+ });
+});
+
+describe('toolInputOpenTime', () => {
+ it('carries a timed span across', () => {
+ expect(
+ toolInputOpenTime({
+ kind: 'timed',
+ startsAt: '2026-08-21T16:30:00Z',
+ endsAt: '2026-08-21T18:30:00Z',
+ timeZone: 'America/New_York',
+ })
+ ).toEqual({
+ kind: 'timed',
+ startsAt: '2026-08-21T16:30:00Z',
+ endsAt: '2026-08-21T18:30:00Z',
+ });
+ });
+
+ it('carries an all-day span across', () => {
+ expect(
+ toolInputOpenTime({
+ kind: 'allDay',
+ startDate: '2026-08-21',
+ endDate: '2026-08-22',
+ })
+ ).toEqual({
+ kind: 'allDay',
+ startDate: '2026-08-21',
+ endDate: '2026-08-22',
+ });
+ });
+});
diff --git a/apps/web/src/lib/core/component/AI/component/tool/calendar/open-tool-event.ts b/apps/web/src/lib/core/component/AI/component/tool/calendar/open-tool-event.ts
new file mode 100644
index 0000000000..e107ae9caf
--- /dev/null
+++ b/apps/web/src/lib/core/component/AI/component/tool/calendar/open-tool-event.ts
@@ -0,0 +1,53 @@
+import type { CalendarBlockEventTime } from '@block-calendar/calendar-range';
+import { openCalendarEventSplit } from '@block-calendar/open-calendar-event';
+import type { NamedTool } from '@service-cognition/generated/tools/tool';
+
+/** The event shape the create and update calendar tools return. */
+export type ToolCalendarEvent = NamedTool<
+ 'UpdateCalendarEvent',
+ 'response'
+>['data'];
+
+type OpenToolCalendarEventOptions = {
+ /** Instance to aim at, when the call targeted one occurrence of a series. */
+ occurrenceKey?: string;
+ /**
+ * Locator timing to use instead of the event's own. An occurrence-scoped
+ * call returns the refreshed series, whose start is the master's rather
+ * than the occurrence's.
+ */
+ time?: CalendarBlockEventTime;
+};
+
+function eventTime(event: ToolCalendarEvent): CalendarBlockEventTime {
+ return event.isAllDay
+ ? { kind: 'allDay', startDate: event.start, endDate: event.end }
+ : { kind: 'timed', startsAt: event.start, endsAt: event.end };
+}
+
+/** Time fields of a tool time input, as calendar navigation expects them. */
+export function toolInputOpenTime(
+ time: NonNullable<NamedTool<'UpdateCalendarEvent', 'call'>['data']['time']>
+): CalendarBlockEventTime {
+ return time.kind === 'allDay'
+ ? { kind: 'allDay', startDate: time.startDate, endDate: time.endDate }
+ : { kind: 'timed', startsAt: time.startsAt, endsAt: time.endsAt };
+}
+
+/**
+ * Open the calendar aimed at an event a calendar tool returned, the same way
+ * clicking an event mention does.
+ */
+export function openToolCalendarEvent(
+ event: ToolCalendarEvent,
+ options?: OpenToolCalendarEventOptions
+) {
+ const occurrenceKey = options?.occurrenceKey;
+ openCalendarEventSplit({
+ eventId: event.eventId,
+ occurrenceKey,
+ // An occurrence key anchors the locator range on its own, so the event's
+ // own timing only stands in for calls that were not occurrence-scoped.
+ time: options?.time ?? (occurrenceKey ? undefined : eventTime(event)),
+ });
+}
diff --git a/apps/web/src/lib/core/component/DocumentPreview.tsx b/apps/web/src/lib/core/component/DocumentPreview.tsx
index 37ea920d61..6cebd8c270 100644
--- a/apps/web/src/lib/core/component/DocumentPreview.tsx
+++ b/apps/web/src/lib/core/component/DocumentPreview.tsx
@@ -1,7 +1,10 @@
import { parseLocalDate } from '@app/features/calendar/utils/calendar-date';
import { openChatWithAgent } from '@app/features/chat/ChatWithAgentButton';
import { globalSplitManager } from '@app/signal/splitLayout';
-import { calendarEventDeepLink } from '@block-calendar/copy-event-mention';
+import {
+ type CalendarMentionTarget,
+ copyCalendarEventMentionTarget,
+} from '@block-calendar/copy-event-mention';
import { openCalendarEventSplit } from '@block-calendar/open-calendar-event';
import { CALENDAR_BLOCK_ID } from '@block-calendar/types';
import { URL_PARAMS as URL_PARAMS_CANVAS } from '@block-canvas/constants';
@@ -693,6 +696,24 @@ export function DocumentPreviewContent(props: DocumentPreviewContentProps) {
});
};
+ // Copying an event has to reproduce what the calendar's own copy action
+ // writes, so pasting into an editor rebuilds the mention instead of
+ // dropping in a bare deep link.
+ const calendarMentionTarget = (): CalendarMentionTarget | undefined => {
+ const target = calendarOpenTarget();
+ if (!target) return undefined;
+ const i = item();
+ const previewed = isCalendarEventPreviewItem(i) ? i.event : undefined;
+ return {
+ eventId: target.eventId,
+ // An untitled event still copies as a mention, under the same
+ // '(No title)' label it carries everywhere else.
+ title: previewed?.title || props.documentInfo.name || '(No title)',
+ occurrenceKey:
+ previewed && !previewed.isRecurring ? undefined : target.occurrenceKey,
+ };
+ };
+
const handleCopy = () => {
try {
let hostname = window.location.hostname.replace('www.', '').toLowerCase();
@@ -700,10 +721,9 @@ export function DocumentPreviewContent(props: DocumentPreviewContentProps) {
hostname = 'dev.macro.com';
}
- const calendarTarget = calendarOpenTarget();
- if (calendarTarget) {
- navigator.clipboard.writeText(calendarEventDeepLink(calendarTarget));
- toast.success('Copied document link to clipboard');
+ const mentionTarget = calendarMentionTarget();
+ if (mentionTarget) {
+ copyCalendarEventMentionTarget(mentionTarget);
return;
}
diff --git a/apps/web/src/lib/service-clients/service-cognition/generated/tools/schemas.ts b/apps/web/src/lib/service-clients/service-cognition/generated/tools/schemas.ts
index 3f41126bfc..dbec80e627 100644
--- a/apps/web/src/lib/service-clients/service-cognition/generated/tools/schemas.ts
+++ b/apps/web/src/lib/service-clients/service-cognition/generated/tools/schemas.ts
@@ -3874,6 +3874,46 @@ export const UpdateCalendarEvent = z.object({
z.null(),
])
.optional(),
+ reminders: z
+ .union([
+ z.object({
+ useDefault: z.boolean(),
+ overrides: z
+ .array(
+ z.object({ method: z.string(), minutes: z.number().int().gte(0) })
+ )
+ .optional(),
+ }),
+ z.null(),
+ ])
+ .optional(),
+ rsvp: z
+ .union([
+ z.any().superRefine((x, ctx) => {
+ const schemas = [
+ z.literal('accepted'),
+ z.literal('declined'),
+ z.literal('tentative'),
+ ];
+ const errors = schemas.reduce<z.ZodError[]>(
+ (errors, schema) =>
+ ((result) => (result.error ? [...errors, result.error] : errors))(
+ schema.safeParse(x)
+ ),
+ []
+ );
+ if (schemas.length - errors.length !== 1) {
+ ctx.addIssue({
+ path: ctx.path,
+ code: 'invalid_union',
+ unionErrors: errors,
+ message: 'Invalid input: Should pass single schema',
+ });
+ }
+ }),
+ z.null(),
+ ])
+ .optional(),
});
export const ToolCalendarEvent = z.object({
diff --git a/apps/web/src/lib/service-clients/service-cognition/generated/tools/types.ts b/apps/web/src/lib/service-clients/service-cognition/generated/tools/types.ts
index 4248bf8caa..c6c6c499c4 100644
--- a/apps/web/src/lib/service-clients/service-cognition/generated/tools/types.ts
+++ b/apps/web/src/lib/service-clients/service-cognition/generated/tools/types.ts
@@ -611,6 +611,10 @@ export type UpdateScopeInput = 'all' | 'this_event';
* A requested change to an event's video conference.
*/
export type ConferenceChangeInput = 'google_meet' | 'remove';
+/**
+ * The requester's own RSVP on an event they were invited to.
+ */
+export type RsvpResponseInput = 'accepted' | 'declined' | 'tentative';
/**
* Content of a web fetch response - either a successful result or an error
*/
@@ -4403,6 +4407,8 @@ export interface TextEditorCodeExecutionToolError {
* `scope` picks how much of a recurring series changes and is always required: "this_event" edits one occurrence (pass the occurrence's `recurrenceId` from ListCalendarEvents) and leaves the rest of the series alone; "all" edits the series itself — with `time` that MOVES EVERY OCCURRENCE, so never use "all" to reschedule a single occurrence. Non-recurring events use "all". There is no this-and-following update: end the series with DeleteCalendarEvent's "this_and_following" and create a new event instead.
*
* Passing `attendees` replaces the full attendee list — include everyone who should remain, not just additions. An empty string for `description` or `location` clears it. Fails on events from calendars the user cannot edit.
+ *
+ * `rsvp` sets the user's own response to an invitation and is independent of the field edits — it can be the only thing this call changes. It applies at the same `scope` as the rest of the call, and only works on events the user is actually an attendee of.
*/
export interface UpdateCalendarEvent {
/**
@@ -4442,6 +4448,14 @@ export interface UpdateCalendarEvent {
* Change the event's video conference: "google_meet" attaches a fresh Google Meet, "remove" detaches the current conference. Omit to leave it untouched.
*/
conference?: ConferenceChangeInput | null;
+ /**
+ * Replacement notification reminders. `useDefault: true` follows the calendar's own defaults; otherwise `overrides` replaces the whole list with entries of `method` "popup" (a Macro notification) or "email" and `minutes` before the start — an empty list silences the event. Omit to keep the current reminders.
+ */
+ reminders?: EventRemindersInput | null;
+ /**
+ * Set the user's own response to the invitation: "accepted", "declined", or "tentative". Omit to leave their response alone.
+ */
+ rsvp?: RsvpResponseInput | null;
}
/**
* Change one of the current user's reminders: reword it, move when it fires, or mark it done. Get the `reminderId` from ListReminders or CreateReminder.
diff --git a/crates/calendar_events/src/inbound/toolset/mod.rs b/crates/calendar_events/src/inbound/toolset/mod.rs
index 9795b075a7..6538960960 100644
--- a/crates/calendar_events/src/inbound/toolset/mod.rs
+++ b/crates/calendar_events/src/inbound/toolset/mod.rs
@@ -37,7 +37,9 @@ pub use list_calendar_events::{
CalendarEventListItem, ListCalendarEvents, ListCalendarEventsResponse,
};
pub use list_calendars::{ListCalendars, ListCalendarsToolResponse, ToolCalendar};
-pub use update_calendar_event::{ConferenceChangeInput, UpdateCalendarEvent, UpdateScopeInput};
+pub use update_calendar_event::{
+ ConferenceChangeInput, RsvpResponseInput, UpdateCalendarEvent, UpdateScopeInput,
+};
/// Service context for calendar AI tools.
pub struct CalendarToolContext<M, O>
diff --git a/crates/calendar_events/src/inbound/toolset/test.rs b/crates/calendar_events/src/inbound/toolset/test.rs
index 8d7acaec29..0504cf3277 100644
--- a/crates/calendar_events/src/inbound/toolset/test.rs
+++ b/crates/calendar_events/src/inbound/toolset/test.rs
@@ -141,6 +141,7 @@ struct MockMutations {
create_error: Mutex<Option<CalendarMutationError>>,
updated: Mutex<Vec<(Uuid, CalendarEventPatch, CalendarUpdateScope)>>,
deleted: Mutex<Vec<(Uuid, CalendarDeletionScope)>>,
+ answered: Mutex<Vec<(Uuid, AttendeeResponseStatus, CalendarRsvpScope)>>,
calendars: Mutex<Vec<VisibleCalendar>>,
}
@@ -193,11 +194,15 @@ impl CalendarMutationService for MockMutations {
async fn respond_to_event(
&self,
_requester_id: &str,
- _event_id: Uuid,
- _response: AttendeeResponseStatus,
- _scope: CalendarRsvpScope,
+ event_id: Uuid,
+ response: AttendeeResponseStatus,
+ scope: CalendarRsvpScope,
) -> Result<crate::domain::models::CalendarEvent, CalendarMutationError> {
- unreachable!("no calendar tool responds to events")
+ self.answered
+ .lock()
+ .unwrap()
+ .push((event_id, response, scope));
+ Ok(sample_event(Vec::new()))
}
async fn disconnect_calendar(
@@ -426,6 +431,8 @@ async fn update_converts_input_into_a_domain_patch() {
}]),
recurrence_lines: None,
conference: Some(ConferenceChangeInput::Remove),
+ reminders: None,
+ rsvp: None,
};
tool.call(context, request_context()).await.unwrap();
@@ -463,6 +470,8 @@ async fn update_passes_the_selected_occurrence_scope() {
attendees: None,
recurrence_lines: None,
conference: None,
+ reminders: None,
+ rsvp: None,
};
tool.call(context, request_context()).await.unwrap();
@@ -491,6 +500,8 @@ async fn scoped_update_requires_a_recurrence_id() {
attendees: None,
recurrence_lines: None,
conference: None,
+ reminders: None,
+ rsvp: None,
};
let error = tool.call(context, request_context()).await.unwrap_err();
assert!(error.description.contains("recurrenceId"));
@@ -515,12 +526,173 @@ async fn series_update_rejects_a_stray_recurrence_id() {
attendees: None,
recurrence_lines: None,
conference: None,
+ reminders: None,
+ rsvp: None,
};
let error = tool.call(context, request_context()).await.unwrap_err();
assert!(error.description.contains("this_event"));
assert!(mutations.updated.lock().unwrap().is_empty());
}
+#[tokio::test]
+async fn update_carries_reminders_into_the_patch() {
+ let (mutations, context) = context(MockMutations::default(), empty_occurrences());
+
+ let tool = UpdateCalendarEvent {
+ event_id: Uuid::from_u128(11),
+ scope: UpdateScopeInput::All,
+ recurrence_id: None,
+ title: None,
+ description: None,
+ location: None,
+ time: None,
+ attendees: None,
+ recurrence_lines: None,
+ conference: None,
+ reminders: Some(EventRemindersInput {
+ use_default: false,
+ overrides: vec![EventReminderOverrideInput {
+ method: "popup".to_string(),
+ minutes: 30,
+ }],
+ }),
+ rsvp: None,
+ };
+ tool.call(context, request_context()).await.unwrap();
+
+ let updated = mutations.updated.lock().unwrap();
+ let (_, patch, _) = updated.first().expect("one update call");
+ assert_eq!(
+ patch.reminders,
+ Some(EventReminders {
+ use_default: false,
+ overrides: vec![EventReminderOverride {
+ method: "popup".to_string(),
+ minutes: 30,
+ }],
+ })
+ );
+}
+
+/// An RSVP is a separate provider call, so a call carrying only one must not
+/// also send an empty patch — the domain rejects a patch that changes nothing.
+#[tokio::test]
+async fn rsvp_alone_answers_without_patching() {
+ let (mutations, context) = context(MockMutations::default(), empty_occurrences());
+ let event_id = Uuid::from_u128(11);
+
+ let tool = UpdateCalendarEvent {
+ event_id,
+ scope: UpdateScopeInput::All,
+ recurrence_id: None,
+ title: None,
+ description: None,
+ location: None,
+ time: None,
+ attendees: None,
+ recurrence_lines: None,
+ conference: None,
+ reminders: None,
+ rsvp: Some(RsvpResponseInput::Declined),
+ };
+ tool.call(context, request_context()).await.unwrap();
+
+ assert!(mutations.updated.lock().unwrap().is_empty());
+ let answered = mutations.answered.lock().unwrap();
+ assert_eq!(
+ *answered.first().expect("one rsvp call"),
+ (
+ event_id,
+ AttendeeResponseStatus::Declined,
+ CalendarRsvpScope::All
+ )
+ );
+}
+
+#[tokio::test]
+async fn rsvp_follows_the_occurrence_scope_of_the_call() {
+ let (mutations, context) = context(MockMutations::default(), empty_occurrences());
+
+ let tool = UpdateCalendarEvent {
+ event_id: Uuid::from_u128(11),
+ scope: UpdateScopeInput::ThisEvent,
+ recurrence_id: Some("2026-08-18T20:00:00+00:00".to_string()),
+ title: None,
+ description: None,
+ location: None,
+ time: None,
+ attendees: None,
+ recurrence_lines: None,
+ conference: None,
+ reminders: None,
+ rsvp: Some(RsvpResponseInput::Tentative),
+ };
+ tool.call(context, request_context()).await.unwrap();
+
+ let answered = mutations.answered.lock().unwrap();
+ let (_, response, scope) = answered.first().expect("one rsvp call");
+ assert_eq!(*response, AttendeeResponseStatus::Tentative);
+ assert_eq!(
+ *scope,
+ CalendarRsvpScope::ThisEvent {
+ recurrence_id: "2026-08-18T20:00:00+00:00".to_string(),
+ }
+ );
+}
+
+/// Replacing the attendee list rewrites every response on the event, so the
+/// RSVP has to be recorded after the patch rather than before it.
+#[tokio::test]
+async fn update_answers_after_applying_the_patch() {
+ let (mutations, context) = context(MockMutations::default(), empty_occurrences());
+
+ let tool = UpdateCalendarEvent {
+ event_id: Uuid::from_u128(11),
+ scope: UpdateScopeInput::All,
+ recurrence_id: None,
+ title: None,
+ description: None,
+ location: None,
+ time: None,
+ attendees: Some(vec![AttendeeInput {
+ email: "[email protected]".to_string(),
+ is_optional: false,
+ }]),
+ recurrence_lines: None,
+ conference: None,
+ reminders: None,
+ rsvp: Some(RsvpResponseInput::Accepted),
+ };
+ tool.call(context, request_context()).await.unwrap();
+
+ assert_eq!(mutations.updated.lock().unwrap().len(), 1);
+ assert_eq!(mutations.answered.lock().unwrap().len(), 1);
+}
+
+#[tokio::test]
+async fn update_without_a_change_or_an_rsvp_is_rejected() {
+ let (mutations, context) = context(MockMutations::default(), empty_occurrences());
+
+ let tool = UpdateCalendarEvent {
+ event_id: Uuid::from_u128(11),
+ scope: UpdateScopeInput::All,
+ recurrence_id: None,
+ title: None,
+ description: None,
+ location: None,
+ time: None,
+ attendees: None,
+ recurrence_lines: None,
+ conference: None,
+ reminders: None,
+ rsvp: None,
+ };
+ let error = tool.call(context, request_context()).await.unwrap_err();
+ assert!(error.description.contains("changes nothing"));
+ assert!(mutations.updated.lock().unwrap().is_empty());
+ assert!(mutations.answered.lock().unwrap().is_empty());
+}
+
#[tokio::test]
async fn scoped_deletion_requires_a_recurrence_id() {
let (mutations, context) = context(MockMutations::default(), empty_occurrences());
diff --git a/crates/calendar_events/src/inbound/toolset/update_calendar_event.rs b/crates/calendar_events/src/inbound/toolset/update_calendar_event.rs
index 49d1d1afb7..bc874af9cf 100644
--- a/crates/calendar_events/src/inbound/toolset/update_calendar_event.rs
+++ b/crates/calendar_events/src/inbound/toolset/update_calendar_event.rs
@@ -10,11 +10,14 @@ use schemars::JsonSchema;
use serde::Deserialize;
use super::{
- AttendeeInput, CalendarToolContext, EventTimeInput, ToolCalendarEvent, mutation_tool_error,
+ AttendeeInput, CalendarToolContext, EventRemindersInput, EventTimeInput, ToolCalendarEvent,
+ mutation_tool_error,
};
use crate::domain::{
- models::{CalendarEventPatch, ConferenceChange},
- ports::{CalendarMutationService, CalendarOccurrenceService, CalendarUpdateScope},
+ models::{AttendeeResponseStatus, CalendarEventPatch, ConferenceChange},
+ ports::{
+ CalendarMutationService, CalendarOccurrenceService, CalendarRsvpScope, CalendarUpdateScope,
+ },
};
/// A requested change to an event's video conference.
@@ -36,6 +39,28 @@ impl From<ConferenceChangeInput> for ConferenceChange {
}
}
+/// The requester's own RSVP on an event they were invited to.
+#[derive(Debug, Deserialize, JsonSchema, Clone, Copy, PartialEq, Eq)]
+#[serde(rename_all = "snake_case")]
+pub enum RsvpResponseInput {
+ /// Attending.
+ Accepted,
+ /// Not attending.
+ Declined,
+ /// Might attend.
+ Tentative,
+}
+
+impl From<RsvpResponseInput> for AttendeeResponseStatus {
+ fn from(input: RsvpResponseInput) -> Self {
+ match input {
+ RsvpResponseInput::Accepted => Self::Accepted,
+ RsvpResponseInput::Declined => Self::Declined,
+ RsvpResponseInput::Tentative => Self::Tentative,
+ }
+ }
+}
+
/// How much of a recurring series an update applies to.
#[derive(Debug, Deserialize, JsonSchema, Clone, Copy, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
@@ -67,7 +92,11 @@ event instead.\n\
\n\
Passing `attendees` replaces the full attendee list — include everyone who should remain, \
not just additions. An empty string for `description` or `location` clears it. Fails on \
-events from calendars the user cannot edit."
+events from calendars the user cannot edit.\n\
+\n\
+`rsvp` sets the user's own response to an invitation and is independent of the field \
+edits — it can be the only thing this call changes. It applies at the same `scope` as \
+the rest of the call, and only works on events the user is actually an attendee of."
)]
pub struct UpdateCalendarEvent {
/// Event to update.
@@ -146,6 +175,25 @@ pub struct UpdateCalendarEvent {
)]
#[serde(default)]
pub conference: Option<ConferenceChangeInput>,
+
+ /// Replacement reminder configuration.
+ #[schemars(
+ description = "Replacement notification reminders. `useDefault: true` follows the \
+ calendar's own defaults; otherwise `overrides` replaces the whole list \
+ with entries of `method` \"popup\" (a Macro notification) or \"email\" \
+ and `minutes` before the start — an empty list silences the event. \
+ Omit to keep the current reminders."
+ )]
+ #[serde(default)]
+ pub reminders: Option<EventRemindersInput>,
+
+ /// The requester's own RSVP.
+ #[schemars(
+ description = "Set the user's own response to the invitation: \"accepted\", \
+ \"declined\", or \"tentative\". Omit to leave their response alone."
+ )]
+ #[serde(default)]
+ pub rsvp: Option<RsvpResponseInput>,
}
impl ToolAnnotated for UpdateCalendarEvent {
@@ -170,6 +218,7 @@ where
event_id=%self.event_id,
scope=?self.scope,
attendee_count=?self.attendees.as_ref().map(Vec::len),
+ rsvp=?self.rsvp,
"Update calendar event"
);
@@ -216,15 +265,55 @@ where
recurrence_lines: self.recurrence_lines.clone(),
visibility: None,
transparency: None,
- reminders: None,
+ reminders: self.reminders.clone().map(Into::into),
conference: self.conference.map(Into::into),
};
- let event = service_context
- .mutations
- .update_event(&requester_id, self.event_id, patch, scope)
- .await
- .map_err(|error| mutation_tool_error("update the calendar event", error))?;
+ // An RSVP is its own provider call, so a call carrying only one runs
+ // only that half. Answering after the patch keeps a replaced attendee
+ // list from discarding the response that was just recorded.
+ let patched = if patch.is_empty() {
+ None
+ } else {
+ Some(
+ service_context
+ .mutations
+ .update_event(&requester_id, self.event_id, patch, scope.clone())
+ .await
+ .map_err(|error| mutation_tool_error("update the calendar event", error))?,
+ )
+ };
+
+ let event = match self.rsvp {
+ Some(rsvp) => {
+ let rsvp_scope = match scope {
+ CalendarUpdateScope::All => CalendarRsvpScope::All,
+ CalendarUpdateScope::ThisEvent { recurrence_id } => {
+ CalendarRsvpScope::ThisEvent { recurrence_id }
+ }
+ };
+ service_context
+ .mutations
+ .respond_to_event(&requester_id, self.event_id, rsvp.into(), rsvp_scope)
+ .await
+ .map_err(|error| {
+ let action = if patched.is_some() {
+ "record the RSVP — the other changes were saved"
+ } else {
+ "record the RSVP"
+ };
+ mutation_tool_error(action, error)
+ })?
+ }
+ None => patched.ok_or_else(|| ToolCallError {
+ description: "This call changes nothing — supply at least one field to update, \
+ or an `rsvp`."
+ .to_string(),
+ internal_error: anyhow::Error::from_boxed(
+ rootcause::report!("update without any change").into_boxed_error(),
+ ),
+ })?,
+ };
Ok(ToolCalendarEvent::from_event(&event))
}