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(search): add calendar event search UI (#5994)
gbirmanbc07a05616df
diff --git a/.sqlx/query-47e360c89a42e3491a9611f30494e9a96b56a961e6f7b7c84a3ac5e6d2dcc496.json b/.sqlx/query-71695e628d3ef339a4288cd8c52ef04f2459b9d28d5d869c1c3f9bc0776dce13.jsonsimilarity index 55%rename from .sqlx/query-47e360c89a42e3491a9611f30494e9a96b56a961e6f7b7c84a3ac5e6d2dcc496.jsonrename to .sqlx/query-71695e628d3ef339a4288cd8c52ef04f2459b9d28d5d869c1c3f9bc0776dce13.jsonindex 71f6ab0865..4bd8060734 100644--- a/.sqlx/query-47e360c89a42e3491a9611f30494e9a96b56a961e6f7b7c84a3ac5e6d2dcc496.json+++ b/.sqlx/query-71695e628d3ef339a4288cd8c52ef04f2459b9d28d5d869c1c3f9bc0776dce13.json@@ -1,6 +1,6 @@{"db_name": "PostgreSQL",- "query": "\n SELECT\n event.id AS \"id!\",\n event.owner_id AS \"owner_id!\",\n event.title AS \"title!\",\n event.status AS \"status!\",\n event.starts_at,\n event.ends_at,\n event.start_date,\n event.end_date,\n event.time_zone,\n (cardinality(event.recurrence_lines) > 0) AS \"is_recurring!\",\n event.conference_url,\n event.is_read_only AS \"is_read_only!\",\n event.created_at AS \"created_at!\",\n event.updated_at AS \"updated_at!\",\n occurrence.occurrence_key AS \"occurrence_key?\",\n occurrence.starts_at AS \"occurrence_starts_at?\",\n occurrence.ends_at AS \"occurrence_ends_at?\",\n occurrence.start_date AS \"occurrence_start_date?\",\n occurrence.end_date AS \"occurrence_end_date?\"\n FROM calendar_events event\n LEFT JOIN LATERAL (\n SELECT\n instance.occurrence_key,\n instance.starts_at,\n instance.ends_at,\n instance.start_date,\n instance.end_date\n FROM calendar_event_occurrences instance\n CROSS JOIN LATERAL (\n SELECT COALESCE(\n instance.starts_at,\n instance.start_date::timestamp AT TIME ZONE 'UTC'\n ) AS at\n ) instance_start\n WHERE instance.event_id = event.id\n AND NOT instance.is_cancelled\n ORDER BY\n (instance_start.at >= $3) DESC,\n CASE WHEN instance_start.at >= $3 THEN instance_start.at END ASC,\n instance_start.at DESC,\n instance.occurrence_key\n LIMIT 1\n ) occurrence ON true\n WHERE event.id = ANY($2)\n AND (\n event.owner_id = $1\n OR EXISTS (\n SELECT 1\n FROM macro_user_links link\n WHERE link.link_id = event.source_link_id\n AND link.primary_macro_id = $1\n )\n )\n ",+ "query": "\n SELECT\n event.id AS \"id!\",\n event.owner_id AS \"owner_id!\",\n event.title AS \"title!\",\n event.status AS \"status!\",\n event.starts_at,\n event.ends_at,\n event.start_date,\n event.end_date,\n event.time_zone,\n (cardinality(event.recurrence_lines) > 0) AS \"is_recurring!\",\n event.conference_url,\n event.organizer_email,\n event.organizer_name,\n event.description,\n event.is_read_only AS \"is_read_only!\",\n event.created_at AS \"created_at!\",\n event.updated_at AS \"updated_at!\",\n occurrence.occurrence_key AS \"occurrence_key?\",\n occurrence.starts_at AS \"occurrence_starts_at?\",\n occurrence.ends_at AS \"occurrence_ends_at?\",\n occurrence.start_date AS \"occurrence_start_date?\",\n occurrence.end_date AS \"occurrence_end_date?\"\n FROM calendar_events event\n LEFT JOIN LATERAL (\n SELECT\n instance.occurrence_key,\n instance.starts_at,\n instance.ends_at,\n instance.start_date,\n instance.end_date\n FROM calendar_event_occurrences instance\n CROSS JOIN LATERAL (\n SELECT COALESCE(\n instance.starts_at,\n instance.start_date::timestamp AT TIME ZONE 'UTC'\n ) AS at\n ) instance_start\n WHERE instance.event_id = event.id\n AND NOT instance.is_cancelled\n ORDER BY\n (instance_start.at >= $3) DESC,\n CASE WHEN instance_start.at >= $3 THEN instance_start.at END ASC,\n instance_start.at DESC,\n instance.occurrence_key\n LIMIT 1\n ) occurrence ON true\n WHERE event.id = ANY($2)\n AND (\n event.owner_id = $1\n OR EXISTS (\n SELECT 1\n FROM macro_user_links link\n WHERE link.link_id = event.source_link_id\n AND link.primary_macro_id = $1\n )\n )\n ","describe": {"columns": [{@@ -60,41 +60,56 @@},{"ordinal": 11,+ "name": "organizer_email",+ "type_info": "Text"+ },+ {+ "ordinal": 12,+ "name": "organizer_name",+ "type_info": "Text"+ },+ {+ "ordinal": 13,+ "name": "description",+ "type_info": "Text"+ },+ {+ "ordinal": 14,"name": "is_read_only!","type_info": "Bool"},{- "ordinal": 12,+ "ordinal": 15,"name": "created_at!","type_info": "Timestamptz"},{- "ordinal": 13,+ "ordinal": 16,"name": "updated_at!","type_info": "Timestamptz"},{- "ordinal": 14,+ "ordinal": 17,"name": "occurrence_key?","type_info": "Text"},{- "ordinal": 15,+ "ordinal": 18,"name": "occurrence_starts_at?","type_info": "Timestamptz"},{- "ordinal": 16,+ "ordinal": 19,"name": "occurrence_ends_at?","type_info": "Timestamptz"},{- "ordinal": 17,+ "ordinal": 20,"name": "occurrence_start_date?","type_info": "Date"},{- "ordinal": 18,+ "ordinal": 21,"name": "occurrence_end_date?","type_info": "Date"}@@ -118,6 +133,9 @@true,null,true,+ true,+ true,+ true,false,false,false,@@ -128,5 +146,5 @@true]},- "hash": "47e360c89a42e3491a9611f30494e9a96b56a961e6f7b7c84a3ac5e6d2dcc496"+ "hash": "71695e628d3ef339a4288cd8c52ef04f2459b9d28d5d869c1c3f9bc0776dce13"}diff --git a/apps/web/src/features/block-calendar/components/CalendarSearch.tsx b/apps/web/src/features/block-calendar/components/CalendarSearch.tsxnew file mode 100644index 0000000000..703d8ed11b--- /dev/null+++ b/apps/web/src/features/block-calendar/components/CalendarSearch.tsx@@ -0,0 +1,256 @@+import { useCalendarView } from '@app/features/calendar/components/CalendarViewContext';+import { useCalendarSearchUiFlag } from '@app/features/calendar/hooks/use-calendar-ui-flag';+import type { CalendarTimeFormat } from '@app/features/calendar/types';+import { parseLocalDate } from '@app/features/calendar/utils/calendar-date';+import { formatCalendarTime } from '@app/features/calendar/utils/time-format';+import { EntityIcon } from '@core/component/EntityIcon';+import { debouncedDependent } from '@core/util/debounce';+import type { EntityData, WithSearch } from '@entity';+import SearchIcon from '@icon/macro-magnifying-glass.svg';+import { Popover } from '@kobalte/core/popover';+import { useSearchSoupQuery } from '@queries/soup/search';+import type { EntityFilters } from '@service-search/generated/models';+import { Button, Layer } from '@ui';+import { createMemo, createSignal, For, Show } from 'solid-js';+import { openCalendarEventSplit } from '../open-calendar-event';++type CalendarSearchResult = WithSearch<+ Extract<EntityData, { type: 'calendar_event' }>+>;+type EventTime = NonNullable<CalendarSearchResult['time']>;++const NIL_UUID = '00000000-0000-0000-0000-000000000000';++/**+ * Restrict unified search to calendar events: every other searchable type has+ * a NIL id in its primary field, which the search service reads as "exclude+ * this type", while calendar events carry no id filter and so are the only+ * matches. This mirrors what the Search view's Calendar type produces.+ */+const CALENDAR_ONLY_FILTERS: EntityFilters = {+ document_filters: { document_ids: [NIL_UUID] },+ email_filters: { email_thread_ids: [NIL_UUID] },+ channel_filters: { channel_ids: [NIL_UUID] },+ channel_thread_filters: { thread_ids: [NIL_UUID] },+ chat_filters: { chat_ids: [NIL_UUID] },+ project_filters: { project_ids: [NIL_UUID] },+ call_filters: { call_ids: [NIL_UUID] },+ foreign_entity_filters: { ids: [NIL_UUID] },+};++const MIN_QUERY_LENGTH = 3;++const dateWithYear = new Intl.DateTimeFormat(undefined, {+ weekday: 'short',+ month: 'short',+ day: 'numeric',+ year: 'numeric',+});+const dateNoYear = new Intl.DateTimeFormat(undefined, {+ weekday: 'short',+ month: 'short',+ day: 'numeric',+});++function formatDateLabel(date: Date): string {+ const formatter =+ date.getFullYear() === new Date().getFullYear() ? dateNoYear : dateWithYear;+ return formatter.format(date);+}++/** The date/time an event row resolved to, matching the calendar's clock. */+function formatEventWhen(+ time: EventTime | undefined,+ timeFormat: CalendarTimeFormat+): string {+ if (!time) return '';+ if (time.kind === 'allDay') {+ const date = parseLocalDate(time.startDate);+ return date ? `${formatDateLabel(date)} · All day` : '';+ }+ const start = new Date(time.startsAt);+ if (Number.isNaN(start.getTime())) return '';+ return `${formatDateLabel(start)} · ${formatCalendarTime(start, timeFormat)}`;+}++/**+ * Keyword search over the caller's calendar events, opened from the calendar+ * header. Selecting a result re-aims the singleton calendar block at that+ * occurrence, the same navigation an event mention or soup row performs.+ */+export function CalendarSearch() {+ const calendarView = useCalendarView();+ const searchEnabled = useCalendarSearchUiFlag();+ const [open, setOpen] = createSignal(false);+ const [rawQuery, setRawQuery] = createSignal('');+ let inputRef: HTMLInputElement | undefined;++ const query = createMemo(() => rawQuery().trim());+ const debouncedQuery = debouncedDependent(query, 250);++ const searchQuery = useSearchSoupQuery(+ () => ({+ params: { page_size: 25 },+ body: {+ search_on: 'name_content',+ match_type: 'partial',+ query: debouncedQuery(),+ filters: CALENDAR_ONLY_FILTERS,+ },+ }),+ () => ({ enabled: open() })+ );++ // Trust the results only once the debounce has caught up to what the user+ // typed AND the fetch for it has settled. Otherwise, for up to the debounce+ // interval after a keystroke, `searchQuery.data` still holds the previous+ // query's rows — which would show stale hits and let Enter open the old+ // first event. Mirrors the soup search's `isSearchServiceDebounceSettled`.+ const isCurrent = () =>+ query().length >= MIN_QUERY_LENGTH &&+ query() === debouncedQuery() &&+ !(searchQuery.isFetching && !searchQuery.isFetchingNextPage);++ const results = createMemo<CalendarSearchResult[]>(() => {+ if (!isCurrent()) return [];+ return (searchQuery.data ?? []).filter(+ (entity): entity is CalendarSearchResult =>+ entity.type === 'calendar_event'+ );+ });++ const isLoading = () => query().length >= MIN_QUERY_LENGTH && !isCurrent();++ const openResult = (event: CalendarSearchResult) => {+ setOpen(false);+ setRawQuery('');+ // An occurrence key anchors the locator range on its own; without one the+ // master span stands in (a series with no occurrence in the window).+ void openCalendarEventSplit({+ eventId: event.id,+ occurrenceKey: event.occurrenceKey,+ time: event.occurrenceKey ? undefined : event.time,+ });+ };++ return (+ <Show when={searchEnabled()}>+ <Popover+ open={open()}+ onOpenChange={(next) => {+ setOpen(next);+ if (!next) setRawQuery('');+ }}+ placement="bottom-end"+ gutter={6}+ flip+ >+ <Popover.Trigger+ as={Button}+ variant="ghost"+ size="icon-sm"+ class="rounded-lg"+ aria-label="Search events"+ >+ <SearchIcon class="size-4" />+ </Popover.Trigger>++ <Popover.Portal>+ <Layer depth={3}>+ <Popover.Content+ class="portal-scope z-modal outline-none"+ onOpenAutoFocus={(event) => {+ event.preventDefault();+ inputRef?.focus();+ }}+ >+ <div class="w-80 max-w-[calc(100vw-2rem)] overflow-hidden rounded-xl bg-surface text-ink shadow-menu ring ring-edge-muted">+ <div class="flex items-center gap-2 border-b border-edge-muted px-3 py-2">+ <SearchIcon class="size-4 shrink-0 text-ink-muted" />+ <input+ ref={inputRef}+ type="text"+ value={rawQuery()}+ onInput={(event) => setRawQuery(event.currentTarget.value)}+ onKeyDown={(event) => {+ if (event.key === 'Enter') {+ const first = results()[0];+ if (first) openResult(first);+ }+ }}+ placeholder="Search events"+ class="min-w-0 flex-1 rounded-sm bg-transparent text-sm caret-accent outline-none placeholder:text-ink-placeholder focus-visible:ring-1 focus-visible:ring-accent"+ />+ </div>++ <div class="max-h-80 overflow-y-auto p-1">+ <Show+ when={query().length >= MIN_QUERY_LENGTH}+ fallback={+ <div class="px-2 py-3 text-center text-xs text-ink-muted">+ Type at least {MIN_QUERY_LENGTH} characters to search+ </div>+ }+ >+ <Show+ when={!isLoading()}+ fallback={+ <div class="px-2 py-3 text-center text-xs text-ink-muted">+ Searching…+ </div>+ }+ >+ <Show+ when={results().length > 0}+ fallback={+ <div class="px-2 py-3 text-center text-xs text-ink-muted">+ No events found+ </div>+ }+ >+ <For each={results()}>+ {(event) => (+ <button+ type="button"+ class="flex w-full items-center gap-2 rounded-lg p-1.5 px-2 text-left outline-none hover:bg-ink/5 focus-visible:bg-ink/5 focus-visible:ring-1 focus-visible:ring-accent"+ onClick={() => openResult(event)}+ >+ <span class="flex size-4 shrink-0 items-center justify-center">+ <EntityIcon+ targetType="calendar"+ size="xs"+ theme="monochrome"+ />+ </span>+ <span class="min-w-0 flex-1">+ <span class="block truncate text-sm text-ink">+ {event.name || 'Untitled event'}+ </span>+ <Show+ when={formatEventWhen(+ event.time,+ calendarView.displaySettings.timeFormat+ )}+ >+ {(label) => (+ <span class="block truncate text-xs text-ink-muted">+ {label()}+ </span>+ )}+ </Show>+ </span>+ </button>+ )}+ </For>+ </Show>+ </Show>+ </Show>+ </div>+ </div>+ </Popover.Content>+ </Layer>+ </Popover.Portal>+ </Popover>+ </Show>+ );+}diff --git a/apps/web/src/features/block-calendar/components/Header.tsx b/apps/web/src/features/block-calendar/components/Header.tsxindex 7cb9917981..8f4c99dde1 100644--- a/apps/web/src/features/block-calendar/components/Header.tsx+++ b/apps/web/src/features/block-calendar/components/Header.tsx@@ -25,6 +25,7 @@ import PlusIcon from '@phosphor/plus.svg';import { Button } from '@ui';import { usePager } from '@ui/components/Pager';import { createMemo, createSignal, onCleanup, Show } from 'solid-js';+import { CalendarSearch } from './CalendarSearch';import { useOpenEventComposer } from './use-open-event-composer';const formatMonthTitle = new Intl.DateTimeFormat(undefined, {@@ -189,6 +190,7 @@ export function Header() {</Button></div></Show>+ <CalendarSearch /><CalendarSettingsDropdown isNarrow={sidePanel?.isNarrow()} /></div></HeaderIsland>diff --git a/apps/web/src/features/calendar/hooks/use-calendar-ui-flag.ts b/apps/web/src/features/calendar/hooks/use-calendar-ui-flag.tsindex a5f7500b1b..743ea6529b 100644--- a/apps/web/src/features/calendar/hooks/use-calendar-ui-flag.ts+++ b/apps/web/src/features/calendar/hooks/use-calendar-ui-flag.ts@@ -4,6 +4,8 @@ import {ENABLE_CALENDAR_PROMPT_MOBILE_OVERRIDE,ENABLE_CALENDAR_PROMPT_WEB_FLAG,ENABLE_CALENDAR_PROMPT_WEB_OVERRIDE,+ ENABLE_CALENDAR_SEARCH_UI_FLAG,+ ENABLE_CALENDAR_SEARCH_UI_OVERRIDE,ENABLE_CALENDAR_UI_FLAG,ENABLE_CALENDAR_UI_OVERRIDE,} from '@core/constant/featureFlags';@@ -17,6 +19,19 @@ export function useCalendarUiFlag(): Accessor<boolean> {return () => flag().enabled;}+/**+ * Whether the calendar search UI (Search-view calendar type/rows and the+ * in-calendar keyword search) is enabled. A sub-feature of the calendar UI, so+ * it requires `enable-calendar-ui` on top of its own flag.+ */+export function useCalendarSearchUiFlag(): Accessor<boolean> {+ const calendarUi = useCalendarUiFlag();+ const searchFlag = useFeatureFlag(ENABLE_CALENDAR_SEARCH_UI_FLAG, {+ enabledOverride: ENABLE_CALENDAR_SEARCH_UI_OVERRIDE,+ });+ return () => calendarUi() && searchFlag().enabled;+}+/*** Whether the "Enable calendar" prompt may surface on this device. Each form* factor has its own kill switch: a phone defers todiff --git a/apps/web/src/features/entity/composed/list-entity/calendar.tsx b/apps/web/src/features/entity/composed/list-entity/calendar.tsxnew file mode 100644index 0000000000..86782bf338--- /dev/null+++ b/apps/web/src/features/entity/composed/list-entity/calendar.tsx@@ -0,0 +1,199 @@+import { UserIcon, type UserIconProps } from '@core/component/UserIcon';+import { emailToMacroId, getDisplayName } from '@core/user';+import RepeatIcon from '@phosphor/repeat.svg';+import { Show } from 'solid-js';+import { Entity } from '../../entity';+import type {+ CalendarEventEntity,+ CalendarEventEntityTime,+} from '../../types/entity';++const timeOnly = new Intl.DateTimeFormat(undefined, {+ hour: 'numeric',+ minute: '2-digit',+});+const stampSameYear = new Intl.DateTimeFormat(undefined, {+ month: 'short',+ day: 'numeric',+});+const stampOtherYear = new Intl.DateTimeFormat(undefined, {+ year: '2-digit',+ month: 'numeric',+ day: 'numeric',+});++/** Parse an all-day `YYYY-MM-DD` key as a local date, no UTC shift. */+function parseAllDay(value: string): Date | undefined {+ const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);+ if (!match) return undefined;+ const date = new Date(+ Number(match[1]),+ Number(match[2]) - 1,+ Number(match[3])+ );+ return Number.isNaN(date.getTime()) ? undefined : date;+}++/** Start instant of the row's resolved occurrence. */+function occurrenceStart(+ time: CalendarEventEntityTime | undefined+): Date | undefined {+ if (!time) return undefined;+ if (time.kind === 'allDay') return parseAllDay(time.startDate);+ const start = new Date(time.startsAt);+ return Number.isNaN(start.getTime()) ? undefined : start;+}++/** Compact right-aligned date for the timestamp column (fits its 8ch slot). */+export function formatStampDate(+ time: CalendarEventEntityTime | undefined+): string {+ const date = occurrenceStart(time);+ if (!date) return '';+ return date.getFullYear() === new Date().getFullYear()+ ? stampSameYear.format(date)+ : stampOtherYear.format(date);+}++/** Time-of-day range for the left detail line; the date rides the stamp. */+function formatTimeOfDay(time: CalendarEventEntityTime | undefined): string {+ if (!time) return '';+ if (time.kind === 'allDay') return 'All day';+ const start = new Date(time.startsAt);+ if (Number.isNaN(start.getTime())) return '';+ const end = new Date(time.endsAt);+ if (Number.isNaN(end.getTime()) || end.getTime() === start.getTime()) {+ return timeOnly.format(start);+ }+ return `${timeOnly.format(start)}–${timeOnly.format(end)}`;+}++/** Plain-text preview of a description that may carry HTML from the source. */+function descriptionPreview(raw: string | undefined): string {+ if (!raw) return '';+ return raw+ .replace(/<[^>]*>/g, ' ')+ .replace(/ /gi, ' ')+ .replace(/&/gi, '&')+ .replace(/</gi, '<')+ .replace(/>/gi, '>')+ .replace(/'|'/gi, "'")+ .replace(/"/gi, '"')+ .replace(/\s+/g, ' ')+ .trim();+}++/** The organizer resolved to a Macro user (id) when their email is one, else+ * keyed by the raw email so a non-Macro organizer still gets a contact icon. */+function organizerIconProps(+ entity: CalendarEventEntity+): UserIconProps | undefined {+ const email = entity.organizer?.email;+ if (!email) return undefined;+ const macroId = emailToMacroId(email);+ return macroId ? { id: macroId } : { email };+}++/** Organizer display: the Macro profile name when resolved, else the source's+ * own name, else the email. Read reactively so it fills in when the user's+ * name cache resolves. */+function organizerName(entity: CalendarEventEntity): string {+ const email = entity.organizer?.email;+ const macroId = email ? emailToMacroId(email) : undefined;+ const resolved = macroId ? getDisplayName(macroId).trim() : '';+ return resolved || entity.organizer?.name || email || '';+}++const Dot = () => <span class="shrink-0 text-ink/30">·</span>;++/**+ * Left-justified content for a calendar event row: the title sits right after+ * the icon like a document or task row, then a muted trailing line carries the+ * time, the organizer (avatar + name), and a description preview — the same+ * reading order those rows use. The date rides the trailing timestamp.+ */+export function CalendarWideContent(props: { entity: CalendarEventEntity }) {+ const iconProps = () => organizerIconProps(props.entity);+ const time = () => formatTimeOfDay(props.entity.time);+ const description = () => descriptionPreview(props.entity.description);++ return (+ <>+ <span class="min-w-0 truncate">+ <Entity.Title entity={props.entity} />+ </span>+ <span class="inline-flex min-w-0 flex-1 items-center gap-1.5 truncate font-medium text-ink/50">+ <Show when={props.entity.isRecurring}>+ <RepeatIcon class="size-3 shrink-0" aria-label="Repeats" />+ </Show>+ <Show when={time()}>+ <span class="shrink-0">{time()}</span>+ </Show>+ <Show when={organizerName(props.entity)}>+ {(name) => (+ <span class="flex shrink-0 items-center gap-1.5">+ <Dot />+ {/* Avatar only when the organizer resolves to a Macro user (needs+ an email); a name-only organizer still shows its name. */}+ <Show when={iconProps()}>+ {(props_) => (+ <span class="size-4 shrink-0 overflow-hidden rounded-full">+ <UserIcon+ {...props_()}+ size="fill"+ suppressClick+ showTooltip={false}+ />+ </span>+ )}+ </Show>+ <span class="max-w-40 truncate">{name()}</span>+ </span>+ )}+ </Show>+ <Show when={description()}>+ <Dot />+ <span class="truncate">{description()}</span>+ </Show>+ </span>+ </>+ );+}++/** The date a calendar row resolved to, for the trailing timestamp slot. */+export function CalendarStamp(props: { entity: CalendarEventEntity }) {+ return <>{formatStampDate(props.entity.time)}</>;+}++/**+ * Compact single-line summary for the narrow mixed-search layout, where there+ * is only one trailing slot: date/time, a recurrence glyph, and the organizer+ * name (no avatar — the row is too tight for one).+ */+export function CalendarEventWhen(props: { entity: CalendarEventEntity }) {+ const start = () => occurrenceStart(props.entity.time);+ const when = () => {+ const date = start();+ if (!date) return '';+ const time = formatTimeOfDay(props.entity.time);+ return time === 'All day'+ ? `${formatStampDate(props.entity.time)} · All day`+ : `${formatStampDate(props.entity.time)} · ${timeOnly.format(date)}`;+ };+ return (+ <span class="inline-flex min-w-0 items-center gap-1 whitespace-nowrap text-xs text-ink-extra-muted font-normal">+ <Show when={props.entity.isRecurring}>+ <RepeatIcon class="size-3 shrink-0" aria-label="Repeats" />+ </Show>+ <span class="shrink-0">{when()}</span>+ <Show when={organizerName(props.entity)}>+ {(name) => (+ <>+ <Dot />+ <span class="max-w-40 truncate">{name()}</span>+ </>+ )}+ </Show>+ </span>+ );+}diff --git a/apps/web/src/features/entity/composed/list-entity/narrow-single-line-layout.tsx b/apps/web/src/features/entity/composed/list-entity/narrow-single-line-layout.tsxindex ad414d65a0..8ae3ba74e0 100644--- a/apps/web/src/features/entity/composed/list-entity/narrow-single-line-layout.tsx+++ b/apps/web/src/features/entity/composed/list-entity/narrow-single-line-layout.tsx@@ -7,6 +7,7 @@ import {isTaskEntity,} from '../../types/entity';import { isSearchEntity } from '../../types/search';+import { CalendarEventWhen } from './calendar';import {ChannelActiveCallBadge,ChannelJoinButton,@@ -104,18 +105,20 @@ export function NarrowSingleLineLayout(props: LayoutProps) {placement="timestamp"class="text-xs text-right text-ink-extra-muted font-light">- <Show- when={!isTaskEntity(props.entity)}- fallback={+ <Switch fallback={<Entity.Timestamp entity={props.entity} />}>+ <Match when={isTaskEntity(props.entity)}><Entity.Propertiesentity={props.entity}maxUserStackUsers={0}showCaret={false}/>- }- >- <Entity.Timestamp entity={props.entity} />- </Show>+ </Match>+ <Match+ when={props.entity.type === 'calendar_event' && props.entity}+ >+ {(entity) => <CalendarEventWhen entity={entity()} />}+ </Match>+ </Switch></Entity.Slot></Show></Entity.Layout>diff --git a/apps/web/src/features/entity/composed/list-entity/wide-layout.tsx b/apps/web/src/features/entity/composed/list-entity/wide-layout.tsxindex ae18babf28..ffb411c33b 100644--- a/apps/web/src/features/entity/composed/list-entity/wide-layout.tsx+++ b/apps/web/src/features/entity/composed/list-entity/wide-layout.tsx@@ -30,6 +30,7 @@ import {} from '../../types/entity';import { isSearchEntity } from '../../types/search';import { AutomationWideContent } from './automation';+import { CalendarStamp, CalendarWideContent } from './calendar';import { CallParticipants, CallWideContent } from './call';import {ChannelActiveCallBadge,@@ -149,6 +150,9 @@ export function WideLayout(props: LayoutProps) {<Match when={isReminderEntity(props.entity) && props.entity}>{(entity) => <ReminderWideContent entity={entity()} />}</Match>+ <Match when={props.entity.type === 'calendar_event' && props.entity}>+ {(entity) => <CalendarWideContent entity={entity()} />}+ </Match><Match when={isGithubPrEntity(props.entity) && props.entity}>{(entity) => (<span class="flex min-w-0 items-center gap-1">@@ -295,7 +299,14 @@ export function WideLayout(props: LayoutProps) {!(isChannelEntity(props.entity) && isSearchEntity(props.entity))}>- <Entity.Timestamp entity={props.entity} />+ <Switch fallback={<Entity.Timestamp entity={props.entity} />}>+ {/* The event's own date, not its sync time. */}+ <Match+ when={props.entity.type === 'calendar_event' && props.entity}+ >+ {(entity) => <CalendarStamp entity={entity()} />}+ </Match>+ </Switch></Show></Entity.Slot></Entity.Layout>diff --git a/apps/web/src/features/entity/extractors/entity-icon.tsx b/apps/web/src/features/entity/extractors/entity-icon.tsxindex 8bd5b351d2..b6549c45e2 100644--- a/apps/web/src/features/entity/extractors/entity-icon.tsx+++ b/apps/web/src/features/entity/extractors/entity-icon.tsx@@ -131,6 +131,7 @@ export function EntityIcon(props: EntityIconProps) {).with({ type: 'foreign' }, () => 'default').with({ type: 'crm_company' }, () => 'crm_company')+ .with({ type: 'calendar_event' }, () => 'calendar')// Always the bell, never the referenced entity's icon: the row is a// reminder first, and what it points at is iconed beside its name// instead — see `reminderReferenceIconType`.diff --git a/apps/web/src/features/entity/types/entity.ts b/apps/web/src/features/entity/types/entity.tsindex 2bb2c902eb..77f265c96d 100644--- a/apps/web/src/features/entity/types/entity.ts+++ b/apps/web/src/features/entity/types/entity.ts@@ -367,6 +367,15 @@ export type CalendarEventEntity = EntityBase & {* than the master's original start; soup rows leave it unset.*/occurrenceKey?: string;+ /** Whether the series carries a recurrence rule, so a row can flag it+ * without parsing the rules. Only search rows populate it. */+ isRecurring?: boolean;+ /** The event's organizer (its creator, in Google's model), when named.+ * Only search rows populate it. */+ organizer?: { name?: string; email?: string };+ /** Free-text description, when the event carries one. May contain HTML from+ * the source. Only search rows populate it. */+ description?: string;/** Direct join URL when known. */conferenceUrl?: string;/** Whether the canonical source prohibits mutation. */diff --git a/apps/web/src/features/next-soup/filters/configs/entity.ts b/apps/web/src/features/next-soup/filters/configs/entity.tsindex f3cdaafc3d..be7b6cc16e 100644--- a/apps/web/src/features/next-soup/filters/configs/entity.ts+++ b/apps/web/src/features/next-soup/filters/configs/entity.ts@@ -2,6 +2,7 @@ import { getEntityProjectId } from '@entity';import { defineQueryFilters } from '../filter-store/compile';import {activeAgentFilter as activeAgentPredicate,+ calendarEventFilter as calendarEventPredicate,callsFilter as callsPredicate,channelsFilter as channelsPredicate,crmCompanyActiveFilter as crmCompanyActivePredicate,@@ -68,6 +69,15 @@ export const callsFilter = config({query: defineQueryFilters({}, { skipTargets: ['callf'] }),});+// Calendar events are searchable by title. Scoping to them alone means+// NIL-excluding every other entity type's id target while leaving `calf`+// untouched, which is exactly what skipping `calf` produces.+export const calendarFilter = config({+ id: 'calendar',+ predicate: calendarEventPredicate,+ query: defineQueryFilters({}, { skipTargets: ['calf'] }),+});+export const crmCompanyFilter = config({id: 'crm-company',predicate: crmCompanyPredicate,diff --git a/apps/web/src/features/next-soup/filters/configs/index.ts b/apps/web/src/features/next-soup/filters/configs/index.tsindex 71a06dd843..6df63d5737 100644--- a/apps/web/src/features/next-soup/filters/configs/index.ts+++ b/apps/web/src/features/next-soup/filters/configs/index.ts@@ -27,6 +27,7 @@ import {} from './email';import {activeAgentFilter,+ calendarFilter,callsFilter,channelsFilter,crmCompanyActiveFilter,@@ -91,6 +92,7 @@ export const SOUP_FILTERS = [notTaskFilter,documentOrFileFilter,activeTaskFilter,+ calendarFilter,callsFilter,crmCompanyFilter,crmCompanyActiveFilter,diff --git a/apps/web/src/features/next-soup/filters/predicates.ts b/apps/web/src/features/next-soup/filters/predicates.tsindex 53215921b7..327fcab3b2 100644--- a/apps/web/src/features/next-soup/filters/predicates.ts+++ b/apps/web/src/features/next-soup/filters/predicates.ts@@ -137,6 +137,10 @@ export function callsFilter(entity: EntityData): boolean {return entity.type === 'call';}+export function calendarEventFilter(entity: EntityData): boolean {+ return entity.type === 'calendar_event';+}+export function crmCompanyFilter(entity: EntityData): boolean {return entity.type === 'crm_company';}diff --git a/apps/web/src/features/next-soup/sidebar/soup-filter-presets.test.ts b/apps/web/src/features/next-soup/sidebar/soup-filter-presets.test.tsindex 0320d83f42..6d07ae1c29 100644--- a/apps/web/src/features/next-soup/sidebar/soup-filter-presets.test.ts+++ b/apps/web/src/features/next-soup/sidebar/soup-filter-presets.test.ts@@ -3,10 +3,12 @@ import { afterEach, describe, expect, it, vi } from 'vitest';const mocks = vi.hoisted(() => ({remindersEnabled: true,calendarUiEnabled: true,+ calendarSearchEnabled: true,}));vi.mock('@core/constant/featureFlags', () => ({ENABLE_CALENDAR_UI: () => mocks.calendarUiEnabled,+ ENABLE_CALENDAR_SEARCH_UI: () => mocks.calendarSearchEnabled,ENABLE_REMINDERS: () => mocks.remindersEnabled,ENABLE_SNIPPETS: () => true,ENABLE_SUPPORTED_SOUP_FOREIGN_ENTITIES_OVERRIDE: false,@@ -15,6 +17,7 @@ vi.mock('@core/constant/featureFlags', () => ({afterEach(() => {mocks.remindersEnabled = true;mocks.calendarUiEnabled = true;+ mocks.calendarSearchEnabled = true;});import { SYSTEM_PROPERTY_IDS } from '@property/constants';@@ -89,10 +92,10 @@ describe('calendar event scoping', () => {).toBeUndefined();});- it('excludes them from search when the calendar UI is off', () => {+ it('excludes them from search when calendar search is off', () => {// Opening a hit needs the calendar block, which the flag gates, so// without it a result would render an inert row.- mocks.calendarUiEnabled = false;+ mocks.calendarSearchEnabled = false;expect(getViewPreset('search', 'all')?.filters.include?.calendarEventIddiff --git a/apps/web/src/features/next-soup/sidebar/soup-filter-presets.ts b/apps/web/src/features/next-soup/sidebar/soup-filter-presets.tsindex 78aea04b34..b5d0b379f8 100644--- a/apps/web/src/features/next-soup/sidebar/soup-filter-presets.ts+++ b/apps/web/src/features/next-soup/sidebar/soup-filter-presets.ts@@ -7,6 +7,7 @@ import {type Query,} from '@app/features/next-soup/filters/filter-store';import {+ ENABLE_CALENDAR_SEARCH_UI,ENABLE_CALENDAR_UI,ENABLE_REMINDERS,ENABLE_SNIPPETS,@@ -608,7 +609,9 @@ export const VIEW_TAB_PRESETS: Record<ListView, ViewTabConfig> = {// Events are title-indexed, so search returns them — but opening// one needs the calendar block, which the flag gates. Without it// a hit would render an inert row, so exclude the type instead.- ...(ENABLE_CALENDAR_UI() ? {} : { calendarEventId: [NIL_UUID] }),+ ...(ENABLE_CALENDAR_SEARCH_UI()+ ? {}+ : { calendarEventId: [NIL_UUID] }),},exclude: getDisabledSnippetSubtypeExclude(),},diff --git a/apps/web/src/features/next-soup/soup-view/filters-bar/search/search-facets.tsx b/apps/web/src/features/next-soup/soup-view/filters-bar/search/search-facets.tsxindex 965747fe3a..b0d69faeb3 100644--- a/apps/web/src/features/next-soup/soup-view/filters-bar/search/search-facets.tsx+++ b/apps/web/src/features/next-soup/soup-view/filters-bar/search/search-facets.tsx@@ -1,8 +1,10 @@+import { useCalendarSearchUiFlag } from '@app/features/calendar/hooks/use-calendar-ui-flag';import type {CallStatus,PropertyFilter,TagFilterMode,} from '@app/features/next-soup/filters/filter-store/types';+import { usePosthog } from '@app/lib/analytics/posthog';import { EntityIcon } from '@core/component/EntityIcon';import { UserIcon } from '@core/component/UserIcon';import { useQuickAccess } from '@core/context/quickAccess';@@ -10,7 +12,7 @@ import { useUserId } from '@core/context/user';import { EntityIcon as EntityIconWithAvatar } from '@entity/extractors/entity-icon';import { PropertyValueIcon } from '@property/component/propertyValue/PropertyValueIcon';import { PROPERTY_OPTION_IDS } from '@property/constants';-import { type Accessor, createMemo, type JSX } from 'solid-js';+import { type Accessor, createEffect, createMemo, type JSX } from 'solid-js';import { useInboxPicker } from '../inbox-picker';import type { SearchableOption } from '../searchable-multi-select';import { useTagOptions } from '../tag-filter';@@ -66,6 +68,17 @@ export const SEARCH_INDEX_OPTIONS: {},];+/**+ * Calendar is offered as a search type only where the calendar UI is enabled:+ * opening an event needs the calendar block, which the same flag gates, so a+ * disabled workspace would surface events it can't open.+ */+const CALENDAR_TYPE_OPTION: (typeof SEARCH_INDEX_OPTIONS)[number] = {+ value: 'calendar',+ label: 'Calendar',+ icon: () => <EntityIcon targetType="calendar" size="xs" theme="monochrome" />,+};+const CALL_STATUS_LABELS: Record<CallStatus, string> = {ATTENDED: 'Attended',MISSED: 'Missed',@@ -299,23 +312,45 @@ export function useSearchFacets(});const tagSource = useTagOptions();-- const type = singleFacet({- id: 'type',- label: 'Type',- options: [- { id: 'all', label: 'All' },- ...SEARCH_INDEX_OPTIONS.map((o) => ({- id: o.value,- label: o.label,- icon: o.icon,- })),- ],- defaultId: 'all',- selectedId: controller.type,- onSelect: (id) => controller.setType(id as SearchTypeValue),+ const calendarSearchEnabled = useCalendarSearchUiFlag();+ const posthog = usePosthog();++ // The calendar type exists only while calendar search is enabled. If the flag+ // turns off (or a persisted search restores a calendar scope while it is off),+ // its Type option disappears and the chip falls back to "All", but the+ // compiled query would still carry the calendar seed — reset the type so the+ // displayed chip and the query agree. Wait for the flags to load first: a+ // PostHog flag reads `false` until it resolves, and resetting on that would+ // rewrite a legitimately-restored Calendar search to All before the flag+ // arrives.+ createEffect(() => {+ if (+ posthog.flagsLoaded() &&+ !calendarSearchEnabled() &&+ controller.type() === 'calendar'+ ) {+ controller.setType('all');+ }});+ const typeOptions = createMemo<FacetOption[]>(() => [+ { id: 'all', label: 'All' },+ ...[+ ...SEARCH_INDEX_OPTIONS,+ ...(calendarSearchEnabled() ? [CALENDAR_TYPE_OPTION] : []),+ ].map((o) => ({ id: o.value, label: o.label, icon: o.icon })),+ ]);++ const buildTypeFacet = () =>+ singleFacet({+ id: 'type',+ label: 'Type',+ options: typeOptions(),+ defaultId: 'all',+ selectedId: controller.type,+ onSelect: (id) => controller.setType(id as SearchTypeValue),+ });+const importance = singleFacet({id: 'importance',label: 'Importance',@@ -486,6 +521,7 @@ export function useSearchFacets(const tagFacets = (): SearchFacetVM[] => (tagSource.hasTags() ? [tags] : []);return createMemo(() => {+ const type = buildTypeFacet();switch (controller.type()) {case 'email':return inboxPicker.hasMultiple()@@ -509,6 +545,9 @@ export function useSearchFacets(case 'folders':case 'all':return [type, ...tagFacets()];+ // Calendar keyword search only for now; who/where/when facets come later.+ case 'calendar':+ return [type];default:return [type];}diff --git a/apps/web/src/features/next-soup/soup-view/filters-bar/search/search-filters-state.ts b/apps/web/src/features/next-soup/soup-view/filters-bar/search/search-filters-state.tsindex 4dda62409d..1c77a7137e 100644--- a/apps/web/src/features/next-soup/soup-view/filters-bar/search/search-filters-state.ts+++ b/apps/web/src/features/next-soup/soup-view/filters-bar/search/search-filters-state.ts@@ -22,7 +22,8 @@ export type SearchIndexId =| 'email'| 'calls'| 'folders'- | 'agent';+ | 'agent'+ | 'calendar';export type SearchTypeValue = SearchIndexId | 'all';@@ -53,6 +54,7 @@ export const SEARCH_INDEX_SEEDS: Record<SearchIndexId, Query> = {calls: defineQueryFilters({}, { skipTargets: ['callf'] }),folders: defineQueryFilters({ exclude: { folderId: [NIL_UUID] } }),agent: defineQueryFilters({ exclude: { chatId: [NIL_UUID] } }),+ calendar: defineQueryFilters({}, { skipTargets: ['calf'] }),};export type SearchFiltersSections = {diff --git a/apps/web/src/lib/core/constant/featureFlags.ts b/apps/web/src/lib/core/constant/featureFlags.tsindex 7439705f7b..85f7cfcf4c 100644--- a/apps/web/src/lib/core/constant/featureFlags.ts+++ b/apps/web/src/lib/core/constant/featureFlags.ts@@ -612,6 +612,32 @@ export function ENABLE_CALENDAR_UI(): boolean {return analytics.posthog.isFeatureEnabled(ENABLE_CALENDAR_UI_FLAG) ?? false;}+// Calendar event search UI: the Search view's Calendar type (and calendar+// rows) plus the in-calendar keyword search. A sub-feature of the calendar UI+// — opening a hit needs the calendar block — so it only takes effect where+// `enable-calendar-ui` is also on. PostHog-gated with a dev-mode default;+// override with VITE_ENABLE_CALENDAR_SEARCH_UI.+export const ENABLE_CALENDAR_SEARCH_UI_FLAG = 'enable-calendar-search-ui';+export const ENABLE_CALENDAR_SEARCH_UI_OVERRIDE =+ getFeatureFlagOverride('ENABLE_CALENDAR_SEARCH_UI') ??+ (DEV_MODE_ENV ? true : undefined);++/**+ * Non-reactive check for imperative call sites (soup filter presets). Gated by+ * the calendar UI too. For reactive UI, prefer `useCalendarSearchUiFlag()`.+ */+export function ENABLE_CALENDAR_SEARCH_UI(): boolean {+ if (!ENABLE_CALENDAR_UI()) {+ return false;+ }+ if (ENABLE_CALENDAR_SEARCH_UI_OVERRIDE !== undefined) {+ return ENABLE_CALENDAR_SEARCH_UI_OVERRIDE;+ }+ return (+ analytics.posthog.isFeatureEnabled(ENABLE_CALENDAR_SEARCH_UI_FLAG) ?? false+ );+}+// The "Enable calendar" prompt on phones. Off by default everywhere,// including dev: the mobile toast layout drops the body and the close button,// so the prompt lands as an undismissable one-line bar over the composer.diff --git a/apps/web/src/lib/queries/soup/transform-utils.ts b/apps/web/src/lib/queries/soup/transform-utils.tsindex f79368262b..96ce47748a 100644--- a/apps/web/src/lib/queries/soup/transform-utils.ts+++ b/apps/web/src/lib/queries/soup/transform-utils.ts@@ -567,6 +567,14 @@ export const useSearchResponseItemMapper = () => {status: metadata.status,time,occurrenceKey: metadata.occurrence?.occurrenceKey,+ isRecurring: metadata.isRecurring,+ organizer: metadata.organizer+ ? {+ name: metadata.organizer.name ?? undefined,+ email: metadata.organizer.email ?? undefined,+ }+ : undefined,+ description: metadata.description ?? undefined,conferenceUrl: metadata.conferenceUrl ?? undefined,isReadOnly: metadata.isReadOnly,createdAt: metadata.createdAt,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.tsindex 4d4e1f5f8d..53c6475a53 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@@ -756,6 +756,16 @@ export const SearchToolResponse = z.object({.optional(),conferenceUrl: z.union([z.string(), z.null()]).optional(),isReadOnly: z.boolean(),+ organizer: z+ .union([+ z.object({+ name: z.union([z.string(), z.null()]).optional(),+ email: z.union([z.string(), z.null()]).optional(),+ }),+ z.null(),+ ])+ .optional(),+ description: z.union([z.string(), z.null()]).optional(),}),z.null(),])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.tsindex cb217322b2..861856abc7 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@@ -1646,6 +1646,15 @@ export interface CalendarEventMetadata {* Whether the canonical source prohibits mutation.*/isReadOnly: boolean;+ /**+ * The event's organizer (creator), when the source names one.+ */+ organizer?: CalendarEventOrganizer | null;+ /**+ * Free-text description, when the event carries one. May contain HTML from+ * the source; clients render a plain-text preview.+ */+ description?: string | null;}/*** The instance a search row points at.@@ -1663,6 +1672,20 @@ export interface CalendarEventSearchOccurrence {occurrenceKey: string;time: CalendarEventSearchTime;}+/**+ * The event's organizer — its creator, in Google's model. Either field can be+ * absent when the source does not name it.+ */+export interface CalendarEventOrganizer {+ /**+ * Display name, when the source provided one.+ */+ name?: string | null;+ /**+ * Organizer email address, when known.+ */+ email?: string | null;+}export interface CalendarEventSearchResult {highlight: SearchHighlight;/**diff --git a/apps/web/src/lib/service-clients/service-search/generated/models/calendarEventMetadata.ts b/apps/web/src/lib/service-clients/service-search/generated/models/calendarEventMetadata.tsindex 100b4a2dd9..f77ddd0250 100644--- a/apps/web/src/lib/service-clients/service-search/generated/models/calendarEventMetadata.ts+++ b/apps/web/src/lib/service-clients/service-search/generated/models/calendarEventMetadata.ts@@ -5,7 +5,9 @@* OpenAPI spec version: 0.1.0*/import type { CalendarEventMetadataConferenceUrl } from './calendarEventMetadataConferenceUrl';+import type { CalendarEventMetadataDescription } from './calendarEventMetadataDescription';import type { CalendarEventMetadataOccurrence } from './calendarEventMetadataOccurrence';+import type { CalendarEventMetadataOrganizer } from './calendarEventMetadataOrganizer';import type { CalendarEventSearchTime } from './calendarEventSearchTime';/**@@ -19,12 +21,16 @@ export interface CalendarEventMetadata {/** Direct conference join URL when known. */conferenceUrl?: CalendarEventMetadataConferenceUrl;createdAt: string;+ /** Free-text description, when the event carries one. May contain HTML from+the source; clients render a plain-text preview. */+ description?: CalendarEventMetadataDescription;/** Whether the canonical source prohibits mutation. */isReadOnly: boolean;/** Whether the series carries a recurrence rule. Lets a row render arecurring badge without parsing the rules. */isRecurring: boolean;occurrence?: CalendarEventMetadataOccurrence;+ organizer?: CalendarEventMetadataOrganizer;/** Canonical status (`confirmed`, `tentative`, `cancelled`). */status: string;/** The series' own span. */diff --git a/apps/web/src/lib/service-clients/service-search/generated/models/calendarEventMetadataDescription.ts b/apps/web/src/lib/service-clients/service-search/generated/models/calendarEventMetadataDescription.tsnew file mode 100644index 0000000000..87308900af--- /dev/null+++ b/apps/web/src/lib/service-clients/service-search/generated/models/calendarEventMetadataDescription.ts@@ -0,0 +1,12 @@+/**+ * Generated by orval v7.21.0 🍺+ * Do not edit manually.+ * search_service+ * OpenAPI spec version: 0.1.0+ */++/**+ * Free-text description, when the event carries one. May contain HTML from+the source; clients render a plain-text preview.+ */+export type CalendarEventMetadataDescription = string | null;diff --git a/apps/web/src/lib/service-clients/service-search/generated/models/calendarEventMetadataOrganizer.ts b/apps/web/src/lib/service-clients/service-search/generated/models/calendarEventMetadataOrganizer.tsnew file mode 100644index 0000000000..667328ce28--- /dev/null+++ b/apps/web/src/lib/service-clients/service-search/generated/models/calendarEventMetadataOrganizer.ts@@ -0,0 +1,9 @@+/**+ * Generated by orval v7.21.0 🍺+ * Do not edit manually.+ * search_service+ * OpenAPI spec version: 0.1.0+ */+import type { CalendarEventOrganizer } from './calendarEventOrganizer';++export type CalendarEventMetadataOrganizer = null | CalendarEventOrganizer;diff --git a/apps/web/src/lib/service-clients/service-search/generated/models/calendarEventOrganizer.ts b/apps/web/src/lib/service-clients/service-search/generated/models/calendarEventOrganizer.tsnew file mode 100644index 0000000000..3f841c195c--- /dev/null+++ b/apps/web/src/lib/service-clients/service-search/generated/models/calendarEventOrganizer.ts@@ -0,0 +1,19 @@+/**+ * Generated by orval v7.21.0 🍺+ * Do not edit manually.+ * search_service+ * OpenAPI spec version: 0.1.0+ */+import type { CalendarEventOrganizerEmail } from './calendarEventOrganizerEmail';+import type { CalendarEventOrganizerName } from './calendarEventOrganizerName';++/**+ * The event's organizer — its creator, in Google's model. Either field can be+absent when the source does not name it.+ */+export interface CalendarEventOrganizer {+ /** Organizer email address, when known. */+ email?: CalendarEventOrganizerEmail;+ /** Display name, when the source provided one. */+ name?: CalendarEventOrganizerName;+}diff --git a/apps/web/src/lib/service-clients/service-search/generated/models/calendarEventOrganizerEmail.ts b/apps/web/src/lib/service-clients/service-search/generated/models/calendarEventOrganizerEmail.tsnew file mode 100644index 0000000000..c00ee458b4--- /dev/null+++ b/apps/web/src/lib/service-clients/service-search/generated/models/calendarEventOrganizerEmail.ts@@ -0,0 +1,11 @@+/**+ * Generated by orval v7.21.0 🍺+ * Do not edit manually.+ * search_service+ * OpenAPI spec version: 0.1.0+ */++/**+ * Organizer email address, when known.+ */+export type CalendarEventOrganizerEmail = string | null;diff --git a/apps/web/src/lib/service-clients/service-search/generated/models/calendarEventOrganizerName.ts b/apps/web/src/lib/service-clients/service-search/generated/models/calendarEventOrganizerName.tsnew file mode 100644index 0000000000..3db78c651d--- /dev/null+++ b/apps/web/src/lib/service-clients/service-search/generated/models/calendarEventOrganizerName.ts@@ -0,0 +1,11 @@+/**+ * Generated by orval v7.21.0 🍺+ * Do not edit manually.+ * search_service+ * OpenAPI spec version: 0.1.0+ */++/**+ * Display name, when the source provided one.+ */+export type CalendarEventOrganizerName = string | null;diff --git a/apps/web/src/lib/service-clients/service-search/generated/models/index.ts b/apps/web/src/lib/service-clients/service-search/generated/models/index.tsindex fe025b476f..1571189435 100644--- a/apps/web/src/lib/service-clients/service-search/generated/models/index.ts+++ b/apps/web/src/lib/service-clients/service-search/generated/models/index.ts@@ -10,7 +10,12 @@ export * from './calendarEventFiltersEndsAfter';export * from './calendarEventFiltersStartsBefore';export * from './calendarEventMetadata';export * from './calendarEventMetadataConferenceUrl';+export * from './calendarEventMetadataDescription';export * from './calendarEventMetadataOccurrence';+export * from './calendarEventMetadataOrganizer';+export * from './calendarEventOrganizer';+export * from './calendarEventOrganizerEmail';+export * from './calendarEventOrganizerName';export * from './calendarEventSearchOccurrence';export * from './calendarEventSearchResponseItem';export * from './calendarEventSearchResponseItemWithMetadata';diff --git a/apps/web/src/lib/service-clients/service-search/openapi.json b/apps/web/src/lib/service-clients/service-search/openapi.jsonindex 225f0bfcc0..bdb4a5f93f 100644--- a/apps/web/src/lib/service-clients/service-search/openapi.json+++ b/apps/web/src/lib/service-clients/service-search/openapi.json@@ -237,6 +237,10 @@"type": "string","format": "date-time"},+ "description": {+ "type": ["string", "null"],+ "description": "Free-text description, when the event carries one. May contain HTML from\nthe source; clients render a plain-text preview."+ },"isReadOnly": {"type": "boolean","description": "Whether the canonical source prohibits mutation."@@ -256,6 +260,17 @@}]},+ "organizer": {+ "oneOf": [+ {+ "type": "null"+ },+ {+ "$ref": "#/components/schemas/CalendarEventOrganizer",+ "description": "The event's organizer (creator), when the source names one."+ }+ ]+ },"status": {"type": "string","description": "Canonical status (`confirmed`, `tentative`, `cancelled`)."@@ -270,6 +285,20 @@}}},+ "CalendarEventOrganizer": {+ "type": "object",+ "description": "The event's organizer — its creator, in Google's model. Either field can be\nabsent when the source does not name it.",+ "properties": {+ "email": {+ "type": ["string", "null"],+ "description": "Organizer email address, when known."+ },+ "name": {+ "type": ["string", "null"],+ "description": "Display name, when the source provided one."+ }+ }+ },"CalendarEventSearchOccurrence": {"type": "object","description": "The instance a search row points at.\n\nA recurring series is indexed once, as its master. Which instance the row\nshould show is decided per request rather than baked into the index: the\nnext occurrence at or after now, else the most recent past one. This is\nthe same resolution a calendar mention performs, so a search row and a\nmention of the same event agree on where they land.",diff --git a/crates/macro_db_client/src/calendar_event/get_events_for_search.rs b/crates/macro_db_client/src/calendar_event/get_events_for_search.rsindex 4431c06a43..e174ed6523 100644--- a/crates/macro_db_client/src/calendar_event/get_events_for_search.rs+++ b/crates/macro_db_client/src/calendar_event/get_events_for_search.rs@@ -33,6 +33,12 @@ pub struct CalendarEventSearchInfo {pub is_recurring: bool,/// Direct conference join URL.pub conference_url: Option<String>,+ /// Organizer email, when the source names one.+ pub organizer_email: Option<String>,+ /// Organizer display name, when the source names one.+ pub organizer_name: Option<String>,+ /// Free-text event description, when the source carries one.+ pub description: Option<String>,/// Whether the canonical source prohibits mutation.pub is_read_only: bool,pub created_at: DateTime<Utc>,@@ -87,6 +93,9 @@ pub async fn get_calendar_events_for_search(event.time_zone,(cardinality(event.recurrence_lines) > 0) AS "is_recurring!",event.conference_url,+ event.organizer_email,+ event.organizer_name,+ event.description,event.is_read_only AS "is_read_only!",event.created_at AS "created_at!",event.updated_at AS "updated_at!",@@ -154,6 +163,9 @@ pub async fn get_calendar_events_for_search(time_zone: row.time_zone,is_recurring: row.is_recurring,conference_url: row.conference_url,+ organizer_email: row.organizer_email,+ organizer_name: row.organizer_name,+ description: row.description,is_read_only: row.is_read_only,created_at: row.created_at,updated_at: row.updated_at,diff --git a/crates/models_search/src/calendar_event.rs b/crates/models_search/src/calendar_event.rsindex d42bfca3c6..c9c79ba538 100644--- a/crates/models_search/src/calendar_event.rs+++ b/crates/models_search/src/calendar_event.rs@@ -73,6 +73,19 @@ pub struct CalendarEventSearchOccurrence {pub time: CalendarEventSearchTime,}+/// The event's organizer — its creator, in Google's model. Either field can be+/// absent when the source does not name it.+#[derive(Debug, Clone, Serialize, Deserialize, ToSchema, JsonSchema)]+#[serde(rename_all = "camelCase")]+pub struct CalendarEventOrganizer {+ /// Display name, when the source provided one.+ #[serde(skip_serializing_if = "Option::is_none")]+ pub name: Option<String>,+ /// Organizer email address, when known.+ #[serde(skip_serializing_if = "Option::is_none")]+ pub email: Option<String>,+}+/// A single response item, part of the CalendarEventSearchResponse object#[derive(Debug, Serialize, Deserialize, ToSchema, JsonSchema)]pub struct CalendarEventSearchResponseItem {@@ -113,6 +126,13 @@ pub struct CalendarEventMetadata {pub conference_url: Option<String>,/// Whether the canonical source prohibits mutation.pub is_read_only: bool,+ /// The event's organizer (creator), when the source names one.+ #[serde(skip_serializing_if = "Option::is_none")]+ pub organizer: Option<CalendarEventOrganizer>,+ /// Free-text description, when the event carries one. May contain HTML from+ /// the source; clients render a plain-text preview.+ #[serde(skip_serializing_if = "Option::is_none")]+ pub description: Option<String>,}/// CalendarEventSearchResponseItem with metadata fetched from macrodb.diff --git a/crates/search_service/src/api/search/calendar_event.rs b/crates/search_service/src/api/search/calendar_event.rsindex fc340d4fa3..bfa084a6ad 100644--- a/crates/search_service/src/api/search/calendar_event.rs+++ b/crates/search_service/src/api/search/calendar_event.rs@@ -6,9 +6,9 @@ use macro_db_client::calendar_event::get_events_for_search::{use macro_user_id::user_id::MacroUserIdStr;use models_properties::{EntityReference, EntityType};use models_search::calendar_event::{- CalendarEventMetadata, CalendarEventSearchOccurrence, CalendarEventSearchResponseItem,- CalendarEventSearchResponseItemWithMetadata, CalendarEventSearchResult,- CalendarEventSearchTime,+ CalendarEventMetadata, CalendarEventOrganizer, CalendarEventSearchOccurrence,+ CalendarEventSearchResponseItem, CalendarEventSearchResponseItemWithMetadata,+ CalendarEventSearchResult, CalendarEventSearchTime,};use models_soup::SoupProperty;use sqlx::types::Uuid;@@ -118,6 +118,17 @@ fn to_occurrence(info: &CalendarEventSearchInfo) -> Option<CalendarEventSearchOc})}+/// Build the organizer payload when the source named a name or an email.+fn to_organizer(info: &CalendarEventSearchInfo) -> Option<CalendarEventOrganizer> {+ if info.organizer_name.is_none() && info.organizer_email.is_none() {+ return None;+ }+ Some(CalendarEventOrganizer {+ name: info.organizer_name.clone(),+ email: info.organizer_email.clone(),+ })+}+pub fn construct_search_result(search_results: Vec<opensearch_client::search::model::SearchHit>,events: HashMap<Uuid, CalendarEventSearchInfo>,@@ -163,6 +174,8 @@ pub fn construct_search_result(occurrence: to_occurrence(info),conference_url: info.conference_url.clone(),is_read_only: info.is_read_only,+ organizer: to_organizer(info),+ description: info.description.clone(),}),properties: properties_map.remove(&entity_id.to_string())diff --git a/crates/search_service/src/api/search/calendar_event/test.rs b/crates/search_service/src/api/search/calendar_event/test.rsindex dd94cbd062..d1e31348e6 100644--- a/crates/search_service/src/api/search/calendar_event/test.rs+++ b/crates/search_service/src/api/search/calendar_event/test.rs@@ -26,6 +26,9 @@ fn timed_series(id: Uuid) -> CalendarEventSearchInfo {time_zone: Some("America/New_York".to_string()),is_recurring: true,conference_url: None,+ organizer_email: Some("[email protected]".to_string()),+ organizer_name: Some("Jacob Beckerman".to_string()),+ description: None,is_read_only: false,created_at: Utc.with_ymd_and_hms(2024, 1, 1, 0, 0, 0).unwrap(),updated_at: Utc.with_ymd_and_hms(2024, 1, 2, 0, 0, 0).unwrap(),@@ -162,3 +165,40 @@ fn multiple_hits_for_one_event_collapse_into_one_row() {"both hits are kept on that row");}++#[test]+fn organizer_rides_on_the_row_when_named() {+ let id = Uuid::new_v4();+ let results = construct_search_result(+ vec![hit(id)],+ HashMap::from([(id, timed_series(id))]),+ HashMap::new(),+ );+ let organizer = results[0]+ .metadata+ .as_ref()+ .expect("metadata")+ .organizer+ .as_ref()+ .expect("organizer");+ assert_eq!(organizer.name.as_deref(), Some("Jacob Beckerman"));+ assert_eq!(organizer.email.as_deref(), Some("[email protected]"));+}++#[test]+fn organizer_absent_when_source_names_neither() {+ let id = Uuid::new_v4();+ let mut info = timed_series(id);+ info.organizer_email = None;+ info.organizer_name = None;+ let results =+ construct_search_result(vec![hit(id)], HashMap::from([(id, info)]), HashMap::new());+ assert!(+ results[0]+ .metadata+ .as_ref()+ .expect("metadata")+ .organizer+ .is_none()+ );+}diff --git a/packages/sdk/generated/search/index.ts b/packages/sdk/generated/search/index.tsindex f27a2fc1da..b443b0ef49 100644--- a/packages/sdk/generated/search/index.ts+++ b/packages/sdk/generated/search/index.ts@@ -1,4 +1,4 @@// This file is auto-generated by @hey-api/openapi-tsexport { type Options, Sdk } from './sdk.gen';-export type { CalendarEventFilters, CalendarEventMetadata, CalendarEventSearchOccurrence, CalendarEventSearchResponseItem, CalendarEventSearchResponseItemWithMetadata, CalendarEventSearchResult, CalendarEventSearchTime, CallFilters, CallRecordMetadata, CallRecordSearchResponseItem, CallRecordSearchResponseItemWithMetadata, CallRecordSearchResult, CallStatus, ChannelFilters, ChannelMessageSearchResponseItem, ChannelMetadata, ChannelNameSearchResponseItem, ChannelSearchRequest, ChannelSearchResponse, ChannelSearchResponseItem, ChannelSearchResponseItemWithMetadata, ChannelSearchResult, ChannelSortTimestamp, ChannelThreadFilters, ChatFilters, ChatMessageSearchResult, ChatMetadata, ChatSearchRequest, ChatSearchResponse, ChatSearchResponseItem, ChatSearchResponseItemWithMetadata, ClientOptions, CrmCompanyFilters, CrmCompanySearchDomain, CrmCompanySearchResponseItem, DataType, DocumentFilters, DocumentMetadata, DocumentSearchRequest, DocumentSearchResponse, DocumentSearchResponseItem, DocumentSearchResponseItemWithMetadata, DocumentSearchResult, DocumentSubType, EmailFilters, EmailSearchParticipant, EmailSearchRequest, EmailSearchResponse, EmailSearchResponseItem, EmailSearchResponseItemWithMetadata, EmailSearchResult, EmptyResponse, EntityFilters, EntityReference, EntityType, ErrorResponse, FileType, ForeignEntityFilters, MatchType, NotificationFilters, ProjectFilters, ProjectMetadata, ProjectSearchMetadata, ProjectSearchRequest, ProjectSearchResponseItem, ProjectSearchResponseItemWithMetadata, ProjectSearchResult, PropertyDefinition, PropertyFilter, PropertyOwner, PropertyValue, ReminderFilters, SearchHighlight, SearchOn, SearchResponse, SharedEmailFilter, SimpleCalendarEventSearchResponseBaseItemHumanReadableTimestamp, SimpleCallRecordSearchResponseBaseItemHumanReadableTimestamp, SimpleChannelSearchReponseBaseItem, SimpleChannelSearchReponseBaseItemHumanReadableTimestamp, SimpleChannelSearchResponse, SimpleChatSearchResponse, SimpleChatSearchResponseBaseItem, SimpleChatSearchResponseBaseItemHumanReadableTimestamp, SimpleDocumentSearchResponse, SimpleDocumentSearchResponseBaseItem, SimpleDocumentSearchResponseBaseItemHumanReadableTimestamp, SimpleEmailSearchResponse, SimpleEmailSearchResponseBaseItem, SimpleEmailSearchResponseBaseItemHumanReadableTimestamp, SimpleProjectSearchResponse, SimpleProjectSearchResponseBaseItem, SimpleProjectSearchResponseBaseItemHumanReadableTimestamp, SimpleUnifiedSearchBaseResponse, SimpleUnifiedSearchData, SimpleUnifiedSearchError, SimpleUnifiedSearchErrors, SimpleUnifiedSearchResponse, SimpleUnifiedSearchResponseBaseItem, SimpleUnifiedSearchResponseBaseItemHumanReadableTimestamp, SimpleUnifiedSearchResponses, SoupProperty, TagFilterMode, TaskFilters, UnifiedSearchData, UnifiedSearchError, UnifiedSearchErrors, UnifiedSearchRequest, UnifiedSearchResponse, UnifiedSearchResponse2, UnifiedSearchResponseItem, UnifiedSearchResponses } from './types.gen';+export type { CalendarEventFilters, CalendarEventMetadata, CalendarEventOrganizer, CalendarEventSearchOccurrence, CalendarEventSearchResponseItem, CalendarEventSearchResponseItemWithMetadata, CalendarEventSearchResult, CalendarEventSearchTime, CallFilters, CallRecordMetadata, CallRecordSearchResponseItem, CallRecordSearchResponseItemWithMetadata, CallRecordSearchResult, CallStatus, ChannelFilters, ChannelMessageSearchResponseItem, ChannelMetadata, ChannelNameSearchResponseItem, ChannelSearchRequest, ChannelSearchResponse, ChannelSearchResponseItem, ChannelSearchResponseItemWithMetadata, ChannelSearchResult, ChannelSortTimestamp, ChannelThreadFilters, ChatFilters, ChatMessageSearchResult, ChatMetadata, ChatSearchRequest, ChatSearchResponse, ChatSearchResponseItem, ChatSearchResponseItemWithMetadata, ClientOptions, CrmCompanyFilters, CrmCompanySearchDomain, CrmCompanySearchResponseItem, DataType, DocumentFilters, DocumentMetadata, DocumentSearchRequest, DocumentSearchResponse, DocumentSearchResponseItem, DocumentSearchResponseItemWithMetadata, DocumentSearchResult, DocumentSubType, EmailFilters, EmailSearchParticipant, EmailSearchRequest, EmailSearchResponse, EmailSearchResponseItem, EmailSearchResponseItemWithMetadata, EmailSearchResult, EmptyResponse, EntityFilters, EntityReference, EntityType, ErrorResponse, FileType, ForeignEntityFilters, MatchType, NotificationFilters, ProjectFilters, ProjectMetadata, ProjectSearchMetadata, ProjectSearchRequest, ProjectSearchResponseItem, ProjectSearchResponseItemWithMetadata, ProjectSearchResult, PropertyDefinition, PropertyFilter, PropertyOwner, PropertyValue, ReminderFilters, SearchHighlight, SearchOn, SearchResponse, SharedEmailFilter, SimpleCalendarEventSearchResponseBaseItemHumanReadableTimestamp, SimpleCallRecordSearchResponseBaseItemHumanReadableTimestamp, SimpleChannelSearchReponseBaseItem, SimpleChannelSearchReponseBaseItemHumanReadableTimestamp, SimpleChannelSearchResponse, SimpleChatSearchResponse, SimpleChatSearchResponseBaseItem, SimpleChatSearchResponseBaseItemHumanReadableTimestamp, SimpleDocumentSearchResponse, SimpleDocumentSearchResponseBaseItem, SimpleDocumentSearchResponseBaseItemHumanReadableTimestamp, SimpleEmailSearchResponse, SimpleEmailSearchResponseBaseItem, SimpleEmailSearchResponseBaseItemHumanReadableTimestamp, SimpleProjectSearchResponse, SimpleProjectSearchResponseBaseItem, SimpleProjectSearchResponseBaseItemHumanReadableTimestamp, SimpleUnifiedSearchBaseResponse, SimpleUnifiedSearchData, SimpleUnifiedSearchError, SimpleUnifiedSearchErrors, SimpleUnifiedSearchResponse, SimpleUnifiedSearchResponseBaseItem, SimpleUnifiedSearchResponseBaseItemHumanReadableTimestamp, SimpleUnifiedSearchResponses, SoupProperty, TagFilterMode, TaskFilters, UnifiedSearchData, UnifiedSearchError, UnifiedSearchErrors, UnifiedSearchRequest, UnifiedSearchResponse, UnifiedSearchResponse2, UnifiedSearchResponseItem, UnifiedSearchResponses } from './types.gen';diff --git a/packages/sdk/generated/search/types.gen.ts b/packages/sdk/generated/search/types.gen.tsindex 6e4cb8aae4..4cee415341 100644--- a/packages/sdk/generated/search/types.gen.ts+++ b/packages/sdk/generated/search/types.gen.ts@@ -47,6 +47,11 @@ export type CalendarEventMetadata = {*/conferenceUrl?: string | null;createdAt: string;+ /**+ * Free-text description, when the event carries one. May contain HTML from+ * the source; clients render a plain-text preview.+ */+ description?: string | null;/*** Whether the canonical source prohibits mutation.*/@@ -57,6 +62,7 @@ export type CalendarEventMetadata = {*/isRecurring: boolean;occurrence?: null | CalendarEventSearchOccurrence;+ organizer?: null | CalendarEventOrganizer;/*** Canonical status (`confirmed`, `tentative`, `cancelled`).*/@@ -68,6 +74,21 @@ export type CalendarEventMetadata = {updatedAt: string;};+/**+ * The event's organizer — its creator, in Google's model. Either field can be+ * absent when the source does not name it.+ */+export type CalendarEventOrganizer = {+ /**+ * Organizer email address, when known.+ */+ email?: string | null;+ /**+ * Display name, when the source provided one.+ */+ name?: string | null;+};+/*** The instance a search row points at.*diff --git a/packages/sdk/specs/search.json b/packages/sdk/specs/search.jsonindex 225f0bfcc0..bdb4a5f93f 100644--- a/packages/sdk/specs/search.json+++ b/packages/sdk/specs/search.json@@ -237,6 +237,10 @@"type": "string","format": "date-time"},+ "description": {+ "type": ["string", "null"],+ "description": "Free-text description, when the event carries one. May contain HTML from\nthe source; clients render a plain-text preview."+ },"isReadOnly": {"type": "boolean","description": "Whether the canonical source prohibits mutation."@@ -256,6 +260,17 @@}]},+ "organizer": {+ "oneOf": [+ {+ "type": "null"+ },+ {+ "$ref": "#/components/schemas/CalendarEventOrganizer",+ "description": "The event's organizer (creator), when the source names one."+ }+ ]+ },"status": {"type": "string","description": "Canonical status (`confirmed`, `tentative`, `cancelled`)."@@ -270,6 +285,20 @@}}},+ "CalendarEventOrganizer": {+ "type": "object",+ "description": "The event's organizer — its creator, in Google's model. Either field can be\nabsent when the source does not name it.",+ "properties": {+ "email": {+ "type": ["string", "null"],+ "description": "Organizer email address, when known."+ },+ "name": {+ "type": ["string", "null"],+ "description": "Display name, when the source provided one."+ }+ }+ },"CalendarEventSearchOccurrence": {"type": "object","description": "The instance a search row points at.\n\nA recurring series is indexed once, as its master. Which instance the row\nshould show is decided per request rather than baked into the index: the\nnext occurrence at or after now, else the most recent past one. This is\nthe same resolution a calendar mention performs, so a search row and a\nmention of the same event agree on where they land.",