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): distinguish failed team OOO fetch from empty result (#6182)
gbirman1773d769b00c
diff --git a/apps/web/src/features/block-calendar/components/SidePanelSections.tsx b/apps/web/src/features/block-calendar/components/SidePanelSections.tsxindex 7dab09d6de..0129e694db 100644--- a/apps/web/src/features/block-calendar/components/SidePanelSections.tsx+++ b/apps/web/src/features/block-calendar/components/SidePanelSections.tsx@@ -16,8 +16,10 @@ import {createMemo,createSignal,For,+ Match,on,Show,+ Switch,} from 'solid-js';function CalendarMiniCalendarSidePanelSection() {@@ -153,49 +155,70 @@ function windowDateLabel(window: TeamOooWindow): string {: `${format(window.start, 'MMM d')} – ${format(lastDay, 'MMM d')}`;}+function TeamOooSkeleton() {+ return (+ <div aria-hidden="true" class="flex flex-col gap-0.5">+ <For each={[0, 1, 2]}>+ {() => (+ <div class="skeleton-shimmer h-8 w-full rounded-lg bg-skeleton" />+ )}+ </For>+ </div>+ );+}+function TeamOooUpcomingList() {const calendarPager = useCalendarPager();- const windows = useUpcomingTeamOoo();+ const upcoming = useUpcomingTeamOoo();+ const windows = upcoming.windows;return (<div class="flex flex-col gap-0.5">- <Show- when={windows().length > 0}- fallback={+ <Switch>+ <Match when={upcoming.isPending()}>+ <TeamOooSkeleton />+ </Match>+ <Match when={upcoming.isError()}><span class="px-2 py-1 text-xs text-ink-muted">- No time off in the next 90 days+ Couldn't load time off</span>- }- >- <For each={windows().slice(0, UPCOMING_SHOWN_MAX)}>- {(window) => (- <button- type="button"- class="flex w-full flex-col rounded-lg px-2 py-1.5 text-left text-xs hover:bg-hover"- onClick={() => calendarPager.gotoDate(window.start)}- >- <span class="flex w-full items-baseline gap-2">- <span class="min-w-0 flex-1 truncate text-ink">- {window.name}- </span>- <span class="shrink-0 text-ink-muted">- {windowDateLabel(window)}- </span>- </span>- <Show when={window.title}>- <span class="w-full truncate text-ink-muted">- {window.title}- </span>- </Show>- </button>- )}- </For>- <Show when={windows().length > UPCOMING_SHOWN_MAX}>+ </Match>+ <Match when={windows().length === 0}><span class="px-2 py-1 text-xs text-ink-muted">- +{windows().length - UPCOMING_SHOWN_MAX} more+ No time off in the next 90 days</span>- </Show>- </Show>+ </Match>+ <Match when={windows().length > 0}>+ <For each={windows().slice(0, UPCOMING_SHOWN_MAX)}>+ {(window) => (+ <button+ type="button"+ class="flex w-full flex-col rounded-lg px-2 py-1.5 text-left text-xs hover:bg-hover"+ onClick={() => calendarPager.gotoDate(window.start)}+ >+ <span class="flex w-full items-baseline gap-2">+ <span class="min-w-0 flex-1 truncate text-ink">+ {window.name}+ </span>+ <span class="shrink-0 text-ink-muted">+ {windowDateLabel(window)}+ </span>+ </span>+ <Show when={window.title}>+ <span class="w-full truncate text-ink-muted">+ {window.title}+ </span>+ </Show>+ </button>+ )}+ </For>+ <Show when={windows().length > UPCOMING_SHOWN_MAX}>+ <span class="px-2 py-1 text-xs text-ink-muted">+ +{windows().length - UPCOMING_SHOWN_MAX} more+ </span>+ </Show>+ </Match>+ </Switch></div>);}diff --git a/apps/web/src/features/calendar/hooks/use-team-ooo.ts b/apps/web/src/features/calendar/hooks/use-team-ooo.tsindex 9e1e5ea02d..4c01cd9883 100644--- a/apps/web/src/features/calendar/hooks/use-team-ooo.ts+++ b/apps/web/src/features/calendar/hooks/use-team-ooo.ts@@ -99,8 +99,11 @@ export function useTeamOooEvents(}));const events = createMemo(() => {- if (!isRangeSupported()) return [];- return (query.data ?? []).map(mapTeamOooItem);+ // Read data only on success: a failed overlay fetch degrades to no events+ // since the grid's own state is driven by the occurrences query, and gating+ // on success keeps this off the pending/errored resource read that suspends.+ if (!isRangeSupported() || !query.isSuccess) return [];+ return query.data.map(mapTeamOooItem);});const visibleEvents = createMemo(() => (isOverlayVisible() ? events() : []));const eventsById = createMemo(@@ -127,8 +130,17 @@ export interface TeamOooWindow {const UPCOMING_TEAM_OOO_DAYS = 90;+/** Upcoming team out-of-office windows with the request's load/error status. */+export interface UpcomingTeamOoo {+ windows: Accessor<TeamOooWindow[]>;+ /** No settled result yet, distinguishing first load from an empty result. */+ isPending: Accessor<boolean>;+ /** The request failed, distinguishing an error from an empty result. */+ isError: Accessor<boolean>;+}+/** Teammates' out-of-office windows from today forward, soonest first. */-export function useUpcomingTeamOoo(): Accessor<TeamOooWindow[]> {+export function useUpcomingTeamOoo(): UpcomingTeamOoo {const userId = useUserId();const rangeStart = new Date();rangeStart.setHours(0, 0, 0, 0);@@ -137,8 +149,11 @@ export function useUpcomingTeamOoo(): Accessor<TeamOooWindow[]> {const range = createCalendarOccurrenceQueryRange(rangeStart, rangeEnd);const query = useTeamOutOfOfficeQuery(() => ({ userId: userId(), range }));- return createMemo(() =>- (query.data ?? []).map((item) => {+ const windows = createMemo<TeamOooWindow[]>(() => {+ // Read data only on success so a pending query never hits the suspending+ // resource read and an errored refetch never surfaces stale rows.+ if (!query.isSuccess) return [];+ return query.data.map((item) => {const time = item.time;const [start, end, allDay] =time.kind === 'timed'@@ -154,6 +169,12 @@ export function useUpcomingTeamOoo(): Accessor<TeamOooWindow[]> {end,allDay,};- })- );+ });+ });++ return {+ windows,+ isPending: () => query.isPending,+ isError: () => query.isError,+ };}