Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(calendar): keep event details beside the event when sections load late (#8873)

gbirmanfa67d2ba770d
diff --git a/apps/web/AGENTS.md b/apps/web/AGENTS.md
index 75c3872d5d..0ee6bf1ed9 100644
--- a/apps/web/AGENTS.md
+++ b/apps/web/AGENTS.md
@@ -39,6 +39,13 @@ Composer typeahead menus choosing the side with room for their full list
phone screen and below one near the top, have a backend-free browser regression:
`bunx playwright test --config src/lib/core/component/LexicalMarkdown/directive/browser-test/playwright.config.ts`.
+Event details placement has a backend-free browser regression: the desktop
+popover stays beside its event when join requests arrive after it opens, and
+slides into a short window; the phone drawer shows late requests:
+`bunx playwright test --config src/features/calendar-view/browser-test/playwright.config.ts`.
+Keep the popover's `flip` limited to `left-start`: an end fallback re-places it
+above the event whenever a late section changes its height.
+
Meeting-note creation, linking, optional team access, retry, and unlinking have desktop and
phone browser coverage in `features/calendar-notes`:
`bunx playwright test --config src/features/calendar-notes/browser-test/playwright.config.ts`.
diff --git a/apps/web/src/features/calendar-view/browser-test/event-details.browser.e2e.ts b/apps/web/src/features/calendar-view/browser-test/event-details.browser.e2e.ts
new file mode 100644
index 0000000000..36a7c21027
--- /dev/null
+++ b/apps/web/src/features/calendar-view/browser-test/event-details.browser.e2e.ts
@@ -0,0 +1,126 @@
+import { expect, type Page, test } from '@playwright/test';
+
+const deliverJoinRequests = (page: Page) =>
+ page.evaluate(() => window.calendarPreview.deliverJoinRequests());
+
+async function openDetails(page: Page, query: string) {
+ await page.goto(`/?${query}`);
+ const anchor = page.getByRole('button', {
+ name: 'Planning review',
+ exact: true,
+ });
+ await anchor.click();
+ const details = page.getByRole('dialog', { name: 'Planning review' });
+ await expect(details).toBeVisible();
+ // Kobalte places the popover after it mounts; wait until it is beside the anchor.
+ await expect
+ .poll(async () => (await details.boundingBox())?.x ?? 0)
+ .toBeGreaterThan(((await anchor.boundingBox())?.x ?? 0) + 1);
+ return { anchor, details };
+}
+
+async function box(locator: ReturnType<Page['getByRole']>) {
+ const rect = await locator.boundingBox();
+ if (!rect) throw new Error('Expected a laid-out element');
+ return { ...rect, bottom: rect.y + rect.height };
+}
+
+test.describe('desktop popover', () => {
+ test.skip(({ isMobile }) => isMobile, 'The phone shows a drawer');
+
+ test.describe('tall window', () => {
+ test.use({ viewport: { width: 1280, height: 1000 } });
+
+ test('stays below the event when join requests arrive after opening', async ({
+ page,
+ }) => {
+ const loaded = await openDetails(page, 'requests=loaded');
+ const withRequests = (await box(loaded.details)).height;
+ const pending = await openDetails(page, '');
+ const opened = await box(pending.details);
+ const withoutRequests = opened.height;
+ // Where a start-aligned popover sits relative to its event's top.
+ const startOffset = opened.y - (await box(pending.anchor)).y;
+ expect(withRequests).toBeGreaterThan(withoutRequests + 40);
+
+ // Put the event where the popover fits below it until the requests
+ // arrive, with room above for the whole grown popover.
+ const top = Math.round(1000 - 8 - (withRequests + withoutRequests) / 2);
+ const { anchor, details } = await openDetails(page, `top=${top}`);
+ const event = await box(anchor);
+ expect(event.bottom).toBeGreaterThan(withRequests + 16);
+ const before = await box(details);
+ expect(Math.abs(before.y - event.y - startOffset)).toBeLessThanOrEqual(1);
+
+ await deliverJoinRequests(page);
+ await expect(
+ details.getByRole('region', { name: 'Requests to join' })
+ ).toBeVisible();
+ await expect
+ .poll(async () => Math.abs((await box(details)).height - withRequests))
+ .toBeLessThan(2);
+ const after = await box(details);
+ // It slides up by what no longer fits instead of flipping above the event.
+ expect(before.y - after.y).toBeLessThanOrEqual(
+ after.height - before.height + 1
+ );
+ expect(after.bottom).toBeGreaterThan(event.bottom + 1);
+ expect(after.bottom).toBeLessThanOrEqual(1000);
+ await expect(
+ details.getByRole('button', { name: 'Add as guest', exact: true })
+ ).toBeInViewport({ ratio: 1 });
+ });
+ });
+
+ test.describe('short window', () => {
+ test.use({ viewport: { width: 1280, height: 560 } });
+
+ test('slides the popover into view beside an event near the bottom', async ({
+ page,
+ }) => {
+ const { anchor, details } = await openDetails(
+ page,
+ 'requests=loaded&top=470'
+ );
+ const event = await box(anchor);
+ const popover = await box(details);
+ expect(popover.y).toBeGreaterThanOrEqual(0);
+ expect(popover.bottom).toBeLessThanOrEqual(560);
+ expect(popover.x).toBeGreaterThanOrEqual(event.x + event.width);
+ await expect(
+ details.getByRole('button', { name: 'Close event details' })
+ ).toBeInViewport({ ratio: 1 });
+ await expect(
+ details.getByRole('button', { name: 'Add as guest', exact: true })
+ ).toBeInViewport({ ratio: 1 });
+ });
+ });
+});
+
+test('the phone drawer shows join requests that arrive after it opens', async ({
+ page,
+ isMobile,
+}) => {
+ test.skip(!isMobile, 'Desktop shows a popover');
+ await page.goto('/');
+ await page
+ .getByRole('button', { name: 'Planning review', exact: true })
+ .click();
+ const drawer = page.getByRole('dialog', { name: 'Planning review' });
+ await expect(drawer).toBeVisible();
+ await expect(
+ drawer.getByRole('region', { name: 'Requests to join' })
+ ).toHaveCount(0);
+
+ await deliverJoinRequests(page);
+ const requests = drawer.getByRole('region', { name: 'Requests to join' });
+ await expect(requests).toBeVisible();
+ await requests
+ .getByRole('button', { name: 'Add as guest', exact: true })
+ .click();
+ // The modal drawer hides the page behind it from the accessibility tree.
+ await expect(page.locator('[aria-label="Preview action"]')).toHaveText(
+ 'Invited [email protected]'
+ );
+ await expect(requests).toHaveCount(0);
+});
diff --git a/apps/web/src/features/calendar-view/browser-test/fixture.tsx b/apps/web/src/features/calendar-view/browser-test/fixture.tsx
new file mode 100644
index 0000000000..221207fcd2
--- /dev/null
+++ b/apps/web/src/features/calendar-view/browser-test/fixture.tsx
@@ -0,0 +1,131 @@
+import '@fontsource-variable/inter';
+import '../../../index.css';
+import { Button, ImperativeDialogHost } from '@ui';
+import { createSignal, onCleanup, Show } from 'solid-js';
+import { render } from 'solid-js/web';
+import type { CalendarEvent } from '../../calendar/types';
+import { macroLightTheme } from '../../theme/themes/macro-light';
+import { SelectedEventDetails } from '../components/SelectedEventDetails';
+
+for (const [token, value] of Object.entries(macroLightTheme.colorTokens)) {
+ document.documentElement.style.setProperty(`--color-${token}`, value);
+}
+document.documentElement.dataset.themeLight = 'true';
+
+const params = new URLSearchParams(location.search);
+const calendar = { id: 'calendar-1', name: 'Calendar', color: '#609fe2' };
+const sampleEvent: CalendarEvent = {
+ id: 'planning-review',
+ eventId: 'event-1',
+ occurrenceKey: '2026-10-29T19:00:00Z',
+ title: 'Planning review',
+ start: '2026-10-29T19:00:00Z',
+ end: '2026-10-29T20:00:00Z',
+ allDay: false,
+ isCancelled: false,
+ isReadOnly: false,
+ description: 'Walk through the roadmap and agree on owners.',
+ recurrenceLines: [],
+ guestPolicy: {
+ canModify: false,
+ canInviteOthers: true,
+ canSeeOtherGuests: true,
+ },
+ viewerCan: {
+ editDetails: true,
+ inviteGuests: true,
+ removeGuests: true,
+ setGuestPolicy: true,
+ rsvp: true,
+ organize: true,
+ },
+ attendees: [
+ {
+ email: '[email protected]',
+ isOptional: false,
+ isOrganizer: true,
+ isSelf: true,
+ responseStatus: 'accepted',
+ },
+ {
+ email: '[email protected]',
+ isOptional: false,
+ isOrganizer: false,
+ isSelf: false,
+ responseStatus: 'accepted',
+ },
+ {
+ email: '[email protected]',
+ isOptional: false,
+ isOrganizer: false,
+ isSelf: false,
+ responseStatus: 'needs_action',
+ },
+ ],
+ organizerEmail: '[email protected]',
+ sourceCalendarIds: [calendar.id],
+ calendarId: calendar.id,
+ calendar,
+ visibleCalendars: [calendar],
+};
+
+/** An event the viewer organizes, its chip placed `?top=` px down the page. */
+function Fixture() {
+ const [selected, setSelected] = createSignal(false);
+ const [boundary, setBoundary] = createSignal<HTMLDivElement>();
+ const [anchor, setAnchor] = createSignal<HTMLButtonElement>();
+ const [message, setMessage] = createSignal('');
+ const onMessage = (event: Event) => {
+ if (event instanceof CustomEvent && typeof event.detail === 'string')
+ setMessage(event.detail);
+ };
+ document.addEventListener('calendar-preview-message', onMessage);
+ onCleanup(() =>
+ document.removeEventListener('calendar-preview-message', onMessage)
+ );
+ return (
+ <main
+ ref={setBoundary}
+ class="relative h-dvh overflow-hidden bg-page p-4 text-ink"
+ >
+ <Show when={message()}>
+ <p
+ role="status"
+ aria-label="Preview action"
+ class="text-sm text-ink-muted"
+ >
+ {message()}
+ </p>
+ </Show>
+ <div
+ class="absolute left-[30%] w-40"
+ style={{ top: `${Number(params.get('top') ?? 40)}px` }}
+ >
+ <Button
+ ref={setAnchor}
+ variant="outline"
+ size="md"
+ fullWidth
+ onClick={() => setSelected(true)}
+ >
+ Planning review
+ </Button>
+ </div>
+ <Show when={boundary()}>
+ {(element) => (
+ <SelectedEventDetails
+ boundary={element()}
+ anchor={anchor}
+ event={() => (selected() ? sampleEvent : undefined)}
+ timeFormat={() => '12-hour'}
+ onClose={() => setSelected(false)}
+ />
+ )}
+ </Show>
+ <ImperativeDialogHost />
+ </main>
+ );
+}
+
+const root = document.getElementById('root');
+if (root) render(() => <Fixture />, root);
diff --git a/apps/web/src/features/calendar-view/browser-test/index.html b/apps/web/src/features/calendar-view/browser-test/index.html
new file mode 100644
index 0000000000..423262fb50
--- /dev/null
+++ b/apps/web/src/features/calendar-view/browser-test/index.html
@@ -0,0 +1,5 @@
+<!doctype html>
+<html lang="en" data-modality="keyboard">
+ <head><meta charset="UTF-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><title>Event details</title></head>
+ <body><div id="root"></div><script type="module" src="/fixture.tsx"></script></body>
+</html>
diff --git a/apps/web/src/features/calendar-view/browser-test/playwright.config.ts b/apps/web/src/features/calendar-view/browser-test/playwright.config.ts
new file mode 100644
index 0000000000..f51450d0c0
--- /dev/null
+++ b/apps/web/src/features/calendar-view/browser-test/playwright.config.ts
@@ -0,0 +1,47 @@
+import { fileURLToPath } from 'node:url';
+import { defineConfig, devices } from '@playwright/test';
+
+const directory = fileURLToPath(new URL('.', import.meta.url));
+const webDirectory = fileURLToPath(new URL('../../../../', import.meta.url));
+const port = Number(process.env.CALENDAR_DETAILS_BROWSER_PORT ?? 3096);
+export default defineConfig({
+ testDir: directory,
+ testMatch: '*.browser.e2e.ts',
+ outputDir: `${directory}/test-results`,
+ timeout: 45_000,
+ fullyParallel: true,
+ use: {
+ baseURL: `http://127.0.0.1:${port}`,
+ trace: 'retain-on-failure',
+ screenshot: 'only-on-failure',
+ contextOptions: { reducedMotion: 'reduce' },
+ },
+ webServer: {
+ command: `bunx vite --config src/features/calendar-view/browser-test/vite.config.ts --port ${port}`,
+ cwd: webDirectory,
+ url: `http://127.0.0.1:${port}`,
+ reuseExistingServer: false,
+ timeout: 120_000,
+ },
+ projects: [
+ {
+ name: 'desktop',
+ use: {
+ ...devices['Desktop Chrome'],
+ launchOptions: {
+ executablePath: process.env.PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH,
+ },
+ },
+ },
+ {
+ name: 'phone',
+ use: {
+ ...devices['iPhone 13'],
+ defaultBrowserType: 'chromium',
+ launchOptions: {
+ executablePath: process.env.PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH,
+ },
+ },
+ },
+ ],
+});
diff --git a/apps/web/src/features/calendar-view/browser-test/preview-adapters.tsx b/apps/web/src/features/calendar-view/browser-test/preview-adapters.tsx
new file mode 100644
index 0000000000..dfc94d6574
--- /dev/null
+++ b/apps/web/src/features/calendar-view/browser-test/preview-adapters.tsx
@@ -0,0 +1,148 @@
+import { Avatar } from '@ui';
+import { createSignal } from 'solid-js';
+import { EventAttendeesSection } from '../../calendar/components/EventDetails';
+import type { CalendarEvent } from '../../calendar/types';
+
+export { sanitizeCalendarDescription } from '../../calendar/utils/calendar-description-sanitizer';
+export const parseMacroAppLink = () => undefined;
+export const recipientEntityMapper = () => () => undefined;
+
+// Sample services for the event details overlays. The popover, drawer, and
+// join-requests section render their real UI; the requests arrive when the
+// test calls `window.calendarPreview.deliverJoinRequests()`.
+export type CalendarJoinRequest = {
+ id: string;
+ eventId: string;
+ requesterId: string;
+ requesterEmail: string;
+ status: 'pending' | 'accepted' | 'declined';
+ createdAt: string;
+};
+
+const sampleRequest: CalendarJoinRequest = {
+ id: 'request-1',
+ eventId: 'event-1',
+ requesterId: 'macro|[email protected]',
+ requesterEmail: '[email protected]',
+ status: 'pending',
+ createdAt: '2026-10-22T18:00:00Z',
+};
+
+const [joinRequests, setJoinRequests] = createSignal<
+ CalendarJoinRequest[] | undefined
+>(
+ new URLSearchParams(location.search).get('requests') === 'loaded'
+ ? [sampleRequest]
+ : undefined
+);
+declare global {
+ interface Window {
+ calendarPreview: { deliverJoinRequests: () => void };
+ }
+}
+window.calendarPreview = {
+ deliverJoinRequests: () => setJoinRequests([sampleRequest]),
+};
+
+function announce(message: string) {
+ document.dispatchEvent(
+ new CustomEvent('calendar-preview-message', { detail: message })
+ );
+}
+
+export function useCalendarJoinRequestsQuery(
+ _eventId: () => string,
+ options: () => { enabled: boolean }
+) {
+ return {
+ get isPending() {
+ return !options().enabled || joinRequests() === undefined;
+ },
+ get data() {
+ return joinRequests();
+ },
+ };
+}
+export function useRespondToCalendarJoinRequestMutation(callbacks?: {
+ onSuccess?: (answered: CalendarJoinRequest) => void;
+}) {
+ return {
+ isPending: false,
+ mutate: (args: {
+ request: CalendarJoinRequest;
+ decision: 'accept' | 'decline';
+ }) => {
+ setJoinRequests((current) =>
+ current?.filter((request) => request.id !== args.request.id)
+ );
+ callbacks?.onSuccess?.({
+ ...args.request,
+ status: args.decision === 'accept' ? 'accepted' : 'declined',
+ });
+ },
+ };
+}
+export const isGuestInviteRefused = () => false;
+
+export const useVisibleCalendarsQuery = () => ({ isSuccess: true, data: [] });
+export const useDeleteCalendarEventMutation = () => ({
+ isPending: false,
+ mutate: () => announce('Delete event · Preview only'),
+});
+export const useSplitLayout = () => ({ openWithSplit: () => {} });
+export const useOpenEventComposer = () => () =>
+ announce('Edit event · Preview only');
+export const useForwardEventEmail = () => () =>
+ announce('Forward event · Preview only');
+export const createGuestInviteController = () => ({ editorOpen: () => false });
+export const useCalendarGuestInvitesFlag = () => () => false;
+export const useCalendarMeetingNotesFlag = () => () => false;
+export const CalendarMeetingNotes = () => null;
+export const EventGuests = (props: { event: CalendarEvent }) => (
+ <EventAttendeesSection attendees={props.event.attendees} />
+);
+export const TeamEventDetails = () => null;
+export const OutlookRsvpAction = () => null;
+export const copyCalendarEventMention = () =>
+ announce('Copy event · Preview only');
+export const downloadCalendarEventIcs = () =>
+ announce('Download event · Preview only');
+export const openDocument = () => announce('Open document · Preview only');
+export const toast = { success: announce, failure: announce };
+
+export const createCalendarRsvpController = () => ({
+ pending: () => false,
+ error: () => undefined,
+ scopeOpen: () => false,
+ scope: () => 'this_event',
+ setScope: () => {},
+ closeScope: () => {},
+ confirmScope: () => {},
+ respond: () => announce('RSVP · Preview only'),
+});
+
+const names: Record<string, string> = {
+ 'macro|[email protected]': 'Morgan Member',
+ '[email protected]': 'Alex Morgan',
+ '[email protected]': 'Sam Lee',
+ '[email protected]': 'You',
+};
+export const emailToMacroId = (email: string) => email;
+export const getDisplayName = (id?: string) => names[id ?? ''] ?? '';
+export const getInitialsFromName = (name: string) =>
+ name
+ .split(' ')
+ .map((part) => part[0])
+ .join('');
+export function UserIcon(props: { id?: string; email?: string; size?: 'md' }) {
+ return (
+ <Avatar size={props.size ?? 'md'}>
+ <Avatar.Fallback>
+ {getInitialsFromName(getDisplayName(props.id ?? props.email))}
+ </Avatar.Fallback>
+ </Avatar>
+ );
+}
+export const OwnerLabel = (props: { ownerId: string }) => (
+ <span class="text-ink">{getDisplayName(props.ownerId)}</span>
+);
diff --git a/apps/web/src/features/calendar-view/browser-test/vite.config.ts b/apps/web/src/features/calendar-view/browser-test/vite.config.ts
new file mode 100644
index 0000000000..2398a3e960
--- /dev/null
+++ b/apps/web/src/features/calendar-view/browser-test/vite.config.ts
@@ -0,0 +1,63 @@
+import { fileURLToPath } from 'node:url';
+import tailwind from '@tailwindcss/vite';
+import { defineConfig } from 'vite';
+import solidPlugin from 'vite-plugin-solid';
+import solidSvg from 'vite-plugin-solid-svg';
+import tsconfigPaths from 'vite-tsconfig-paths';
+
+const directory = fileURLToPath(new URL('.', import.meta.url));
+const webDirectory = fileURLToPath(new URL('../../../../', import.meta.url));
+const workspaceDirectory = fileURLToPath(
+ new URL('../../../../../../', import.meta.url)
+);
+
+const previewAdapters = `${directory}/preview-adapters.tsx`;
+const previewImports = [
+ '@queries/calendar/calendars',
+ '@queries/calendar/join-requests',
+ '@queries/calendar/mutations',
+ '@components/app/split-layout/layout',
+ '@app/features/calendar-view/components/use-open-event-composer',
+ '@app/features/calendar-view/components/use-forward-event-email',
+ '@app/features/calendar/hooks/create-guest-invite-controller',
+ '@app/features/calendar/hooks/use-calendar-ui-flag',
+ '@app/features/calendar-notes/calendar-meeting-notes',
+ '@app/features/calendar-view/components/EventGuests',
+ '@app/features/calendar-team/components/team-event-details',
+ '@app/features/calendar/views/event-replacement',
+ '@app/features/calendar-view/copy-event-mention',
+ '@app/features/calendar-view/download-event-ics',
+ '@core/component/LexicalMarkdown/component/core/BlockLink',
+ '@core/component/UserIcon',
+ '@core/component/Toast/Toast',
+ '@core/user/combinedRecipient',
+ '@core/user',
+ '@entity/owner/owner-display',
+ '../utils/calendar-description',
+ '../../calendar/hooks/create-calendar-rsvp-controller',
+];
+
+/** The real event details popover and drawer, with sample data and preview services. */
+export default defineConfig({
+ root: directory,
+ cacheDir: `${directory}/.vite`,
+ plugins: [
+ solidPlugin(),
+ solidSvg({ defaultAsComponent: true }),
+ tsconfigPaths({ projects: [`${webDirectory}/tsconfig.json`] }),
+ tailwind(),
+ ],
+ resolve: {
+ dedupe: ['solid-js'],
+ alias: previewImports.map((find) => ({
+ find,
+ replacement: previewAdapters,
+ })),
+ },
+ server: {
+ host: '127.0.0.1',
+ port: 3096,
+ strictPort: true,
+ fs: { allow: [workspaceDirectory] },
+ },
+});
diff --git a/apps/web/src/features/calendar-view/components/SelectedEventDetails.tsx b/apps/web/src/features/calendar-view/components/SelectedEventDetails.tsx
index e108a678a4..eb8c0b581c 100644
--- a/apps/web/src/features/calendar-view/components/SelectedEventDetails.tsx
+++ b/apps/web/src/features/calendar-view/components/SelectedEventDetails.tsx
@@ -529,7 +529,11 @@ function EventDetailsPopover(props: EventDetailsPopoverProps) {
}}
placement="right-start"
gutter={8}
- flip
+ // Flip only to the other side, never to an end alignment: sections
+ // that arrive after opening (join requests, meeting notes) change the
+ // height, and an end fallback would re-place the popover from below
+ // the event to above it. Slide keeps a tall popover in view instead.
+ flip="left-start"
slide
overlap
fitViewport
diff --git a/docs/agent-guide/calendar.md b/docs/agent-guide/calendar.md
index 330d12cd43..c34e0dbf13 100644
--- a/docs/agent-guide/calendar.md
+++ b/docs/agent-guide/calendar.md
@@ -535,6 +535,13 @@ switches the open details.
Desktop event details stay inside the visible calendar grid, including Home
previews and narrow splits. They overlap wide Day-view events when needed and
shrink to fit the pane; long details scroll while the RSVP row stays visible.
+As in Google Calendar, the popover opens beside the event, aligned with its top,
+and switches only between the right and left side; when it doesn't fit below,
+it slides up to stay in the window instead of opening above the event. Sections
+that load after it opens (join requests, meeting notes) therefore never move it
+from below the event to above it. Check placement with an event low in a tall
+window, a short window, and a pending join request; the backend-free regression
+is `apps/web/src/features/calendar-view/browser-test/playwright.config.ts`.
The `New event` composer (also opened by dragging a range on the grid) has an `Event kind`
pill choosing between `Event` and `Out of office`. Picking `Out of office` hides the guests,