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): select the reminded instance when opening a calendar notification (#6915)

gbirman714a4b93315a
diff --git a/apps/web/src/features/inbox-view/inbox-preview-navigation.ts b/apps/web/src/features/inbox-view/inbox-preview-navigation.ts
index d876486222..9aa952f019 100644
--- a/apps/web/src/features/inbox-view/inbox-preview-navigation.ts
+++ b/apps/web/src/features/inbox-view/inbox-preview-navigation.ts
@@ -1,4 +1,5 @@
import {
+ calendarEventTimeForEntity,
getChannelEntityTarget,
getDocumentCommentTarget,
} from '@app/features/next-soup/utils';
@@ -15,9 +16,10 @@ import type { InboxPreviewRouteParams } from './inbox-route-schema';
function calendarSearch(
params: CalendarBlockProps | undefined,
- time: Extract<PreviewPanelSelection, { type: 'calendar_event' }>['time']
+ selection: Extract<PreviewPanelSelection, { type: 'calendar_event' }>
): Partial<InboxPreviewSearchParams> {
const range = params?.range;
+ const time = calendarEventTimeForEntity(selection);
return {
eventId: params?.eventId ?? '',
occurrenceKey: params?.occurrenceKey ?? '',
@@ -95,7 +97,7 @@ function selectionSearch(
...base,
...calendarSearch(
blockParams as CalendarBlockProps | undefined,
- selection.time
+ selection
),
};
case 'reminder':
diff --git a/apps/web/src/features/next-soup/utils.test.ts b/apps/web/src/features/next-soup/utils.test.ts
index a2b01155b5..ab2913acae 100644
--- a/apps/web/src/features/next-soup/utils.test.ts
+++ b/apps/web/src/features/next-soup/utils.test.ts
@@ -1,3 +1,4 @@
+import { createCalendarRange } from '@app/features/calendar-view/calendar-range';
import { previewBlockTarget } from '@components/app/previewTarget';
import { isTouchDevice } from '@core/mobile/isTouchDevice';
import { afterEach, describe, expect, it, vi } from 'vitest';
@@ -401,6 +402,47 @@ describe('calendar view navigation', () => {
expect.any(Object)
);
});
+
+ it('keeps a recurring reminder on its instance through the Inbox preview route', () => {
+ const result = inboxPreviewNavigation({
+ type: 'calendar_event',
+ id: 'event-1',
+ time: {
+ kind: 'timed',
+ startsAt: '2026-05-18T22:00:00Z',
+ endsAt: '2026-05-18T22:30:00Z',
+ },
+ notifications: () => [
+ {
+ notification_metadata: {
+ tag: 'calendar_event_reminder',
+ content: {
+ eventId: 'event-1',
+ occurrenceKey: '2026-09-23T22:00:00+00:00',
+ startsAt: '2026-09-23T22:00:00Z',
+ endsAt: '2026-09-23T22:30:00Z',
+ },
+ },
+ } as UnifiedNotification,
+ ],
+ } as never);
+ expect(result.search).toMatchObject({
+ occurrenceKey: '2026-09-23T22:00:00+00:00',
+ startsAt: '2026-09-23T22:00:00Z',
+ endsAt: '2026-09-23T22:30:00Z',
+ });
+
+ const selection = inboxPreviewSelection(result.params, result.search);
+ expect(previewBlockTarget(selection!).params).toMatchObject({
+ eventId: 'event-1',
+ occurrenceKey: '2026-09-23T22:00:00+00:00',
+ range: createCalendarRange({
+ kind: 'timed',
+ startsAt: '2026-09-23T22:00:00Z',
+ endsAt: '2026-09-23T22:30:00Z',
+ }),
+ });
+ });
});
describe('Drive document routing', () => {
diff --git a/apps/web/src/features/next-soup/utils.ts b/apps/web/src/features/next-soup/utils.ts
index 2990534ad7..aaa5ffa4ef 100644
--- a/apps/web/src/features/next-soup/utils.ts
+++ b/apps/web/src/features/next-soup/utils.ts
@@ -1,7 +1,10 @@
import { isListViewID } from '@app/constants/list-views';
import { getPreferredCalendarPeriodView } from '@app/features/calendar/calendar-preferences';
import { openCalendarView } from '@app/features/calendar-view/calendar-navigation';
-import { createCalendarRange } from '@app/features/calendar-view/calendar-range';
+import {
+ type CalendarEventTime,
+ createCalendarRange,
+} from '@app/features/calendar-view/calendar-range';
import {
calendarFocusedEventSearchKey,
calendarPath,
@@ -871,19 +874,28 @@ export function calendarEventLinkTarget(entity: CalendarPreviewSelection): {
return { eventId: eventId ?? entity.id, occurrenceKey };
}
-/** Build a Calendar view focus target for an event row's occurrence. */
-export function calendarViewTargetForEntity(
- entity: CalendarPreviewSelection
-): CalendarViewTarget {
+function calendarReminderContent(entity: CalendarPreviewSelection) {
const notifications = isWithNotification(entity)
? (entity.notifications?.() ?? [])
: [];
const metadata = notifications
.map((notification) => notification.notification_metadata)
.find((candidate) => candidate?.tag === 'calendar_event_reminder');
- const content =
- metadata?.tag === 'calendar_event_reminder' ? metadata.content : undefined;
- const time = content?.startsAt
+ return metadata?.tag === 'calendar_event_reminder'
+ ? metadata.content
+ : undefined;
+}
+
+/**
+ * The time of the instance an event row points at. A reminder names the
+ * instance that is starting, while a recurring row's own time is the series'
+ * first instance.
+ */
+export function calendarEventTimeForEntity(
+ entity: CalendarPreviewSelection
+): CalendarEventTime | undefined {
+ const content = calendarReminderContent(entity);
+ return content?.startsAt
? {
kind: 'timed' as const,
startsAt: content.startsAt,
@@ -892,6 +904,14 @@ export function calendarViewTargetForEntity(
: content?.startDate
? { kind: 'allDay' as const, startDate: content.startDate }
: entity.time;
+}
+
+/** Build a Calendar view focus target for an event row's occurrence. */
+export function calendarViewTargetForEntity(
+ entity: CalendarPreviewSelection
+): CalendarViewTarget {
+ const content = calendarReminderContent(entity);
+ const time = calendarEventTimeForEntity(entity);
return {
eventId: content?.eventId ?? entity.id,