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): toggle the team out-of-office overlay with a checkbox (#8149)
gbirmanaaaa2dfbb5bd
diff --git a/apps/web/src/features/calendar-view/components/CalendarSidebar.tsx b/apps/web/src/features/calendar-view/components/CalendarSidebar.tsxindex 33f5996889..44139a3d31 100644--- a/apps/web/src/features/calendar-view/components/CalendarSidebar.tsx+++ b/apps/web/src/features/calendar-view/components/CalendarSidebar.tsx@@ -13,6 +13,7 @@ import {useHasTeammates,useUpcomingTeamOoo,} from '@app/features/calendar/hooks/use-team-ooo';+import { TEAM_OOO_SOURCE_ID } from '@app/features/calendar/types';import { ShowFeatureFlag } from '@app/lib/analytics/posthog';import { UserIcon } from '@core/component/UserIcon';import { enableCalendarTeamOoo } from '@core/constant/featureFlags';@@ -20,7 +21,7 @@ import { isTouchDevice } from '@core/mobile/isTouchDevice';import CaretDownIcon from '@phosphor/caret-down.svg';import PlusIcon from '@phosphor/plus.svg';import CloseIcon from '@phosphor/x.svg';-import { cn, Calendar as MiniCalendar } from '@ui';+import { Checkbox, cn, Calendar as MiniCalendar } from '@ui';import { tourTarget } from '@ui/components/Tour';import { format } from 'date-fns';import {@@ -233,16 +234,34 @@ function TeamOooUpcomingList() {}function CalendarTeamOooSection() {+ const calendarView = useCalendarView();const hasTeammates = useHasTeammates();const [open, setOpen] = createSignal(true);return (<Show when={hasTeammates()}><CollapsibleSection.Root open={open()} onOpenChange={setOpen}>- <CollapsibleSection.Trigger>- <span class="min-w-0 truncate">Team out of office</span>- <CollapsibleSection.Indicator />- </CollapsibleSection.Trigger>+ <CollapsibleSection.Header>+ <Checkbox+ checked={calendarView.isSourceVisible(TEAM_OOO_SOURCE_ID)}+ onChange={(visible) =>+ calendarView.setSourceVisibility(TEAM_OOO_SOURCE_ID, visible)+ }+ title="Show on calendar"+ class="h-full shrink-0 pr-1 pl-(--sidebar-item-inset)"+ >+ <Checkbox.Control class="size-3.5 [&_svg]:size-2.5" />+ <Checkbox.Label class="absolute inset-0">+ <span class="sr-only">+ Show team out of office on the calendar+ </span>+ </Checkbox.Label>+ </Checkbox>+ <CollapsibleSection.Trigger class="min-w-0 flex-1 pl-1">+ <span class="min-w-0 truncate">Team out of office</span>+ <CollapsibleSection.Indicator />+ </CollapsibleSection.Trigger>+ </CollapsibleSection.Header><CollapsibleSection.Content><TeamOooUpcomingList /></CollapsibleSection.Content>diff --git a/apps/web/src/features/calendar-view/components/Page.tsx b/apps/web/src/features/calendar-view/components/Page.tsxindex da2b4c551e..10399bd45b 100644--- a/apps/web/src/features/calendar-view/components/Page.tsx+++ b/apps/web/src/features/calendar-view/components/Page.tsx@@ -233,6 +233,7 @@ export function Page(props: {});const teamOoo = useTeamOooEvents({range,+ isSourceVisible: isRenderedSourceVisible,refetchOnWindowFocus: isActive,});const visibleEvents = createMemo(() =>diff --git a/apps/web/src/features/calendar/hooks/use-team-ooo.test.tsx b/apps/web/src/features/calendar/hooks/use-team-ooo.test.tsxnew file mode 100644index 0000000000..72b3592705--- /dev/null+++ b/apps/web/src/features/calendar/hooks/use-team-ooo.test.tsx@@ -0,0 +1,117 @@+import {+ type CalendarOccurrenceQueryRange,+ createCalendarOccurrenceQueryRange,+} from '@queries/calendar/occurrences';+import type {+ TeamOutOfOfficeQueryInput,+ TeamOutOfOfficeQueryOptions,+} from '@queries/calendar/team-ooo';+import type { TeamOutOfOfficeItem } from '@service-storage/generated/schemas/teamOutOfOfficeItem';+import { cleanup, render, screen, waitFor } from '@solidjs/testing-library';+import {+ QueryClient,+ QueryClientProvider,+ useQuery,+} from '@tanstack/solid-query';+import { type Accessor, createSignal, For, Suspense } from 'solid-js';+import { afterEach, describe, expect, it, vi } from 'vitest';+import { TEAM_OOO_SOURCE_ID } from '../types';+import { useTeamOooEvents } from './use-team-ooo';++const requests = vi.hoisted(() => ({+ teamOoo: vi.fn<() => Promise<TeamOutOfOfficeItem[]>>(),+}));++vi.mock('@core/context/user', () => ({+ useUserId: () => () => 'user',+}));+vi.mock('@core/user', () => ({+ getDisplayName: () => 'Ada',+ tryMacroId: (id: string) => id,+}));+vi.mock('@queries/team/teams', () => ({+ useCurrentTeamQuery: () => ({ isSuccess: false }),+}));+vi.mock('./use-calendar-ui-flag', () => ({+ useCalendarTeamOooFlag: () => () => true,+}));+vi.mock('@queries/calendar/team-ooo', () => ({+ useTeamOutOfOfficeQuery: (+ input: Accessor<TeamOutOfOfficeQueryInput>,+ options?: Accessor<TeamOutOfOfficeQueryOptions>+ ) =>+ useQuery(() => ({+ queryKey: ['team-ooo', input().userId, input().range],+ queryFn: requests.teamOoo,+ enabled: options?.().enabled !== false,+ })),+}));++afterEach(() => {+ cleanup();+ requests.teamOoo.mockReset();+});++function vacation(range: CalendarOccurrenceQueryRange): TeamOutOfOfficeItem {+ return {+ eventId: 'vacation',+ occurrenceKey: range.startDate,+ ownerId: 'teammate',+ title: 'Vacation',+ time: {+ kind: 'allDay',+ startDate: range.startDate,+ endDate: range.endDate,+ },+ };+}++function TeamOooTitles(props: {+ range: CalendarOccurrenceQueryRange;+ hiddenSourceIds: Accessor<ReadonlySet<string>>;+}) {+ const teamOoo = useTeamOooEvents({+ range: () => props.range,+ isSourceVisible: (sourceId) => !props.hiddenSourceIds().has(sourceId),+ });+ return (+ <ul>+ <For each={teamOoo.events()}>{(event) => <li>{event.title}</li>}</For>+ </ul>+ );+}++describe('useTeamOooEvents', () => {+ it('drops the overlay and skips the request while team out of office is hidden', async () => {+ const start = new Date();+ start.setHours(0, 0, 0, 0);+ const end = new Date(start);+ end.setDate(end.getDate() + 7);+ const range = createCalendarOccurrenceQueryRange(start, end);+ requests.teamOoo.mockResolvedValue([vacation(range)]);+ const [hiddenSourceIds, setHiddenSourceIds] = createSignal<+ ReadonlySet<string>+ >(new Set([TEAM_OOO_SOURCE_ID]));+ const client = new QueryClient({+ defaultOptions: { queries: { retry: false } },+ });++ render(() => (+ <QueryClientProvider client={client}>+ <Suspense>+ <TeamOooTitles range={range} hiddenSourceIds={hiddenSourceIds} />+ </Suspense>+ </QueryClientProvider>+ ));++ await Promise.resolve();+ expect(requests.teamOoo).not.toHaveBeenCalled();+ expect(screen.queryByText('Ada: Vacation')).toBeNull();++ setHiddenSourceIds(new Set<string>());+ expect(await screen.findByText('Ada: Vacation')).toBeTruthy();++ setHiddenSourceIds(new Set([TEAM_OOO_SOURCE_ID]));+ await waitFor(() => expect(screen.queryByText('Ada: Vacation')).toBeNull());+ });+});diff --git a/apps/web/src/features/calendar/hooks/use-team-ooo.ts b/apps/web/src/features/calendar/hooks/use-team-ooo.tsindex f2c3550bb6..8cc8ffccb9 100644--- a/apps/web/src/features/calendar/hooks/use-team-ooo.ts+++ b/apps/web/src/features/calendar/hooks/use-team-ooo.ts@@ -80,6 +80,7 @@ export interface TeamOooEventData {export interface TeamOooEventOptions {range: Accessor<CalendarOccurrenceQueryRange | undefined>;+ isSourceVisible?: (sourceId: string) => boolean;refetchOnWindowFocus?: Accessor<boolean>;}@@ -93,10 +94,12 @@ export function useTeamOooEvents(const range = options.range();return range !== undefined && isCalendarRangeSupported(range);});+ const isOverlayVisible = () =>+ teamOooEnabled() && options.isSourceVisible?.(TEAM_OOO_SOURCE_ID) !== false;const query = useTeamOutOfOfficeQuery(() => ({ userId: userId(), range: options.range() }),() => ({- enabled: isRangeSupported() && teamOooEnabled(),+ enabled: isRangeSupported() && isOverlayVisible(),refetchOnWindowFocus: options.refetchOnWindowFocus?.(),}));@@ -104,7 +107,7 @@ export function useTeamOooEvents(// Pending reads suspend, and placeholder data belongs to the previous// range. Neither can supply events for the current viewport.if (- !teamOooEnabled() ||+ !isOverlayVisible() ||!isRangeSupported() ||!query.isSuccess ||query.isPaused ||diff --git a/apps/web/src/features/calendar/types.ts b/apps/web/src/features/calendar/types.tsindex 7b79f55b75..399ed426ec 100644--- a/apps/web/src/features/calendar/types.ts+++ b/apps/web/src/features/calendar/types.ts@@ -134,7 +134,7 @@ export interface CalendarEvent {description?: string;}-/** Source id every teammate out-of-office event carries; it is always shown. */+/** Source id every teammate out-of-office event carries; hiding it hides the overlay. */export const TEAM_OOO_SOURCE_ID = 'team-ooo';/** Shared presentation source until calendar/account metadata is exposed. */diff --git a/apps/web/src/features/calendar/utils/preferences.test.ts b/apps/web/src/features/calendar/utils/preferences.test.tsindex bdfbc7c6ae..6d10037fe9 100644--- a/apps/web/src/features/calendar/utils/preferences.test.ts+++ b/apps/web/src/features/calendar/utils/preferences.test.ts@@ -8,7 +8,7 @@ afterEach(() => {});describe('calendar preferences', () => {- it('drops a saved team out-of-office hide now that it has no switch', async () => {+ it('keeps a saved team out-of-office hide across reloads', async () => {localStorage.setItem(CALENDAR_PREFERENCES_KEY,JSON.stringify({ hiddenSourceIds: ['team-ooo', 'holidays'] })@@ -22,6 +22,6 @@ describe('calendar preferences', () => {return ids;});- expect(hidden).toEqual(['holidays']);+ expect(hidden).toEqual(['team-ooo', 'holidays']);});});diff --git a/apps/web/src/features/calendar/utils/preferences.ts b/apps/web/src/features/calendar/utils/preferences.tsindex b01451149c..6f7551e034 100644--- a/apps/web/src/features/calendar/utils/preferences.ts+++ b/apps/web/src/features/calendar/utils/preferences.ts@@ -5,11 +5,10 @@ import {CALENDAR_PREFERENCES_KEY,getPreferredCalendarPeriodView,} from '../calendar-preferences';-import {- type CalendarPeriodView,- type CalendarTimeFormat,- type CalendarWeekStart,- TEAM_OOO_SOURCE_ID,+import type {+ CalendarPeriodView,+ CalendarTimeFormat,+ CalendarWeekStart,} from '../types';import { getDefaultCalendarTimeFormat } from './time-format';@@ -38,18 +37,10 @@ export const useCalendarPreferences = createSharedRoot(() => {createStore<CalendarPreferences>(defaultPreferences),{name: CALENDAR_PREFERENCES_KEY,- deserialize: (value) => {- const stored = JSON.parse(value) as Partial<CalendarPreferences>;- return {- ...defaultPreferences,- ...stored,- // Team out of office has no off switch; an older saved hide would- // otherwise keep it off for good.- hiddenSourceIds: (stored.hiddenSourceIds ?? []).filter(- (id) => id !== TEAM_OOO_SOURCE_ID- ),- };- },+ deserialize: (value) => ({+ ...defaultPreferences,+ ...(JSON.parse(value) as Partial<CalendarPreferences>),+ }),});return [preferences, setPreferences] as const;diff --git a/apps/web/tests/calendar-team/README.md b/apps/web/tests/calendar-team/README.mdindex 6ba7fa9ac3..43af65f18b 100644--- a/apps/web/tests/calendar-team/README.md+++ b/apps/web/tests/calendar-team/README.md@@ -2,7 +2,7 @@This harness loads the complete bundled app and intercepts auth, team, and calendar HTTP traffic with synthetic identities. It blocks nonlocal requests and websocket traffic. It does not verify the Rust service or Google permissions. Own-calendar reads use the existing REST fallback.-It uses a live clock and checks that loading placeholders disappear before capture. It checks that no surface reads teammate calendars or shows team calendar controls, and exercises the Team sharing select and the account-grouped "Calendars that count as busy" list, failing if any change flashes a loading state.+It uses a live clock and checks that loading placeholders disappear before capture. It checks that no surface reads teammate calendars or shows team calendar controls, that the `Team out of office` checkbox hides and restores a teammate's out-of-office chip while the sidebar keeps listing it, and exercises the Team sharing select and the account-grouped "Calendars that count as busy" list, failing if any change flashes a loading state.Imported own point events must render compactly with a single time,without drag/resize. Editing the point's title must omit time from its request.diff --git a/apps/web/tests/calendar-team/browser.ts b/apps/web/tests/calendar-team/browser.tsindex f83319fa93..900d37bf9e 100644--- a/apps/web/tests/calendar-team/browser.ts+++ b/apps/web/tests/calendar-team/browser.ts@@ -93,6 +93,16 @@ const ownPoint = {time: pointTime(11),},};+const nextDate = new Date(Date.parse(fixtureDate) + 86_400_000)+ .toISOString()+ .slice(0, 10);+// Busy-only sharing withholds the title, so the chip falls back to "Out of office".+const bobOutOfOffice = {+ eventId: '00000000-0000-0000-0000-000000009002',+ occurrenceKey: fixtureDate,+ ownerId: BOB,+ time: { kind: 'allDay', startDate: fixtureDate, endDate: nextDate },+};await page.route('**/*', async (route) => {const request = route.request();const url = new URL(request.url());@@ -198,7 +208,7 @@ await page.route('**/*', async (route) => {return respond({}, 404);}if (path === '/dss/calendar-events/team-out-of-office')- return respond({ items: [], hasMore: false });+ return respond({ items: [bobOutOfOffice], hasMore: false });if (path === `/calendar/events/${ownPoint.event.id}` &&request.method() === 'PATCH'@@ -355,6 +365,38 @@ try {await page.keyboard.press('Escape');mutations.length = 0;+ // The section checkbox hides only the grid overlay; the list keeps the row.+ const teamOooToggle = sidebar.getByRole('checkbox', {+ name: 'Show team out of office on the calendar',+ });+ const teamOooChip = activeCalendar.getByText('Bob Fixture: Out of office', {+ exact: true,+ });+ const teamOooRow = sidebar.getByRole('button', { name: /Bob Fixture/ });+ await expect(teamOooToggle).toBeChecked();+ await expect(teamOooChip).toBeVisible();+ await expect(teamOooRow).toBeVisible();+ await sidebar.getByTitle('Show on calendar').click();+ await expect(teamOooToggle).not.toBeChecked();+ await expect(teamOooChip).toHaveCount(0);+ await expect(teamOooRow).toBeVisible();+ assert.deepEqual(+ await page.evaluate(+ () =>+ JSON.parse(localStorage.getItem('macro:pref:calendar:settings') ?? '{}')+ .hiddenSourceIds+ ),+ ['team-ooo'],+ 'Hiding team out of office must persist with calendar visibility'+ );+ await page.screenshot({+ path: '/tmp/calendar-team-ooo-hidden.png',+ fullPage: true,+ });+ await sidebar.getByTitle('Show on calendar').click();+ await expect(teamOooToggle).toBeChecked();+ await expect(teamOooChip).toBeVisible();+await page.goto(`${origin}/app/settings/calendar`, {waitUntil: 'domcontentloaded',});@@ -444,7 +486,7 @@ try {assert.deepEqual(errors, []);assert.deepEqual(requestFailures, []);console.log(- 'PASS: imported point rendering and metadata-only edit, no team calendar overlay or controls, team sharing select, account-grouped busy calendars, and settings changes without a loading flash'+ 'PASS: imported point rendering and metadata-only edit, team out-of-office overlay checkbox, no team calendar overlay or controls, team sharing select, account-grouped busy calendars, and settings changes without a loading flash');} catch (error) {console.error(error);diff --git a/docs/agent-guide/calendar.md b/docs/agent-guide/calendar.mdindex ad101a5226..9f057ce8a6 100644--- a/docs/agent-guide/calendar.md+++ b/docs/agent-guide/calendar.md@@ -205,8 +205,10 @@ Collapsible `Upcoming events` and `Calendars` sections follow; calendaraccount rows use Drive-style trailing disclosure buttons and animated nestedbranches. Their 14px visibility checkboxes precede the swatch and label, withseparate account and individual-calendar visibility controls. `Team out of office`-is feature-gated and lists teammates with 24px avatars; it is a plain-collapsible section, and the grid overlay always shows. Clicking a teammate's row navigates to that+is feature-gated and lists teammates with 24px avatars; its header has the same+14px checkbox before the title, which shows or hides the grid overlay and is saved+with the calendar visibility preferences. The teammate rows have no checkboxes and+stay listed while the overlay is hidden. Clicking a teammate's row navigates to thatdate, opens read-only event details, and marks the row active. The icon-only`Calendar settings` control fills the sidebar footer.An account checkbox toggles its calendars together in one update. The checkbox@@ -440,9 +442,9 @@ touch devices — and is hidden when you are the only guest.With the `enable-calendar-team-ooo` flag on, teammates' Google Calendar out-of-office eventsoverlay the grid as read-only chips titled `<name>: <event title>`. The sidebar's`Team out of office` section (shown only when the user belongs to a team with other members)-is a collapsible list of the next 90 days of teammate absences, with no switch: the overlay-always shows; clicking a row navigates the grid to-that date. Coverage depends on each teammate having connected their own calendar and using+is a collapsible list of the next 90 days of teammate absences. The checkbox in its header+shows or hides the overlay (the list itself always shows); clicking a row navigates the grid+to that date. Coverage depends on each teammate having connected their own calendar and usingGoogle's out-of-office event type.A calendar event mentioned in a channel message opens the calendar focused on the viewer's