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): allow all-day out-of-office events (#6474)
gbirman3ae92ec0dc95
diff --git a/apps/web/src/features/calendar/components/composer/EventForm.tsx b/apps/web/src/features/calendar/components/composer/EventForm.tsxindex 6dde515655..f3110bf25f 100644--- a/apps/web/src/features/calendar/components/composer/EventForm.tsx+++ b/apps/web/src/features/calendar/components/composer/EventForm.tsx@@ -147,12 +147,7 @@ export function EventForm(props: EventFormProps) {onAllDayChange={controller.setAllDay}startDisabled={fieldIsDisabled('start')}endDisabled={fieldIsDisabled('end')}- allDayDisabled={- fieldIsDisabled('allDay') ||- // Google requires timed out-of-office events. Leaving- // all-day mode stays possible in case one was seeded.- (isOutOfOffice() && !state().allDay)- }+ allDayDisabled={fieldIsDisabled('allDay')}invalid={controller.dateRangeError() !== undefined}describedBy={dateRangeDescribedBy()}/>diff --git a/apps/web/src/features/calendar/components/composer/create-calendar-event-form-controller.test.ts b/apps/web/src/features/calendar/components/composer/create-calendar-event-form-controller.test.tsindex dfacd34e8b..3800d3fd90 100644--- a/apps/web/src/features/calendar/components/composer/create-calendar-event-form-controller.test.ts+++ b/apps/web/src/features/calendar/components/composer/create-calendar-event-form-controller.test.ts@@ -159,7 +159,7 @@ const MIXED_CALENDARS = () => [];describe('out of office', () => {- it('switching the kind forces a timed range and defaults the decline mode', () => {+ it('keeps the all-day range on switch and defaults the decline mode', () => {const today = format(new Date(), 'yyyy-MM-dd');const controller = controllerFor({allDay: true,@@ -170,7 +170,10 @@ describe('out of office', () => {controller.setEventKind('out_of_office');expect(controller.isOutOfOffice()).toBe(true);- expect(controller.state().allDay).toBe(false);+ // The switch keeps all-day; an all-day out-of-office save is encoded as a+ // full-day timed span, since Google has no date-based out-of-office event.+ expect(controller.state().allDay).toBe(true);+ expect(controller.submitValues()?.time.kind).toBe('timed');expect(controller.state().outOfOffice).toEqual({autoDeclineMode: 'decline_none',declineMessage: '',diff --git a/apps/web/src/features/calendar/components/composer/create-calendar-event-form-controller.ts b/apps/web/src/features/calendar/components/composer/create-calendar-event-form-controller.tsindex f59cc8fc0d..83c45632b6 100644--- a/apps/web/src/features/calendar/components/composer/create-calendar-event-form-controller.ts+++ b/apps/web/src/features/calendar/components/composer/create-calendar-event-form-controller.ts@@ -374,13 +374,16 @@ export function createCalendarEventFormController(const setEventKind = (kind: EventEditorEventKind) => {if (kind === eventKind()) return;if (kind === 'out_of_office') {- // Google requires a timed span, so the switch leaves all-day mode. The- // hidden guest, location, and conference values stay in state for a- // switch back; a save while out of office never submits them. The- // description resets instead: its editor re-initializes from the- // initial value when it reappears, so kept edits would be invisible.+ // The all-day choice carries over: Google has no date-based out-of-office+ // event, so an all-day one is saved as a full-day timed span (see+ // buildEventTime), the same shape Google Calendar stores its own all-day+ // out-of-office events as. The hidden guest, location, and conference+ // values stay in state for a switch back; a save while out of office never+ // submits them. The description resets instead: its editor re-initializes+ // from the initial value when it reappears, so kept edits would be+ // invisible.replaceState({- ...convertTimesForAllDay(state(), false),+ ...state(),eventType: 'out_of_office',description: initialValue().description,outOfOffice: state().outOfOffice ?? {diff --git a/apps/web/src/features/calendar/components/composer/event-form-model.test.ts b/apps/web/src/features/calendar/components/composer/event-form-model.test.tsindex 58d561fc64..63d98f5b55 100644--- a/apps/web/src/features/calendar/components/composer/event-form-model.test.ts+++ b/apps/web/src/features/calendar/components/composer/event-form-model.test.ts@@ -1,5 +1,6 @@import { describe, expect, it } from 'vitest';import {+ buildEventTime,defaultEditorInitialValues,type EventEditorInitialValues,eventHasEnded,@@ -13,6 +14,11 @@ function values(return { ...defaultEditorInitialValues(NOW), ...overrides };}+/** Local midnight of a `yyyy-MM-dd` date as a UTC ISO instant. */+function localMidnight(date: string): string {+ return new Date(`${date}T00:00`).toISOString();+}+describe('eventHasEnded', () => {it('treats a finished timed range as past', () => {expect(@@ -58,3 +64,49 @@ describe('eventHasEnded', () => {).toBe(false);});});++describe('buildEventTime', () => {+ it('keeps an all-day regular event date-based', () => {+ expect(+ buildEventTime(+ values({ allDay: true, start: '2026-09-17', end: '2026-09-17' })+ )+ ).toEqual({+ kind: 'allDay',+ startDate: '2026-09-17',+ endDate: '2026-09-18',+ });+ });++ it('encodes an all-day out-of-office event as a full-day timed span', () => {+ const time = buildEventTime(+ values({+ allDay: true,+ start: '2026-09-17',+ end: '2026-09-17',+ eventType: 'out_of_office',+ })+ );+ expect(time?.kind).toBe('timed');+ if (time?.kind !== 'timed') throw new Error('expected a timed range');+ expect(time.startsAt).toBe(localMidnight('2026-09-17'));+ expect(time.endsAt).toBe(localMidnight('2026-09-18'));+ expect(time.timeZone).toBe(+ Intl.DateTimeFormat().resolvedOptions().timeZone+ );+ });++ it('spans every day of a multi-day all-day out-of-office event', () => {+ const time = buildEventTime(+ values({+ allDay: true,+ start: '2026-09-17',+ end: '2026-09-19',+ eventType: 'out_of_office',+ })+ );+ if (time?.kind !== 'timed') throw new Error('expected a timed range');+ expect(time.startsAt).toBe(localMidnight('2026-09-17'));+ expect(time.endsAt).toBe(localMidnight('2026-09-20'));+ });+});diff --git a/apps/web/src/features/calendar/components/composer/event-form-model.ts b/apps/web/src/features/calendar/components/composer/event-form-model.tsindex 45780abd24..2aac643d50 100644--- a/apps/web/src/features/calendar/components/composer/event-form-model.ts+++ b/apps/web/src/features/calendar/components/composer/event-form-model.ts@@ -50,6 +50,11 @@ function shiftDateValue(value: string, days: number) {return format(addDays(parseISO(value), days), DATE_VALUE);}+/** Local midnight of a `yyyy-MM-dd` date, as a UTC ISO instant. */+function localMidnightIso(date: string): string {+ return new Date(`${date}T00:00`).toISOString();+}+/** Default editor slot: the next full hour, one hour long. */function defaultEditorTimes(reference: Date) {const start = addHours(startOfHour(reference), 1);@@ -259,6 +264,18 @@ export function buildEventTime(if (!state.start || !state.end || state.end < state.start) {return undefined;}+ // Google has no date-based out-of-office event, so encode an all-day one as+ // a timed span covering whole days in the editor's time zone. It then reads+ // and renders as a full-day timed block, the same as Google Calendar shows+ // its own all-day out-of-office events.+ if (state.eventType === 'out_of_office') {+ return {+ kind: 'timed',+ startsAt: localMidnightIso(state.start),+ endsAt: localMidnightIso(shiftDateValue(state.end, 1)),+ timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone,+ };+ }return {kind: 'allDay',startDate: state.start,