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): cache meeting notes and reflect inherited team access (#8876)
gbirmancc945affd33f
diff --git a/apps/web/AGENTS.md b/apps/web/AGENTS.mdindex 3d01d0b7df..4503213faf 100644--- a/apps/web/AGENTS.md+++ b/apps/web/AGENTS.md@@ -47,9 +47,17 @@ sample data; keep notes aligned with those existing surfaces and preserve theirdialog open guards. Open the existing document Share dialog for note access,keep labeled Options controls visible beside truncated titles without redundanthover tooltips, and use existing team memberships for optional note sharing.+Keep meeting-note reads cached across event opens, show cached Quick Access+matches while note searches refresh, and keep event actions usable while notes+load. Show meeting-derived team viewing in the document's Team access summary;+keep it distinct from additional direct sharing and keep Unlink stable while+team access saves.Include linked meetings in Markdown side-panel References, behind the same flag;reuse the shared single-line ReferenceRow with the title and date inline, andresolve meeting details and opening targets through authorized calendar previews.+Treat missing reference projection fields during backend rollout as unresolved,+not denied; offer Retry on the links query without bypassing the server's+reference authorization.Gate event notes and document Share meeting-link controls with`enable-calendar-meeting-notes` before mounting their query sources; it defaultson in dev and uses PostHog in production.diff --git a/apps/web/src/features/block-md/component/sidepanel/MarkdownReferencesSection.tsx b/apps/web/src/features/block-md/component/sidepanel/MarkdownReferencesSection.tsxindex 408fcc9420..139b81a710 100644--- a/apps/web/src/features/block-md/component/sidepanel/MarkdownReferencesSection.tsx+++ b/apps/web/src/features/block-md/component/sidepanel/MarkdownReferencesSection.tsx@@ -85,6 +85,7 @@ function ReferencesSection(props: {<MeetingReferencedocumentId={props.documentId}link={link}+ onRetry={props.onRetry}onOpenCalendar={() => {if (isMobile()) sidePanel?.setIsOpen(false);}}diff --git a/apps/web/src/features/calendar-notes/calendar-meeting-notes.tsx b/apps/web/src/features/calendar-notes/calendar-meeting-notes.tsxindex a27e26e589..e3e23aa677 100644--- a/apps/web/src/features/calendar-notes/calendar-meeting-notes.tsx+++ b/apps/web/src/features/calendar-notes/calendar-meeting-notes.tsx@@ -1,11 +1,16 @@import { Permissions } from '@core/component/SharePermissions';-import { ShareModal } from '@core/component/TopBar/ShareButton';+import { useQuickAccess } from '@core/context/quickAccess';import { useUserId } from '@core/context/user';-import { Show, Suspense } from 'solid-js';+import { lazy, Show, Suspense } from 'solid-js';import type { CalendarEvent } from '../calendar/types';+import { createLocalNoteSearch } from './queries/local-note-search';import { createNotesSource } from './queries/notes-source';import { MeetingNotesView } from './views/meeting-notes';+const ShareModal = lazy(async () => ({+ default: (await import('@core/component/TopBar/ShareButton')).ShareModal,+}));+/** App composition; the view and controller also mount without calendar chrome. */export function CalendarMeetingNotes(props: {event: CalendarEvent;@@ -13,10 +18,15 @@ export function CalendarMeetingNotes(props: {onDialogChange: (open: boolean) => void;}) {const userId = useUserId();- const source = createNotesSource(userId, () => ({- eventId: props.event.eventId,- occurrenceKey: props.event.occurrenceKey,- }));+ const localSearch = createLocalNoteSearch(useQuickAccess(), userId);+ const source = createNotesSource(+ userId,+ () => ({+ eventId: props.event.eventId,+ occurrenceKey: props.event.occurrenceKey,+ }),+ localSearch+ );return (<Suspense><Showdiff --git a/apps/web/src/features/calendar-notes/components/document-notes-section.tsx b/apps/web/src/features/calendar-notes/components/document-notes-section.tsxindex d1f71e942d..bf51ef7f5e 100644--- a/apps/web/src/features/calendar-notes/components/document-notes-section.tsx+++ b/apps/web/src/features/calendar-notes/components/document-notes-section.tsx@@ -1,6 +1,7 @@import CalendarIcon from '@icon/system/regular/calendar-blank.svg';+import { Key } from '@solid-primitives/keyed';import { Button, Checkbox } from '@ui';-import { For, Show } from 'solid-js';+import { Show } from 'solid-js';import type { DocumentNoteLink, NoteRead, NoteTeam } from '../core/types';export function DocumentNotesSection(props: {@@ -8,6 +9,7 @@ export function DocumentNotesSection(props: {team: NoteRead<NoteTeam | null>;selected?: DocumentNoteLink;saving: boolean;+ removing: boolean;error?: string;onSelect: (link: DocumentNoteLink | undefined) => void;onRemove: () => void;@@ -49,25 +51,28 @@ export function DocumentNotesSection(props: {{props.error}</p></Show>- <For each={props.state.data}>+ <Key+ each={props.state.data}+ by={(link) => JSON.stringify([link.eventId, link.occurrenceKey])}+ >{(link) => (<div class="mt-3 rounded-xl border border-edge-muted p-3"><div class="flex items-start gap-3"><CalendarIcon class="mt-0.5 size-4 shrink-0 text-ink-muted" /><div class="min-w-0 flex-1">- <p class="truncate font-medium">{link.eventTitle}</p>+ <p class="truncate font-medium">{link().eventTitle}</p><p class="mt-1 text-xs text-ink-muted">- {link.occurrenceKey === 'single'+ {link().occurrenceKey === 'single'? 'One-time meeting'- : link.occurrenceKey.slice(0, 10)}{' '}+ : link().occurrenceKey.slice(0, 10)}{' '}· Can view</p></div><Buttonvariant="ghost"size="sm"- disabled={props.saving}- onClick={() => props.onSelect(link)}+ disabled={props.removing}+ onClick={() => props.onSelect(link())}>Unlink</Button>@@ -75,10 +80,10 @@ export function DocumentNotesSection(props: {<Show when={props.team.data}>{(team) => (<Checkbox- checked={link.team?.id === team().id}+ checked={link().team?.id === team().id}disabled={props.saving}onChange={(checked) =>- props.onTeam(link, checked ? team().id : undefined)+ props.onTeam(link(), checked ? team().id : undefined)}class="mt-3 gap-2">@@ -91,18 +96,18 @@ export function DocumentNotesSection(props: {</Show><Showwhen={- link.team &&+ link().team &&props.team.data !== undefined &&- link.team.id !== props.team.data?.id+ link().team?.id !== props.team.data?.id}><div class="mt-3 flex items-center justify-between gap-3 text-xs text-ink-muted">- <span>{link.team?.name} can also view this note.</span>+ <span>{link().team?.name} can also view this note.</span><Buttonvariant="ghost"size="sm"disabled={props.saving}- onClick={() => props.onTeam(link, undefined)}+ onClick={() => props.onTeam(link(), undefined)}>Remove team access</Button>@@ -110,8 +115,8 @@ export function DocumentNotesSection(props: {</Show><Showwhen={- props.selected?.eventId === link.eventId &&- props.selected?.occurrenceKey === link.occurrenceKey+ props.selected?.eventId === link().eventId &&+ props.selected?.occurrenceKey === link().occurrenceKey}><div class="mt-3 border-t border-edge-muted pt-3">@@ -134,14 +139,14 @@ export function DocumentNotesSection(props: {disabled={props.saving}onClick={props.onRemove}>- {props.saving ? 'Removing…' : 'Unlink meeting'}+ {props.removing ? 'Removing…' : 'Unlink meeting'}</Button></div></div></Show></div>)}- </For>+ </Key></section></Show>);diff --git a/apps/web/src/features/calendar-notes/components/note-dialog.tsx b/apps/web/src/features/calendar-notes/components/note-dialog.tsxindex f977d0f69b..6e52a5eadc 100644--- a/apps/web/src/features/calendar-notes/components/note-dialog.tsx+++ b/apps/web/src/features/calendar-notes/components/note-dialog.tsx@@ -1,4 +1,3 @@-import { ListSkeleton } from '@app/components/view-shell/ListSkeleton';import CheckIcon from '@icon/system/regular/check.svg';import FileTextIcon from '@icon/system/regular/file-text.svg';import LinkIcon from '@icon/system/regular/link.svg';@@ -19,6 +18,7 @@ export function NoteDialog(props: {selected?: NoteDocument;onSelect: (document: NoteDocument) => void;linkedIds: string[];+ linksReady: boolean;teamId?: string;onTeam: (id: string | undefined) => void;saving: boolean;@@ -85,10 +85,14 @@ export function NoteDialog(props: {aria-label="Your markdown documents"aria-busy={props.picker.pending}>- <Show when={props.picker.pending && !props.picker.data}>- <For each={[0, 1, 2]}>- {() => <ListSkeleton.Bar class="my-2 h-5 w-3/4" />}- </For>+ <Show+ when={+ props.picker.pending && !props.picker.data?.documents.length+ }+ >+ <p role="status" class="px-3 py-5 text-sm text-ink-muted">+ Searching notes…+ </p></Show><Show when={props.picker.error}><p role="alert" class="py-4 text-sm text-failure">@@ -214,7 +218,13 @@ export function NoteDialog(props: {variant={props.kind === 'unlink' ? 'danger' : 'strong'}size="md"onClick={props.onSave}- disabled={!props.selected || props.saving}+ disabled={+ !props.selected ||+ props.saving ||+ (props.kind === 'link' &&+ (!props.linksReady ||+ props.linkedIds.includes(props.selected.documentId)))+ }><Show when={props.kind === 'link'}><LinkIcon />diff --git a/apps/web/src/features/calendar-notes/components/notes-section.tsx b/apps/web/src/features/calendar-notes/components/notes-section.tsxindex 8926d3bb05..186c40b19e 100644--- a/apps/web/src/features/calendar-notes/components/notes-section.tsx+++ b/apps/web/src/features/calendar-notes/components/notes-section.tsx@@ -1,6 +1,6 @@-import { ListSkeleton } from '@app/components/view-shell/ListSkeleton';import CaretDownIcon from '@icon/system/regular/caret-down.svg';import FileTextIcon from '@icon/system/regular/file-text.svg';+import SpinnerIcon from '@icon/system/regular/spinner.svg';import { Button, Dropdown } from '@ui';import { For, onCleanup, Show } from 'solid-js';import type { MeetingNote, NoteRead } from '../core/types';@@ -46,43 +46,36 @@ export function NotesSection(props: {{props.state.data?.length}</span></Show>+ <Show when={props.state.pending && !props.state.data}>+ <span role="status" aria-label="Loading meeting notes">+ <SpinnerIcon class="size-3 animate-spin text-ink-extra-muted" />+ </span>+ </Show></div>- <Show when={props.state.data}>- <div class="flex shrink-0 items-center gap-1">- <Button- variant="ghost"- size="xs"- aria-label={createLabel()}- disabled={props.creating}- onClick={props.onCreate}- >- {props.creating || props.createdUnlinked- ? createLabel()- : 'Create'}- </Button>- <Button- variant="ghost"- size="xs"- depth={3}- aria-label="Link existing"- disabled={props.creating}- onClick={props.onLink}- >- Link- </Button>- </div>- </Show>- </div>- <Show when={props.state.pending && !props.state.data}>- <div- role="status"- aria-label="Loading meeting notes"- class="flex flex-col gap-2 py-2"- >- <ListSkeleton.Bar class="h-4 w-3/4" />- <ListSkeleton.Bar class="h-3 w-1/2" />+ <div class="flex shrink-0 items-center gap-1">+ <Button+ variant="ghost"+ size="xs"+ aria-label={createLabel()}+ disabled={props.creating}+ onClick={props.onCreate}+ >+ {props.creating || props.createdUnlinked+ ? createLabel()+ : 'Create'}+ </Button>+ <Button+ variant="ghost"+ size="xs"+ depth={3}+ aria-label="Link existing"+ disabled={props.creating}+ onClick={props.onLink}+ >+ Link+ </Button></div>- </Show>+ </div><Show when={props.state.error}><divrole="alert"diff --git a/apps/web/src/features/calendar-notes/context/notes-source.ts b/apps/web/src/features/calendar-notes/context/notes-source.tsindex 92791dda4b..31887100c9 100644--- a/apps/web/src/features/calendar-notes/context/notes-source.ts+++ b/apps/web/src/features/calendar-notes/context/notes-source.ts@@ -28,6 +28,12 @@ export type NotesSource = {unlink: (documentId: string) => Promise<Result<void, NoteFailure>>;};+/** Already cached, owned Markdown candidates from the app's Quick Access source. */+export type NoteDocumentSearch = (+ query: Accessor<string>,+ enabled: Accessor<boolean>+) => Accessor<NoteDocument[]>;+export type DocumentNotesSource = {links: Accessor<NoteRead<DocumentNoteLink[]>>;team: Accessor<NoteRead<NoteTeam | null>>;diff --git a/apps/web/src/features/calendar-notes/document-meeting-notes.test.tsx b/apps/web/src/features/calendar-notes/document-meeting-notes.test.tsxnew file mode 100644index 0000000000..1e1ca05282--- /dev/null+++ b/apps/web/src/features/calendar-notes/document-meeting-notes.test.tsx@@ -0,0 +1,65 @@+import { queryClient } from '@queries/client';+import { calendarNotesClient } from '@service-calendar/notes';+import { cleanup, render, screen } from '@solidjs/testing-library';+import { QueryClientProvider } from '@tanstack/solid-query';+import { err, ok } from 'neverthrow';+import { afterEach, expect, it, vi } from 'vitest';+import { DocumentMeetingNotes } from './document-meeting-notes';+import { notesKeys } from './queries/keys';++vi.mock('@core/context/user', () => ({ useUserId: () => () => 'owner' }));+vi.mock('@queries/team/teams', () => ({+ useCurrentTeamQuery: () => ({ isPending: false, isError: false, data: null }),+}));+vi.mock('@core/util/create', () => ({ createMarkdownFile: vi.fn() }));+vi.mock('@service-calendar/notes', () => ({+ calendarNotesClient: { documentLinks: vi.fn() },+}));+vi.mock('@queries/client', async () => {+ const { QueryClient } = await import('@tanstack/solid-query');+ return {+ queryClient: new QueryClient({+ defaultOptions: { queries: { retry: false } },+ }),+ };+});+afterEach(() => {+ cleanup();+ queryClient.clear();+ vi.resetAllMocks();+});++it('retains cached links after a failed refresh without reporting their grants as confirmed', async () => {+ vi.mocked(calendarNotesClient.documentLinks).mockResolvedValue(+ ok([+ {+ documentName: 'Notes',+ eventId: 'event',+ eventTitle: 'Planning',+ occurrenceKey: 'single',+ canViewMeeting: true,+ team: { id: 'team', name: 'Macro' },+ },+ ])+ );+ const onAccessState = vi.fn();+ render(() => (+ <QueryClientProvider client={queryClient}>+ <DocumentMeetingNotes documentId="note" onAccessState={onAccessState} />+ </QueryClientProvider>+ ));+ await vi.waitFor(() =>+ expect(onAccessState).toHaveBeenLastCalledWith('shared', ['team'])+ );+ const unlink = screen.getByRole('button', { name: 'Unlink' });+ vi.mocked(calendarNotesClient.documentLinks).mockResolvedValue(+ err([{ code: 'NETWORK_ERROR', message: 'Network unavailable' }])+ );+ await queryClient.refetchQueries({+ queryKey: notesKeys.documentLinks('owner', 'note').queryKey,+ });+ await vi.waitFor(() =>+ expect(onAccessState).toHaveBeenLastCalledWith('error', [])+ );+ expect(screen.getByRole('button', { name: 'Unlink' })).toBe(unlink);+});diff --git a/apps/web/src/features/calendar-notes/document-meeting-notes.tsx b/apps/web/src/features/calendar-notes/document-meeting-notes.tsxindex 291858c44c..18c44f8a10 100644--- a/apps/web/src/features/calendar-notes/document-meeting-notes.tsx+++ b/apps/web/src/features/calendar-notes/document-meeting-notes.tsx@@ -7,7 +7,7 @@ import { DocumentNotesView } from './views/document-notes';/** Owner-only meeting grants within the document share panel. */export function DocumentMeetingNotes(props: {documentId: string;- onAccessState?: (state: MeetingAccessState) => void;+ onAccessState?: (state: MeetingAccessState, teamIds: string[]) => void;}) {const userId = useUserId();const source = createDocumentNotesSource(userId, () => props.documentId);@@ -20,7 +20,11 @@ export function DocumentMeetingNotes(props: {? 'loading': state.data.length? 'shared'- : 'none'+ : 'none',+ state.error+ ? []+ : (state.data?.flatMap((link) => (link.team ? [link.team.id] : [])) ??+ []));});return (diff --git a/apps/web/src/features/calendar-notes/meeting-reference.tsx b/apps/web/src/features/calendar-notes/meeting-reference.tsxindex efa855278c..bfe12e675d 100644--- a/apps/web/src/features/calendar-notes/meeting-reference.tsx+++ b/apps/web/src/features/calendar-notes/meeting-reference.tsx@@ -15,6 +15,7 @@ export function MeetingReference(props: {link: DocumentReference;documentId: string;onOpenCalendar?: () => void;+ onRetry?: () => void;}) {const occurrenceKey = () =>props.link.occurrenceKey === 'single'@@ -22,6 +23,7 @@ export function MeetingReference(props: {: props.link.occurrenceKey;const resolved = () => resolveReferencePreview(props.link);const event = () => resolved()?.event;+ const unresolved = () => typeof props.link.canViewMeeting !== 'boolean';const [detailsOpen, setDetailsOpen] = createSignal(false);const title = () => event()?.title || props.link.eventTitle;const date = () => {@@ -54,7 +56,11 @@ export function MeetingReference(props: {if (!current?.viewerEventId) {span.setAttr('calendar.notes.reference.outcome',- current ? 'shared_preview' : 'unavailable'+ unresolved()+ ? 'unresolved'+ : current+ ? 'shared_preview'+ : 'unavailable');setDetailsOpen(true);return;@@ -110,7 +116,9 @@ export function MeetingReference(props: {when={event()}fallback={<p class="p-4 text-sm text-ink-muted">- This meeting is no longer available to you.+ {unresolved()+ ? 'Meeting details are temporarily unavailable. Please try again.'+ : 'This meeting is no longer available to you.'}</p>}>@@ -122,7 +130,12 @@ export function MeetingReference(props: {/>)}</Show>- <div class="flex justify-end p-3">+ <div class="flex justify-end gap-2 p-3">+ <Show when={unresolved() && props.onRetry}>+ <Button variant="ghost" onClick={props.onRetry}>+ Retry+ </Button>+ </Show><Button variant="ghost" onClick={() => setDetailsOpen(false)}>Close</Button>diff --git a/apps/web/src/features/calendar-notes/primitives/document-notes-controller.ts b/apps/web/src/features/calendar-notes/primitives/document-notes-controller.tsindex 117b9a9447..1ffaa141b2 100644--- a/apps/web/src/features/calendar-notes/primitives/document-notes-controller.ts+++ b/apps/web/src/features/calendar-notes/primitives/document-notes-controller.ts@@ -5,13 +5,14 @@ import type { DocumentNoteLink } from '../core/types';export function createDocumentNotesController(source: DocumentNotesSource) {const [selected, setSelected] = createSignal<DocumentNoteLink>();const [saving, setSaving] = createSignal(false);+ const [removing, setRemoving] = createSignal(false);const [error, setError] = createSignal<string>();let disposed = false;onCleanup(() => {disposed = true;});function select(link: DocumentNoteLink | undefined) {- if (saving()) return;+ if (removing()) return;setSelected(link);setError(undefined);}@@ -19,9 +20,11 @@ export function createDocumentNotesController(source: DocumentNotesSource) {const link = selected();if (!link || saving()) return;setSaving(true);+ setRemoving(true);const result = await source.unlink(link);if (disposed) return;setSaving(false);+ setRemoving(false);if (result.isErr()) setError(result.error.message);else select(undefined);}@@ -34,5 +37,5 @@ export function createDocumentNotesController(source: DocumentNotesSource) {setSaving(false);if (result.isErr()) setError(result.error.message);}- return { selected, saving, error, select, remove, setTeam };+ return { selected, saving, removing, error, select, remove, setTeam };}diff --git a/apps/web/src/features/calendar-notes/primitives/notes-controller.test.ts b/apps/web/src/features/calendar-notes/primitives/notes-controller.test.tsnew file mode 100644index 0000000000..672961e268--- /dev/null+++ b/apps/web/src/features/calendar-notes/primitives/notes-controller.test.ts@@ -0,0 +1,44 @@+import { ok } from 'neverthrow';+import { createRoot, createSignal } from 'solid-js';+import { expect, it, vi } from 'vitest';+import type { NotesSource } from '../context/notes-source';+import type { MeetingNote } from '../core/types';+import { createNotesController } from './notes-controller';++it('does not overwrite an existing team grant when its link arrives after selection', async () => {+ const document = { documentId: 'note', name: 'Notes' };+ const [notes, setNotes] = createSignal<MeetingNote[]>();+ const source: NotesSource = {+ notes: () => ({ pending: !notes(), data: notes() }),+ picker: () => () => ({+ pending: false,+ data: { documents: [document], teams: [] },+ }),+ create: async () => ok(document),+ retry: async () => {},+ link: vi.fn(async () => ok(undefined)),+ unlink: async () => ok(undefined),+ };+ const { controller, dispose } = createRoot((dispose) => ({+ controller: createNotesController(source, () => {}),+ dispose,+ }));+ try {+ controller.openLink();+ controller.setSelected(document);+ await controller.save();+ expect(source.link).not.toHaveBeenCalled();+ setNotes([+ { ...document, canManage: true, team: { id: 'team', name: 'Macro' } },+ ]);+ await controller.save();+ expect(source.link).not.toHaveBeenCalled();+ expect(controller.dialog()?.kind).toBe('link');+ controller.setSelected({ documentId: 'new-note', name: 'Another note' });+ await controller.save();+ expect(source.link).toHaveBeenCalledExactlyOnceWith('new-note', undefined);+ expect(controller.dialog()).toBeUndefined();+ } finally {+ dispose();+ }+});diff --git a/apps/web/src/features/calendar-notes/primitives/notes-controller.ts b/apps/web/src/features/calendar-notes/primitives/notes-controller.tsindex bac86ca383..b9d4b37c5e 100644--- a/apps/web/src/features/calendar-notes/primitives/notes-controller.ts+++ b/apps/web/src/features/calendar-notes/primitives/notes-controller.ts@@ -49,6 +49,16 @@ export function createNotesController(const active = dialog();const document = selected();if (!active || active.kind === 'sharing' || !document || saving()) return;+ if (active.kind === 'link') {+ const linkedNotes = source.notes().data;+ // PUT also changes an existing link's team grant. An early or stale+ // selection must never turn "link" into an unintended sharing update.+ if (!linkedNotes) return;+ if (linkedNotes.some((note) => note.documentId === document.documentId)) {+ setError('This note is already linked to the meeting.');+ return;+ }+ }setSaving(true);setError(undefined);const result =diff --git a/apps/web/src/features/calendar-notes/queries/local-note-search.ts b/apps/web/src/features/calendar-notes/queries/local-note-search.tsnew file mode 100644index 0000000000..e770d250a9--- /dev/null+++ b/apps/web/src/features/calendar-notes/queries/local-note-search.ts@@ -0,0 +1,27 @@+import type { QuickAccessContextValue } from '@core/context/quickAccess/types';+import { type Accessor, createMemo } from 'solid-js';+import type { NoteDocumentSearch } from '../context/notes-source';++export function createLocalNoteSearch(+ quickAccess: QuickAccessContextValue,+ userId: Accessor<string | undefined>+): NoteDocumentSearch {+ return (query, enabled) => {+ const list = quickAccess.useList({+ buckets: ['note', 'task', 'snippet', 'skill'],+ searchTerm: query,+ enabled,+ });+ return createMemo(() => {+ const owner = userId();+ if (!owner || !enabled()) return [];+ return list+ .items()+ .flatMap(({ data }) =>+ data.ownerId === owner+ ? [{ documentId: data.id, name: data.name }]+ : []+ );+ });+ };+}diff --git a/apps/web/src/features/calendar-notes/queries/notes-source.test.tsx b/apps/web/src/features/calendar-notes/queries/notes-source.test.tsxindex d8bc180b79..9b02d7a2e4 100644--- a/apps/web/src/features/calendar-notes/queries/notes-source.test.tsx+++ b/apps/web/src/features/calendar-notes/queries/notes-source.test.tsx@@ -3,14 +3,21 @@ import { queryClient } from '@queries/client';import { calendarNotesClient } from '@service-calendar/notes';import { QueryClientProvider } from '@tanstack/solid-query';import { err, ok } from 'neverthrow';-import { createComponent, createRoot, createSignal } from 'solid-js';+import {+ type Accessor,+ createComponent,+ createRoot,+ createSignal,+} from 'solid-js';import { afterEach, beforeEach, expect, it, vi } from 'vitest';-import type { NotesSource } from '../context/notes-source';+import type { NoteDocumentSearch, NotesSource } from '../context/notes-source';+import type { NotePicker, NoteRead } from '../core/types';+import { notesKeys } from './keys';import { createNotesSource } from './notes-source';vi.mock('@core/util/create', () => ({ createMarkdownFile: vi.fn() }));vi.mock('@service-calendar/notes', () => ({- calendarNotesClient: { list: vi.fn(), link: vi.fn() },+ calendarNotesClient: { list: vi.fn(), link: vi.fn(), documents: vi.fn() },}));vi.mock('@queries/client', async () => {const { QueryClient } = await import('@tanstack/solid-query');@@ -25,22 +32,30 @@ let dispose = () => {};beforeEach(() => {vi.mocked(calendarNotesClient.list).mockResolvedValue(ok([]));vi.mocked(calendarNotesClient.link).mockResolvedValue(ok({}));+ vi.mocked(calendarNotesClient.documents).mockResolvedValue(+ ok({ documents: [], teams: [] })+ );});afterEach(() => {dispose();queryClient.clear();vi.resetAllMocks();+ vi.useRealTimers();});-function mountSource() {+function mountSource(localSearch: NoteDocumentSearch = () => () => []) {const [user, setUser] = createSignal<string | undefined>('owner');const [target, setTarget] = createSignal({eventId: 'event-a',occurrenceKey: '2026-10-23T14:00:00Z',});let source: NotesSource | undefined;+ const [query, setQuery] = createSignal('');+ const [enabled, setEnabled] = createSignal(false);+ let picker: Accessor<NoteRead<NotePicker>> | undefined;function Probe() {- source = createNotesSource(user, target);+ source = createNotesSource(user, target, localSearch);+ picker = source.picker(query, enabled);return null;}createRoot((cleanup) => {@@ -52,10 +67,93 @@ function mountSource() {},});});- if (!source) throw new Error('Notes source did not mount');- return { source, setUser, setTarget };+ if (!source || !picker) throw new Error('Notes source did not mount');+ return { source, setUser, setTarget, picker, setQuery, setEnabled };}+it('reopens a recently viewed meeting from cache without another request', async () => {+ const notes = [+ { documentId: 'note-a', name: 'Notes', team: null, canManage: true },+ ];+ vi.mocked(calendarNotesClient.list).mockResolvedValue(ok(notes));+ const first = mountSource();+ await vi.waitFor(() => expect(first.source.notes().data).toHaveLength(1));+ dispose();+ const reopened = mountSource();+ expect(reopened.source.notes().data?.[0].documentId).toBe('note-a');+ expect(reopened.source.notes().pending).toBe(false);+ expect(calendarNotesClient.list).toHaveBeenCalledOnce();+ reopened.setTarget({ eventId: 'different-event', occurrenceKey: 'single' });+ expect(reopened.source.notes().data).toBeUndefined();+});++it('keeps matching candidates while a new search is pending and reuses earlier queries', async () => {+ vi.useFakeTimers();+ const initial = {+ documents: [+ { documentId: 'alpha', name: 'Alpha sync' },+ { documentId: 'beta', name: 'Beta sync' },+ ],+ teams: [{ id: 'team', name: 'Macro' }],+ };+ queryClient.setQueryData(notesKeys.documents('owner', '').queryKey, initial);+ const response =+ Promise.withResolvers<+ Awaited<ReturnType<typeof calendarNotesClient.documents>>+ >();+ vi.mocked(calendarNotesClient.documents).mockReturnValue(response.promise);+ const mounted = mountSource();+ mounted.setEnabled(true);+ mounted.setQuery('alp');+ expect(mounted.picker().data?.documents).toEqual([initial.documents[0]]);+ await vi.advanceTimersByTimeAsync(180);+ expect(mounted.picker().data?.documents).toEqual([initial.documents[0]]);+ expect(mounted.picker().data?.teams).toEqual(initial.teams);+ expect(mounted.picker().pending).toBe(true);+ response.resolve(+ ok({ documents: [initial.documents[0]], teams: initial.teams })+ );+ await vi.advanceTimersByTimeAsync(0);+ mounted.setQuery('');+ await vi.advanceTimersByTimeAsync(180);+ expect(mounted.picker().data?.documents).toEqual(initial.documents);+ expect(calendarNotesClient.documents).toHaveBeenCalledOnce();+});++it('shows local candidates before the server responds and deduplicates remote matches', async () => {+ const local = { documentId: 'cached', name: 'Cached note' };+ const response =+ Promise.withResolvers<+ Awaited<ReturnType<typeof calendarNotesClient.documents>>+ >();+ vi.mocked(calendarNotesClient.documents).mockReturnValue(response.promise);+ const mounted = mountSource(() => () => [local]);+ mounted.setEnabled(true);+ expect(mounted.picker().data?.documents).toEqual([local]);+ response.resolve(+ ok({+ documents: [local, { documentId: 'server', name: 'Server note' }],+ teams: [],+ })+ );+ await vi.waitFor(() =>+ expect(mounted.picker().data?.documents).toHaveLength(2)+ );+});++it('does not keep another account’s notes or teams as placeholder results', () => {+ queryClient.setQueryData(notesKeys.documents('owner', '').queryKey, {+ documents: [{ documentId: 'private', name: 'Private note' }],+ teams: [{ id: 'private-team', name: 'Previous team' }],+ });+ const mounted = mountSource();+ mounted.setEnabled(true);+ expect(mounted.picker().data?.documents).toHaveLength(1);+ mounted.setUser('another-owner');+ expect(mounted.picker().data?.documents).toEqual([]);+ expect(mounted.picker().data?.teams).toEqual([]);+});+it('links to the original occurrence when selection changes during creation', async () => {let finish = (_id: string) => {};vi.mocked(createMarkdownFile).mockReturnValueOnce(diff --git a/apps/web/src/features/calendar-notes/queries/notes-source.ts b/apps/web/src/features/calendar-notes/queries/notes-source.tsindex 3115a70451..52eca807b6 100644--- a/apps/web/src/features/calendar-notes/queries/notes-source.ts+++ b/apps/web/src/features/calendar-notes/queries/notes-source.ts@@ -1,5 +1,5 @@-import { createMarkdownFile } from '@core/util/create';import { catchToResult, throwOnErr } from '@core/util/result';+import { matchesTokenSubsequences } from '@core/util/string';import { Telemetry } from '@macro-inc/observability';import { queryClient } from '@queries/client';import { queryReadyGate } from '@queries/gate';@@ -9,13 +9,18 @@ import { calendarNotesClient } from '@service-calendar/notes';import { createDebouncedMemo } from '@solid-primitives/memo';import { useMutation, useQuery } from '@tanstack/solid-query';import { err, ok } from 'neverthrow';-import type { Accessor } from 'solid-js';-import type { DocumentNotesSource, NotesSource } from '../context/notes-source';+import { type Accessor, createMemo } from 'solid-js';+import type {+ DocumentNotesSource,+ NoteDocumentSearch,+ NotesSource,+} from '../context/notes-source';import type {DocumentNoteLink,MeetingNote,NoteCreateFailure,NoteFailure,+ NotePicker,NoteTarget,} from '../core/types';import { notesKeys } from './keys';@@ -34,8 +39,8 @@ function notesOptions(userId: string | undefined, target: NoteTarget) {return notes.map((note) => ({ ...note, team: note.team ?? undefined }));},enabled: !!userId,- staleTime: 0,- gcTime: 0,+ staleTime: 30_000,+ gcTime: 5 * 60_000,refetchInterval: 30_000,refetchOnWindowFocus: true,};@@ -44,15 +49,49 @@ function notesOptions(userId: string | undefined, target: NoteTarget) {function pickerOptions(userId: string | undefined,query: string,- enabled: boolean+ enabled: boolean,+ eventId: string,+ localCount: number) {return {queryKey: notesKeys.documents(userId, query).queryKey,queryFn: ({ signal }: { signal: AbortSignal }) =>- throwOnErr(() => calendarNotesClient.documents(query, signal)),+ Telemetry.span('calendar.notes.search', async (span) => {+ span.setAttr('event.id', eventId);+ span.setAttr('search.query_length', query.length);+ span.setAttr('search.debounce_ms', 180);+ span.setAttr('search.local_result_count', localCount);+ const result = await span.span(+ 'calendar.notes.search.server',+ async (server) => {+ const result = await calendarNotesClient.documents(query, signal);+ if (result.isOk()) {+ server.setAttr(+ 'search.result_count',+ result.value.documents.length+ );+ } else if (!signal.aborted) {+ server.error('Meeting note search failed');+ }+ return result;+ }+ );+ span.setAttr(+ 'search.outcome',+ signal.aborted ? 'cancelled' : result.isOk() ? 'success' : 'error'+ );+ if (result.isErr() && !signal.aborted)+ span.error('Meeting note search failed');+ return throwOnErr(async () => result);+ }),enabled: !!userId && enabled,- staleTime: 0,- gcTime: 0,+ staleTime: 60_000,+ gcTime: 5 * 60_000,+ // Keep matching results while typing, but never carry them across accounts.+ placeholderData: (+ previous: NotePicker | undefined,+ previousQuery: { queryKey: readonly unknown[] } | undefined+ ) => (previousQuery?.queryKey[2] === userId ? previous : undefined),};}@@ -97,7 +136,8 @@ function refreshNotes() {export function createNotesSource(userId: Accessor<string | undefined>,- target: Accessor<NoteTarget>+ target: Accessor<NoteTarget>,+ localSearch: NoteDocumentSearch): NotesSource {const notes = useQuery(() => notesOptions(userId(), target()));const link = useMutation(() => ({@@ -164,13 +204,36 @@ export function createNotesSource(});},picker(query, enabled) {- const debounced = createDebouncedMemo(query, 180);+ const normalized = () => query().trim();+ const debounced = createDebouncedMemo(normalized, 180);+ const local = localSearch(normalized, enabled);const picker = useQuery(() =>- pickerOptions(userId(), debounced(), enabled())+ pickerOptions(+ userId(),+ debounced(),+ enabled(),+ target().eventId,+ local().length+ ));+ const data = createMemo(() => {+ const remote = queryReadyGate(picker) ? picker.data : undefined;+ const documents = new Map(+ local().map((document) => [document.documentId, document])+ );+ for (const document of remote?.documents ?? []) {+ if (matchesTokenSubsequences(document.name, normalized())) {+ documents.set(document.documentId, document);+ }+ }+ return {+ documents: [...documents.values()],+ teams: remote?.teams ?? [],+ };+ });return () => ({- data: queryReadyGate(picker) ? picker.data : undefined,- pending: picker.isPending,+ data: data(),+ pending: picker.isFetching || normalized() !== debounced(),error: picker.isError? 'Couldn’t load your notes. Try again.': undefined,@@ -202,7 +265,7 @@ export function createNotesSource(/** Reference previews are adapted at the calendar API boundary. */export type DocumentReference = DocumentNoteLink &- Pick<CalendarDocumentLink, 'teamEvent' | 'event' | 'canViewMeeting'>;+ Partial<Pick<CalendarDocumentLink, 'teamEvent' | 'event' | 'canViewMeeting'>>;export function documentLinksOptions(userId: string | undefined,@@ -217,8 +280,8 @@ export function documentLinksOptions(return links.map((link) => ({ ...link, team: link.team ?? undefined }));},enabled: !!userId,- staleTime: 0,- gcTime: 0,+ staleTime: 30_000,+ gcTime: 5 * 60_000,refetchInterval: 30_000,refetchOnWindowFocus: true,};@@ -274,3 +337,5 @@ export function createDocumentNotesSource(},};}++import { createMarkdownFile } from '@core/util/create';diff --git a/apps/web/src/features/calendar-notes/views/document-notes.test.tsx b/apps/web/src/features/calendar-notes/views/document-notes.test.tsxnew file mode 100644index 0000000000..38a3bbd07d--- /dev/null+++ b/apps/web/src/features/calendar-notes/views/document-notes.test.tsx@@ -0,0 +1,48 @@+import { cleanup, fireEvent, render, screen } from '@solidjs/testing-library';+import { ok } from 'neverthrow';+import { createSignal } from 'solid-js';+import { afterEach, expect, it, vi } from 'vitest';+import type { DocumentNotesSource } from '../context/notes-source';+import type { DocumentNoteLink } from '../core/types';+import { DocumentNotesView } from './document-notes';++afterEach(cleanup);++it('keeps Unlink mounted and usable while team access saves, without allowing concurrent writes', async () => {+ const link = {+ eventId: 'event',+ occurrenceKey: 'single',+ eventTitle: 'Sync',+ };+ const team = { id: 'team', name: 'Macro' };+ const [links, setLinks] = createSignal<DocumentNoteLink[]>([link]);+ const saved = Promise.withResolvers<void>();+ const source: DocumentNotesSource = {+ links: () => ({ data: links(), pending: false }),+ team: () => ({ data: team, pending: false }),+ retry: async () => {},+ setTeam: async () => {+ await saved.promise;+ setLinks([{ ...link, team }]);+ return ok(undefined);+ },+ unlink: vi.fn(async () => ok(undefined)),+ };+ render(() => <DocumentNotesView source={source} />);+ const unlink = screen.getByRole('button', { name: 'Unlink' });+ const checkbox = screen.getByRole('checkbox');+ await fireEvent.click(checkbox);+ expect(unlink.hasAttribute('disabled')).toBe(false);+ await fireEvent.click(unlink);+ const confirm = screen.getByRole('button', { name: 'Unlink meeting' });+ expect(confirm.hasAttribute('disabled')).toBe(true);+ await fireEvent.click(confirm);+ expect(source.unlink).not.toHaveBeenCalled();++ saved.resolve();+ await vi.waitFor(() => expect(confirm.hasAttribute('disabled')).toBe(false));+ expect(screen.getByRole('button', { name: 'Unlink' })).toBe(unlink);+ expect(screen.getByRole('checkbox')).toBe(checkbox);+ await fireEvent.click(confirm);+ expect(source.unlink).toHaveBeenCalledOnce();+});diff --git a/apps/web/src/features/calendar-notes/views/document-notes.tsx b/apps/web/src/features/calendar-notes/views/document-notes.tsxindex 79d6ba8ee0..b73a121e71 100644--- a/apps/web/src/features/calendar-notes/views/document-notes.tsx+++ b/apps/web/src/features/calendar-notes/views/document-notes.tsx@@ -11,6 +11,7 @@ export function DocumentNotesView(props: { source: DocumentNotesSource }) {team={props.source.team()}selected={controller.selected()}saving={controller.saving()}+ removing={controller.removing()}error={controller.error()}onSelect={controller.select}onTeam={(link, teamId) =>diff --git a/apps/web/src/features/calendar-notes/views/meeting-notes.tsx b/apps/web/src/features/calendar-notes/views/meeting-notes.tsxindex 3862393563..0d9e67e046 100644--- a/apps/web/src/features/calendar-notes/views/meeting-notes.tsx+++ b/apps/web/src/features/calendar-notes/views/meeting-notes.tsx@@ -68,10 +68,11 @@ export function MeetingNotesView(props: {linkedIds={props.source.notes().data?.map((note) => note.documentId) ?? []}+ linksReady={props.source.notes().data !== undefined}teamId={controller.teamId()}onTeam={controller.setTeamId}saving={controller.saving()}- error={controller.error()}+ error={controller.error() ?? props.source.notes().error}onSave={() =>fireAndForget(controller.save(), 'calendar.notes.save')}diff --git a/apps/web/src/lib/core/component/TopBar/ShareButton.test.tsx b/apps/web/src/lib/core/component/TopBar/ShareButton.test.tsxindex d17256adbd..f2ba36c1f1 100644--- a/apps/web/src/lib/core/component/TopBar/ShareButton.test.tsx+++ b/apps/web/src/lib/core/component/TopBar/ShareButton.test.tsx@@ -20,12 +20,13 @@ import {vi.mock('@app/features/calendar-notes/document-meeting-notes', () => ({DocumentMeetingNotes: (props: {documentId: string;- onAccessState?: (state: 'shared' | 'none') => void;+ onAccessState?: (state: 'shared' | 'none', teamIds: string[]) => void;}) => {mocks.mountMeetingNotes(props.documentId);onCleanup(mocks.unmountMeetingNotes);props.onAccessState?.(- props.documentId === 'meeting-note' ? 'shared' : 'none'+ props.documentId === 'meeting-note' ? 'shared' : 'none',+ []);return (<section aria-label="Meeting links">@@ -319,7 +320,7 @@ vi.mock('@queries/call/call', () => ({vi.mock('@queries/team/teams', () => ({useCurrentTeamQuery: () => ({isSuccess: mocks.hasTeam,- data: mocks.hasTeam ? { id: 'team-1' } : undefined,+ data: mocks.hasTeam ? { team: { id: 'team-1', name: 'Macro' } } : undefined,}),}));vi.mock('@solidjs/router', () => ({ useNavigate: () => vi.fn() }));diff --git a/apps/web/src/lib/core/component/TopBar/ShareButton.tsx b/apps/web/src/lib/core/component/TopBar/ShareButton.tsxindex 1b2f4b6352..f3d4120c5e 100644--- a/apps/web/src/lib/core/component/TopBar/ShareButton.tsx+++ b/apps/web/src/lib/core/component/TopBar/ShareButton.tsx@@ -420,6 +420,9 @@ interface LinkSharingControlsProps {/** Owner-only explicit team sharing, present only for entity types that support it. */interface TeamShareControls {accessLevel: AccessLevel | null | undefined;+ /** An independent view grant that is managed under Meeting links. */+ meetingViewAccess?: boolean;+ meetingAccess?: MeetingAccessState | 'unknown';setAccessLevel: (scope: TeamShareScope) => void;/** Noun for the copy, e.g. "document" or "chat". */itemNoun: string;@@ -437,13 +440,33 @@ function teamShareOnOwnCard(function TeamAccessSection(props: { teamShare: TeamShareControls }) {const teamShareScope = () => getTeamShareScope(props.teamShare.accessLevel);+ const label = () => {+ const scope = teamShareScope();+ if (scope !== 'NONE') return getTeamShareScopeCopy(scope);+ if (props.teamShare.meetingViewAccess) return 'View via meeting';+ if (props.teamShare.meetingAccess === 'loading') return 'Checking…';+ if (props.teamShare.meetingAccess === 'error')+ return 'Check meeting access';+ if (props.teamShare.meetingAccess === 'unknown') return 'Direct: None';+ return getTeamShareScopeCopy(scope);+ };return (<div class="flex flex-wrap items-center justify-between gap-3"><div class="flex flex-col gap-1"><span class="font-medium">Team access</span><p class="text-sm text-ink-muted">- Share this {props.teamShare.itemNoun} directly with the owner's team.+ <Show+ when={props.teamShare.meetingViewAccess}+ fallback={+ <>+ Share this {props.teamShare.itemNoun} directly with the owner's+ team.+ </>+ }+ >+ Your team can view through meeting links.+ </Show></p></div><Dropdown>@@ -452,7 +475,7 @@ function TeamAccessSection(props: { teamShare: TeamShareControls }) {aria-label="Team access"class="min-w-16.75 py-1 pl-2 pr-1 flex items-center gap-1">- {getTeamShareScopeCopy(teamShareScope())}+ {label()}<ChevronDownIcon class="size-4 text-ink-extra-muted" /></Dropdown.Trigger><Dropdown.Content portalScope="local">@@ -466,7 +489,12 @@ function TeamAccessSection(props: { teamShare: TeamShareControls }) {<For each={props.teamShare.scopeOptions}>{(option) => (<Dropdown.RadioItem value={option.value}>- <span class="flex-1 truncate">{option.label}</span>+ <span class="flex-1 truncate">+ {option.value === 'NONE' &&+ props.teamShare.meetingViewAccess+ ? 'Use meeting access'+ : option.label}+ </span><Dropdown.ItemIndicator><CheckIcon class="size-3.5 text-accent" /></Dropdown.ItemIndicator>@@ -487,8 +515,20 @@ function LinkSharingControls(props: LinkSharingControlsProps) {const status = getShareStatus(props.linkShare,props.hasExplicitShares || props.meetingAccess === 'shared',- props.teamShare?.accessLevel+ props.teamShare?.accessLevel ??+ (props.teamShare?.meetingViewAccess ? 'view' : undefined));+ if (+ status.label === 'Team' &&+ props.teamShare?.meetingViewAccess &&+ !props.teamShare.accessLevel &&+ !props.linkShare+ ) {+ return {+ ...status,+ tooltip: 'Your team can view through meeting links.',+ };+ }if (status.label === 'Shared' && props.meetingAccess === 'shared') {return {...status,@@ -657,7 +697,7 @@ function RecipientsSkeleton() {interface MobileShareDrawerProps {meetingNotesEnabled: boolean;meetingAccess?: MeetingAccessState | 'unknown';- onMeetingAccessState: (state: MeetingAccessState) => void;+ onMeetingAccessState: (state: MeetingAccessState, teamIds: string[]) => void;requests: SharingSource;requestLevels: readonly AccessLevel[];editPermissionEnabled?: boolean;@@ -1069,9 +1109,24 @@ export function ShareModal(props: ShareModalProps) {documentId: string;userId: string | undefined;state: MeetingAccessState;+ teamIds: string[];}>();- const setMeetingAccess = (state: MeetingAccessState) =>- setMeetingAccessSnapshot({ documentId: props.id, userId: userId(), state });+ const setMeetingAccess = (state: MeetingAccessState, teamIds: string[]) =>+ setMeetingAccessSnapshot({+ documentId: props.id,+ userId: userId(),+ state,+ teamIds,+ });+ const meetingTeamAccess = () => {+ const snapshot = meetingAccessSnapshot();+ if (snapshot?.documentId !== props.id || snapshot.userId !== userId())+ return false;+ const teamId = currentTeamQuery.isSuccess+ ? currentTeamQuery.data?.team?.id+ : undefined;+ return !!teamId && snapshot.teamIds.includes(teamId);+ };const meetingAccess = (): MeetingAccessState => {const snapshot = meetingAccessSnapshot();return snapshot?.documentId === props.id && snapshot.userId === userId()@@ -1556,7 +1611,11 @@ export function ShareModal(props: ShareModalProps) {setCallRecordTeamShareCache(props.id, shared);}if (scope === 'NONE') {- toast.success(`Removed team access for this ${itemNoun}`);+ toast.success(+ canManageMeetingLinks()+ ? `Removed direct team access for this ${itemNoun}`+ : `Removed team access for this ${itemNoun}`+ );return;}@@ -1591,6 +1650,8 @@ export function ShareModal(props: ShareModalProps) {currentTeamQuery.data? {accessLevel: teamShareAccessLevel(),+ meetingViewAccess: canManageMeetingLinks() && meetingTeamAccess(),+ meetingAccess: meetingAccessForSharing(),setAccessLevel: setTeamShareAccessLevel,itemNoun:props.blockAlias === 'snippet'diff --git a/docs/agent-guide/calendar.md b/docs/agent-guide/calendar.mdindex 3a5fc895e3..0dcc01d8c4 100644--- a/docs/agent-guide/calendar.md+++ b/docs/agent-guide/calendar.md@@ -13,6 +13,10 @@ This creates a Markdown document named after the meeting, links it with meetingviewer access, and opens it immediately. Team access starts off. A meeting canhave multiple notes; **Create** and **Link** remain on the section title rowso you can keep creating notes or linking existing documents.+Both actions are available while notes load. Reopening a recently viewed event+uses cached notes immediately while stale data refreshes in the background.+The picker can open while existing links load, but submission waits for that+check so selecting an already-linked note cannot change its sharing.Choose **Link** to search the titles of Markdown documents you own, select one, reviewthe sharing explanation, and optionally include your existing team before@@ -26,6 +30,10 @@ from current Macro team memberships; they do not introduce departments or subteaLinked meetings also appear in the note’s side-panel **References** section.Only readers with meeting-detail access see those references; owners retain safeunavailable-meeting entries.+Click a meeting reference to reopen that exact occurrence. If the calendar+backend has not yet deployed embedded reference previews, the dialog reports+that meeting details are temporarily unavailable and offers **Retry**. Missing+fields must not be described as removed meeting access.Open the linked title to read the original document. On desktop it opens in anew split; on mobile it replaces the calendar pane and closes event details.@@ -39,8 +47,10 @@ removes this meeting’s grants without deleting the document. Keep the labeledOptions button visible beside long titles; truncate the title without wideningthe event details. Labeled note controls do not need extra hover tooltips.The linking dialog uses a wider desktop layout and a phone sheet. Only the-document results scroll. The picker uses the calendar notes endpoint’s title-search (up to 30 recently updated owned Markdown documents), not full-text search. The meeting context,+document results scroll. The picker starts with owned Markdown matches from+Quick Access's local cache, then adds the calendar notes endpoint's title+results (up to 30 per query), not full-text search. Matching results stay visible+while typing and searches are cached across opens. The meeting context,sharing controls, and action buttons stay visible, including in a short viewport.A former team’s grant can be removed in Share while the meeting is still visible;unlinking remains available even if the meeting is no longer accessible.@@ -56,6 +66,10 @@ links** (inside **Link** on mobile). Every saved link remains removable here eveif the meeting was cancelled, fell outside the sync window, or stopped beingshared with the owner. **Unlink** asks before removing its meeting/team grants.Unavailable meetings use a safe label rather than revealing private details.+Checking **Also share with Macro** also updates **Team access** to **View via+meeting** when there is no direct team grant. The dropdown's **Use meeting+access** option removes only additional direct sharing; uncheck the meeting's+checkbox to remove its team grant. Unlink stays in place while a team save runs.Full-detail team events expose the same note controls; provider actions such asediting the event or RSVPing stay unavailable. Busy-only team entries anddiff --git a/docs/agent-guide/media/calendar-notes/search-cached-results.png b/docs/agent-guide/media/calendar-notes/search-cached-results.pngnew file mode 100644index 0000000000..c0298f7bdfBinary files /dev/null and b/docs/agent-guide/media/calendar-notes/search-cached-results.png differdiff --git a/docs/agent-guide/media/calendar-notes/sharing-team-access.png b/docs/agent-guide/media/calendar-notes/sharing-team-access.pngnew file mode 100644index 0000000000..34f59708c8Binary files /dev/null and b/docs/agent-guide/media/calendar-notes/sharing-team-access.png differdiff --git a/docs/architecture/calendar-meeting-notes.md b/docs/architecture/calendar-meeting-notes.mdindex 89f18304a2..0a0caf6d1b 100644--- a/docs/architecture/calendar-meeting-notes.md+++ b/docs/architecture/calendar-meeting-notes.md@@ -94,7 +94,12 @@ the existing read-only event preview otherwise. The note flag gates this querybefore it mounts.The links response includes `canViewMeeting` and an optional exact `event`-preview, so References never performs a separate, more permissive mention read.+preview, which References uses without another lookup. During a rolling deploy,+an older calendar service can omit those fields. Missing projection fields mean+the reference is unresolved, not that meeting access was denied; the dialog+offers Retry on the links query. It never substitutes a broader mention lookup+for the server's source-scoped authorization. An explicit `canViewMeeting: false`+still means the linked meeting is unavailable to the reader.It also includes an optional `teamEvent` projection, resolved throughthe same source entitlement reader and sanitizer as the team calendar. It neverborrows canonical details, includes busy-only content, or substitutes a nearby@@ -107,6 +112,24 @@ team access controls, and inline unlink confirmation. That list does not requirecurrent meeting access. It usesgeneric labels for inaccessible or indirectly shared meetings, so it cannot reveala richer canonical event title through a restricted provider projection.+The standard Team access control includes the current team's meeting-derived+view grant: it shows **View via meeting** when there is no direct team grant.+**Use meeting access** removes only additional direct team sharing; the meeting+checkbox still owns its independent grant. A team save does not disable or+remount the Unlink trigger, and destructive writes remain serialized.++Event notes and document links remain cached per account and target for five+minutes, with a 30-second freshness window and mutation invalidation. Event+Create and Link actions do not wait for the notes request. The picker immediately+uses the app's owned Markdown Quick Access candidates, then adds server title+matches. Matching previous results remain visible during the debounced request;+search responses are fresh for a minute and cached for five minutes. Previous+results never carry across accounts. This supplements the existing owned-note+endpoint; it does not use the full-text search backend.+Picker server reads emit `calendar.notes.search` and a server phase with meeting+ID, query length, configured debounce, local/remote result counts, and outcome.+Quick Access retains its existing search-page and materialization traces. Search+text and document names are not recorded.The calendar service mounts these authenticated routes even when provider sync isdisabled. Every response is private and non-cacheable: