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): mention events shared with your channels from the @ menu (#8742)
gbirman737ee3026fc3
diff --git a/.sqlx/query-0654d206e896e42d6e43ce0c2c0654958a3937c0cc6d71f06a34fcc5b404d15a.json b/.sqlx/query-0654d206e896e42d6e43ce0c2c0654958a3937c0cc6d71f06a34fcc5b404d15a.jsonnew file mode 100644index 0000000000..2b64ab9e8f--- /dev/null+++ b/.sqlx/query-0654d206e896e42d6e43ce0c2c0654958a3937c0cc6d71f06a34fcc5b404d15a.json@@ -0,0 +1,22 @@+{+ "db_name": "PostgreSQL",+ "query": "\n SELECT DISTINCT event.id AS \"id!\"\n FROM comms_channel_participants participant\n JOIN entity_access grant_row\n ON grant_row.source_id = participant.channel_id::text\n AND grant_row.source_type = 'channel'\n AND grant_row.entity_type = 'calendar_event'\n JOIN calendar_events event ON event.id = grant_row.entity_id\n WHERE participant.user_id = $1\n AND participant.left_at IS NULL\n AND event.status <> 'cancelled'\n AND event.visibility IN ('default', 'public')\n AND NOT EXISTS (\n SELECT 1\n FROM calendar_events held\n WHERE held.ical_uid = event.ical_uid\n AND held.status <> 'cancelled'\n AND (\n held.owner_id = $1\n OR EXISTS (\n SELECT 1\n FROM macro_user_links link\n WHERE link.link_id = held.source_link_id\n AND link.primary_macro_id = $1\n )\n )\n )\n ",+ "describe": {+ "columns": [+ {+ "ordinal": 0,+ "name": "id!",+ "type_info": "Uuid"+ }+ ],+ "parameters": {+ "Left": [+ "Text"+ ]+ },+ "nullable": [+ false+ ]+ },+ "hash": "0654d206e896e42d6e43ce0c2c0654958a3937c0cc6d71f06a34fcc5b404d15a"+}diff --git a/.sqlx/query-71695e628d3ef339a4288cd8c52ef04f2459b9d28d5d869c1c3f9bc0776dce13.json b/.sqlx/query-e37f4ad26cedd8187256b56fe295ccb90bee8396e070a7c535b8a6350c539a3d.jsonsimilarity index 50%rename from .sqlx/query-71695e628d3ef339a4288cd8c52ef04f2459b9d28d5d869c1c3f9bc0776dce13.jsonrename to .sqlx/query-e37f4ad26cedd8187256b56fe295ccb90bee8396e070a7c535b8a6350c539a3d.jsonindex 4bd8060734..5002b6702a 100644--- a/.sqlx/query-71695e628d3ef339a4288cd8c52ef04f2459b9d28d5d869c1c3f9bc0776dce13.json+++ b/.sqlx/query-e37f4ad26cedd8187256b56fe295ccb90bee8396e070a7c535b8a6350c539a3d.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.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 ",+ "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 CASE WHEN viewer.on_calendar THEN event.conference_url END AS 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 CROSS JOIN LATERAL (\n SELECT (\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 ) AS on_calendar\n ) viewer\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 viewer.on_calendar\n OR (\n event.status <> 'cancelled'\n AND event.visibility IN ('default', 'public')\n AND EXISTS (\n SELECT 1\n FROM entity_access grant_row\n JOIN comms_channel_participants participant\n ON participant.channel_id::text = grant_row.source_id\n AND participant.user_id = $1\n AND participant.left_at IS NULL\n WHERE grant_row.entity_id = event.id\n AND grant_row.entity_type = 'calendar_event'\n AND grant_row.source_type = 'channel'\n )\n )\n )\n ","describe": {"columns": [{@@ -132,19 +132,19 @@true,true,null,- true,+ null,true,true,true,false,false,false,- false,+ true,true,true,true,true]},- "hash": "71695e628d3ef339a4288cd8c52ef04f2459b9d28d5d869c1c3f9bc0776dce13"+ "hash": "e37f4ad26cedd8187256b56fe295ccb90bee8396e070a7c535b8a6350c539a3d"}diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/hooks/useCalendarEventMention.test.ts b/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/hooks/useCalendarEventMention.test.tsindex 0414699807..958891997b 100644--- a/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/hooks/useCalendarEventMention.test.ts+++ b/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/hooks/useCalendarEventMention.test.ts@@ -58,13 +58,24 @@ it('offers each event once, pinned to its occurrence only when it repeats', () =expect(items[0].data.when).toBeTruthy();});-function mentionTitles(search: {+type SearchState = {isPending: boolean;status: string;data: CalendarEventEntity[] | undefined;-}) {- vi.mocked(useSearchSoupQuery).mockReturnValue(- search as unknown as ReturnType<typeof useSearchSoupQuery>+};++const NO_SHARES: SearchState = {+ isPending: false,+ status: 'success',+ data: [],+};++function mentionTitles(own: SearchState, shared: SearchState = NO_SHARES) {+ vi.mocked(useSearchSoupQuery).mockImplementation(+ (args) =>+ (args().body.calendar_event_scope === 'shared_with_you'+ ? shared+ : own) as unknown as ReturnType<typeof useSearchSoupQuery>);return createRoot((dispose) => {const { events } = useCalendarEventMention({@@ -85,3 +96,35 @@ it('keeps the found events when a later search fails, and waits for the first onmentionTitles({ isPending: true, status: 'pending', data: undefined })).toEqual([]);});++it('lists events shared with your channels after your own, in their order', () => {+ const own: SearchState = {+ isPending: false,+ status: 'success',+ data: [+ event('b', { name: 'Standup B' }),+ event('a', { name: 'Standup A' }),+ ],+ };+ const shared: SearchState = {+ isPending: false,+ status: 'success',+ data: [event('shared', { name: 'Standup shared' })],+ };++ expect(mentionTitles(own, shared)).toEqual([+ 'Standup B',+ 'Standup A',+ 'Standup shared',+ ]);+ // A shared answer that lands first waits for your own events.+ expect(+ mentionTitles(+ { isPending: true, status: 'pending', data: undefined },+ shared+ )+ ).toEqual([]);+ expect(+ mentionTitles(own, { isPending: true, status: 'pending', data: undefined })+ ).toEqual(['Standup B', 'Standup A']);+});diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/hooks/useCalendarEventMention.ts b/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/hooks/useCalendarEventMention.tsindex c129f978a8..b541e225e3 100644--- a/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/hooks/useCalendarEventMention.ts+++ b/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/hooks/useCalendarEventMention.ts@@ -6,6 +6,7 @@ import {type SearchSoupQueryArgs,useSearchSoupQuery,} from '@queries/soup/search';+import type { CalendarEventSearchScope } from '@service-search/generated/models';import { createLazyMemo } from '@solid-primitives/memo';import type { Accessor } from 'solid-js';import type { CalendarEventMentionItem } from '../../../../utils/mentionsUtils';@@ -70,9 +71,23 @@ export function calendarEventMentionItems(return items;}+function calendarEventResults(+ results: readonly WithSearch<EntityData>[]+): CalendarEventEntity[] {+ return results.filter(+ (+ entity+ ): entity is WithSearch<Extract<EntityData, { type: 'calendar_event' }>> =>+ entity.type === 'calendar_event'+ );+}+/*** Calendar events for the mention menu, through the same unified search the- * calendar's own search uses, and only where that search is offered.+ * calendar's own search uses, and only where that search is offered. Events+ * shared with the viewer's channels follow the viewer's own, as documents+ * shared that way appear beside their own; mentioning one inserts the shared+ * event, which opens for whoever can already see it.*/export function useCalendarEventMention(options: UseCalendarEventMentionOptions@@ -82,30 +97,33 @@ export function useCalendarEventMention(const enabled = () =>options.enabled() && calendarSearch() && term().length >= MIN_QUERY_LENGTH;- const args = createLazyMemo(- (): SearchSoupQueryArgs => ({- params: { cursor: null, page_size: 10 },- body: {- match_type: 'partial',- search_on: 'name',- query: term(),- filters: CALENDAR_ONLY_SEARCH_FILTERS,- },- })- );- const search = useSearchSoupQuery(args, () => ({ enabled: enabled() }));+ const searchArgs = (scope?: CalendarEventSearchScope) =>+ createLazyMemo(+ (): SearchSoupQueryArgs => ({+ params: { cursor: null, page_size: 10 },+ body: {+ match_type: 'partial',+ search_on: 'name',+ query: term(),+ filters: CALENDAR_ONLY_SEARCH_FILTERS,+ calendar_event_scope: scope,+ },+ })+ );+ const own = useSearchSoupQuery(searchArgs(), () => ({ enabled: enabled() }));+ const shared = useSearchSoupQuery(searchArgs('shared_with_you'), () => ({+ enabled: enabled(),+ }));const events = createLazyMemo((): CalendarEventMentionItem[] => {- if (!enabled() || !queryReadyGate(search)) return [];- return calendarEventMentionItems(- search.data.filter(- (- entity- ): entity is WithSearch<- Extract<EntityData, { type: 'calendar_event' }>- > => entity.type === 'calendar_event'- )- );+ if (!enabled() || !queryReadyGate(own)) return [];+ // Shared events only ever follow the viewer's own, so a late answer+ // appends below what is already listed instead of reordering it.+ const sharedEvents = queryReadyGate(shared) ? shared.data : [];+ return calendarEventMentionItems([+ ...calendarEventResults(own.data),+ ...calendarEventResults(sharedEvents),+ ]);});return { events };diff --git a/apps/web/src/lib/service-clients/service-search/generated/models/calendarEventSearchScope.ts b/apps/web/src/lib/service-clients/service-search/generated/models/calendarEventSearchScope.tsnew file mode 100644index 0000000000..c6691a1ffb--- /dev/null+++ b/apps/web/src/lib/service-clients/service-search/generated/models/calendarEventSearchScope.ts@@ -0,0 +1,24 @@+/**+ * Generated by orval v7.21.0 🍺+ * Do not edit manually.+ * search_service+ * OpenAPI spec version: 0.1.0+ */++/**+ * Which calendar events a unified search covers.++Sharing an event with a channel lets its members see the sharer's copy,+which is on none of their own calendars, so the default scope never finds+it. Shared events are a separate scope rather than part of the default, so+a caller can list them after the caller's own events without reordering+those.+ */+export type CalendarEventSearchScope =+ (typeof CalendarEventSearchScope)[keyof typeof CalendarEventSearchScope];++// eslint-disable-next-line @typescript-eslint/no-redeclare+export const CalendarEventSearchScope = {+ own: 'own',+ shared_with_you: 'shared_with_you',+} as const;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 b95e4f69ab..44f00ea0f8 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@@ -30,6 +30,7 @@ export * from './calendarEventSearchResponseItemWithMetadataAllOfMetadata';export * from './calendarEventSearchResponseItemWithMetadataAllOfProperties';export * from './calendarEventSearchResult';export * from './calendarEventSearchResultScore';+export * from './calendarEventSearchScope';export * from './calendarEventSearchTime';export * from './calendarEventSearchTimeOneOf';export * from './calendarEventSearchTimeOneOfFour';diff --git a/apps/web/src/lib/service-clients/service-search/generated/models/unifiedSearchRequest.ts b/apps/web/src/lib/service-clients/service-search/generated/models/unifiedSearchRequest.tsindex 599582546f..d41100e97d 100644--- a/apps/web/src/lib/service-clients/service-search/generated/models/unifiedSearchRequest.ts+++ b/apps/web/src/lib/service-clients/service-search/generated/models/unifiedSearchRequest.ts@@ -4,13 +4,18 @@* search_service* OpenAPI spec version: 0.1.0*/-+import type { CalendarEventSearchScope } from './calendarEventSearchScope';import type { EntityFilters } from './entityFilters';import type { MatchType } from './matchType';import type { SearchOn } from './searchOn';import type { UnifiedSearchRequestCollapse } from './unifiedSearchRequestCollapse';export interface UnifiedSearchRequest {+ /** Which calendar events to search. Defaults to `own`: events on the+caller's own and delegated calendars. `shared_with_you` searches only+events shared with a channel the caller belongs to that are on none of+their calendars. */+ calendar_event_scope?: CalendarEventSearchScope;collapse?: UnifiedSearchRequestCollapse;/** Entity filters in the same shape as soup. Entity types with a NIL UUID in their primary ID field are excluded from search. */filters?: EntityFilters;diff --git a/apps/web/src/lib/service-clients/service-search/openapi.json b/apps/web/src/lib/service-clients/service-search/openapi.jsonindex 742ad60759..cd195fadcd 100644--- a/apps/web/src/lib/service-clients/service-search/openapi.json+++ b/apps/web/src/lib/service-clients/service-search/openapi.json@@ -504,6 +504,11 @@}}},+ "CalendarEventSearchScope": {+ "type": "string",+ "description": "Which calendar events a unified search covers.\n\nSharing an event with a channel lets its members see the sharer's copy,\nwhich is on none of their own calendars, so the default scope never finds\nit. Shared events are a separate scope rather than part of the default, so\na caller can list them after the caller's own events without reordering\nthose.",+ "enum": ["own", "shared_with_you"]+ },"CalendarEventSearchTime": {"oneOf": [{@@ -4674,6 +4679,10 @@"type": "object","required": ["query", "match_type"],"properties": {+ "calendar_event_scope": {+ "$ref": "#/components/schemas/CalendarEventSearchScope",+ "description": "Which calendar events to search. Defaults to `own`: events on the\ncaller's own and delegated calendars. `shared_with_you` searches only\nevents shared with a channel the caller belongs to that are on none of\ntheir calendars."+ },"collapse": {"type": ["boolean", "null"]},diff --git a/crates/ai_tools/src/search/search_service/content.rs b/crates/ai_tools/src/search/search_service/content.rsindex 2cd8f74226..a4dfb2ddf6 100644--- a/crates/ai_tools/src/search/search_service/content.rs+++ b/crates/ai_tools/src/search/search_service/content.rs@@ -161,6 +161,7 @@ impl AsyncTool<SearchToolContext> for ContentSearch {filters: content_filters(&self.entity_types, &self.agent_session_ids, base_filters),search_on: models_search::SearchOn::Content,include_crm: false,+ calendar_event_scope: Default::default(),collapse: None,};diff --git a/crates/ai_tools/src/search/search_service/name.rs b/crates/ai_tools/src/search/search_service/name.rsindex 15760d9f1b..7eac82a066 100644--- a/crates/ai_tools/src/search/search_service/name.rs+++ b/crates/ai_tools/src/search/search_service/name.rs@@ -161,6 +161,7 @@ impl AsyncTool<SearchToolContext> for NameSearch {filters: search_filters(&non_channel_types, base_filters),search_on: models_search::SearchOn::Name,include_crm: false,+ calendar_event_scope: Default::default(),collapse: None,});let channel_request = include_channels.then(|| ChannelNameSearchRequest {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 e174ed6523..4c4cbf9435 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@@ -31,7 +31,8 @@ pub struct CalendarEventSearchInfo {pub time_zone: Option<String>,/// Whether the series carries any recurrence rule.pub is_recurring: bool,- /// Direct conference join URL.+ /// Direct conference join URL. Withheld from a channel share, whose+ /// copies and exports never carry the join link either.pub conference_url: Option<String>,/// Organizer email, when the source names one.pub organizer_email: Option<String>,@@ -55,10 +56,12 @@ pub struct CalendarEventSearchInfo {/// Fetch search metadata for `event_ids` the requester may see, resolving one/// contextual occurrence per event.///-/// Visibility mirrors the soup predicate: the requester owns the projection,-/// or the event's source link is delegated to them through `macro_user_links`.-/// An id the requester cannot see is simply absent from the result, which-/// drops the hit during enrichment.+/// Visibility mirrors the event's access check: the requester owns the+/// projection, the event's source link is delegated to them through+/// `macro_user_links`, or it was shared with a channel they currently belong+/// to and is still live and neither private nor confidential. An id the+/// requester cannot see is simply absent from the result, which drops the hit+/// during enrichment.////// A recurring series is indexed once, as its master, so the instance a row/// should display is decided here rather than baked into the index. The@@ -68,7 +71,7 @@ pub struct CalendarEventSearchInfo {/// Occurrences are materialized only inside a rolling window, so a series can/// legitimately resolve to no occurrence at all; callers fall back to the/// master span.-#[tracing::instrument(skip(db, event_ids), fields(event_count = event_ids.len()), err)]+#[tracing::instrument(skip(db, requester_id, event_ids), fields(event_count = event_ids.len()), err)]pub async fn get_calendar_events_for_search(db: &Pool<Postgres>,requester_id: &str,@@ -92,7 +95,7 @@ pub async fn get_calendar_events_for_search(event.end_date,event.time_zone,(cardinality(event.recurrence_lines) > 0) AS "is_recurring!",- event.conference_url,+ CASE WHEN viewer.on_calendar THEN event.conference_url END AS conference_url,event.organizer_email,event.organizer_name,event.description,@@ -105,6 +108,17 @@ pub async fn get_calendar_events_for_search(occurrence.start_date AS "occurrence_start_date?",occurrence.end_date AS "occurrence_end_date?"FROM calendar_events event+ CROSS JOIN LATERAL (+ SELECT (+ event.owner_id = $1+ OR EXISTS (+ SELECT 1+ FROM macro_user_links link+ WHERE link.link_id = event.source_link_id+ AND link.primary_macro_id = $1+ )+ ) AS on_calendar+ ) viewerLEFT JOIN LATERAL (SELECTinstance.occurrence_key,@@ -130,12 +144,21 @@ pub async fn get_calendar_events_for_search() occurrence ON trueWHERE event.id = ANY($2)AND (- event.owner_id = $1- OR EXISTS (- SELECT 1- FROM macro_user_links link- WHERE link.link_id = event.source_link_id- AND link.primary_macro_id = $1+ viewer.on_calendar+ OR (+ event.status <> 'cancelled'+ AND event.visibility IN ('default', 'public')+ AND EXISTS (+ SELECT 1+ FROM entity_access grant_row+ JOIN comms_channel_participants participant+ ON participant.channel_id::text = grant_row.source_id+ AND participant.user_id = $1+ AND participant.left_at IS NULL+ WHERE grant_row.entity_id = event.id+ AND grant_row.entity_type = 'calendar_event'+ AND grant_row.source_type = 'channel'+ )))"#,@@ -179,3 +202,56 @@ pub async fn get_calendar_events_for_search(}).collect())}++/// Ids of the events shared with a channel the requester currently belongs to+/// that they hold on none of their calendars: what a search scoped to shared+/// events may match.+///+/// A grant counts only under the event's access check (live, neither private+/// nor confidential). A meeting the requester also holds, owned or through a+/// delegated inbox, is left out: a mention of it resolves to their own copy,+/// which their own scope already finds.+#[tracing::instrument(skip(db, requester_id), fields(shared_event_count), err)]+pub async fn get_channel_shared_calendar_event_ids(+ db: &Pool<Postgres>,+ requester_id: &str,+) -> anyhow::Result<Vec<Uuid>> {+ let ids = sqlx::query_scalar!(+ r#"+ SELECT DISTINCT event.id AS "id!"+ FROM comms_channel_participants participant+ JOIN entity_access grant_row+ ON grant_row.source_id = participant.channel_id::text+ AND grant_row.source_type = 'channel'+ AND grant_row.entity_type = 'calendar_event'+ JOIN calendar_events event ON event.id = grant_row.entity_id+ WHERE participant.user_id = $1+ AND participant.left_at IS NULL+ AND event.status <> 'cancelled'+ AND event.visibility IN ('default', 'public')+ AND NOT EXISTS (+ SELECT 1+ FROM calendar_events held+ WHERE held.ical_uid = event.ical_uid+ AND held.status <> 'cancelled'+ AND (+ held.owner_id = $1+ OR EXISTS (+ SELECT 1+ FROM macro_user_links link+ WHERE link.link_id = held.source_link_id+ AND link.primary_macro_id = $1+ )+ )+ )+ "#,+ requester_id,+ )+ .fetch_all(db)+ .await?;+ tracing::Span::current().record("shared_event_count", ids.len());+ Ok(ids)+}++#[cfg(test)]+mod test;diff --git a/crates/macro_db_client/src/calendar_event/get_events_for_search/test.rs b/crates/macro_db_client/src/calendar_event/get_events_for_search/test.rsnew file mode 100644index 0000000000..0762f05d19--- /dev/null+++ b/crates/macro_db_client/src/calendar_event/get_events_for_search/test.rs@@ -0,0 +1,203 @@+use super::*;++const OWNER: &str = "macro|[email protected]";+const MEMBER: &str = "macro|[email protected]";+const ATTENDEE: &str = "macro|[email protected]";+const FORMER: &str = "macro|[email protected]";+const STRANGER: &str = "macro|[email protected]";++async fn insert_event(+ pool: &Pool<Postgres>,+ owner_id: &str,+ ical_uid: &str,+ visibility: &str,+) -> Uuid {+ let link_id = Uuid::now_v7();+ sqlx::query(+ r#"+ INSERT INTO email_links (id, macro_id, fusionauth_user_id, email_address, provider)+ VALUES ($1, $2, $2, $1::text || '@example.com', 'GMAIL')+ "#,+ )+ .bind(link_id)+ .bind(owner_id)+ .execute(pool)+ .await+ .unwrap();+ let event_id = Uuid::now_v7();+ sqlx::query(+ r#"+ INSERT INTO calendar_events (+ id, owner_id, source_link_id, ical_uid, title, visibility,+ canonical_source_kind, conference_url, starts_at, ends_at+ )+ VALUES (+ $1, $2, $3, $4, 'Pilates', $5, 'google', 'https://meet.google.com/abc-defg-hij',+ now(), now() + interval '1 hour'+ )+ "#,+ )+ .bind(event_id)+ .bind(owner_id)+ .bind(link_id)+ .bind(ical_uid)+ .bind(visibility)+ .execute(pool)+ .await+ .unwrap();+ event_id+}++async fn insert_channel(pool: &Pool<Postgres>) -> Uuid {+ let channel_id = Uuid::now_v7();+ sqlx::query(+ "INSERT INTO comms_channels (id, channel_type, owner_id) VALUES ($1, 'private', $2)",+ )+ .bind(channel_id)+ .bind(OWNER)+ .execute(pool)+ .await+ .unwrap();+ for (participant, left) in [+ (OWNER, false),+ (MEMBER, false),+ (ATTENDEE, false),+ (FORMER, true),+ ] {+ sqlx::query(+ r#"+ INSERT INTO comms_channel_participants (channel_id, user_id, role, left_at)+ VALUES ($1, $2, 'member', CASE WHEN $3 THEN now() END)+ "#,+ )+ .bind(channel_id)+ .bind(participant)+ .bind(left)+ .execute(pool)+ .await+ .unwrap();+ }+ channel_id+}++async fn share_with_channel(pool: &Pool<Postgres>, event_id: Uuid, channel_id: Uuid) {+ sqlx::query(+ r#"+ INSERT INTO entity_access (entity_id, entity_type, source_id, source_type, access_level)+ VALUES ($1, 'calendar_event', $2::uuid::text, 'channel', 'view')+ "#,+ )+ .bind(event_id)+ .bind(channel_id)+ .execute(pool)+ .await+ .unwrap();+}++#[sqlx::test]+async fn shared_ids_cover_live_shares_the_member_holds_no_copy_of(pool: Pool<Postgres>) {+ let shared = insert_event(&pool, OWNER, "[email protected]", "default").await;+ let attended = insert_event(&pool, OWNER, "[email protected]", "public").await;+ insert_event(&pool, ATTENDEE, "[email protected]", "default").await;+ let private = insert_event(&pool, OWNER, "[email protected]", "private").await;+ let confidential = insert_event(&pool, OWNER, "[email protected]", "confidential").await;+ insert_event(&pool, OWNER, "[email protected]", "default").await;+ let channel_id = insert_channel(&pool).await;+ for event_id in [shared, attended, private, confidential] {+ share_with_channel(&pool, event_id, channel_id).await;+ }++ let mut member = get_channel_shared_calendar_event_ids(&pool, MEMBER)+ .await+ .unwrap();+ member.sort();+ assert_eq!(member, vec![shared, attended]);++ // A copy of the same meeting on the attendee's own calendar is what their+ // own scope finds, so the share does not list it twice.+ assert_eq!(+ get_channel_shared_calendar_event_ids(&pool, ATTENDEE)+ .await+ .unwrap(),+ vec![shared]+ );+ // The sharer holds every event they shared.+ assert!(+ get_channel_shared_calendar_event_ids(&pool, OWNER)+ .await+ .unwrap()+ .is_empty()+ );+ for outsider in [FORMER, STRANGER] {+ assert!(+ get_channel_shared_calendar_event_ids(&pool, outsider)+ .await+ .unwrap()+ .is_empty(),+ "{outsider}"+ );+ }++ sqlx::query("UPDATE calendar_events SET status = 'cancelled' WHERE id = $1")+ .bind(shared)+ .execute(&pool)+ .await+ .unwrap();+ assert_eq!(+ get_channel_shared_calendar_event_ids(&pool, MEMBER)+ .await+ .unwrap(),+ vec![attended]+ );+}++#[sqlx::test]+async fn search_metadata_reaches_a_channel_share_without_its_join_link(pool: Pool<Postgres>) {+ let shared = insert_event(&pool, OWNER, "[email protected]", "default").await;+ let private = insert_event(&pool, OWNER, "[email protected]", "private").await;+ let unshared = insert_event(&pool, OWNER, "[email protected]", "default").await;+ let channel_id = insert_channel(&pool).await;+ share_with_channel(&pool, shared, channel_id).await;+ share_with_channel(&pool, private, channel_id).await;+ let ids = [shared, private, unshared];+ let now = Utc::now();++ let owner = get_calendar_events_for_search(&pool, OWNER, &ids, now)+ .await+ .unwrap();+ assert_eq!(owner.len(), 3);+ assert_eq!(+ owner[&shared].conference_url.as_deref(),+ Some("https://meet.google.com/abc-defg-hij")+ );++ let member = get_calendar_events_for_search(&pool, MEMBER, &ids, now)+ .await+ .unwrap();+ assert_eq!(member.keys().collect::<Vec<_>>(), vec![&shared]);+ assert_eq!(member[&shared].title, "Pilates");+ assert_eq!(member[&shared].owner_id, OWNER);+ assert_eq!(member[&shared].conference_url, None);++ for outsider in [FORMER, STRANGER] {+ assert!(+ get_calendar_events_for_search(&pool, outsider, &ids, now)+ .await+ .unwrap()+ .is_empty(),+ "{outsider}"+ );+ }++ sqlx::query("UPDATE calendar_events SET status = 'cancelled' WHERE id = $1")+ .bind(shared)+ .execute(&pool)+ .await+ .unwrap();+ assert!(+ get_calendar_events_for_search(&pool, MEMBER, &ids, now)+ .await+ .unwrap()+ .is_empty()+ );+}diff --git a/crates/models_search/src/calendar_event.rs b/crates/models_search/src/calendar_event.rsindex c9c79ba538..91a2da38ec 100644--- a/crates/models_search/src/calendar_event.rs+++ b/crates/models_search/src/calendar_event.rs@@ -5,6 +5,27 @@ use schemars::JsonSchema;use serde::{Deserialize, Serialize};use utoipa::ToSchema;+/// Which calendar events a unified search covers.+///+/// Sharing an event with a channel lets its members see the sharer's copy,+/// which is on none of their own calendars, so the default scope never finds+/// it. Shared events are a separate scope rather than part of the default, so+/// a caller can list them after the caller's own events without reordering+/// those.+#[derive(+ Debug, Default, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, ToSchema, JsonSchema,+)]+#[serde(rename_all = "snake_case")]+pub enum CalendarEventSearchScope {+ /// Events on the caller's own calendars and on inboxes delegated to them.+ #[default]+ Own,+ /// Only events someone shared with a channel the caller belongs to and that+ /// the caller holds on none of their calendars, under the same rule as the+ /// event's own access check: never a private, confidential or cancelled one.+ SharedWithYou,+}+/// Timed or all-day span of a calendar event.////// Deliberately a local mirror of `models_soup::calendar_event::SoupCalendarEventTime`diff --git a/crates/models_search/src/unified.rs b/crates/models_search/src/unified.rsindex 3e2ab23c7c..bcf959bf91 100644--- a/crates/models_search/src/unified.rs+++ b/crates/models_search/src/unified.rs@@ -1,6 +1,7 @@use chrono::{DateTime, Utc};use uuid::Uuid;+use crate::calendar_event::CalendarEventSearchScope;use crate::call_record::CallRecordSearchResponseItemWithMetadata;use crate::channel::{ChannelMessageSearchResponseItem, ChannelNameSearchResponseItem};use crate::chat::ChatSearchResponseItemWithMetadata;@@ -107,6 +108,13 @@ pub struct UnifiedSearchRequest {#[serde(default)]pub include_crm: bool,+ /// Which calendar events to search. Defaults to `own`: events on the+ /// caller's own and delegated calendars. `shared_with_you` searches only+ /// events shared with a channel the caller belongs to that are on none of+ /// their calendars.+ #[serde(default)]+ pub calendar_event_scope: CalendarEventSearchScope,+#[schemars(skip)]pub collapse: Option<bool>,}diff --git a/crates/opensearch_client/src/search/calendar_events.rs b/crates/opensearch_client/src/search/calendar_events.rsindex d02fb99849..77924ad7fc 100644--- a/crates/opensearch_client/src/search/calendar_events.rs+++ b/crates/opensearch_client/src/search/calendar_events.rs@@ -34,7 +34,8 @@ const SOURCE_NAMES_KEY: &str = "source_names";/// `source_names` every copy's, so a shared calendar's bracketed re-import/// of a member's event is found under either. Access mirrors the soup/// predicate: `owner_id == caller` or the event's `source_link_id` is one of-/// the caller's delegated inbox links.+/// the caller's delegated inbox links. Events shared with the caller's+/// channels arrive as an explicit `ids_only` set instead.pub(crate) struct CalendarEventQueryBuilder {inner: SearchQueryBuilder<CalendarEventSearchConfig>,link_ids: Vec<String>,diff --git a/crates/search_service/AGENTS.md b/crates/search_service/AGENTS.mdindex 4229dbe694..0b470277f4 100644--- a/crates/search_service/AGENTS.md+++ b/crates/search_service/AGENTS.md@@ -56,6 +56,12 @@ per-entity-type search plus a unified search across them — mounted intoanalyzes to nothing (`-`, `@`) matches no document and empties the search.`terms::drop_wordless_terms` removes such terms for exact and partialqueries; run new term handling through it.+- Calendar events have two scopes (`calendar_event_scope` on the unified+ request): `own` matches the caller's own and delegated calendars by+ owner and inbox link; `shared_with_you` resolves the events shared with the+ caller's channels in Postgres and searches by id, leaving out meetings the+ caller holds a copy of. Enrichment re-checks every hit against the event's+ access rule and withholds a share's join link.## Relateddiff --git a/crates/search_service/src/api/search/simple/filter.rs b/crates/search_service/src/api/search/simple/filter.rsindex 6a3e98836c..372ebf91eb 100644--- a/crates/search_service/src/api/search/simple/filter.rs+++ b/crates/search_service/src/api/search/simple/filter.rs@@ -2,6 +2,7 @@//! This is used in simple_unified.rsuse comms_db_client::model::SimpleMention;+use models_search::calendar_event::CalendarEventSearchScope;use opensearch_client::search::unified::{UnifiedCalendarEventSearchArgs, UnifiedCallRecordSearchArgs, UnifiedChannelMessageSearchArgs,UnifiedChatSearchArgs, UnifiedDocumentSearchArgs, UnifiedEmailSearchArgs,@@ -200,7 +201,14 @@ impl FilterVariantToSearchArgs for item_filters::CallFilters {}}-impl FilterVariantToSearchArgs for item_filters::CalendarEventFilters {+/// Calendar event filters with the set of events the request searches, which+/// lives on the request rather than in the soup-shaped filters.+pub(super) struct ScopedCalendarEventFilters {+ pub filters: item_filters::CalendarEventFilters,+ pub scope: CalendarEventSearchScope,+}++impl FilterVariantToSearchArgs for ScopedCalendarEventFilters {type Output = UnifiedCalendarEventSearchArgs;async fn filter_to_search_args(@@ -214,15 +222,15 @@ impl FilterVariantToSearchArgs for item_filters::CalendarEventFilters {return Ok(UnifiedCalendarEventSearchArgs::default());}- let response = filter_calendar_events(ctx, user_id, self).await?;+ let response = filter_calendar_events(ctx, user_id, &self.filters, self.scope).await?;Ok(UnifiedCalendarEventSearchArgs {calendar_event_ids: response.calendar_event_ids,link_ids: response.link_ids,ids_only: response.ids_only,- statuses: self.statuses.clone(),- organizer_emails: self.organizers.clone(),- attendee_emails: self.attendees.clone(),+ statuses: self.filters.statuses.clone(),+ organizer_emails: self.filters.organizers.clone(),+ attendee_emails: self.filters.attendees.clone(),..Default::default()})}diff --git a/crates/search_service/src/api/search/simple/simple_calendar_event.rs b/crates/search_service/src/api/search/simple/simple_calendar_event.rsindex 07f1cb7668..ed09230f4d 100644--- a/crates/search_service/src/api/search/simple/simple_calendar_event.rs+++ b/crates/search_service/src/api/search/simple/simple_calendar_event.rs@@ -1,5 +1,6 @@use crate::api::search::simple::SearchError;use item_filters::CalendarEventFilters;+use models_search::calendar_event::CalendarEventSearchScope;use uuid::Uuid;use crate::api::context::SearchHandlerState;@@ -14,26 +15,33 @@ pub(in crate::api::search) struct FilterCalendarEventResponse {/// Resolve what the caller may search over.///-/// Access is resolved here rather than taken from the request: an event is-/// visible when the caller owns its projection or the event's source link is-/// one of their inboxes (own or delegated). `fetch_inboxes_for_macro_id` is-/// the authority for that set, so a caller cannot widen their own scope by-/// passing link ids.+/// Access is resolved here rather than taken from the request. In the own+/// scope an event is visible when the caller owns its projection or the+/// event's source link is one of their inboxes (own or delegated).+/// `fetch_inboxes_for_macro_id` is the authority for that set, so a caller+/// cannot widen their own scope by passing link ids. The shared scope is the+/// explicit set of events shared with the caller's channels, so it always+/// searches by id.///-/// `ids_only` is set only when the caller named specific event ids. Otherwise-/// the query stays scoped by owner/link, because an empty id list under-/// `ids_only` would be rejected rather than matching everything.-#[tracing::instrument(skip(ctx, filters), err)]+/// `ids_only` is otherwise set only when the caller named specific event ids.+/// Without them the query stays scoped by owner/link, because an empty id list+/// under `ids_only` would be rejected rather than matching everything.+#[tracing::instrument(+ name = "search.calendar_event_access",+ skip(ctx, user_id, filters),+ fields(+ named_event_count = filters.calendar_event_ids.len(),+ calendar_event_count,+ link_count+ ),+ err+)]pub(in crate::api::search) async fn filter_calendar_events(ctx: &SearchHandlerState,user_id: &str,filters: &CalendarEventFilters,+ scope: CalendarEventSearchScope,) -> Result<FilterCalendarEventResponse, SearchError> {- let inboxes = email_db_client::links::get::fetch_inboxes_for_macro_id(&ctx.db, user_id)- .await- .map_err(SearchError::InternalError)?;- let link_ids: Vec<String> = inboxes.iter().map(|l| l.id.to_string()).collect();-// Keep only well-formed ids: the index stores `entity_id` as a keyword, so// a malformed value would silently match nothing rather than error.let calendar_event_ids: Vec<String> = filters@@ -43,11 +51,41 @@ pub(in crate::api::search) async fn filter_calendar_events(.cloned().collect();- let ids_only = !filters.calendar_event_ids.is_empty();-- Ok(FilterCalendarEventResponse {- calendar_event_ids,- link_ids,- ids_only,- })+ let response = match scope {+ CalendarEventSearchScope::Own => {+ let inboxes = email_db_client::links::get::fetch_inboxes_for_macro_id(&ctx.db, user_id)+ .await+ .map_err(SearchError::InternalError)?;+ FilterCalendarEventResponse {+ calendar_event_ids,+ link_ids: inboxes.iter().map(|l| l.id.to_string()).collect(),+ ids_only: !filters.calendar_event_ids.is_empty(),+ }+ }+ CalendarEventSearchScope::SharedWithYou => {+ let named: Vec<Uuid> = calendar_event_ids+ .iter()+ .filter_map(|id| Uuid::parse_str(id).ok())+ .collect();+ let shared = macro_db_client::calendar_event::get_events_for_search::get_channel_shared_calendar_event_ids(+ &ctx.db, user_id,+ )+ .await+ .map_err(SearchError::InternalError)?;+ FilterCalendarEventResponse {+ // Named ids narrow within the shared set; they never add to it.+ calendar_event_ids: shared+ .into_iter()+ .filter(|id| filters.calendar_event_ids.is_empty() || named.contains(id))+ .map(|id| id.to_string())+ .collect(),+ link_ids: Vec::new(),+ ids_only: true,+ }+ }+ };+ let span = tracing::Span::current();+ span.record("calendar_event_count", response.calendar_event_ids.len());+ span.record("link_count", response.link_ids.len());+ Ok(response)}diff --git a/crates/search_service/src/api/search/simple/simple_unified.rs b/crates/search_service/src/api/search/simple/simple_unified.rsindex 43a6b70511..82a9ab8594 100644--- a/crates/search_service/src/api/search/simple/simple_unified.rs+++ b/crates/search_service/src/api/search/simple/simple_unified.rs@@ -1,4 +1,4 @@-use crate::api::search::simple::filter::FilterVariantToSearchArgs;+use crate::api::search::simple::filter::{FilterVariantToSearchArgs, ScopedCalendarEventFilters};use crate::api::search::crm_company;use crate::api::search::simple::{simple_channel, simple_chat};@@ -273,6 +273,7 @@ pub(in crate::api::search) async fn perform_unified_search(let crm_company_filters = req.filters.crm_company_filters.clone();let should_include_crm = crm_access.is_some() && !tags_active;+ let calendar_event_scope = req.calendar_event_scope;let search_filters = SearchEntityFilters::from(req.filters);let requested_sessions = search_filters.agent_session_filters@@ -299,7 +300,10 @@ pub(in crate::api::search) async fn perform_unified_search(let doc_filters = search_filters.document_filters;let project_filters = search_filters.project_filters;let call_filters = search_filters.call_filters;- let calendar_event_filters = search_filters.calendar_event_filters;+ let calendar_event_filters = ScopedCalendarEventFilters {+ filters: search_filters.calendar_event_filters,+ scope: calendar_event_scope,+ };let should_include_documents = search_filters.should_include_documents;// A tag filter drops channels (and CRM, below) because they aren'tdiff --git a/crates/skills/src/outbound/search_service_searcher.rs b/crates/skills/src/outbound/search_service_searcher.rsindex 9f1e92ef7a..6430720220 100644--- a/crates/skills/src/outbound/search_service_searcher.rs+++ b/crates/skills/src/outbound/search_service_searcher.rs@@ -57,6 +57,7 @@ impl SkillSearcher for SearchServiceSkillSearcher {filters: entity_filters_from_include(vec![UnifiedSearchIndex::Documents], base_filters),search_on: models_search::SearchOn::Name,include_crm: false,+ calendar_event_scope: Default::default(),collapse: None,};diff --git a/docs/agent-guide/calendar.md b/docs/agent-guide/calendar.mdindex e529277840..39c5bf0094 100644--- a/docs/agent-guide/calendar.md+++ b/docs/agent-guide/calendar.md@@ -666,7 +666,12 @@ three characters of its title in a composer that offers event mentions (message,document composers; spreadsheet and database cells and typed reference fields do not): where calendar search is on(`enable-calendar-search-ui`), the menu lists matches under `Calendar events` (all of them inone list on phones), one row per event with when it starts, and picking one inserts the same-chip a paste does, pinned to the found instance of a repeating event.+chip a paste does, pinned to the found instance of a repeating event. Events someone shared+with a channel you belong to, and that are on none of your calendars, follow your own events+in that list without a marker, as documents shared that way sit beside your own; their chip+names the shared event, so it opens for whoever can already see it. Posting it elsewhere does+not share it on (only someone holding the event on their own calendar can), so people without+access see `No Access`, like any other mention they cannot open.A calendar event mentioned in a channel message opens the calendar focused on the viewer'sown copy of the meeting. When a person holds the event on their own calendar and posts themention, it is shared read-only with the channel's current members: a member without a copy ofdiff --git a/packages/sdk-docs/reference/generated/search/types.gen/README.md b/packages/sdk-docs/reference/generated/search/types.gen/README.mdindex 24cb36d926..c76940695d 100644--- a/packages/sdk-docs/reference/generated/search/types.gen/README.md+++ b/packages/sdk-docs/reference/generated/search/types.gen/README.md@@ -13,6 +13,7 @@- [CalendarEventSearchResponseItem](type-aliases/CalendarEventSearchResponseItem.md)- [CalendarEventSearchResponseItemWithMetadata](type-aliases/CalendarEventSearchResponseItemWithMetadata.md)- [CalendarEventSearchResult](type-aliases/CalendarEventSearchResult.md)+- [CalendarEventSearchScope](type-aliases/CalendarEventSearchScope.md)- [CalendarEventSearchTime](type-aliases/CalendarEventSearchTime.md)- [CallFilters](type-aliases/CallFilters.md)- [CallRecordMetadata](type-aliases/CallRecordMetadata.md)diff --git a/packages/sdk-docs/reference/generated/search/types.gen/type-aliases/CalendarEventSearchScope.md b/packages/sdk-docs/reference/generated/search/types.gen/type-aliases/CalendarEventSearchScope.mdnew file mode 100644index 0000000000..3d2a1ff757--- /dev/null+++ b/packages/sdk-docs/reference/generated/search/types.gen/type-aliases/CalendarEventSearchScope.md@@ -0,0 +1,11 @@+# Type Alias: CalendarEventSearchScope++> **CalendarEventSearchScope** = `"own"` \| `"shared_with_you"`++Which calendar events a unified search covers.++Sharing an event with a channel lets its members see the sharer's copy,+which is on none of their own calendars, so the default scope never finds+it. Shared events are a separate scope rather than part of the default, so+a caller can list them after the caller's own events without reordering+those.diff --git a/packages/sdk-docs/reference/generated/search/types.gen/type-aliases/UnifiedSearchRequest.md b/packages/sdk-docs/reference/generated/search/types.gen/type-aliases/UnifiedSearchRequest.mdindex 72c2785916..7f4f909deb 100644--- a/packages/sdk-docs/reference/generated/search/types.gen/type-aliases/UnifiedSearchRequest.md+++ b/packages/sdk-docs/reference/generated/search/types.gen/type-aliases/UnifiedSearchRequest.md@@ -1,11 +1,12 @@# Type Alias: UnifiedSearchRequest-> **UnifiedSearchRequest** = \{ `collapse?`: `boolean` \| `null`; `filters?`: [`EntityFilters`](EntityFilters.md); `include_crm?`: `boolean`; `match_type`: [`MatchType`](MatchType.md); `query`: `string`; `search_on?`: [`SearchOn`](SearchOn.md); \}+> **UnifiedSearchRequest** = \{ `calendar_event_scope?`: [`CalendarEventSearchScope`](CalendarEventSearchScope.md); `collapse?`: `boolean` \| `null`; `filters?`: [`EntityFilters`](EntityFilters.md); `include_crm?`: `boolean`; `match_type`: [`MatchType`](MatchType.md); `query`: `string`; `search_on?`: [`SearchOn`](SearchOn.md); \}## Properties| Property | Type | Description || ------ | ------ | ------ |+| <a id="property-calendar_event_scope"></a> `calendar_event_scope?` | [`CalendarEventSearchScope`](CalendarEventSearchScope.md) | Which calendar events to search. Defaults to `own`: events on the caller's own and delegated calendars. `shared_with_you` searches only events shared with a channel the caller belongs to that are on none of their calendars. || <a id="property-collapse"></a> `collapse?` | `boolean` \| `null` | - || <a id="property-filters"></a> `filters?` | [`EntityFilters`](EntityFilters.md) | Entity filters in the same shape as soup. Entity types with a NIL UUID in their primary ID field are excluded from search. || <a id="property-include_crm"></a> `include_crm?` | `boolean` | Opt in to searching the caller's team CRM companies (name/domain). Off by default: CRM results are only included when this is true and the caller has a qualifying team membership. CRM has no content index, so it is searched only under Name / NameContent. |diff --git a/packages/sdk/generated/search/index.ts b/packages/sdk/generated/search/index.tsindex 1ec8fde1a9..085b18eea5 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 { AgentSessionAuthor, AgentSessionFilters, AgentSessionSearchResponseItem, AgentSessionSearchResult, 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, Highlight, InitiativeFilters, MatchType, NotificationFilters, NotificationState, ProjectFilters, ProjectMetadata, ProjectSearchMetadata, ProjectSearchRequest, ProjectSearchResponseItem, ProjectSearchResponseItemWithMetadata, ProjectSearchResult, PropertyDefinition, PropertyFilter, PropertyOwner, PropertyValue, SearchGotoAgentSession, SearchGotoCallRecord, SearchGotoChannel, SearchGotoChat, SearchGotoContent, SearchGotoDocument, SearchGotoEmail, SearchHighlight, SearchOn, SearchResponse, SharedEmailFilter, SimpleCalendarEventSearchResponseBaseItemHumanReadableTimestamp, SimpleCallRecordSearchResponseBaseItemHumanReadableTimestamp, SimpleChannelSearchReponseBaseItem, SimpleChannelSearchReponseBaseItemHumanReadableTimestamp, SimpleChannelSearchResponse, SimpleChatSearchResponse, SimpleChatSearchResponseBaseItem, SimpleChatSearchResponseBaseItemHumanReadableTimestamp, SimpleDocumentSearchResponse, SimpleDocumentSearchResponseBaseItem, SimpleDocumentSearchResponseBaseItemHumanReadableTimestamp, SimpleEmailSearchResponse, SimpleEmailSearchResponseBaseItem, SimpleEmailSearchResponseBaseItemHumanReadableTimestamp, SimpleProjectSearchResponse, SimpleProjectSearchResponseBaseItem, SimpleProjectSearchResponseBaseItemHumanReadableTimestamp, SimpleSearchResponse, SimpleSearchResponseItem, SimpleUnifiedSearchBaseResponse, SimpleUnifiedSearchData, SimpleUnifiedSearchError, SimpleUnifiedSearchErrors, SimpleUnifiedSearchResponse, SimpleUnifiedSearchResponseBaseItem, SimpleUnifiedSearchResponseBaseItemHumanReadableTimestamp, SimpleUnifiedSearchResponses, SoupProperty, TagFilterMode, TaskFilters, UnifiedSearchData, UnifiedSearchError, UnifiedSearchErrors, UnifiedSearchRequest, UnifiedSearchResponse, UnifiedSearchResponse2, UnifiedSearchResponseItem, UnifiedSearchResponses } from './types.gen';+export type { AgentSessionAuthor, AgentSessionFilters, AgentSessionSearchResponseItem, AgentSessionSearchResult, CalendarEventFilters, CalendarEventMetadata, CalendarEventOrganizer, CalendarEventSearchOccurrence, CalendarEventSearchResponseItem, CalendarEventSearchResponseItemWithMetadata, CalendarEventSearchResult, CalendarEventSearchScope, 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, Highlight, InitiativeFilters, MatchType, NotificationFilters, NotificationState, ProjectFilters, ProjectMetadata, ProjectSearchMetadata, ProjectSearchRequest, ProjectSearchResponseItem, ProjectSearchResponseItemWithMetadata, ProjectSearchResult, PropertyDefinition, PropertyFilter, PropertyOwner, PropertyValue, SearchGotoAgentSession, SearchGotoCallRecord, SearchGotoChannel, SearchGotoChat, SearchGotoContent, SearchGotoDocument, SearchGotoEmail, SearchHighlight, SearchOn, SearchResponse, SharedEmailFilter, SimpleCalendarEventSearchResponseBaseItemHumanReadableTimestamp, SimpleCallRecordSearchResponseBaseItemHumanReadableTimestamp, SimpleChannelSearchReponseBaseItem, SimpleChannelSearchReponseBaseItemHumanReadableTimestamp, SimpleChannelSearchResponse, SimpleChatSearchResponse, SimpleChatSearchResponseBaseItem, SimpleChatSearchResponseBaseItemHumanReadableTimestamp, SimpleDocumentSearchResponse, SimpleDocumentSearchResponseBaseItem, SimpleDocumentSearchResponseBaseItemHumanReadableTimestamp, SimpleEmailSearchResponse, SimpleEmailSearchResponseBaseItem, SimpleEmailSearchResponseBaseItemHumanReadableTimestamp, SimpleProjectSearchResponse, SimpleProjectSearchResponseBaseItem, SimpleProjectSearchResponseBaseItemHumanReadableTimestamp, SimpleSearchResponse, SimpleSearchResponseItem, 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 2e57a301db..3ca920b09d 100644--- a/packages/sdk/generated/search/types.gen.ts+++ b/packages/sdk/generated/search/types.gen.ts@@ -219,6 +219,17 @@ export type CalendarEventSearchResult = {score?: number | null;};+/**+ * Which calendar events a unified search covers.+ *+ * Sharing an event with a channel lets its members see the sharer's copy,+ * which is on none of their own calendars, so the default scope never finds+ * it. Shared events are a separate scope rather than part of the default, so+ * a caller can list them after the caller's own events without reordering+ * those.+ */+export type CalendarEventSearchScope = 'own' | 'shared_with_you';+/*** Timed or all-day span of a calendar event.*@@ -2422,6 +2433,13 @@ export type TaskFilters = {};export type UnifiedSearchRequest = {+ /**+ * Which calendar events to search. Defaults to `own`: events on the+ * caller's own and delegated calendars. `shared_with_you` searches only+ * events shared with a channel the caller belongs to that are on none of+ * their calendars.+ */+ calendar_event_scope?: CalendarEventSearchScope;collapse?: boolean | null;/*** Entity filters in the same shape as soup. Entity types with a NIL UUID in their primary ID field are excluded from search.diff --git a/packages/sdk/specs/search.json b/packages/sdk/specs/search.jsonindex 742ad60759..cd195fadcd 100644--- a/packages/sdk/specs/search.json+++ b/packages/sdk/specs/search.json@@ -504,6 +504,11 @@}}},+ "CalendarEventSearchScope": {+ "type": "string",+ "description": "Which calendar events a unified search covers.\n\nSharing an event with a channel lets its members see the sharer's copy,\nwhich is on none of their own calendars, so the default scope never finds\nit. Shared events are a separate scope rather than part of the default, so\na caller can list them after the caller's own events without reordering\nthose.",+ "enum": ["own", "shared_with_you"]+ },"CalendarEventSearchTime": {"oneOf": [{@@ -4674,6 +4679,10 @@"type": "object","required": ["query", "match_type"],"properties": {+ "calendar_event_scope": {+ "$ref": "#/components/schemas/CalendarEventSearchScope",+ "description": "Which calendar events to search. Defaults to `own`: events on the\ncaller's own and delegated calendars. `shared_with_you` searches only\nevents shared with a channel the caller belongs to that are on none of\ntheir calendars."+ },"collapse": {"type": ["boolean", "null"]},