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(scheduling): load reschedule slots on the guest's local date (#8302)
gbirman04e8ea7889dc
diff --git a/apps/web/src/features/scheduling/components/reschedule-form.test.tsx b/apps/web/src/features/scheduling/components/reschedule-form.test.tsxnew file mode 100644index 0000000000..82e2434bd9--- /dev/null+++ b/apps/web/src/features/scheduling/components/reschedule-form.test.tsx@@ -0,0 +1,104 @@+import { cleanup, render, screen } from '@solidjs/testing-library';+import userEvent from '@testing-library/user-event';+import { afterEach, beforeEach, expect, it, vi } from 'vitest';+import { RescheduleForm } from './reschedule-form';++vi.mock('./TimezoneSelect', () => ({+ TimezoneSelect: (props: {+ value: string;+ onChange: (zone: string) => void;+ }) => (+ <select+ aria-label="Your time zone"+ value={props.value}+ onChange={(e) => props.onChange(e.currentTarget.value)}+ >+ <option value="UTC">UTC</option>+ <option value="Asia/Tokyo">Asia/Tokyo</option>+ </select>+ ),+}));++beforeEach(() => {+ vi.useFakeTimers({ toFake: ['Date'] });+ vi.setSystemTime(new Date('2026-10-19T12:00:00Z'));+});+afterEach(() => {+ cleanup();+ vi.useRealTimers();+});++it('loads the selected local date and zone and submits the returned instant', async () => {+ const user = userEvent.setup();+ const load = vi.fn(async () => [+ {+ startsAt: '2026-10-19T16:00:00Z',+ endsAt: '2026-10-19T16:30:00Z',+ },+ ]);+ const submit = vi.fn(async () => {});+ render(() => (+ <RescheduleForm load={load} submit={submit} onCancel={() => {}} />+ ));+ await user.selectOptions(+ screen.getByLabelText('Your time zone'),+ 'Asia/Tokyo'+ );+ await user.click(screen.getByRole('button', { name: 'Date' }));+ await user.click(screen.getByRole('gridcell', { name: '20' }));+ expect(load).toHaveBeenCalledWith('2026-10-20', 'Asia/Tokyo');+ expect(+ screen.getByRole('button', { name: /^Time Time / }).textContent+ ).toMatch(/1:00\sAM/);+ await user.click(screen.getByRole('button', { name: 'Confirm new time' }));+ expect(submit).toHaveBeenCalledWith('2026-10-19T16:00:00Z');+});++it.each(['success', 'error'])(+ 'ignores a pending %s after the zone changes',+ async (outcome) => {+ const user = userEvent.setup();+ let finish!: () => void;+ const pending = new Promise<{ startsAt: string; endsAt: string }[]>(+ (resolve, reject) => {+ finish = () =>+ outcome === 'success'+ ? resolve([+ {+ startsAt: '2026-10-20T16:00:00Z',+ endsAt: '2026-10-20T16:30:00Z',+ },+ ])+ : reject(new Error('Unavailable'));+ }+ );+ const load = vi.fn(() => pending);+ const submit = vi.fn(async () => {});+ const { container } = render(() => (+ <RescheduleForm load={load} submit={submit} onCancel={() => {}} />+ ));+ await user.click(screen.getByRole('button', { name: 'Date' }));+ await user.click(screen.getByRole('gridcell', { name: '20' }));+ expect(screen.getByRole('status').textContent).toContain(+ 'Checking availability'+ );+ await user.selectOptions(+ screen.getByLabelText('Your time zone'),+ 'Asia/Tokyo'+ );+ expect(screen.queryByRole('status')).toBeNull();+ finish();+ await Promise.allSettled([pending]);+ expect(+ container.querySelector<HTMLInputElement>('input[type="date"]')?.value+ ).toBe('');+ expect(screen.queryByRole('button', { name: /^Time Time / })).toBeNull();+ expect(screen.queryByRole('alert')).toBeNull();+ const confirm = screen.getByRole<HTMLButtonElement>('button', {+ name: 'Confirm new time',+ });+ expect(confirm.disabled).toBe(true);+ await user.click(confirm);+ expect(submit).not.toHaveBeenCalled();+ }+);diff --git a/apps/web/src/features/scheduling/components/reschedule-form.tsx b/apps/web/src/features/scheduling/components/reschedule-form.tsxindex 602184e9bc..225a7942eb 100644--- a/apps/web/src/features/scheduling/components/reschedule-form.tsx+++ b/apps/web/src/features/scheduling/components/reschedule-form.tsx@@ -4,7 +4,10 @@ import { createSignal, Show } from 'solid-js';import { Field, SelectInput, TimeZoneInput } from './fields';export function RescheduleForm(props: {- load: (date: string) => Promise<{ startsAt: string; endsAt: string }[]>;+ load: (+ date: string,+ timeZone: string+ ) => Promise<{ startsAt: string; endsAt: string }[]>;submit: (startsAt: string) => Promise<void>;onCancel: () => void;}) {@@ -32,7 +35,7 @@ export function RescheduleForm(props: {}setLoading(true);try {- const times = await props.load(value);+ const times = await props.load(value, zone());if (current === request) {setSlots(times);setSelected(times[0]?.startsAt ?? '');@@ -45,7 +48,7 @@ export function RescheduleForm(props: {};const save = async (e: SubmitEvent) => {e.preventDefault();- if (!selected() || saving()) return;+ if (!date() || !selected() || saving() || loading()) return;setError('');setSaving(true);try {@@ -69,10 +72,13 @@ export function RescheduleForm(props: {value={zone()}disabled={saving()}onChange={(value) => {+ request++;setZone(value);setDate('');setSlots([]);setSelected('');+ setLoading(false);+ setError('');}}/></Field>diff --git a/apps/web/src/features/scheduling/queries/keys.ts b/apps/web/src/features/scheduling/queries/keys.tsindex 99510b8694..b9f7875968 100644--- a/apps/web/src/features/scheduling/queries/keys.ts+++ b/apps/web/src/features/scheduling/queries/keys.ts@@ -1,10 +1,11 @@import { createQueryKeys } from '@lukemorales/query-key-factory';export const schedulingKeys = createQueryKeys('scheduling', {- replacementSlots: (id: string, token: string, date: string) => [- id,- token,- date,- ],+ replacementSlots: (+ id: string,+ token: string,+ date: string,+ timeZone: string+ ) => [id, token, date, timeZone],receipt: (id: string, token: string) => [id, token],settings: (scope: string) => [scope],bookings: (scope: string, from: string, to: string) => [scope, from, to],diff --git a/apps/web/src/features/scheduling/queries/public.ts b/apps/web/src/features/scheduling/queries/public.tsindex 148ef60362..4580e1a348 100644--- a/apps/web/src/features/scheduling/queries/public.ts+++ b/apps/web/src/features/scheduling/queries/public.ts@@ -125,13 +125,14 @@ export function createBookingReceiptSource(await reschedule.mutateAsync(startsAt);await receipt.refetch();},- replacementSlots: (date: string) =>+ replacementSlots: (date: string, timeZone: string) =>queryClient.fetchQuery({- queryKey: schedulingKeys.replacementSlots(id(), token(), date).queryKey,+ queryKey: schedulingKeys.replacementSlots(id(), token(), date, timeZone)+ .queryKey,queryFn: async () =>(await throwOnErr(() =>- schedulingClient.replacementSlots(id(), token(), date)+ schedulingClient.replacementSlots(id(), token(), date, timeZone))).slots,staleTime: 0,diff --git a/apps/web/src/features/scheduling/queries/receipt.test.ts b/apps/web/src/features/scheduling/queries/receipt.test.tsnew file mode 100644index 0000000000..50a009eec1--- /dev/null+++ b/apps/web/src/features/scheduling/queries/receipt.test.ts@@ -0,0 +1,61 @@+import { queryClient } from '@queries/client';+import { schedulingClient } from '@service-email/scheduling';+import { QueryClient, QueryClientProvider } from '@tanstack/solid-query';+import { err, ok } from 'neverthrow';+import { createComponent, createRoot } from 'solid-js';+import { expect, it, vi } from 'vitest';+import { createBookingReceiptSource } from './public';++vi.mock('@service-email/scheduling', () => ({+ schedulingClient: {+ receipt: vi.fn(async () => err([{ code: 'NOT_FOUND' }])),+ replacementSlots: vi.fn(),+ },+}));+vi.mock('@queries/client', async () => {+ const { QueryClient } = await import('@tanstack/solid-query');+ return { queryClient: new QueryClient() };+});++it('does not share pending replacement slots across visitor time zones', async () => {+ const client = new QueryClient();+ let source!: ReturnType<typeof createBookingReceiptSource>;+ const dispose = createRoot((dispose) => {+ createComponent(QueryClientProvider, {+ client,+ get children() {+ source = createBookingReceiptSource(+ () => 'booking',+ () => 'token'+ );+ return null;+ },+ });+ return dispose;+ });+ const tokyo = [+ { startsAt: '2026-10-19T16:00:00Z', endsAt: '2026-10-19T16:30:00Z' },+ ];+ const la = [+ { startsAt: '2026-10-20T16:00:00Z', endsAt: '2026-10-20T16:30:00Z' },+ ];+ const slots = vi.mocked(schedulingClient.replacementSlots);+ slots+ .mockResolvedValueOnce(ok({ slots: tokyo }))+ .mockResolvedValueOnce(ok({ slots: la }));+ try {+ const results = await Promise.all([+ source.replacementSlots('2026-10-20', 'Asia/Tokyo'),+ source.replacementSlots('2026-10-20', 'America/Los_Angeles'),+ ]);+ expect(results).toEqual([tokyo, la]);+ expect(slots.mock.calls).toEqual([+ ['booking', 'token', '2026-10-20', 'Asia/Tokyo'],+ ['booking', 'token', '2026-10-20', 'America/Los_Angeles'],+ ]);+ } finally {+ dispose();+ client.clear();+ queryClient.clear();+ }+});diff --git a/apps/web/src/features/scheduling/views/booking-receipt-view.tsx b/apps/web/src/features/scheduling/views/booking-receipt-view.tsxindex 948f8ffc4f..52b362087f 100644--- a/apps/web/src/features/scheduling/views/booking-receipt-view.tsx+++ b/apps/web/src/features/scheduling/views/booking-receipt-view.tsx@@ -8,7 +8,10 @@ export function BookingReceiptView(props: {receipt?: BookingReceipt;unavailable: boolean;cancel: () => Promise<void>;- loadSlots: (date: string) => Promise<{ startsAt: string; endsAt: string }[]>;+ loadSlots: (+ date: string,+ timeZone: string+ ) => Promise<{ startsAt: string; endsAt: string }[]>;reschedule: (start: string) => Promise<void>;/** Shown inside another Macro page, which already frames the receipt. */embedded?: boolean;diff --git a/apps/web/src/lib/service-clients/service-email/scheduling.ts b/apps/web/src/lib/service-clients/service-email/scheduling.tsindex 81dee4d986..9f26892af1 100644--- a/apps/web/src/lib/service-clients/service-email/scheduling.ts+++ b/apps/web/src/lib/service-clients/service-email/scheduling.ts@@ -75,9 +75,14 @@ export const schedulingClient = {`${host}/public/bookings/${encodeURIComponent(id)}`,{ headers: { Authorization: `Bearer ${token}` } }),- replacementSlots: (id: string, token: string, date: string) =>+ replacementSlots: (+ id: string,+ token: string,+ date: string,+ timeZone: string+ ) =>safeFetch<{ slots: { startsAt: string; endsAt: string }[] }>(- `${host}/public/bookings/${encodeURIComponent(id)}/slots?date=${encodeURIComponent(date)}`,+ `${host}/public/bookings/${encodeURIComponent(id)}/slots?date=${encodeURIComponent(date)}&timeZone=${encodeURIComponent(timeZone)}`,{ headers: { Authorization: `Bearer ${token}` } }),reschedule: (id: string, token: string, startsAt: string) =>diff --git a/crates/calendar_scheduling/AGENTS.md b/crates/calendar_scheduling/AGENTS.mdindex c11398cbdb..329cb9f068 100644--- a/crates/calendar_scheduling/AGENTS.md+++ b/crates/calendar_scheduling/AGENTS.md@@ -46,6 +46,7 @@ MacroDB migrations.## Gotchas+- Replacement availability uses the visitor's `timeZone` and local date; omitted zones and host administration keep schedule-date semantics.- Booking range queries are half-open and capped at 733 days and 5,000 records;insights must treat a failed query as an error, never as an empty dataset.- Existing bookings keep their original event/schedule snapshot after thediff --git a/crates/calendar_scheduling/README.md b/crates/calendar_scheduling/README.mdindex c944474bd7..989bf28ebf 100644--- a/crates/calendar_scheduling/README.md+++ b/crates/calendar_scheduling/README.md@@ -32,6 +32,10 @@ not configured personal availability use the team schedule.Round robin assigns one available host, favoring the least assigned host. Publicslots are displayed on the visitor's local date. Existing bookings retain theiroriginal event/schedule snapshots for management after a link is edited or removed.+Replacement-slot requests accept `timeZone` with `date` to return starts on the+visitor's local day, across host dates and daylight-saving boundaries. Requests+without `timeZone` retain schedule-date semantics for existing clients and host+administration. The booking's own reservation and calendar event remain excluded.Booking queries accept a half-open `from`/`to` range of start times, up to 733 days(room for two full comparison years across daylight-saving changes). They return thediff --git a/crates/calendar_scheduling/src/domain/management.rs b/crates/calendar_scheduling/src/domain/management.rsindex edb2fa253e..4247ee89a9 100644--- a/crates/calendar_scheduling/src/domain/management.rs+++ b/crates/calendar_scheduling/src/domain/management.rs@@ -53,6 +53,6 @@ impl<R: Repository, C: Calendars, D: Directory> Service<R, C, D> {date: NaiveDate,) -> Result<Vec<Slot>, Error> {let record = self.manage(user, id).await?;- self.replacement_slots(id, record.token, date).await+ self.replacement_slots(id, record.token, date, None).await}}diff --git a/crates/calendar_scheduling/src/domain/service.rs b/crates/calendar_scheduling/src/domain/service.rsindex 85f13c9d2f..e548dc4f62 100644--- a/crates/calendar_scheduling/src/domain/service.rs+++ b/crates/calendar_scheduling/src/domain/service.rs@@ -707,12 +707,15 @@ impl<R: Repository, C: Calendars, D: Directory> Service<R, C, D> {}Ok(record)}- /// Return replacement slots while excluding this booking's own reservation and calendar event.+ /// Return slots on the visitor's date, excluding this booking's reservation and calendar event.+ /// Omitting the visitor zone preserves host-date semantics for existing clients.+ #[tracing::instrument(skip_all, fields(booking_id = %id, %date, time_zone = ?zone), err)]pub async fn replacement_slots(&self,id: Uuid,token: Uuid,date: NaiveDate,+ zone: Option<chrono_tz::Tz>,) -> Result<Vec<Slot>, Error> {let record = self.receipt(id, token).await?;self.repository@@ -738,14 +741,20 @@ impl<R: Repository, C: Calendars, D: Directory> Service<R, C, D> {};// Current membership is authoritative even when the original link was removed.self.validate_booking_hosts(&owner, &event.hosts).await?;- let (start, end) = day_bounds(&record.schedule, date)?;+ let viewer_schedule = Schedule {+ time_zone: zone.unwrap_or(record.schedule.time_zone),+ ..record.schedule.clone()+ };+ let (start, end) = day_bounds(&viewer_schedule, date)?;if start > Utc::now() + Duration::days(i64::from(event.horizon_days) + 1)|| end < Utc::now(){return Ok(vec![]);}let occupied_start = start - Duration::minutes(i64::from(event.before_minutes));- let occupied_end = end + Duration::minutes(i64::from(event.after_minutes));+ // A slot starting before visitor midnight may finish on their next day.+ let occupied_end = end+ + Duration::minutes(i64::from(event.duration_minutes) + i64::from(event.after_minutes));let mut busy = self.calendars.busy(@@ -760,12 +769,22 @@ impl<R: Repository, C: Calendars, D: Directory> Service<R, C, D> {.busy(&event.hosts, occupied_start, occupied_end, Some(id)).await?,);- self.respect_host_hours(- &owner,- &event,- slots_for_date(&event, &record.schedule, date, Utc::now(), &busy)?,- )- .await+ let mut host_date = start.with_timezone(&record.schedule.time_zone).date_naive();+ let last = (end - Duration::seconds(1))+ .with_timezone(&record.schedule.time_zone)+ .date_naive();+ let mut slots = vec![];+ let now = Utc::now();+ while host_date <= last {+ slots.extend(+ slots_for_date(&event, &record.schedule, host_date, now, &busy)?+ .into_iter()+ .filter(|s| s.starts_at >= start && s.starts_at < end),+ );+ host_date = host_date.succ_opt().ok_or(Error::Conflict)?;+ }+ slots.sort_by_key(|s| s.starts_at);+ self.respect_host_hours(&owner, &event, slots).await}/// Move a booking while retaining both reservations until the calendar accepts the change.pub async fn reschedule(@@ -780,7 +799,7 @@ impl<R: Repository, C: Calendars, D: Directory> Service<R, C, D> {.with_timezone(&record.schedule.time_zone).date_naive();let slot = self- .replacement_slots(id, token, date)+ .replacement_slots(id, token, date, None).await?.into_iter().find(|s| s.starts_at == starts_at)diff --git a/crates/calendar_scheduling/src/domain/service/test.rs b/crates/calendar_scheduling/src/domain/service/test.rsindex f787f51026..e0a6405887 100644--- a/crates/calendar_scheduling/src/domain/service/test.rs+++ b/crates/calendar_scheduling/src/domain/service/test.rs@@ -1263,6 +1263,7 @@ impl AttachmentReadiness for Arc<Calendar> {mod booking_links;mod management;+mod replacement;#[cfg(all(feature = "client", feature = "inbound"))]mod http_administration;diff --git a/crates/calendar_scheduling/src/domain/service/test/http_administration.rs b/crates/calendar_scheduling/src/domain/service/test/http_administration.rsindex 07d01383ab..070dfa22e6 100644--- a/crates/calendar_scheduling/src/domain/service/test/http_administration.rs+++ b/crates/calendar_scheduling/src/domain/service/test/http_administration.rs@@ -128,3 +128,74 @@ async fn client_and_router_preserve_authority_and_all_management_workflows() {));server.abort();}++#[tokio::test]+async fn public_replacements_forward_time_zone_and_preserve_legacy_dates() {+ let service = Arc::new(TestService::new(+ Arc::new(Memory::default()),+ Arc::new(Calendar::default()),+ Members,+ ));+ let p = service.save("admin", None, profile(None)).await.unwrap();+ let record = service+ .book(p.id, p.event_types[0].id, request())+ .await+ .unwrap();+ let app = router(RouterState::new(+ service,+ MacroAuthorizationState::new(Arc::new(Identity)),+ ));+ let listener = tokio::net::TcpListener::bind("127.0.0.1:0").await.unwrap();+ let url = format!(+ "http://{}/public/bookings/{}/slots",+ listener.local_addr().unwrap(),+ record.booking.id+ );+ let server = tokio::spawn(async move {+ axum::serve(listener, app).await.unwrap();+ });+ let client = reqwest::Client::new();+ let date = record.booking.starts_at.date_naive();+ for (suffix, zone) in [+ ("&timeZone=Asia%2FTokyo", chrono_tz::Asia::Tokyo),+ (+ "&timeZone=America%2FLos_Angeles",+ chrono_tz::America::Los_Angeles,+ ),+ ("", chrono_tz::UTC),+ ] {+ let response = client+ .get(format!("{url}?date={date}{suffix}"))+ .bearer_auth(record.token)+ .send()+ .await+ .unwrap()+ .error_for_status()+ .unwrap()+ .json::<serde_json::Value>()+ .await+ .unwrap();+ let slots: Vec<Slot> = serde_json::from_value(response["slots"].clone()).unwrap();+ assert!(!slots.is_empty());+ assert!(+ slots+ .iter()+ .all(|s| s.starts_at.with_timezone(&zone).date_naive() == date)+ );+ }+ let invalid = client+ .get(format!("{url}?date={date}&timeZone=not-a-zone"))+ .bearer_auth(record.token)+ .send()+ .await+ .unwrap();+ assert_eq!(invalid.status(), reqwest::StatusCode::BAD_REQUEST);+ let forbidden = client+ .get(format!("{url}?date={date}&timeZone=Asia%2FTokyo"))+ .bearer_auth(Uuid::new_v4())+ .send()+ .await+ .unwrap();+ assert_eq!(forbidden.status(), reqwest::StatusCode::NOT_FOUND);+ server.abort();+}diff --git a/crates/calendar_scheduling/src/domain/service/test/replacement.rs b/crates/calendar_scheduling/src/domain/service/test/replacement.rsnew file mode 100644index 0000000000..b0b95be233--- /dev/null+++ b/crates/calendar_scheduling/src/domain/service/test/replacement.rs@@ -0,0 +1,165 @@+use super::*;++#[tokio::test]+async fn replacements_use_the_visitor_date_and_keep_the_booking_snapshot() {+ let service = TestService::new(+ Arc::new(Memory::default()),+ Arc::new(Calendar::default()),+ Members,+ );+ let mut p = profile(None);+ p.schedules[0].time_zone = chrono_tz::America::Los_Angeles;+ let mut p = service.save("admin", None, p).await.unwrap();+ let date = request().starts_at.date_naive();+ let start = p.schedules[0]+ .time_zone+ .from_local_datetime(&date.and_hms_opt(9, 0, 0).unwrap())+ .single()+ .unwrap()+ .with_timezone(&Utc);+ let record = service+ .book(+ p.id,+ p.event_types[0].id,+ BookingRequest {+ starts_at: start,+ ..request()+ },+ )+ .await+ .unwrap();+ // Rescheduling must continue to use the saved schedule after the link is removed.+ p.event_types.clear();+ p.schedules[0].time_zone = chrono_tz::UTC;+ service.save("admin", None, p).await.unwrap();+ let zone = chrono_tz::Asia::Tokyo;+ let visitor_date = start.with_timezone(&zone).date_naive();+ let slots = service+ .replacement_slots(record.booking.id, record.token, visitor_date, Some(zone))+ .await+ .unwrap();+ assert_eq!(slots.len(), 16);+ assert!(slots.iter().any(|s| s.starts_at == start));+ assert!(+ slots+ .iter()+ .all(|s| s.starts_at.with_timezone(&zone).date_naive() == visitor_date)+ );+ assert!(slots.iter().all(|s| {+ s.starts_at+ .with_timezone(&record.schedule.time_zone)+ .date_naive()+ == date+ }));+ assert!(+ slots+ .windows(2)+ .all(|pair| pair[0].starts_at < pair[1].starts_at)+ );+ let moved = service+ .reschedule(record.booking.id, record.token, slots[1].starts_at)+ .await+ .unwrap();+ assert_eq!(+ moved.booking.starts_at.with_timezone(&zone).date_naive(),+ visitor_date+ );+ let legacy = service+ .replacement_slots(record.booking.id, record.token, date, None)+ .await+ .unwrap();+ assert_eq!(legacy.len(), 16);+ assert!(matches!(+ service+ .replacement_slots(record.booking.id, Uuid::new_v4(), visitor_date, Some(zone))+ .await,+ Err(Error::NotFound)+ ));+}++#[tokio::test]+async fn replacements_combine_host_dates_and_check_conflicts_after_visitor_midnight() {+ let service = TestService::new(+ Arc::new(Memory::default()),+ Arc::new(Calendar::default()),+ Members,+ );+ let mut p = profile(None);+ for day in &mut p.schedules[0].weekly {+ day.windows = vec![TimeWindow {+ start: "00:00".into(),+ end: "23:00".into(),+ }];+ }+ p.event_types[0].duration_minutes = 60;+ let p = service.save("admin", None, p).await.unwrap();+ let record = service+ .book(p.id, p.event_types[0].id, request())+ .await+ .unwrap();+ let date = record.booking.starts_at.date_naive();+ let zone = chrono_tz::Asia::Tokyo;+ // Tokyo midnight is 15:00 UTC. A candidate at 14:30 overlaps this other booking.+ let conflict_start = date.and_hms_opt(15, 0, 0).unwrap().and_utc();+ service+ .book(+ p.id,+ p.event_types[0].id,+ BookingRequest {+ starts_at: conflict_start,+ ..request()+ },+ )+ .await+ .unwrap();+ let slots = service+ .replacement_slots(record.booking.id, record.token, date, Some(zone))+ .await+ .unwrap();+ assert!(+ slots+ .iter()+ .any(|s| s.starts_at.date_naive() == date.pred_opt().unwrap())+ );+ assert!(slots.iter().any(|s| s.starts_at.date_naive() == date));+ assert!(+ slots+ .iter()+ .all(|s| s.starts_at.with_timezone(&zone).date_naive() == date)+ );+ assert!(+ slots+ .iter()+ .any(|s| s.starts_at == record.booking.starts_at)+ );+ assert!(+ !slots+ .iter()+ .any(|s| s.starts_at == conflict_start - Duration::minutes(30))+ );+}++#[test]+fn visitor_day_bounds_follow_daylight_saving_transitions() {+ let mut schedule = profile(None).schedules.remove(0);+ schedule.time_zone = chrono_tz::America::New_York;+ let (start, end) = day_bounds(&schedule, NaiveDate::from_ymd_opt(2026, 3, 8).unwrap()).unwrap();+ assert_eq!(+ start,+ "2026-03-08T05:00:00Z".parse::<DateTime<Utc>>().unwrap()+ );+ assert_eq!(+ end,+ "2026-03-09T04:00:00Z".parse::<DateTime<Utc>>().unwrap()+ );+ let (start, end) =+ day_bounds(&schedule, NaiveDate::from_ymd_opt(2026, 11, 1).unwrap()).unwrap();+ assert_eq!(+ start,+ "2026-11-01T04:00:00Z".parse::<DateTime<Utc>>().unwrap()+ );+ assert_eq!(+ end,+ "2026-11-02T05:00:00Z".parse::<DateTime<Utc>>().unwrap()+ );+}diff --git a/crates/calendar_scheduling/src/inbound/router.rs b/crates/calendar_scheduling/src/inbound/router.rsindex 83735807b5..3b23497463 100644--- a/crates/calendar_scheduling/src/inbound/router.rs+++ b/crates/calendar_scheduling/src/inbound/router.rs@@ -338,13 +338,13 @@ async fn replacement_slots<>(State(s): State<RouterState<R, C, D, A>>,Path(id): Path<Uuid>,- Query(q): Query<ReplacementQuery>,+ Query(q): Query<SlotQuery>,headers: HeaderMap,) -> Result<Json<SlotsResponse>, ApiError> {Ok(Json(SlotsResponse {slots: s.service- .replacement_slots(id, booking_token(&headers)?, q.date)+ .replacement_slots(id, booking_token(&headers)?, q.date, q.time_zone).await?,}))}diff --git a/docs/agent-guide/calendar.md b/docs/agent-guide/calendar.mdindex b756c1db12..1c8240c5d6 100644--- a/docs/agent-guide/calendar.md+++ b/docs/agent-guide/calendar.md@@ -153,8 +153,10 @@ Uncertain calendar writes retain the booking and show its private receipt whileAfter a network response cannot be verified, `Check booking status` retries the original request;do not create a replacement booking. Receipt pages poll while the calendar update is pending. The private`/app/booking/:id#token` receipt supports cancellation and rescheduling; preserve-that private link. Rescheduling dates are labelled in the availability schedule's-time zone. Calendar provider failures show an error; they never report a+that private link. Rescheduling defaults to the browser's time zone; `Your time+zone` controls both the selected calendar date and the displayed times. Changing+the zone clears the date and times and discards outstanding availability results.+Calendar provider failures show an error; they never report aconfirmed booking. Current integrations check hosts' connected calendars andwrite invitations/Google Meet through the existing calendar service.