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): name the weekday of a weekly rule without BYDAY in event details (#8671)

gbirmane5c52ecd1931
diff --git a/apps/web/src/features/calendar/utils/recurrence.test.ts b/apps/web/src/features/calendar/utils/recurrence.test.ts
index 697d1b48b6..7ffb1e71a8 100644
--- a/apps/web/src/features/calendar/utils/recurrence.test.ts
+++ b/apps/web/src/features/calendar/utils/recurrence.test.ts
@@ -3,6 +3,7 @@ import { describe, expect, it } from 'vitest';
import {
buildRecurrenceLines,
defaultCustomConfig,
+ eventRecurrenceDescription,
formatRecurrenceDescription,
monthlyOrdinalFor,
parseRecurrenceConfig,
@@ -179,6 +180,24 @@ describe('formatRecurrenceDescription', () => {
);
});
+ it('names the start weekday of a weekly rule without weekdays', () => {
+ const lines = ['RRULE:FREQ=WEEKLY;COUNT=3'];
+ // Saturday, October 24 2026 (local).
+ const saturday = new Date(2026, 9, 24, 14, 0, 0);
+ expect(
+ formatRecurrenceDescription(lines, { locale: 'en-US', start: saturday })
+ ).toBe('Weekly on Saturday · 3 occurrences');
+ expect(formatRecurrenceDescription(lines, { locale: 'en-US' })).toBe(
+ 'Weekly · 3 occurrences'
+ );
+ expect(
+ formatRecurrenceDescription(['RRULE:FREQ=WEEKLY;BYDAY=MO'], {
+ locale: 'en-US',
+ start: saturday,
+ })
+ ).toBe('Weekly on Monday');
+ });
+
it('returns undefined when the lines do not declare recurrence', () => {
expect(formatRecurrenceDescription([])).toBeUndefined();
expect(formatRecurrenceDescription(['EXDATE:20260815'])).toBeUndefined();
@@ -197,6 +216,27 @@ const timedUntil = (date: string) =>
.slice(0, 19)
.replaceAll(/[-:]/g, '')}Z`;
+describe('eventRecurrenceDescription', () => {
+ it('reads the weekday of the occurrence slot in the event’s own zone', () => {
+ // 22:00 on Saturday, October 24 in New York is already Sunday in UTC.
+ expect(
+ eventRecurrenceDescription({
+ recurrenceLines: ['RRULE:FREQ=WEEKLY'],
+ occurrenceKey: '2026-10-25T02:00:00+00:00',
+ allDay: false,
+ timeZone: 'America/New_York',
+ })
+ ).toBe('Weekly on Saturday');
+ expect(
+ eventRecurrenceDescription({
+ recurrenceLines: ['RRULE:FREQ=WEEKLY;COUNT=3'],
+ occurrenceKey: '2026-10-24',
+ allDay: true,
+ })
+ ).toBe('Weekly on Saturday · 3 occurrences');
+ });
+});
+
describe('buildRecurrenceLines', () => {
it('serializes the shapes the custom editor produces', () => {
expect(
diff --git a/apps/web/src/features/calendar/utils/recurrence.ts b/apps/web/src/features/calendar/utils/recurrence.ts
index b7ab11d88b..910b6a4644 100644
--- a/apps/web/src/features/calendar/utils/recurrence.ts
+++ b/apps/web/src/features/calendar/utils/recurrence.ts
@@ -1,6 +1,6 @@
import { formatOrdinal, plural } from '@core/util/string';
import { TZDateMini } from '@date-fns/tz';
-import { format } from 'date-fns';
+import { format, parseISO } from 'date-fns';
import type { CalendarEvent } from '../types';
const POSITIVE_INTEGER_REGEX = /^\d+$/;
@@ -368,6 +368,30 @@ function parseUntilDate(value: string) {
export interface RecurrenceDescriptionOptions {
/** Locale used for weekday, month, date, and list formatting. */
locale?: Intl.LocalesArgument;
+ /**
+ * Where the series starts, in the zone its rule is expressed in. A weekly
+ * rule without BYDAY repeats on this weekday (RFC 5545), so the
+ * description names it, as the composer's weekly preset does.
+ */
+ start?: Date;
+}
+
+function withImpliedWeekday(
+ rule: ParsedRecurrenceRule,
+ start: Date | undefined
+): ParsedRecurrenceRule {
+ if (
+ rule.frequency !== 'WEEKLY' ||
+ rule.byDay.length > 0 ||
+ !start ||
+ Number.isNaN(start.getTime())
+ ) {
+ return rule;
+ }
+ return {
+ ...rule,
+ byDay: [{ weekday: WEEKDAY_CODES[start.getDay()] as WeekdayCode }],
+ };
}
/** Formats recurrence properties as concise, human-readable text. */
@@ -378,7 +402,7 @@ export function formatRecurrenceDescription(
const { locale } = options;
const parsed = parseRecurrenceLines(lines);
let description = parsed.rule
- ? formatRuleDetails(parsed.rule, locale)
+ ? formatRuleDetails(withImpliedWeekday(parsed.rule, options.start), locale)
: undefined;
if (!description && parsed.additionalDates.length > 0) {
@@ -690,11 +714,32 @@ export function defaultCustomConfig(start: Date): RecurrenceConfig {
};
}
+/**
+ * Where an occurrence sits in its series: its original start (the occurrence
+ * key, which a moved occurrence keeps), in the event's own zone.
+ */
+function occurrenceSlotStart(
+ event: Pick<CalendarEvent, 'occurrenceKey' | 'allDay' | 'timeZone'>
+): Date | undefined {
+ const slot = event.allDay
+ ? parseISO(event.occurrenceKey)
+ : new Date(event.occurrenceKey);
+ if (Number.isNaN(slot.getTime())) return undefined;
+ return !event.allDay && event.timeZone
+ ? TZDateMini.tz(event.timeZone, slot)
+ : slot;
+}
+
/** How an event repeats, as event details describe it; undefined for a one-off event. */
export function eventRecurrenceDescription(
- event: Pick<CalendarEvent, 'recurrenceLines' | 'recurrenceId'>
+ event: Pick<
+ CalendarEvent,
+ 'recurrenceLines' | 'recurrenceId' | 'occurrenceKey' | 'allDay' | 'timeZone'
+ >
): string | undefined {
- const description = formatRecurrenceDescription(event.recurrenceLines);
+ const description = formatRecurrenceDescription(event.recurrenceLines, {
+ start: occurrenceSlotStart(event),
+ });
if (description) return description;
return event.recurrenceLines.length > 0 || event.recurrenceId !== undefined
diff --git a/docs/agent-guide/calendar.md b/docs/agent-guide/calendar.md
index 3e942ad648..5822dc8410 100644
--- a/docs/agent-guide/calendar.md
+++ b/docs/agent-guide/calendar.md
@@ -532,7 +532,9 @@ an untouched rule must not be reformatted and included in a reminder-only PATCH.
A weekly rule without `BYDAY` repeats on the start's weekday: plain `FREQ=WEEKLY` opens on the
`Weekly on <day>` preset, and one with an end (such as `COUNT=3`) opens `Custom` with that day
selected, since the presets never end. Either is saved as written while untouched; moving the
-start to another weekday keeps a custom rule on the day the editor shows.
+start to another weekday keeps a custom rule on the day the editor shows. Event details (desktop
+popover and phone drawer) and Forward by email's summary name the day too (`Weekly on Saturday ·
+3 occurrences`), read from the occurrence's original slot in the event's own time zone.
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, both hidden when you are the
only guest (always so on a snapshot). Copying puts every guest's address on the clipboard,