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
feat(calendar): add meeting link option and update date selection ui (#5752)
dev-rb7961222fc89f
diff --git a/apps/web/src/features/calendar/components/composer/EventDateTimeRangeFields.tsx b/apps/web/src/features/calendar/components/composer/EventDateTimeRangeFields.tsxindex b7fcb4b0a5..0335297ee5 100644--- a/apps/web/src/features/calendar/components/composer/EventDateTimeRangeFields.tsx+++ b/apps/web/src/features/calendar/components/composer/EventDateTimeRangeFields.tsx@@ -23,66 +23,53 @@ function formatTime(value: string) {return timeLabelFormatter.format(new Date(2000, 0, 1, hour, minute));}-export interface EventDateTimeRangeFieldsProps {- start: string;- end: string;+interface EventDateTimeDropdownProps {+ id: string;+ label: 'Start' | 'End';+ value: string;allDay: boolean;- onStartChange: (value: string) => void;- onEndChange: (value: string) => void;- onAllDayChange: (allDay: boolean) => void;- startDisabled?: boolean;- endDisabled?: boolean;- allDayDisabled?: boolean;+ onDateChange: (value: string) => void;+ onTimeChange: (value: string) => void;+ fieldDisabled?: boolean;invalid?: boolean;describedBy?: string;+ placement: 'bottom-start' | 'bottom-end';}-/** Combined date-range display with start/end calendar and time controls. */-export function EventDateTimeRangeFields(props: EventDateTimeRangeFieldsProps) {- const fieldId = createUniqueId();+function EventDateTimeDropdown(props: EventDateTimeDropdownProps) {const [open, setOpen] = createSignal(false);- let trigger: HTMLButtonElement | undefined;-- const startParts = () => splitLocalDateTime(props.start);- const endParts = () => splitLocalDateTime(props.end);- const startDate = () => parseLocalDate(startParts().date);- const endDate = () => parseLocalDate(endParts().date);- const disabled = () =>- props.startDisabled && props.endDisabled && props.allDayDisabled;- const rangeLabel = () => {- const start = startDate();- const end = endDate();- const startLabel = start ? dateLabelFormatter.format(start) : 'Start date';- const endLabel = end ? dateLabelFormatter.format(end) : 'End date';- if (props.allDay) return `${startLabel} – ${endLabel}`;- return `${startLabel} ${formatTime(startParts().time)} – ${endLabel} ${formatTime(endParts().time)}`;+ const parts = () => splitLocalDateTime(props.value);+ const selectedDate = () => parseLocalDate(parts().date);+ const label = () => {+ const date = selectedDate();+ const dateLabel = date+ ? dateLabelFormatter.format(date)+ : `${props.label} date`;+ return props.allDay+ ? dateLabel+ : `${dateLabel} ${formatTime(parts().time)}`;};return (<Popover- anchorRef={() => trigger}- open={open() && !disabled()}- onOpenChange={(nextOpen) => setOpen(!disabled() && nextOpen)}- placement="bottom-start"+ open={open() && !props.fieldDisabled}+ onOpenChange={(nextOpen) => setOpen(!props.fieldDisabled && nextOpen)}+ placement={props.placement}gutter={4}flipslide>- <button- ref={trigger}- type="button"- disabled={disabled()}- aria-label="Edit event date and time range"- aria-expanded={open()}- aria-haspopup="dialog"+ <Popover.Trigger+ disabled={props.fieldDisabled}+ aria-label={`Edit event ${props.label.toLowerCase()} date and time`}aria-invalid={props.invalid || undefined}aria-describedby={props.describedBy}class={cn(- 'group inline-flex min-h-8 w-fit max-w-full self-start items-center gap-2 rounded-lg bg-transparent px-2 text-left text-xs text-ink-muted transition-colors hover:bg-hover hover:text-ink focus-visible:text-ink focus-visible:ring focus-visible:ring-accent/10',- open() && 'bg-hover',- props.invalid && 'text-failure'+ 'group inline-flex h-7 w-fit max-w-48 min-w-0 items-center justify-between gap-1.5 rounded-lg border border-edge-muted bg-surface px-2 py-1 text-left text-xs leading-tight text-ink-muted hover:bg-hover hover:text-ink focus-visible:bg-active focus-visible:text-ink focus-visible:ring-accent/10 data-expanded:bg-hover data-expanded:text-ink',+ open() && 'bg-hover text-ink',+ props.invalid &&+ 'border-failure text-failure hover:text-failure focus-visible:text-failure data-expanded:text-failure')}- onClick={() => setOpen((current) => !current)}><CalendarBlankIconclass={cn(@@ -92,14 +79,21 @@ export function EventDateTimeRangeFields(props: EventDateTimeRangeFieldsProps) {: 'text-ink-extra-muted group-hover:text-ink-muted group-focus-visible:text-ink-muted')}/>- <span class="min-w-0 truncate">{rangeLabel()}</span>- <CaretDownIcon class="size-3 shrink-0 text-ink-extra-muted group-hover:text-ink-muted group-focus-visible:text-ink-muted" />- </button>+ <span class="min-w-0 flex-1 truncate">{label()}</span>+ <CaretDownIcon+ class={cn(+ 'size-3 shrink-0',+ props.invalid+ ? 'text-failure'+ : 'text-ink-extra-muted group-hover:text-ink-muted group-focus-visible:text-ink-muted'+ )}+ />+ </Popover.Trigger><Popover.Portal><Layer depth={3}><Popover.Content- class="portal-scope z-action-menu w-[38rem] max-w-[calc(100vw-1rem)] overflow-hidden rounded-xl border border-edge bg-menu shadow-menu menu-open-animation"+ class="portal-scope z-action-menu w-72 max-w-[calc(100vw-1rem)] overflow-hidden rounded-xl border border-edge bg-menu shadow-menu menu-open-animation"on:keydown={(event: KeyboardEvent) => {if (event.key !== 'Escape') return;event.preventDefault();@@ -109,82 +103,30 @@ export function EventDateTimeRangeFields(props: EventDateTimeRangeFieldsProps) {onOpenAutoFocus={(event) => event.preventDefault()}onCloseAutoFocus={(event) => event.preventDefault()}>- <Popover.Title class="sr-only">- Choose event date and time range+ <Popover.Title class="px-3 pt-3 text-xs font-medium text-ink">+ {props.label} {props.allDay ? 'date' : 'date and time'}</Popover.Title>- <div class="grid grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] items-start">- <div class="min-w-0 p-3">- <Calendar- required- fixedWeeks- value={startDate()}- onValueChange={(date) => {- if (!date || props.startDisabled) return;- const nextDate = formatLocalDate(date);- props.onStartChange(- props.allDay- ? nextDate- : withLocalDate(props.start, nextDate)- );- }}- />- </div>- <ArrowRightIcon- aria-label="to"- class="mt-[1.125rem] size-4 shrink-0 text-ink-extra-muted"+ <div class="p-3">+ <Calendar+ required+ fixedWeeks+ value={selectedDate()}+ onValueChange={(date) => {+ if (!date || props.fieldDisabled) return;+ props.onDateChange(formatLocalDate(date));+ }}/>- <div class="min-w-0 p-3">- <Calendar- required- fixedWeeks- value={endDate()}- onValueChange={(date) => {- if (!date || props.endDisabled) return;- const nextDate = formatLocalDate(date);- props.onEndChange(- props.allDay- ? nextDate- : withLocalDate(props.end, nextDate)- );- }}- />- </div></div><div class="border-t border-edge p-3">- <div class="grid grid-cols-2 gap-3">- <div class={cn(props.allDay && 'opacity-50')}>- <EventTimeInput- id={`composer-start-time-${fieldId}`}- label="Start time"- value={startParts().time}- onChange={(time) =>- props.onStartChange(withLocalTime(props.start, time))- }- disabled={props.startDisabled || props.allDay}- />- </div>- <div class={cn(props.allDay && 'opacity-50')}>- <EventTimeInput- id={`composer-end-time-${fieldId}`}- label="End time"- value={endParts().time}- onChange={(time) =>- props.onEndChange(withLocalTime(props.end, time))- }- disabled={props.endDisabled || props.allDay}- />- </div>- </div>- <div class="mt-3 flex items-center gap-2">- <ToggleSwitch- checked={props.allDay}- disabled={props.allDayDisabled}- onChange={props.onAllDayChange}- size="sm"- aria-label="All day"+ <div class={cn(props.allDay && 'opacity-50')}>+ <EventTimeInput+ id={props.id}+ label={`${props.label} time`}+ value={parts().time}+ onChange={props.onTimeChange}+ disabled={props.fieldDisabled || props.allDay}/>- <span class="text-xs text-ink-muted">All day</span></div></div></Popover.Content>@@ -193,3 +135,81 @@ export function EventDateTimeRangeFields(props: EventDateTimeRangeFieldsProps) {</Popover>);}++export interface EventDateTimeRangeFieldsProps {+ start: string;+ end: string;+ allDay: boolean;+ onStartChange: (value: string) => void;+ onEndChange: (value: string) => void;+ onAllDayChange: (allDay: boolean) => void;+ startDisabled?: boolean;+ endDisabled?: boolean;+ allDayDisabled?: boolean;+ invalid?: boolean;+ describedBy?: string;+}++/** Separate start/end date-time dropdowns joined by a directional arrow. */+export function EventDateTimeRangeFields(props: EventDateTimeRangeFieldsProps) {+ const fieldId = createUniqueId();++ return (+ <div class="flex w-full items-center justify-between gap-3">+ <div class="flex min-w-0 items-center gap-2">+ <EventDateTimeDropdown+ id={`composer-start-time-${fieldId}`}+ label="Start"+ value={props.start}+ allDay={props.allDay}+ onDateChange={(date) =>+ props.onStartChange(+ props.allDay ? date : withLocalDate(props.start, date)+ )+ }+ onTimeChange={(time) =>+ props.onStartChange(withLocalTime(props.start, time))+ }+ fieldDisabled={props.startDisabled}+ invalid={props.invalid}+ describedBy={props.describedBy}+ placement="bottom-start"+ />+ <ArrowRightIcon+ aria-label="to"+ class={cn(+ 'size-3.5 shrink-0 text-ink-extra-muted',+ props.invalid && 'text-failure'+ )}+ />+ <EventDateTimeDropdown+ id={`composer-end-time-${fieldId}`}+ label="End"+ value={props.end}+ allDay={props.allDay}+ onDateChange={(date) =>+ props.onEndChange(+ props.allDay ? date : withLocalDate(props.end, date)+ )+ }+ onTimeChange={(time) =>+ props.onEndChange(withLocalTime(props.end, time))+ }+ fieldDisabled={props.endDisabled}+ invalid={props.invalid}+ describedBy={props.describedBy}+ placement="bottom-end"+ />+ </div>+ <ToggleSwitch+ checked={props.allDay}+ disabled={props.allDayDisabled}+ onChange={props.onAllDayChange}+ size="sm"+ label="All day"+ labelClass="whitespace-nowrap text-xs text-ink-muted"+ class="shrink-0"+ />+ </div>+ );+}diff --git a/apps/web/src/features/calendar/components/composer/EventForm.tsx b/apps/web/src/features/calendar/components/composer/EventForm.tsxindex e88afe1d3c..cd55144856 100644--- a/apps/web/src/features/calendar/components/composer/EventForm.tsx+++ b/apps/web/src/features/calendar/components/composer/EventForm.tsx@@ -5,6 +5,7 @@ import type { CalendarEventFormController } from './create-calendar-event-form-cimport { EventDateTimeRangeFields } from './EventDateTimeRangeFields';import {EventComposerCalendarPill,+ EventComposerConferencePill,EventComposerGuestsPill,EventComposerLocationPill,EventComposerRecurrencePill,@@ -70,7 +71,7 @@ export function EventForm(props: EventFormProps) {<div class="flex min-h-0 flex-1 flex-col gap-6 overflow-y-auto scrollbar-hidden"><div class="flex min-w-0 flex-col gap-6 text-sm text-ink-muted"><div class="flex min-w-0 flex-col gap-1">- <div class="flex min-w-0 flex-col gap-0">+ <div class="flex min-w-0 flex-col gap-1"><EventDateTimeRangeFieldsstart={state().start}end={state().end}@@ -91,7 +92,7 @@ export function EventForm(props: EventFormProps) {<pid={dateRangeErrorId}role="alert"- class="px-2 text-xs text-failure"+ class="text-xs text-failure">{error()}</p>@@ -158,6 +159,16 @@ export function EventForm(props: EventFormProps) {disabled={props.pending}readOnly={fieldIsReadOnly('guests')}/>+ <EventComposerConferencePill+ value={state().conference}+ canKeepExisting={+ controller.initialConferenceChoice() === 'existing'+ }+ onChange={(conference) =>+ controller.setField('conference', conference)+ }+ disabled={fieldIsDisabled('conference')}+ /><EventComposerLocationPillvalue={state().location}onChange={(location) => controller.setField('location', location)}diff --git a/apps/web/src/features/calendar/components/composer/EventPropertyPills.tsx b/apps/web/src/features/calendar/components/composer/EventPropertyPills.tsxindex c5c35f0c16..d23564936c 100644--- a/apps/web/src/features/calendar/components/composer/EventPropertyPills.tsx+++ b/apps/web/src/features/calendar/components/composer/EventPropertyPills.tsx@@ -9,6 +9,7 @@ import MagnifyingGlassIcon from '@phosphor/magnifying-glass.svg';import MapPinIcon from '@phosphor/map-pin.svg';import RepeatIcon from '@phosphor/repeat.svg';import UsersIcon from '@phosphor/users.svg';+import VideoCameraIcon from '@phosphor/video-camera.svg';import { OptionCheckBox } from '@property/editors/selectors/OptionCheckBox';import { cn, Layer, Select, Tooltip } from '@ui';import * as EmailValidator from 'email-validator';@@ -28,6 +29,7 @@ import {} from '../../utils/event-reminders';import {type EventEditorCalendarOption,+ type EventEditorConferenceChoice,type EventEditorGuestOption,guestEmail,type SelectedEventEditorGuest,@@ -548,6 +550,83 @@ export function EventComposerLocationPill();}+interface EventComposerConferenceOption {+ value: EventEditorConferenceChoice;+ label: string;+}++const GOOGLE_MEET_OPTION: EventComposerConferenceOption = {+ value: 'google_meet',+ label: 'Google Meet',+};+const NO_CONFERENCING_OPTION: EventComposerConferenceOption = {+ value: 'none',+ label: 'No meeting link',+};+const EXISTING_CONFERENCING_OPTION: EventComposerConferenceOption = {+ value: 'existing',+ label: 'Current conferencing',+};++export interface EventComposerConferencePillProps {+ value: EventEditorConferenceChoice;+ canKeepExisting: boolean;+ onChange: (value: EventEditorConferenceChoice) => void;+ disabled?: boolean;+}++/** Compact selector for adding, replacing, or removing video conferencing. */+export function EventComposerConferencePill(+ props: EventComposerConferencePillProps+) {+ const options = createMemo(() => [+ NO_CONFERENCING_OPTION,+ ...(props.canKeepExisting ? [EXISTING_CONFERENCING_OPTION] : []),+ GOOGLE_MEET_OPTION,+ ]);+ const selectedOption = () =>+ options().find((option) => option.value === props.value) ?? options()[0];++ return (+ <Select<EventComposerConferenceOption>+ options={options()}+ value={selectedOption()}+ onChange={(option) => option && props.onChange(option.value)}+ optionValue="value"+ optionTextValue="label"+ disabled={props.disabled}+ >+ <Tooltip label="Set event video conferencing" placement="bottom">+ <Select.Trigger+ aria-label="Video conferencing"+ class={cn(PROPERTY_TRIGGER_CLASS, 'max-w-48 overflow-hidden')}+ >+ <VideoCameraIcon class="size-3.5 shrink-0 text-ink-extra-muted" />+ <Select.Value<EventComposerConferenceOption>>+ {(selectState) => (+ <span+ class={cn(+ 'truncate',+ PROPERTY_VALUE_CLASS,+ props.value === 'none' && 'text-ink-extra-muted'+ )}+ >+ {props.value === 'none'+ ? 'Add meeting link'+ : selectState.selectedOption().label}+ </span>+ )}+ </Select.Value>+ <Select.Icon />+ </Select.Trigger>+ </Tooltip>+ <Select.Content>+ <Select.Listbox />+ </Select.Content>+ </Select>+ );+}+export interface EventComposerRemindersPillProps {minutes: number[];usedSlots: number;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 28d7793e97..fbb63eed00 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@@ -14,6 +14,7 @@ import {convertTimesForAllDay,createEventEditorState,type EventEditorCalendarOption,+ type EventEditorConferenceChoice,type EventEditorGuestOption,type EventEditorInitialValues,type EventEditorSubmitValues,@@ -33,6 +34,7 @@ interface EventComposerFormSnapshot {guestEmails: readonly string[];location: string;description: string;+ conference: EventEditorConferenceChoice;reminderMinutes: readonly number[];}@@ -74,6 +76,7 @@ function isEventComposerFormDirty(initial.calendarId !== current.calendarId ||initial.location !== current.location ||initial.description !== current.description ||+ initial.conference !== current.conference ||!arraysEqual(normalizedGuestEmails(initial.guestEmails),normalizedGuestEmails(current.guestEmails)@@ -213,6 +216,7 @@ export function createCalendarEventFormController(guestEmails: selectedGuests().map(guestEmail),location: state().location,description: state().description,+ conference: state().conference,reminderMinutes: normalizedReminderMinutes(reminderMinutes()),});@@ -226,6 +230,7 @@ export function createCalendarEventFormController(guestEmails: initialGuestEmails(),location: initialValue().location,description: initialValue().description,+ conference: initialValue().conference,reminderMinutes: normalizedReminderMinutes(initialReminderMinutes()),});@@ -287,6 +292,11 @@ export function createCalendarEventFormController(if (!time || !recurrence.canSave()) return undefined;const current = state();const reminders = reminderUpdate();+ const conference =+ current.conference === 'existing' ||+ current.conference === initialValue().conference+ ? undefined+ : current.conference;return {title: current.title,time,@@ -295,6 +305,7 @@ export function createCalendarEventFormController(guestEmails: selectedGuests().map(guestEmail),location: current.location,description: current.description,+ ...(conference ? { conference } : {}),...(reminders ? { reminders } : {}),};};@@ -320,6 +331,7 @@ export function createCalendarEventFormController(selectedGuests,effectiveCalendarId,selectedCalendarOption,+ initialConferenceChoice: () => initialValue().conference,reminderMinutes,preservedReminderCount,canAddReminder,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 41c844f8a6..73bf0b8022 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@@ -3,6 +3,7 @@ import {recipientEntityMapper,type WithCustomUserInput,} from '@core/user/combinedRecipient';+import type { ConferenceChange } from '@service-email/generated/schemas/conferenceChange';import type { EventTime } from '@service-email/generated/schemas/eventTime';import type { EventReminderOverride } from '@service-storage/generated/schemas/eventReminderOverride';import type { EventReminders } from '@service-storage/generated/schemas/eventReminders';@@ -50,6 +51,9 @@ function defaultEditorTimes(reference: Date) {return { start, end: addHours(start, 1) };}+/** Conferencing displayed by the editor before it is submitted. */+export type EventEditorConferenceChoice = 'none' | 'google_meet' | 'existing';+/** Values used to initialize the shared event editor form. */export interface EventEditorInitialValues {title: string;@@ -63,6 +67,8 @@ export interface EventEditorInitialValues {guests: string;location: string;description: string;+ /** What conferencing the saved event should carry. */+ conference: EventEditorConferenceChoice;/** Per-user reminder configuration; absent means the calendar default. */reminders?: EventReminders;}@@ -87,6 +93,7 @@ type EventEditorField =| 'guests'| 'location'| 'description'+ | 'conference'| 'reminders';/** Field-level disabled state supplied by a create/edit owner. */@@ -103,6 +110,8 @@ export interface EventEditorSubmitValues {guestEmails: string[];location: string;description: string;+ /** Present only when conferencing should be attached, replaced, or removed. */+ conference?: ConferenceChange;/** Present only when the user changed the event's reminder configuration. */reminders?: EventReminders;}@@ -121,6 +130,7 @@ export function defaultEditorInitialValues(guests: '',location: '',description: '',+ conference: 'none',reminders: undefined,};}@@ -148,6 +158,15 @@ export function calendarSelectionToEditorInitialValues(selection: {};}+function initialConferenceChoice(+ event: CalendarEvent+): EventEditorConferenceChoice {+ if (!event.conferenceUrl) return 'none';+ return event.conferenceProvider === 'google_meet'+ ? 'google_meet'+ : 'existing';+}+/** Converts an existing event into values for the shared editor. */export function calendarEventToEditorInitialValues(event: CalendarEvent@@ -174,6 +193,7 @@ export function calendarEventToEditorInitialValues(guests,location: event.location ?? '',description: event.description ?? '',+ conference: initialConferenceChoice(event),reminders: event.reminders,};}@@ -188,6 +208,7 @@ export function calendarEventToEditorInitialValues(guests,location: event.location ?? '',description: event.description ?? '',+ conference: initialConferenceChoice(event),reminders: event.reminders,};}diff --git a/apps/web/src/features/calendar/hooks/use-event-editor.ts b/apps/web/src/features/calendar/hooks/use-event-editor.tsindex 3b5ab87bfa..10890e5c4d 100644--- a/apps/web/src/features/calendar/hooks/use-event-editor.ts+++ b/apps/web/src/features/calendar/hooks/use-event-editor.ts@@ -110,6 +110,7 @@ export function useEventEditor(props: UseEventEditorProps) {...(recurrenceChanged? { recurrenceLines: values.recurrenceLines }: {}),+ ...(values.conference ? { conference: values.conference } : {}),...(values.reminders ? { reminders: values.reminders } : {}),},});@@ -124,6 +125,7 @@ export function useEventEditor(props: UseEventEditorProps) {location: values.location === '' ? undefined : values.location,description: values.description === '' ? undefined : values.description,attendees: values.guestEmails.map((email) => ({ email })),+ ...(values.conference ? { conference: values.conference } : {}),...(values.reminders ? { reminders: values.reminders } : {}),});};diff --git a/apps/web/src/features/calendar/types.ts b/apps/web/src/features/calendar/types.tsindex b7341498d8..55ffa6beeb 100644--- a/apps/web/src/features/calendar/types.ts+++ b/apps/web/src/features/calendar/types.ts@@ -47,9 +47,8 @@ export interface CalendarEvent {/** Direct conference join URL, when available. */conferenceUrl?: string;/**- * Which conferencing system backs `conferenceUrl`. Only `google_meet` is- * one Macro can attach and detach; anything else is shown for joining but- * never rewritten.+ * Which conferencing system backs `conferenceUrl`. Macro can generate a+ * Google Meet; other conferencing is preserved unless explicitly replaced.*/conferenceProvider?: ConferenceProvider;/** Event organizer display name. */