Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
fix(calendar): show an occurrence's own content after a this_event edit (#6405)
gbirman079c4894abc4
diff --git a/.sqlx/query-0b3f0cb2b011d106bf5b77a0101467061d2fb02b9ea48c41fee3d9515e65ee3a.json b/.sqlx/query-011685c3f1ce2931cb599481ebd7388d8ee0c96ffbaa51d6a43ad6dc5b9d40ff.jsonsimilarity index 56%rename from .sqlx/query-0b3f0cb2b011d106bf5b77a0101467061d2fb02b9ea48c41fee3d9515e65ee3a.jsonrename to .sqlx/query-011685c3f1ce2931cb599481ebd7388d8ee0c96ffbaa51d6a43ad6dc5b9d40ff.jsonindex f128517c09..885d770c8d 100644--- a/.sqlx/query-0b3f0cb2b011d106bf5b77a0101467061d2fb02b9ea48c41fee3d9515e65ee3a.json+++ b/.sqlx/query-011685c3f1ce2931cb599481ebd7388d8ee0c96ffbaa51d6a43ad6dc5b9d40ff.json@@ -1,6 +1,6 @@{"db_name": "PostgreSQL",- "query": "\n SELECT\n occurrence.event_id,\n occurrence.occurrence_key,\n occurrence.recurrence_id,\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 occurrence.is_cancelled,\n event.owner_id,\n event.ical_uid,\n event.title,\n event.description,\n event.location,\n event.status,\n event.visibility,\n event.transparency,\n event.event_type,\n event.starts_at,\n event.ends_at,\n event.start_date,\n event.end_date,\n event.time_zone,\n event.recurrence_lines,\n event.organizer_email,\n event.organizer_name,\n event.creator_email,\n event.creator_name,\n event.conference_url,\n event.conference_provider,\n event.sequence,\n event.is_read_only,\n event.reminders_use_default,\n event.reminder_overrides,\n event.created_at,\n event.updated_at\n FROM calendar_event_occurrences occurrence\n JOIN calendar_events event ON event.id = occurrence.event_id\n WHERE occurrence.owner_id IN (\n SELECT $1::text\n UNION\n SELECT link.child_macro_id\n FROM macro_user_links link\n WHERE link.primary_macro_id = $1\n )\n AND event.status <> 'cancelled'\n AND NOT occurrence.is_cancelled\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 AND (\n occurrence.timed_span && tstzrange($2, $3, '[)')\n OR occurrence.day_span && daterange($4, $5, '[)')\n )\n AND (\n $6::timestamptz IS NULL\n OR (\n COALESCE(\n occurrence.starts_at,\n occurrence.start_date::timestamp AT TIME ZONE 'UTC'\n ),\n occurrence.event_id,\n occurrence.occurrence_key\n ) > ($6, $7, $8)\n )\n ORDER BY\n COALESCE(occurrence.starts_at, occurrence.start_date::timestamp AT TIME ZONE 'UTC'),\n occurrence.event_id,\n occurrence.occurrence_key\n LIMIT $9\n ",+ "query": "\n SELECT\n occurrence.event_id,\n occurrence.occurrence_key,\n occurrence.recurrence_id,\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 occurrence.is_cancelled,\n override.title AS override_title,\n override.description AS override_description,\n override.location AS override_location,\n override.status AS override_status,\n event.owner_id,\n event.ical_uid,\n event.title,\n event.description,\n event.location,\n event.status,\n event.visibility,\n event.transparency,\n event.event_type,\n event.starts_at,\n event.ends_at,\n event.start_date,\n event.end_date,\n event.time_zone,\n event.recurrence_lines,\n event.organizer_email,\n event.organizer_name,\n event.creator_email,\n event.creator_name,\n event.conference_url,\n event.conference_provider,\n event.sequence,\n event.is_read_only,\n event.reminders_use_default,\n event.reminder_overrides,\n event.created_at,\n event.updated_at\n FROM calendar_event_occurrences occurrence\n JOIN calendar_events event ON event.id = occurrence.event_id\n LEFT JOIN calendar_event_overrides override\n ON override.event_id = occurrence.event_id\n AND override.recurrence_id = occurrence.recurrence_id\n WHERE occurrence.owner_id IN (\n SELECT $1::text\n UNION\n SELECT link.child_macro_id\n FROM macro_user_links link\n WHERE link.primary_macro_id = $1\n )\n AND event.status <> 'cancelled'\n AND NOT occurrence.is_cancelled\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 AND (\n occurrence.timed_span && tstzrange($2, $3, '[)')\n OR occurrence.day_span && daterange($4, $5, '[)')\n )\n AND (\n $6::timestamptz IS NULL\n OR (\n COALESCE(\n occurrence.starts_at,\n occurrence.start_date::timestamp AT TIME ZONE 'UTC'\n ),\n occurrence.event_id,\n occurrence.occurrence_key\n ) > ($6, $7, $8)\n )\n ORDER BY\n COALESCE(occurrence.starts_at, occurrence.start_date::timestamp AT TIME ZONE 'UTC'),\n occurrence.event_id,\n occurrence.occurrence_key\n LIMIT $9\n ","describe": {"columns": [{@@ -45,136 +45,156 @@},{"ordinal": 8,- "name": "owner_id",+ "name": "override_title","type_info": "Text"},{"ordinal": 9,- "name": "ical_uid",+ "name": "override_description","type_info": "Text"},{"ordinal": 10,- "name": "title",+ "name": "override_location","type_info": "Text"},{"ordinal": 11,- "name": "description",+ "name": "override_status","type_info": "Text"},{"ordinal": 12,- "name": "location",+ "name": "owner_id","type_info": "Text"},{"ordinal": 13,- "name": "status",+ "name": "ical_uid","type_info": "Text"},{"ordinal": 14,- "name": "visibility",+ "name": "title","type_info": "Text"},{"ordinal": 15,- "name": "transparency",+ "name": "description","type_info": "Text"},{"ordinal": 16,- "name": "event_type",+ "name": "location","type_info": "Text"},{"ordinal": 17,+ "name": "status",+ "type_info": "Text"+ },+ {+ "ordinal": 18,+ "name": "visibility",+ "type_info": "Text"+ },+ {+ "ordinal": 19,+ "name": "transparency",+ "type_info": "Text"+ },+ {+ "ordinal": 20,+ "name": "event_type",+ "type_info": "Text"+ },+ {+ "ordinal": 21,"name": "starts_at","type_info": "Timestamptz"},{- "ordinal": 18,+ "ordinal": 22,"name": "ends_at","type_info": "Timestamptz"},{- "ordinal": 19,+ "ordinal": 23,"name": "start_date","type_info": "Date"},{- "ordinal": 20,+ "ordinal": 24,"name": "end_date","type_info": "Date"},{- "ordinal": 21,+ "ordinal": 25,"name": "time_zone","type_info": "Text"},{- "ordinal": 22,+ "ordinal": 26,"name": "recurrence_lines","type_info": "TextArray"},{- "ordinal": 23,+ "ordinal": 27,"name": "organizer_email","type_info": "Text"},{- "ordinal": 24,+ "ordinal": 28,"name": "organizer_name","type_info": "Text"},{- "ordinal": 25,+ "ordinal": 29,"name": "creator_email","type_info": "Text"},{- "ordinal": 26,+ "ordinal": 30,"name": "creator_name","type_info": "Text"},{- "ordinal": 27,+ "ordinal": 31,"name": "conference_url","type_info": "Text"},{- "ordinal": 28,+ "ordinal": 32,"name": "conference_provider","type_info": "Text"},{- "ordinal": 29,+ "ordinal": 33,"name": "sequence","type_info": "Int4"},{- "ordinal": 30,+ "ordinal": 34,"name": "is_read_only","type_info": "Bool"},{- "ordinal": 31,+ "ordinal": 35,"name": "reminders_use_default","type_info": "Bool"},{- "ordinal": 32,+ "ordinal": 36,"name": "reminder_overrides","type_info": "Jsonb"},{- "ordinal": 33,+ "ordinal": 37,"name": "created_at","type_info": "Timestamptz"},{- "ordinal": 34,+ "ordinal": 38,"name": "updated_at","type_info": "Timestamptz"}@@ -201,6 +221,10 @@true,true,false,+ true,+ true,+ true,+ true,false,false,false,@@ -230,5 +254,5 @@false]},- "hash": "0b3f0cb2b011d106bf5b77a0101467061d2fb02b9ea48c41fee3d9515e65ee3a"+ "hash": "011685c3f1ce2931cb599481ebd7388d8ee0c96ffbaa51d6a43ad6dc5b9d40ff"}diff --git a/crates/calendar_events/src/domain/models.rs b/crates/calendar_events/src/domain/models.rsindex 3ab7888578..649fdcb143 100644--- a/crates/calendar_events/src/domain/models.rs+++ b/crates/calendar_events/src/domain/models.rs@@ -669,6 +669,72 @@ pub struct CalendarEventOverride {pub attendees: Option<Vec<CalendarAttendee>>,}+impl CalendarEventOverride {+ /// The content this exception replaces on its occurrence.+ pub fn content(&self) -> OccurrenceContent<'_> {+ OccurrenceContent {+ title: self.title.as_deref(),+ description: self.description.as_deref(),+ location: self.location.as_deref(),+ status: self.status,+ }+ }++ /// Overlay this exception on its series event so the event reads as the+ /// overridden occurrence: the exception's content, its time, and its own+ /// attendee list when it carries one.+ pub fn apply_to(&self, event: &mut CalendarEvent) {+ event.apply_occurrence_content(self.content());+ event.time = self.time.clone();+ if let Some(attendees) = &self.attendees {+ event.attendees = attendees.clone();+ }+ }+}++/// The content an exception replaces on one occurrence of a series. A field+/// left `None` inherits the series value.+#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]+pub struct OccurrenceContent<'a> {+ /// Replacement title.+ pub title: Option<&'a str>,+ /// Replacement description.+ pub description: Option<&'a str>,+ /// Replacement location.+ pub location: Option<&'a str>,+ /// Replacement status.+ pub status: Option<EventStatus>,+}++impl CalendarEvent {+ /// Read this series event as one occurrence: the exception's content+ /// replaces the series content on the entity and on every calendar copy,+ /// so a client showing any copy sees the occurrence's own text.+ pub fn apply_occurrence_content(&mut self, content: OccurrenceContent<'_>) {+ if let Some(title) = content.title {+ self.title = title.to_string();+ for source in &mut self.sources {+ source.title = title.to_string();+ }+ }+ if let Some(description) = content.description {+ self.description = Some(description.to_string());+ for source in &mut self.sources {+ source.description = Some(description.to_string());+ }+ }+ if let Some(location) = content.location {+ self.location = Some(location.to_string());+ for source in &mut self.sources {+ source.location = Some(location.to_string());+ }+ }+ if let Some(status) = content.status {+ self.status = status;+ }+ }+}+/// A start-only value used to identify an overridden occurrence.#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]diff --git a/crates/calendar_events/src/domain/mutations.rs b/crates/calendar_events/src/domain/mutations.rsindex 83cc8408f7..c4479647cd 100644--- a/crates/calendar_events/src/domain/mutations.rs+++ b/crates/calendar_events/src/domain/mutations.rs@@ -158,8 +158,38 @@ where&self,viewer: Option<&ActorInboxes>,upsert: CalendarEventUpsert,+ ) -> Result<CalendarEvent, CalendarMutationError> {+ let event = upsert.event.clone();+ self.persist_echo_as(viewer, upsert, event).await+ }++ /// Persist the provider echo of an occurrence-scoped write and return the+ /// event as that occurrence reads: the series master is what gets stored,+ /// but the caller changed one instance, so the exception's content,+ /// time, and attendees overlay the canonical event in the response.+ async fn persist_occurrence_echo(+ &self,+ viewer: Option<&ActorInboxes>,+ upsert: CalendarEventUpsert,+ recurrence_id: &str,) -> Result<CalendarEvent, CalendarMutationError> {let mut event = upsert.event.clone();+ if let Some(exception) = upsert+ .overrides+ .iter()+ .find(|exception| exception.recurrence_id == recurrence_id)+ {+ exception.apply_to(&mut event);+ }+ self.persist_echo_as(viewer, upsert, event).await+ }++ async fn persist_echo_as(+ &self,+ viewer: Option<&ActorInboxes>,+ upsert: CalendarEventUpsert,+ mut event: CalendarEvent,+ ) -> Result<CalendarEvent, CalendarMutationError> {let super::models::CalendarEventSource::Google(source) = &upsert.source;let email_link_id = source.email_link_id;let outcome = self@@ -325,7 +355,8 @@ where.map_err(provider_error)?;match outcome {GoogleInstanceUpdateOutcome::Applied(upsert) => {- self.persist_echo(target.actor.as_ref(), *upsert).await+ self.persist_occurrence_echo(target.actor.as_ref(), *upsert, &recurrence_id)+ .await}GoogleInstanceUpdateOutcome::OccurrenceGone(upsert) => {// Nothing was written, but the provider's view of the@@ -460,9 +491,13 @@ where.await.map_err(provider_error)?;match outcome {- GoogleRsvpOutcome::Applied(upsert) => {- self.persist_echo(target.actor.as_ref(), *upsert).await- }+ GoogleRsvpOutcome::Applied(upsert) => match &scope {+ CalendarRsvpScope::All => self.persist_echo(target.actor.as_ref(), *upsert).await,+ CalendarRsvpScope::ThisEvent { recurrence_id } => {+ self.persist_occurrence_echo(target.actor.as_ref(), *upsert, recurrence_id)+ .await+ }+ },GoogleRsvpOutcome::NotAttendee => Err(CalendarMutationError::NotAttendee),GoogleRsvpOutcome::Gone => {self.retire_gone_source(&target).await;diff --git a/crates/calendar_events/src/domain/mutations/test.rs b/crates/calendar_events/src/domain/mutations/test.rsindex 94550f93b8..8158a08390 100644--- a/crates/calendar_events/src/domain/mutations/test.rs+++ b/crates/calendar_events/src/domain/mutations/test.rs@@ -1,12 +1,12 @@use super::*;use crate::domain::models::{ActorInboxes, AppliedGoogleGrant, CalendarAttendee, CalendarAttendeeInput,- CalendarBackfillJobKey, CalendarCreationTarget, CalendarEventSource, CalendarLinkTokenIdentity,- CalendarOccurrence, CalendarOccurrenceCursor, CalendarSyncStatus, CalendarWatchRelease,- ConferenceChange, DisconnectedGoogleCalendar, EventStatus, EventTransparency, EventType,- EventVisibility, GoogleCalendarSyncSnapshot, GoogleCalendarTarget, GoogleEventSource,- GoogleWatchChannel, OutOfOfficeAutoDeclineMode, OutOfOfficeProperties, ProviderCalendar,- StoredGoogleCalendar, VisibleCalendar,+ CalendarBackfillJobKey, CalendarCreationTarget, CalendarEventOverride, CalendarEventSource,+ CalendarLinkTokenIdentity, CalendarOccurrence, CalendarOccurrenceCursor, CalendarSyncStatus,+ CalendarWatchRelease, ConferenceChange, DisconnectedGoogleCalendar, EventStart, EventStatus,+ EventTransparency, EventType, EventVisibility, GoogleCalendarSyncSnapshot,+ GoogleCalendarTarget, GoogleEventSource, GoogleWatchChannel, OutOfOfficeAutoDeclineMode,+ OutOfOfficeProperties, ProviderCalendar, StoredGoogleCalendar, VisibleCalendar,};use crate::domain::ports::RetiredCalendarEvent;use chrono::{Duration, TimeZone};@@ -418,6 +418,7 @@ struct FakeProvider {calls: Arc<Mutex<Vec<String>>>,rsvp_self_emails: Arc<Mutex<Vec<Vec<String>>>>,echo_attendees: Vec<CalendarAttendee>,+ echo_overrides: Vec<CalendarEventOverride>,created_drafts: Arc<Mutex<Vec<CalendarEventDraft>>>,updated_patches: Arc<Mutex<Vec<CalendarEventPatch>>>,}@@ -429,6 +430,7 @@ impl FakeProvider {calls: Arc::new(Mutex::new(Vec::new())),rsvp_self_emails: Arc::new(Mutex::new(Vec::new())),echo_attendees: Vec::new(),+ echo_overrides: Vec::new(),created_drafts: Arc::new(Mutex::new(Vec::new())),updated_patches: Arc::new(Mutex::new(Vec::new())),}@@ -437,6 +439,7 @@ impl FakeProvider {fn echo(&self, owner_id: &str) -> CalendarEventUpsert {let mut upsert = echo_upsert(owner_id);upsert.event.attendees = self.echo_attendees.clone();+ upsert.overrides = self.echo_overrides.clone();upsert}@@ -1635,6 +1638,117 @@ async fn occurrence_scoped_attendee_update_prefers_the_occurrence_rsvp_over_the_);}+fn echo_override(+ recurrence_id: &str,+ attendees: Option<Vec<CalendarAttendee>>,+) -> CalendarEventOverride {+ let original_start = Utc.with_ymd_and_hms(2026, 8, 18, 20, 0, 0).unwrap();+ CalendarEventOverride {+ recurrence_id: recurrence_id.to_string(),+ original_time: EventStart::Timed(original_start),+ time: EventTime::Timed {+ starts_at: original_start + Duration::hours(1),+ ends_at: original_start + Duration::hours(2),+ time_zone: None,+ },+ title: Some("Renamed occurrence".to_string()),+ description: Some("Only this occurrence changed".to_string()),+ location: None,+ status: Some(EventStatus::Tentative),+ attendees,+ }+}++/// The provider echo of an occurrence-scoped edit is the series, whose+/// master keeps the old content; the caller edited one instance, so the+/// response must read as that instance while the series is what persists.+#[tokio::test]+async fn occurrence_scoped_update_answers_with_the_occurrence_not_the_series() {+ let recurrence_id = "2026-08-18T20:00:00+00:00";+ let mut provider = FakeProvider::new(FakeProviderBehavior::Echo);+ provider.echo_overrides = vec![+ echo_override("2026-08-17T20:00:00+00:00", None),+ echo_override(recurrence_id, None),+ ];+ let repo = FakeRepo {+ mutation_target: Some(mutation_target(false)),+ ..FakeRepo::default()+ };+ let upserts = repo.upserts.clone();++ let event = service(repo, provider, FakeTokens::ok())+ .update_event(+ "macro|user",+ Uuid::now_v7(),+ None,+ CalendarEventPatch {+ description: Some("Only this occurrence changed".to_string()),+ ..CalendarEventPatch::default()+ },+ CalendarUpdateScope::ThisEvent {+ recurrence_id: recurrence_id.to_string(),+ },+ )+ .await+ .unwrap();++ let expected = echo_override(recurrence_id, None);+ assert_eq!(event.title, "Renamed occurrence");+ assert_eq!(+ event.description.as_deref(),+ Some("Only this occurrence changed")+ );+ assert_eq!(event.status, EventStatus::Tentative);+ assert_eq!(event.time, expected.time);+ let persisted = upserts.lock().unwrap();+ assert_eq!(+ persisted[0].event.title, "Echo",+ "the series master is stored untouched; only the response reads as the occurrence"+ );+ assert_eq!(persisted[0].overrides.len(), 2);+}++/// An occurrence-scoped RSVP is recorded on the exception, so the response+/// must carry that occurrence's attendee list rather than the series answer.+#[tokio::test]+async fn occurrence_scoped_rsvp_answers_with_the_occurrence_attendees() {+ let recurrence_id = "2026-08-18T20:00:00+00:00";+ let mut series_self = echo_attendee("[email protected]", true);+ series_self.response_status = AttendeeResponseStatus::Accepted;+ let mut occurrence_self = series_self.clone();+ occurrence_self.response_status = AttendeeResponseStatus::Declined;+ let mut provider = FakeProvider::new(FakeProviderBehavior::Echo);+ provider.echo_attendees = vec![series_self];+ provider.echo_overrides = vec![echo_override(recurrence_id, Some(vec![occurrence_self]))];++ let event = service(+ FakeRepo {+ mutation_target: Some(mutation_target(false)),+ ..FakeRepo::default()+ },+ provider,+ FakeTokens::ok(),+ )+ .respond_to_event(+ "macro|user",+ Uuid::now_v7(),+ None,+ AttendeeResponseStatus::Declined,+ CalendarRsvpScope::ThisEvent {+ recurrence_id: recurrence_id.to_string(),+ },+ )+ .await+ .unwrap();++ let own = event+ .attendees+ .iter()+ .find(|attendee| attendee.is_self)+ .expect("the requester stays on the occurrence's attendee list");+ assert_eq!(own.response_status, AttendeeResponseStatus::Declined);+}+#[tokio::test]async fn update_on_a_provider_deleted_event_retires_the_stale_source() {let repo = FakeRepo {diff --git a/crates/calendar_events/src/outbound/pg.rs b/crates/calendar_events/src/outbound/pg.rsindex 7743cdd709..ad55e8ec89 100644--- a/crates/calendar_events/src/outbound/pg.rs+++ b/crates/calendar_events/src/outbound/pg.rs@@ -23,8 +23,8 @@ use crate::domain::{DisconnectedGoogleCalendar, DueCalendarReminder, EventReminderOverride, EventReminders,EventStart, EventStatus, EventTime, EventTransparency, EventType, EventVisibility,GOOGLE_CALENDAR_SCOPES, GoogleCalendarSyncSnapshot, GoogleScopeSet, GoogleWatchChannel,- OccurrenceRange, ProviderCalendar, StoredGoogleCalendar, TeamOutOfOffice, VisibleCalendar,- is_system_calendar,+ OccurrenceContent, OccurrenceRange, ProviderCalendar, StoredGoogleCalendar,+ TeamOutOfOffice, VisibleCalendar, is_system_calendar,},ports::{CalendarBackfillRepository, CalendarEventChange, CalendarEventWrite,@@ -285,6 +285,10 @@ struct OccurrenceJoinRow {occurrence_start_date: Option<NaiveDate>,occurrence_end_date: Option<NaiveDate>,is_cancelled: bool,+ override_title: Option<String>,+ override_description: Option<String>,+ override_location: Option<String>,+ override_status: Option<String>,owner_id: String,ical_uid: String,title: String,@@ -879,6 +883,10 @@ impl CalendarRepository for PgCalendarRepository {occurrence.start_date AS occurrence_start_date,occurrence.end_date AS occurrence_end_date,occurrence.is_cancelled,+ override.title AS override_title,+ override.description AS override_description,+ override.location AS override_location,+ override.status AS override_status,event.owner_id,event.ical_uid,event.title,@@ -908,6 +916,9 @@ impl CalendarRepository for PgCalendarRepository {event.updated_atFROM calendar_event_occurrences occurrenceJOIN calendar_events event ON event.id = occurrence.event_id+ LEFT JOIN calendar_event_overrides override+ ON override.event_id = occurrence.event_id+ AND override.recurrence_id = occurrence.recurrence_idWHERE occurrence.owner_id IN (SELECT $1::textUNION@@ -3963,11 +3974,15 @@ fn mention_preview_from_row(row: MentionPreviewRow) -> Result<CalendarMentionPre}fn event_from_join(- row: OccurrenceJoinRow,+ mut row: OccurrenceJoinRow,attendees: Vec<CalendarAttendee>,sources: Vec<CalendarEventSourceContent>,) -> Result<CalendarEvent, Report> {- Ok(CalendarEvent {+ let override_title = row.override_title.take();+ let override_description = row.override_description.take();+ let override_location = row.override_location.take();+ let override_status = row.override_status.take();+ let mut event = CalendarEvent {id: row.event_id,owner_id: row.owner_id,ical_uid: row.ical_uid,@@ -4007,7 +4022,16 @@ fn event_from_join(attendees,created_at: row.created_at,updated_at: row.updated_at,- })+ };+ // An exception's content replaces the series content for that occurrence+ // alone, the same way its attendee list shadows the series list.+ event.apply_occurrence_content(OccurrenceContent {+ title: override_title.as_deref(),+ description: override_description.as_deref(),+ location: override_location.as_deref(),+ status: override_status.as_deref().map(event_status),+ });+ Ok(event)}fn occurrence_from_join(row: &OccurrenceJoinRow) -> Result<CalendarOccurrence, Report> {diff --git a/crates/calendar_events/src/outbound/pg/test.rs b/crates/calendar_events/src/outbound/pg/test.rsindex bb89051c07..1bdbf07cf3 100644--- a/crates/calendar_events/src/outbound/pg/test.rs+++ b/crates/calendar_events/src/outbound/pg/test.rs@@ -1499,6 +1499,113 @@ async fn occurrence_attendee_override_shadows_the_series_response(pool: PgPool));}+/// A single-occurrence edit lands on the exception, never on the master, so+/// the occurrence carrying it must read the exception's content — on the+/// entity and on the calendar copy a client shows — while its siblings keep+/// the series content.+#[sqlx::test(migrator = "MACRO_DB_MIGRATIONS")]+async fn occurrence_content_override_shadows_the_series_content(pool: PgPool) {+ let owner_id = "macro|[email protected]";+ let link_id = insert_link(&pool, owner_id).await;+ let repo = PgCalendarRepository::new(pool);+ let provider = provider_ids(&repo, link_id).await;+ let mut upsert = timed_upsert(+ owner_id,+ link_id,+ provider,+ "[email protected]",+ "Series title",+ 1,+ );+ upsert.event.description = Some("Series description".to_string());+ upsert.event.location = Some("Series room".to_string());++ let edited_start = Utc.with_ymd_and_hms(2026, 7, 25, 14, 0, 0).unwrap();+ let recurrence_id = edited_start.to_rfc3339();+ upsert.occurrences[1].recurrence_id = Some(recurrence_id.clone());+ upsert.overrides = vec![CalendarEventOverride {+ recurrence_id: recurrence_id.clone(),+ original_time: EventStart::Timed(edited_start),+ time: EventTime::Timed {+ starts_at: edited_start,+ ends_at: edited_start + Duration::hours(1),+ time_zone: Some("UTC".to_string()),+ },+ title: Some("Edited title".to_string()),+ description: Some("Only this occurrence changed".to_string()),+ location: None,+ status: Some(EventStatus::Tentative),+ attendees: None,+ }];+ repo.upsert_event_fixture(upsert).await.unwrap();++ let starts_at = Utc.with_ymd_and_hms(2026, 7, 24, 0, 0, 0).unwrap();+ let ends_at = Utc.with_ymd_and_hms(2026, 7, 26, 0, 0, 0).unwrap();+ let result = repo+ .list_occurrences(+ owner_id,+ OccurrenceRange {+ starts_at,+ ends_at,+ start_date: starts_at.date_naive(),+ end_date: ends_at.date_naive(),+ },+ None,+ 100,+ )+ .await+ .unwrap();++ assert_eq!(result.len(), 2);+ let content_at = |key: &str| {+ let (event, _) = result+ .iter()+ .find(|(_, occurrence)| occurrence.occurrence_key == key)+ .expect("the occurrence is listed");+ let copy = event+ .sources+ .first()+ .expect("the listing carries the calendar copy");+ (+ event.title.as_str(),+ event.description.as_deref(),+ event.location.as_deref(),+ event.status,+ copy.title.as_str(),+ copy.description.as_deref(),+ copy.location.as_deref(),+ )+ };+ assert_eq!(+ content_at(&recurrence_id),+ (+ "Edited title",+ Some("Only this occurrence changed"),+ Some("Series room"),+ EventStatus::Tentative,+ "Edited title",+ Some("Only this occurrence changed"),+ Some("Series room"),+ ),+ "the exception's content replaces the series content on the entity and its copy, \+ and a field the exception leaves unset inherits the series value"+ );+ let series_start = Utc.with_ymd_and_hms(2026, 7, 24, 14, 0, 0).unwrap();+ assert_eq!(+ content_at(&series_start.to_rfc3339()),+ (+ "Series title",+ Some("Series description"),+ Some("Series room"),+ EventStatus::Confirmed,+ "Series title",+ Some("Series description"),+ Some("Series room"),+ ),+ "a sibling occurrence keeps the series content"+ );+}+/// An exception that explicitly replaces the attendee list with an empty one/// must project no attendees for that occurrence — not fall back to the/// series list, which only an exception without an attendee list inherits.