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(mentions): give database, form, skill, routine and agent session chips the unavailable card (#8763)
gbirman603bdcdffa64
diff --git a/apps/web/src/lib/core/component/DocumentPreview.test.tsx b/apps/web/src/lib/core/component/DocumentPreview.test.tsxindex 5cf56a35b9..cc695d15f3 100644--- a/apps/web/src/lib/core/component/DocumentPreview.test.tsx+++ b/apps/web/src/lib/core/component/DocumentPreview.test.tsx@@ -336,6 +336,16 @@ describe('a mention card for an item that is gone or hidden', () => {it.each([['md', 'document', "This document was deleted or doesn't exist."],['channel', 'channel', "This channel was deleted or doesn't exist."],+ ['skill', 'document', "This skill was deleted or doesn't exist."],+ ['task', 'document', "This task was deleted or doesn't exist."],+ ['database', 'database', "This database was deleted or doesn't exist."],+ ['form', 'form', "This form was deleted or doesn't exist."],+ ['routine', 'routine', "This routine was deleted or doesn't exist."],+ [+ 'agent',+ 'agent_session',+ "This agent session was deleted or doesn't exist.",+ ],] as const)('names a deleted %s', (blockName, type, message) => {mocks.item = {id: 'mentioned-item',@@ -360,6 +370,11 @@ describe('a mention card for an item that is gone or hidden', () => {it.each([['md', 'document', 'document'],['channel', 'channel', 'channel'],+ ['skill', 'document', 'skill'],+ ['database', 'database', 'database'],+ ['form', 'form', 'form'],+ ['routine', 'routine', 'routine'],+ ['agent', 'agent_session', 'agent session'],] as const)('names a %s the viewer can’t open', (blockName, type, noun) => {mocks.item = {id: 'mentioned-item',diff --git a/apps/web/src/lib/core/component/DocumentPreview.tsx b/apps/web/src/lib/core/component/DocumentPreview.tsxindex 25a4516723..1104d20e03 100644--- a/apps/web/src/lib/core/component/DocumentPreview.tsx+++ b/apps/web/src/lib/core/component/DocumentPreview.tsx@@ -31,7 +31,11 @@ import {import { StaticMarkdown } from '@core/component/LexicalMarkdown/component/core/StaticMarkdown';import { channelTheme } from '@core/component/LexicalMarkdown/theme';import { toast } from '@core/component/Toast/Toast';-import { itemToBlockName, resolveBlockAlias } from '@core/constant/allBlocks';+import {+ isBlockAlias,+ itemToBlockName,+ resolveBlockAlias,+} from '@core/constant/allBlocks';import { getDisplayName, tryMacroId } from '@core/user';import { copyBranchNameToClipboard } from '@core/util/branchName';import { fireAndForget } from '@core/util/fireAndForget';@@ -515,6 +519,17 @@ export type DocumentPreviewContentProps = {onOpened?: () => void;};+/**+ * Tasks, skills and snippets are documents underneath; their cards name the+ * kind of item the reference points at rather than its storage.+ */+function aliasNoun(alias: BlockAlias): string | undefined {+ return match(alias)+ .with('task', 'skill', 'snippet', (named) => named)+ .with('csv', () => undefined)+ .exhaustive();+}+/*** The inner preview body shared by every document/task preview: the header* (icon + filename + action buttons), the task body@@ -562,7 +577,13 @@ export function DocumentPreviewContent(props: DocumentPreviewContentProps) {// A gone or hidden item's card names what it was. The preview reports a// cancelled meeting as missing too.- const itemNoun = () => getShareItemNoun(itemPreviewEntity().type);+ const itemNoun = () => {+ const type = props.documentInfo.type;+ return (+ (isBlockAlias(type) ? aliasNoun(type) : undefined) ??+ getShareItemNoun(itemPreviewEntity().type)+ );+ };const deletedMessage = () =>itemPreviewEntity().type === 'calendar_event'? 'This event was deleted or cancelled.'diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/AgentSessionMention.tsx b/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/AgentSessionMention.tsxindex c523787b92..79d239763f 100644--- a/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/AgentSessionMention.tsx+++ b/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/AgentSessionMention.tsx@@ -1,6 +1,11 @@import { useSplitLayout } from '@components/app/split-layout/layout';-import { PopupPreview } from '@core/component/DocumentPreview';+import {+ type DocumentPreviewContentProps,+ PopupPreview,+} from '@core/component/DocumentPreview';+import { DocumentPreviewSheet } from '@core/component/DocumentPreviewSheet';import { HoverCard } from '@core/component/HoverCard';+import { isTouchDevice } from '@core/mobile/isTouchDevice';import { openInNewSplitForMention } from '@core/util/openInNewSplit';import { useNativeSplitNavigationHandler } from '@core/util/useSplitNavigationHandler';import {@@ -14,7 +19,7 @@ import {COMMAND_PRIORITY_NORMAL,KEY_ENTER_COMMAND,} from 'lexical';-import { onMount, Show, Suspense, useContext } from 'solid-js';+import { createSignal, onMount, Show, Suspense, useContext } from 'solid-js';import { LexicalWrapperContext } from '../../context/LexicalWrapperContext';import { autoRegister } from '../../plugins';import { AgentSessionMentionLabel } from './AgentSessionMentionLabel';@@ -44,6 +49,11 @@ export function AgentSessionMention(props: AgentSessionMentionDecoratorProps) {const current = preview();return current?.access === 'access' ? current.data : undefined;};+ // A deleted or private session has nothing to open; its card says which.+ const isUnavailable = () => {+ const access = preview()?.access;+ return access === 'no_access' || access === 'does_not_exist';+ };const label = () => {const current = preview();if (current?.access === 'no_access') return 'Private agent session';@@ -54,7 +64,14 @@ export function AgentSessionMention(props: AgentSessionMentionDecoratorProps) {const selected = () =>wrapper?.selection?.type === 'node' &&wrapper.selection.nodeKeys.has(props.key);+ const [previewCardOpen, setPreviewCardOpen] = createSignal(false);+ const [previewSheetOpen, setPreviewSheetOpen] = createSignal(false);const open = (event: MouseEvent | KeyboardEvent | null) => {+ if (isUnavailable()) {+ if (isTouchDevice()) setPreviewSheetOpen(true);+ else setPreviewCardOpen(true);+ return;+ }if (!session()) return;layout?.openWithSplit({ type: 'agent', id: props.id },@@ -71,7 +88,7 @@ export function AgentSessionMention(props: AgentSessionMentionDecoratorProps) {wrapper.editor.registerCommand(KEY_ENTER_COMMAND,(event) => {- if (!selected() || !session()) return false;+ if (!selected() || !(session() || isUnavailable())) return false;open(event);return true;},@@ -92,46 +109,63 @@ export function AgentSessionMention(props: AgentSessionMentionDecoratorProps) {if ($isAgentSessionMentionNode(node)) node.setExpanded(expanded);});};+ // One set of preview props for the hover card and the touch sheet.+ const previewContentProps: DocumentPreviewContentProps = {+ get documentInfo(): DocumentPreviewContentProps['documentInfo'] {+ return { id: props.id, type: 'agent', params: {}, isOpenable: true };+ },+ get previewInfo() {+ return {+ isPreviewable: false,+ showPreview: canExpand(),+ handlePreviewToggle: () => setExpanded(true),+ };+ },+ };return (<Showwhen={props.expanded && session()}fallback={- <HoverCard- disabled={!session()}- trigger={- <span- data-agent-session-mention="true"- data-agent-session-id={props.id}- data-agent-session-label={label()}- class="py-0.5 rounded-xs hover:bg-hover focus:bg-active"- classList={{ 'bg-active': selected() }}- title={label()}- {...navigation}- >- <AgentSessionMentionLabel label={label()} />- </span>- }- content={- <Suspense>- <PopupPreview- mouseEnter={() => {}}- mouseLeave={() => {}}- documentInfo={{- id: props.id,- type: 'agent',- params: {},- isOpenable: true,- }}- previewInfo={{- isPreviewable: false,- showPreview: canExpand(),- handlePreviewToggle: () => setExpanded(true),- }}- />- </Suspense>- }- />+ <>+ <Show+ when={isTouchDevice() && (isUnavailable() || previewSheetOpen())}+ >+ <DocumentPreviewSheet+ open={previewSheetOpen()}+ onOpenChange={setPreviewSheetOpen}+ {...previewContentProps}+ />+ </Show>+ <HoverCard+ disabled={!session() && !isUnavailable()}+ open={previewCardOpen()}+ onOpenChange={setPreviewCardOpen}+ keepOpenOnTriggerPress={isUnavailable()}+ trigger={+ <span+ data-agent-session-mention="true"+ data-agent-session-id={props.id}+ data-agent-session-label={label()}+ class="py-0.5 rounded-xs hover:bg-hover focus:bg-active"+ classList={{ 'bg-active': selected() }}+ title={label()}+ {...navigation}+ >+ <AgentSessionMentionLabel label={label()} />+ </span>+ }+ content={+ <Suspense>+ <PopupPreview+ mouseEnter={() => {}}+ mouseLeave={() => {}}+ {...previewContentProps}+ />+ </Suspense>+ }+ />+ </>}><div class="block w-full" data-agent-session-expanded="true">diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/DocumentMention.tsx b/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/DocumentMention.tsxindex 7de89e2ec6..38837441f1 100644--- a/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/DocumentMention.tsx+++ b/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/DocumentMention.tsx@@ -35,6 +35,7 @@ import { formatDate } from '@core/util/date';import { fireAndForget } from '@core/util/fireAndForget';import { matches } from '@core/util/match';import { openInNewSplitForMention } from '@core/util/openInNewSplit';+import { ThrownResultError } from '@core/util/result';import { useNativeSplitNavigationHandler } from '@core/util/useSplitNavigationHandler';import {$convertMentionToCard,@@ -46,6 +47,7 @@ import ArrowsOut from '@phosphor/arrows-out-simple.svg';import EyeSlashDuo from '@phosphor/eye-slash.svg';import TrashSimple from '@phosphor/trash-simple.svg';import {+ failedReadAccess,type ItemEntity,isAccessiblePreviewItem,isCalendarEventPreviewItem,@@ -419,8 +421,151 @@ export function DocumentMention(props: DocumentMentionDecoratorProps) {);}-/** Routine references use their saved label; routines have no shared item preview. */+/** Whether a mention was made in the last minute; it stops being recent while mounted. */+function createRecentMention(createdAt: number | undefined) {+ const recentForMs = createdAt+ ? createdAt + RECENT_MENTION_THRESHOLD_MS - Date.now()+ : 0;+ const [isRecent, setIsRecent] = createSignal(recentForMs > 0);+ if (recentForMs > 0) {+ const timer = setTimeout(() => setIsRecent(false), recentForMs);+ onCleanup(() => clearTimeout(timer));+ }+ return isRecent;+}++/**+ * A database, form or routine reference whose item is gone or hidden from the+ * viewer. It reads `Deleted` or `No Access` like any other unavailable+ * reference, and clicking it keeps the item's card open (a tap opens the card+ * as a sheet) instead of opening anything.+ */+function UnavailableMention(props: {+ access: PreviewItemNoAccess['access'];+ documentInfo: DocumentPreviewContentProps['documentInfo'];+ collapsed?: boolean;+}) {+ const [previewCardOpen, setPreviewCardOpen] = createSignal(false);+ const [previewSheetOpen, setPreviewSheetOpen] = createSignal(false);+ const open = (event: MouseEvent | KeyboardEvent) => {+ event.preventDefault();+ event.stopPropagation();+ if (isTouchDevice()) setPreviewSheetOpen(true);+ else setPreviewCardOpen(true);+ };+ return (+ <>+ <Show when={isTouchDevice()}>+ <DocumentPreviewSheet+ open={previewSheetOpen()}+ onOpenChange={setPreviewSheetOpen}+ documentInfo={props.documentInfo}+ />+ </Show>+ <HoverCard+ open={previewCardOpen()}+ onOpenChange={setPreviewCardOpen}+ keepOpenOnTriggerPress+ trigger={+ <span+ class="rounded-xs hover:bg-hover focus-visible:outline-2 focus-visible:outline-ink/30"+ role="link"+ tabIndex={0}+ on:mousedown={(event) => event.preventDefault()}+ on:click={open}+ onKeyDown={(event) => {+ if (event.key === 'Enter') open(event);+ }}+ >+ <Show+ when={props.access === 'no_access'}+ fallback={+ <MentionContainer+ icon={<TrashSimple />}+ text="Deleted"+ collapsed={props.collapsed}+ />+ }+ >+ <MentionContainer+ icon={<EyeSlashDuo />}+ text="No Access"+ collapsed={props.collapsed}+ />+ </Show>+ </span>+ }+ content={+ <PopupPreview+ mouseEnter={() => {}}+ mouseLeave={() => {}}+ documentInfo={props.documentInfo}+ />+ }+ />+ </>+ );+}++/**+ * How a database or form reference reads once its detail read fails, or+ * nothing while it keeps the chip it loaded: a refetch that fails for any+ * reason but the item being gone leaves the loaded chip on screen.+ */+function detailUnavailable(detail: {+ isError: boolean;+ error: unknown;+ dataUpdatedAt: number;+}): PreviewItemNoAccess['access'] | undefined {+ if (!detail.isError) return undefined;+ const access =+ detail.error instanceof ThrownResultError+ ? failedReadAccess(detail.error.errors)+ : 'no_access';+ if (detail.dataUpdatedAt > 0 && access !== 'does_not_exist') return undefined;+ return access;+}+function RoutineMention(props: DocumentMentionDecoratorProps) {+ const lexicalWrapper = useContext(LexicalWrapperContext);+ if (lexicalWrapper?.skipPreviewFetch) return <RoutineLink {...props} />;+ return <PreviewedRoutineMention {...props} />;+}++function PreviewedRoutineMention(props: DocumentMentionDecoratorProps) {+ const { item } = useItemPreviewData(() => ({+ id: props.documentId,+ type: 'routine',+ }));+ const isRecentMention = createRecentMention(props.createdAt);+ // A routine made in the last minute can briefly preview as missing; it+ // still opens rather than reading as deleted.+ const unavailable = () => {+ const i = item();+ if (i.loading || i.access === 'access') return undefined;+ if (i.access === 'does_not_exist' && isRecentMention()) return undefined;+ return i.access;+ };+ return (+ <Show when={unavailable()} fallback={<RoutineLink {...props} />}>+ {(access) => (+ <UnavailableMention+ access={access()}+ collapsed={props.collapsed}+ documentInfo={{+ id: props.documentId,+ type: 'routine',+ params: {},+ isOpenable: true,+ }}+ />+ )}+ </Show>+ );+}++/** Routine references use their saved label; routines have no hover preview. */+function RoutineLink(props: DocumentMentionDecoratorProps) {const name = () =>props.documentName?.replaceAll('\n', ' ').trim() || 'Routine';const open = (event: MouseEvent | KeyboardEvent) => {@@ -471,7 +616,6 @@ function DatabaseMention(props: DocumentMentionDecoratorProps) {const name = () =>detail.isSuccess ? detail.data.database.name : props.documentName;const open = (event: MouseEvent | KeyboardEvent) => {- if (detail.isError) return;event.preventDefault();event.stopPropagation();openDocument(@@ -491,51 +635,64 @@ function DatabaseMention(props: DocumentMentionDecoratorProps) {});};return (- <span class="inline-flex items-baseline gap-1">- <span- class="rounded-xs hover:bg-hover focus-visible:outline-2 focus-visible:outline-ink/30"- role="link"- tabIndex={0}- on:mousedown={(event) => event.preventDefault()}- on:click={open}- onKeyDown={(event) => {- if (event.key === 'Enter') open(event);- }}- >- <MentionContainer- icon={<EntityIcon targetType="database" size="fill" />}- collapsed={props.collapsed}- text={- <span- data-document-mention="true"- data-document-id={props.documentId}- data-block-name="database"- data-document-name={name()}+ <Show+ when={detailUnavailable(detail)}+ fallback={+ <span class="inline-flex items-baseline gap-1">+ <span+ class="rounded-xs hover:bg-hover focus-visible:outline-2 focus-visible:outline-ink/30"+ role="link"+ tabIndex={0}+ on:mousedown={(event) => event.preventDefault()}+ on:click={open}+ onKeyDown={(event) => {+ if (event.key === 'Enter') open(event);+ }}+ >+ <MentionContainer+ icon={<EntityIcon targetType="database" size="fill" />}+ collapsed={props.collapsed}+ text={+ <span+ data-document-mention="true"+ data-document-id={props.documentId}+ data-block-name="database"+ data-document-name={name()}+ >+ {name() || 'Database'}+ </span>+ }+ />+ </span>+ <Show+ when={enabled().enabled && editable() && wrapper?.isInteractable()}+ >+ <Button+ variant="ghost"+ size="icon-xs"+ label="Expand database"+ on:mousedown={(event) => event.preventDefault()}+ on:click={expand}>- {detail.isError ? 'Database unavailable' : name() || 'Database'}- </span>- }+ <ArrowsOut class="size-3.5" />+ </Button>+ </Show>+ </span>+ }+ >+ {(access) => (+ <UnavailableMention+ access={access()}+ collapsed={props.collapsed}+ documentInfo={{+ id: props.documentId,+ type: 'database',+ params: props.blockParams ?? {},+ isOpenable: true,+ }}/>- </span>- <Show- when={- enabled().enabled &&- editable() &&- wrapper?.isInteractable() &&- !detail.isError- }- >- <Button- variant="ghost"- size="icon-xs"- label="Expand database"- on:mousedown={(event) => event.preventDefault()}- on:click={expand}- >- <ArrowsOut class="size-3.5" />- </Button>- </Show>- </span>+ )}+ </Show>);}@@ -548,7 +705,6 @@ function FormMention(props: DocumentMentionDecoratorProps) {const name = () =>detail.isSuccess ? detail.data.form.name : props.documentName;const open = (event: MouseEvent | KeyboardEvent) => {- if (detail.isError) return;event.preventDefault();event.stopPropagation();openDocument(@@ -559,31 +715,49 @@ function FormMention(props: DocumentMentionDecoratorProps) {);};return (- <span- class="rounded-xs hover:bg-hover focus-visible:outline-2 focus-visible:outline-ink/30"- role="link"- tabIndex={0}- on:mousedown={(event) => event.preventDefault()}- on:click={open}- onKeyDown={(event) => {- if (event.key === 'Enter') open(event);- }}+ <Show+ when={detailUnavailable(detail)}+ fallback={+ <span+ class="rounded-xs hover:bg-hover focus-visible:outline-2 focus-visible:outline-ink/30"+ role="link"+ tabIndex={0}+ on:mousedown={(event) => event.preventDefault()}+ on:click={open}+ onKeyDown={(event) => {+ if (event.key === 'Enter') open(event);+ }}+ >+ <MentionContainer+ icon={<EntityIcon targetType="form" size="fill" />}+ collapsed={props.collapsed}+ text={+ <span+ data-document-mention="true"+ data-document-id={props.documentId}+ data-block-name="form"+ data-document-name={name()}+ >+ {name() || 'Form'}+ </span>+ }+ />+ </span>+ }>- <MentionContainer- icon={<EntityIcon targetType="form" size="fill" />}- collapsed={props.collapsed}- text={- <span- data-document-mention="true"- data-document-id={props.documentId}- data-block-name="form"- data-document-name={name()}- >- {detail.isError ? 'Form unavailable' : name() || 'Form'}- </span>- }- />- </span>+ {(access) => (+ <UnavailableMention+ access={access()}+ collapsed={props.collapsed}+ documentInfo={{+ id: props.documentId,+ type: 'form',+ params: props.blockParams ?? {},+ isOpenable: true,+ }}+ />+ )}+ </Show>);}@@ -678,14 +852,7 @@ function DocumentMentionInner(props: DocumentMentionDecoratorProps) {// Check if this is a recently created mention that we should show fallback for.// It stops being recent while mounted, so a chip for an event deleted in the// meantime then reads and opens as deleted without a remount.- const recentForMs = props.createdAt- ? props.createdAt + RECENT_MENTION_THRESHOLD_MS - Date.now()- : 0;- const [isRecentMention, setIsRecentMention] = createSignal(recentForMs > 0);- if (recentForMs > 0) {- const timer = setTimeout(() => setIsRecentMention(false), recentForMs);- onCleanup(() => clearTimeout(timer));- }+ const isRecentMention = createRecentMention(props.createdAt);const showEmbedOption = createMemo(() => {if (!lexicalWrapper?.isInteractable()) return false;diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/browser-test/routine-mention.tsx b/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/browser-test/routine-mention.tsxindex 60c1e6e8e4..f305c0cec2 100644--- a/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/browser-test/routine-mention.tsx+++ b/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/browser-test/routine-mention.tsx@@ -6,6 +6,10 @@ import type {SplitContent,SplitManager,} from '@components/app/split-layout/layoutManager';+import { queryClient } from '@queries/client';+import { previewKeys } from '@queries/preview/keys';+import type { PreviewItem } from '@queries/preview/types';+import { QueryClientProvider } from '@tanstack/solid-query';import { render } from 'solid-js/web';import { channelTheme } from '../../../theme';import {@@ -21,6 +25,16 @@ const mention = `<m-document-mention>${JSON.stringify({blockName: 'routine',})}</m-document-mention>`;+// The viewer can read the routine, so its chip opens it.+queryClient.setQueryData(previewKeys.item(id).queryKey, {+ id,+ type: 'routine',+ access: 'access',+ loading: false,+ rawName: 'Daily review',+ name: 'Daily review',+} satisfies PreviewItem);+// Only navigation is used by this isolated decorator fixture.setGlobalSplitManager({openWithSplit(content: SplitContent) {@@ -33,25 +47,27 @@ render(() => (<AnalyticsContextProvider><PosthogProvider>- <StaticMarkdownContext theme={channelTheme}>- <main class="p-4 text-ink bg-page">- <StaticMarkdown- markdown={`Created ${mention}.`}- target="internal"- />- <p>- <DocumentMention- key="collapsed-routine"- theme={channelTheme}- documentId={id}- documentName="Collapsed review"- blockName="routine"- collapsed+ <QueryClientProvider client={queryClient}>+ <StaticMarkdownContext theme={channelTheme}>+ <main class="p-4 text-ink bg-page">+ <StaticMarkdown+ markdown={`Created ${mention}.`}+ target="internal"/>- </p>- <output id="opened" aria-label="Opened split" />- </main>- </StaticMarkdownContext>+ <p>+ <DocumentMention+ key="collapsed-routine"+ theme={channelTheme}+ documentId={id}+ documentName="Collapsed review"+ blockName="routine"+ collapsed+ />+ </p>+ <output id="opened" aria-label="Opened split" />+ </main>+ </StaticMarkdownContext>+ </QueryClientProvider></PosthogProvider></AnalyticsContextProvider>),diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/browser-test/unavailable-mention.browser.e2e.ts b/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/browser-test/unavailable-mention.browser.e2e.tsindex df2a1d1216..2824e10897 100644--- a/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/browser-test/unavailable-mention.browser.e2e.ts+++ b/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/browser-test/unavailable-mention.browser.e2e.ts@@ -12,13 +12,34 @@ const cases = [],['Deleted channel', 'Deleted', "This channel was deleted or doesn't exist."],['Hidden event', 'No Access', "You don't have access to this event"],+ [+ 'Deleted database',+ 'Deleted',+ "This database was deleted or doesn't exist.",+ ],+ ['Hidden database', 'No Access', "You don't have access to this database"],+ ['Deleted form', 'Deleted', "This form was deleted or doesn't exist."],+ ['Hidden form', 'No Access', "You don't have access to this form"],+ ['Deleted skill', 'Deleted', "This skill was deleted or doesn't exist."],+ ['Deleted routine', 'Deleted', "This routine was deleted or doesn't exist."],+ ['Hidden routine', 'No Access', "You don't have access to this routine"],+ [+ 'Deleted agent session',+ 'Deleted agent session',+ "This agent session was deleted or doesn't exist.",+ ],+ [+ 'Hidden agent session',+ 'Private agent session',+ "You don't have access to this agent session",+ ],] as const;function chip(page: Page, label: string, name: string) {return page.getByRole('paragraph').filter({ hasText: `${label}:` })- .getByRole('link', { name });+ .getByText(name, { exact: true });}for (const [label, name, card] of cases) {@@ -37,18 +58,35 @@ for (const [label, name, card] of cases) {});}-test('Enter on a selected deleted chip keeps its card open', async ({+test('a database chip whose refetch failed keeps its loaded chip', async ({page,}) => {await page.goto(fixture);- const card = "This document was deleted or doesn't exist.";- await expect(chip(page, 'Selected in an editor', 'Deleted')).toBeVisible();+ const loaded = page+ .getByRole('paragraph')+ .filter({ hasText: 'Loaded database:' });+ await expect(loaded.getByText('Roadmap', { exact: true })).toBeVisible();+ await expect(loaded.getByText('No Access', { exact: true })).toBeHidden();+});++test('Enter on a deleted chip selected in a composer keeps its card open', async ({+ page,+}) => {+ await page.goto(fixture);+ const composer = page.getByRole('textbox', { name: 'Composer' });+ await expect(composer.getByText('Deleted', { exact: true })).toBeVisible();++ await composer.focus();+ await page.evaluate(() => window.selectComposerMention?.());+ await page.keyboard.press('Enter');- expect(- await page.evaluate(() => window.pressEnterOnSelectedMention?.())- ).toBe(true);- await expect(page.getByText(card, { exact: true })).toBeVisible();- await expect(page.getByText(/file/)).toBeHidden();+ await expect(+ page.getByText("This document was deleted or doesn't exist.", {+ exact: true,+ })+ ).toBeVisible();+ // The chip took the Enter; the editor did not break the line.+ await expect(composer.locator('p')).toHaveCount(1);});test.describe('on a phone', () => {diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/browser-test/unavailable-mention.tsx b/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/browser-test/unavailable-mention.tsxindex 0ac270be5e..c327b99e55 100644--- a/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/browser-test/unavailable-mention.tsx+++ b/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/browser-test/unavailable-mention.tsx@@ -1,28 +1,44 @@import '@app/index.css';import { AnalyticsContextProvider } from '@app/lib/analytics/analytics-context';import { PosthogProvider } from '@app/lib/analytics/posthog';-import type { BlockName } from '@core/block';+import type { BlockAlias, BlockName } from '@core/block';import { UserContextProvider } from '@core/context/user';+import { onElementConnect } from '@core/util/onElementConnect';+import { ThrownResultError } from '@core/util/result';+import { $dfs } from '@lexical/utils';+import {+ $isDocumentMentionNode,+ DocumentMentionNode,+} from '@macro-inc/lexical-core';+import { setDecorator } from '@macro-inc/lexical-core/decoratorRegistry';+import { agentSessionKeys } from '@queries/agent-session/keys';import { authKeys } from '@queries/auth/keys';import type { UserInfoData } from '@queries/auth/user-info';import { queryClient } from '@queries/client';import { previewKeys } from '@queries/preview/keys';import type { PreviewItem, PreviewItemNoAccess } from '@queries/preview/types';+import { databaseDetailQueryOptions } from '@queries/storage/databases';+import { formDetailQueryOptions } from '@queries/storage/forms';+import { systemSkillsQueryOptions } from '@queries/storage/system-skills';import { MemoryRouter, Route } from '@solidjs/router';import { QueryClientProvider } from '@tanstack/solid-query';-import {- KEY_ENTER_COMMAND,- type LexicalCommand,- type LexicalEditor,-} from 'lexical';-import { For } from 'solid-js';+import { $createNodeSelection, $setSelection } from 'lexical';+import { For, onCleanup } from 'solid-js';import { render } from 'solid-js/web';-import { LexicalWrapperContext } from '../../../context/LexicalWrapperContext';-import type { PluginManager, SelectionData } from '../../../plugins';+import {+ createLexicalWrapper,+ LexicalWrapperContext,+} from '../../../context/LexicalWrapperContext';+import { selectionDataPlugin } from '../../../plugins';import { channelTheme } from '../../../theme';+import { setEditorStateFromMarkdown } from '../../../utils';+import { DecoratorRenderer } from '../../core/DecoratorRenderer';import { StaticMarkdownContext } from '../../core/StaticMarkdown';+import { AgentSessionMention } from '../AgentSessionMention';import { DocumentMention } from '../DocumentMention';+setDecorator(DocumentMentionNode, DocumentMention);+// The previews answer as the API does for an item deleted (or a meeting// cancelled) since it was mentioned, or one the viewer can't open.const mentions = [@@ -50,13 +66,72 @@ const mentions = [blockName: 'calendar',preview: { type: 'calendar_event', access: 'no_access' },},+ {+ label: 'Deleted database',+ id: '01a16d55-0000-7000-8000-000000000005',+ blockName: 'database',+ preview: { type: 'database', access: 'does_not_exist' },+ },+ {+ label: 'Hidden database',+ id: '01a16d55-0000-7000-8000-000000000006',+ blockName: 'database',+ preview: { type: 'database', access: 'no_access' },+ },+ {+ label: 'Deleted form',+ id: '01a16d55-0000-7000-8000-000000000007',+ blockName: 'form',+ preview: { type: 'form', access: 'does_not_exist' },+ },+ {+ label: 'Hidden form',+ id: '01a16d55-0000-7000-8000-000000000008',+ blockName: 'form',+ preview: { type: 'form', access: 'no_access' },+ },+ {+ label: 'Deleted skill',+ id: '01a16d55-0000-7000-8000-000000000009',+ blockName: 'skill',+ preview: { type: 'document', access: 'does_not_exist' },+ },+ {+ label: 'Deleted routine',+ id: '01a16d55-0000-7000-8000-00000000000a',+ blockName: 'routine',+ preview: { type: 'routine', access: 'does_not_exist' },+ },+ {+ label: 'Hidden routine',+ id: '01a16d55-0000-7000-8000-00000000000b',+ blockName: 'routine',+ preview: { type: 'routine', access: 'no_access' },+ },] as const satisfies ReadonlyArray<{label: string;id: string;- blockName: BlockName;+ blockName: BlockName | BlockAlias;preview: Pick<PreviewItemNoAccess, 'type' | 'access'>;}>;+const sessions = [+ {+ label: 'Deleted agent session',+ id: '01a16d55-0000-7000-8000-00000000000c',+ access: 'does_not_exist',+ },+ {+ label: 'Hidden agent session',+ id: '01a16d55-0000-7000-8000-00000000000d',+ access: 'no_access',+ },+] as const satisfies ReadonlyArray<{+ label: string;+ id: string;+ access: PreviewItemNoAccess['access'];+}>;+for (const mention of mentions) {queryClient.setQueryData(previewKeys.item(mention.id).queryKey, {id: mention.id,@@ -64,6 +139,69 @@ for (const mention of mentions) {loading: false,} satisfies PreviewItem);}+// Database and form chips read their own detail; a deleted one answers 404 and+// a hidden one 403.+for (const mention of mentions) {+ const queryKey =+ mention.blockName === 'database'+ ? databaseDetailQueryOptions(mention.id).queryKey+ : mention.blockName === 'form'+ ? formDetailQueryOptions(mention.id).queryKey+ : undefined;+ if (!queryKey) continue;+ queryClient.setQueryDefaults(queryKey, { retryOnMount: false });+ queryClient+ .getQueryCache()+ .build(queryClient, { queryKey })+ .setState({+ status: 'error',+ error: new ThrownResultError([+ mention.preview.access === 'does_not_exist'+ ? { code: 'NOT_FOUND', message: 'Not found' }+ : { code: 'FORBIDDEN', message: 'Forbidden' },+ ]),+ errorUpdatedAt: Date.now(),+ fetchStatus: 'idle',+ });+}+// A database that loaded, then failed to refetch for a reason other than+// being gone, keeps the chip it loaded.+const loadedDatabaseId = '01a16d55-0000-7000-8000-00000000000e';+{+ const { queryKey } = databaseDetailQueryOptions(loadedDatabaseId);+ queryClient.setQueryDefaults(queryKey, {+ retryOnMount: false,+ refetchOnMount: false,+ });+ queryClient+ .getQueryCache()+ .build(queryClient, { queryKey })+ .setState({+ status: 'error',+ data: { database: { id: loadedDatabaseId, name: 'Roadmap' } },+ dataUpdatedAt: Date.now(),+ error: new ThrownResultError([+ { code: 'NETWORK_ERROR', message: 'Failed to fetch' },+ ]),+ errorUpdatedAt: Date.now(),+ fetchStatus: 'idle',+ });+}+queryClient.setQueryData(systemSkillsQueryOptions().queryKey, []);+for (const session of sessions) {+ for (const graphql of [false, true]) {+ queryClient.setQueryData(+ agentSessionKeys.preview(session.id, graphql).queryKey,+ { access: session.access }+ );+ }+ queryClient.setQueryData(previewKeys.item(session.id).queryKey, {+ id: session.id,+ type: 'agent_session',+ access: session.access,+ loading: false,+ } satisfies PreviewItem);+}// A signed-in viewer: the no-access card sends anyone else to sign in.queryClient.setQueryData(authKeys.userInfo.queryKey, {authenticated: true,@@ -72,55 +210,50 @@ queryClient.setQueryData(authKeys.userInfo.queryKey, {declare global {interface Window {- pressEnterOnSelectedMention?: () => boolean;+ selectComposerMention?: () => void;}}-// An editor holding the deleted document's chip as its node selection, so-// Enter reaches the chip's KEY_ENTER_COMMAND handler as it does in a composer.-const selectedMentionKey = 'selected-deleted-document';-const editor = {- registerCommand: <T,>(- command: LexicalCommand<T>,- handler: (payload: T) => boolean- ) => {- if (command === KEY_ENTER_COMMAND) {- window.pressEnterOnSelectedMention = () =>- (handler as (event: KeyboardEvent | null) => boolean)(null);- }- return () => {};- },- isEditable: () => false,- hasNode: () => false,- update: () => {},- dispatchCommand: () => true,-};--function SelectedMention() {- const selection = {- type: 'node',- nodeKeys: new Set([selectedMentionKey]),- } as SelectionData;+/** An editable editor holding the deleted document's chip. */+function Composer() {+ const wrapper = createLexicalWrapper({+ type: 'chat',+ namespace: 'unavailable-mention-composer',+ isInteractable: () => true,+ });+ wrapper.plugins.richText().use(selectionDataPlugin(wrapper));+ setEditorStateFromMarkdown(+ wrapper.editor,+ `Before <m-document-mention>${JSON.stringify({+ documentId: mentions[1].id,+ blockName: mentions[1].blockName,+ documentName: 'Planning',+ })}</m-document-mention> after`+ );+ // Selects the chip as a node, as arrowing onto it in a composer does.+ window.selectComposerMention = () =>+ wrapper.editor.update(() => {+ const mention = $dfs().find(({ node }) => $isDocumentMentionNode(node));+ if (!mention) return;+ const selection = $createNodeSelection();+ selection.add(mention.node.getKey());+ $setSelection(selection);+ });+ onCleanup(() => wrapper.cleanup());return (- <LexicalWrapperContext.Provider- value={{- type: 'markdown',- owner: null,- plugins: {} as PluginManager,- editor: editor as unknown as LexicalEditor,- cleanup: () => {},- isInteractable: () => true,- selection,- }}- >- <DocumentMention- key={selectedMentionKey}- theme={channelTheme}- documentId={mentions[1].id}- documentName="Planning"- blockName={mentions[1].blockName}- createdAt={Date.now() - 10 * 60 * 1000}+ <LexicalWrapperContext.Provider value={wrapper}>+ <div+ ref={(element) =>+ onElementConnect(element, () =>+ wrapper.editor.setRootElement(element)+ )+ }+ contentEditable+ role="textbox"+ aria-label="Composer"+ class="w-96 border border-edge-muted p-2 outline-none"/>+ <DecoratorRenderer editor={wrapper.editor} /></LexicalWrapperContext.Provider>);}@@ -144,8 +277,30 @@ function Fixture() {)}</For><p>- Selected in an editor: <SelectedMention />+ Loaded database:{' '}+ <DocumentMention+ key={loadedDatabaseId}+ theme={channelTheme}+ documentId={loadedDatabaseId}+ documentName="Roadmap"+ blockName="database"+ createdAt={Date.now() - 10 * 60 * 1000}+ /></p>+ <For each={sessions}>+ {(session) => (+ <p>+ {session.label}:{' '}+ <AgentSessionMention+ key={session.id}+ theme={channelTheme}+ id={session.id}+ label="Planning"+ />+ </p>+ )}+ </For>+ <Composer /></main>);}diff --git a/apps/web/src/lib/queries/preview/failed-read.ts b/apps/web/src/lib/queries/preview/failed-read.tsnew file mode 100644index 0000000000..39c758717a--- /dev/null+++ b/apps/web/src/lib/queries/preview/failed-read.ts@@ -0,0 +1,19 @@+import type { ResultError } from '@core/util/result';+import type { PreviewItemNoAccess } from './types';++/** A failed read; the forms service names a missing form in its refusal body. */+type FailedRead = ResultError & { refusal?: { code?: unknown } | null };++/** How an item whose own read failed previews: gone, or hidden from the viewer. */+export function failedReadAccess(+ errors: readonly FailedRead[]+): PreviewItemNoAccess['access'] {+ return errors.some(+ (error) =>+ error.code === 'NOT_FOUND' ||+ error.code === 'GONE' ||+ error.refusal?.code === 'notFound'+ )+ ? 'does_not_exist'+ : 'no_access';+}diff --git a/apps/web/src/lib/queries/preview/fetchers.ts b/apps/web/src/lib/queries/preview/fetchers.tsindex a11d6b6640..c732b6fe8a 100644--- a/apps/web/src/lib/queries/preview/fetchers.ts+++ b/apps/web/src/lib/queries/preview/fetchers.ts@@ -14,6 +14,7 @@ import { toSubType } from '@entity/types/entity';import { cognitionApiServiceClient } from '@service-cognition/client';import { emailClient } from '@service-email/client';import type { ApiThread } from '@service-email/generated/schemas';+import { scheduledActionClient } from '@service-scheduled-action/client';import { storageServiceClient } from '@service-storage/client';import type { FileType } from '@service-storage/generated/schemas/fileType';import { entityMessagesClient } from '@service-storage/messages';@@ -25,6 +26,7 @@ import { emailKeys } from '../email/keys';import { threadQueryOptions } from '../email/thread';import { representativeThreadMessage } from '../email/thread-subject';import { normalizeMessageSender } from '../messages/message-sender';+import { failedReadAccess } from './failed-read';import type { ItemEntity, MessageContext, PreviewItem } from './types';async function fetchSessionPreviews(ids: string[]): Promise<PreviewItem[]> {@@ -428,14 +430,7 @@ async function fetchDatabasePreviews(ids: string[]): Promise<PreviewItem[]> {const base = { id, type: 'database', loading: false } as const;const detail = await storageServiceClient.databases.get({ id });if (detail.isErr())- return {- ...base,- access: detail.error.some(- (error) => error.code === 'NOT_FOUND' || error.code === 'GONE'- )- ? 'does_not_exist'- : 'no_access',- };+ return { ...base, access: failedReadAccess(detail.error) };const { database } = detail.value;if (database.trashed_at !== null)return { ...base, access: 'does_not_exist' };@@ -460,17 +455,7 @@ async function fetchFormPreviews(ids: string[]): Promise<PreviewItem[]> {const base = { id, type: 'form', loading: false } as const;const detail = await storageServiceClient.forms.get({ id });if (detail.isErr())- return {- ...base,- access: detail.error.some(- (error) =>- error.code === 'NOT_FOUND' ||- error.code === 'GONE' ||- error.refusal?.code === 'notFound'- )- ? 'does_not_exist'- : 'no_access',- };+ return { ...base, access: failedReadAccess(detail.error) };const { form } = detail.value;return {...base,@@ -483,6 +468,26 @@ async function fetchFormPreviews(ids: string[]): Promise<PreviewItem[]> {);}+/** A routine previews from its own read; one that is gone reads as deleted. */+async function fetchRoutinePreviews(ids: string[]): Promise<PreviewItem[]> {+ return Promise.all(+ ids.map(async (id): Promise<PreviewItem> => {+ const base = { id, type: 'routine', loading: false } as const;+ const routine = await scheduledActionClient.getRoutine(id);+ if (routine.isErr())+ return { ...base, access: failedReadAccess(routine.error) };+ return {+ ...base,+ access: 'access',+ rawName: routine.value.name,+ name: routine.value.name,+ owner: routine.value.owner,+ updatedAt: routine.value.updated_at,+ };+ })+ );+}+function filterMapToId(items: Array<ItemEntity>, type: ItemEntity['type']) {return items.filter((i) => i.type === type).map(({ id }) => id);}@@ -513,6 +518,7 @@ export async function fetchRestPreviewBatch(doFetch(fetchCalendarEventPreviews, filterMapToId(items, 'calendar_event')),doFetch(fetchDatabasePreviews, filterMapToId(items, 'database')),doFetch(fetchFormPreviews, filterMapToId(items, 'form')),+ doFetch(fetchRoutinePreviews, filterMapToId(items, 'routine')),]);const resultMap = new Map<string, PreviewItem>();results.flat().forEach((result) => {diff --git a/apps/web/src/lib/queries/preview/index.ts b/apps/web/src/lib/queries/preview/index.tsindex 684b9fe015..c47bcb2df7 100644--- a/apps/web/src/lib/queries/preview/index.ts+++ b/apps/web/src/lib/queries/preview/index.ts@@ -1,3 +1,4 @@+export { failedReadAccess } from './failed-read';export { defaultNameTransform } from './fetchers';export {getItemPreview,diff --git a/apps/web/src/lib/queries/preview/tests/failed-read.test.ts b/apps/web/src/lib/queries/preview/tests/failed-read.test.tsnew file mode 100644index 0000000000..bf63c99377--- /dev/null+++ b/apps/web/src/lib/queries/preview/tests/failed-read.test.ts@@ -0,0 +1,23 @@+import { expect, it } from 'vitest';+import { failedReadAccess } from '../failed-read';++const failure = (code: string, refusal?: { code: string }) => ({+ name: 'ResultError',+ code,+ message: code,+ refusal,+});++it('reads an item the service reports missing as deleted', () => {+ expect(failedReadAccess([failure('NOT_FOUND')])).toBe('does_not_exist');+ expect(failedReadAccess([failure('GONE')])).toBe('does_not_exist');+ expect(failedReadAccess([failure('FORBIDDEN', { code: 'notFound' })])).toBe(+ 'does_not_exist'+ );+});++it('reads any other failure as hidden from the viewer', () => {+ expect(failedReadAccess([failure('FORBIDDEN')])).toBe('no_access');+ expect(failedReadAccess([failure('UNAUTHORIZED')])).toBe('no_access');+ expect(failedReadAccess([failure('NETWORK_ERROR')])).toBe('no_access');+});diff --git a/apps/web/src/lib/queries/preview/tests/routine-fetcher.test.ts b/apps/web/src/lib/queries/preview/tests/routine-fetcher.test.tsnew file mode 100644index 0000000000..e56c71fe64--- /dev/null+++ b/apps/web/src/lib/queries/preview/tests/routine-fetcher.test.ts@@ -0,0 +1,70 @@+import { errAsync, okAsync } from 'neverthrow';+import { expect, it, vi } from 'vitest';++const getRoutine = vi.hoisted(() => vi.fn());+vi.mock('@service-scheduled-action/client', () => ({+ scheduledActionClient: { getRoutine },+}));+vi.mock('@service-storage/client', () => ({ storageServiceClient: {} }));+vi.mock('@core/constant/allBlocks', () => ({ itemToSafeName: () => '' }));+vi.mock('@service-cognition/client', () => ({ cognitionApiServiceClient: {} }));+vi.mock('@service-email/client', () => ({ emailClient: {} }));+vi.mock('@service-storage/messages', () => ({ entityMessagesClient: {} }));+vi.mock('../../email/thread', () => ({ threadQueryOptions: vi.fn() }));+vi.mock('../../client', () => ({ queryClient: {} }));+vi.mock('../../agent-session/mention-fetchers', () => ({+ fetchAgentSessionMentionPreviews: vi.fn(),+}));++import { fetchRestPreviewBatch } from '../fetchers';++it('previews a routine the viewer can read, a deleted one as gone, and a hidden one as no access', async () => {+ getRoutine.mockReturnValueOnce(+ okAsync({+ id: 'standup',+ name: 'Daily standup',+ owner: 'macro|[email protected]',+ updated_at: '2026-10-01T09:00:00Z',+ })+ );+ const readable = await fetchRestPreviewBatch([+ { type: 'routine', id: 'standup' },+ ]);+ expect(getRoutine).toHaveBeenCalledWith('standup');+ expect(readable.get('standup')).toEqual({+ id: 'standup',+ type: 'routine',+ access: 'access',+ loading: false,+ rawName: 'Daily standup',+ name: 'Daily standup',+ owner: 'macro|[email protected]',+ updatedAt: '2026-10-01T09:00:00Z',+ });++ getRoutine.mockReturnValueOnce(+ errAsync([{ code: 'NOT_FOUND', message: 'No such routine' }])+ );+ const gone = await fetchRestPreviewBatch([+ { type: 'routine', id: 'deleted' },+ ]);+ expect(gone.get('deleted')).toEqual({+ id: 'deleted',+ type: 'routine',+ access: 'does_not_exist',+ loading: false,+ });++ getRoutine.mockReturnValueOnce(+ errAsync([{ code: 'FORBIDDEN', message: 'Not your routine' }])+ );+ const hidden = await fetchRestPreviewBatch([+ { type: 'routine', id: 'private' },+ ]);+ expect(hidden.get('private')).toEqual({+ id: 'private',+ type: 'routine',+ access: 'no_access',+ loading: false,+ });+});diff --git a/apps/web/src/lib/queries/storage/system-skills.ts b/apps/web/src/lib/queries/storage/system-skills.tsindex 2e4f9dc156..53cc36d79c 100644--- a/apps/web/src/lib/queries/storage/system-skills.ts+++ b/apps/web/src/lib/queries/storage/system-skills.ts@@ -13,7 +13,7 @@ async function fetchSystemSkills() {return result.value.skills;}-function systemSkillsQueryOptions() {+export function systemSkillsQueryOptions() {return {queryKey: SYSTEM_SKILLS_QUERY_KEY,queryFn: fetchSystemSkills,diff --git a/docs/agent-guide/documents.md b/docs/agent-guide/documents.mdindex 0ba2f688e3..ae358d18d4 100644--- a/docs/agent-guide/documents.md+++ b/docs/agent-guide/documents.md@@ -2519,9 +2519,11 @@ inline reference showing the shared agent icon and an underlined session title.Chips omit persona avatars and status. Click it (or select the node and pressEnter) to open `/app/agent/<id>`.It references an existing session; it does not invoke the persona, attach its-transcript to AI context, or grant access. Private/deleted sessions show an-unavailable label. Mounted references refresh every 30 seconds while the tab is-active to update titles and check access. Expanded session references are block-level+transcript to AI context, or grant access. Private and deleted sessions read+`Private agent session` and `Deleted agent session`; clicking one (a tap on a+touch device) opens a card that says why, as other unavailable references do.+Mounted references refresh every 30 seconds while the tab is active to update+titles and check access. Expanded session references are block-levelMagic Chips with the same filled background as document cards. Click the card bodyto select its editor node (border and selection ring); use **Open session** to navigate.The collapse action returns the card to an inline session mention. Text before and@@ -2541,8 +2543,14 @@ reads `No Access`. Clicking either keeps its card open instead of doing nothing,and on a touch device a tap opens the same card as a bottom sheet. The card namesthe item: `This document was deleted or doesn't exist.`, `This channel was deletedor doesn't exist.`, `You don't have access to this event`, and so on (a calendar-event's reads `This event was deleted or cancelled.`). A reference made in the last-minute whose item hasn't reached the preview yet still opens it.+event's reads `This event was deleted or cancelled.`). Skill, task and snippet+references name their kind rather than "document". Database, form and routine+references keep their own chip while the item opens, and switch to this `Deleted`+or `No Access` chip and card once it doesn't; a database or form chip that+loaded keeps its chip through a failed refresh unless the item is gone. Their+detail reads answer non-owners 401/403 for a missing item too, so a deleted+database or form reads `No Access` to anyone but its owner. A reference made in+the last minute whose item hasn't reached the preview yet still opens it.With `ENABLE_GRAPHQL_SOUP` enabled, the popup reuses the reference's live `ItemPreviews`batch, including task properties and viewer permission, without another fetch.diff --git a/docs/agent-guide/navigation.md b/docs/agent-guide/navigation.mdindex 7f3f179f99..50d43b7f7f 100644--- a/docs/agent-guide/navigation.md+++ b/docs/agent-guide/navigation.md@@ -837,9 +837,11 @@ but cannot resume until the run ends. Completed one-offs remain visible withtheir history and do not repeat.An `m-document-mention` with `blockName: "routine"`, the returned routine ID,-and the saved name renders as a clickable mention in an agent reply. Routines-do not appear in the mention menu. Anyone signed in with the link can view its-settings, instructions, and triggers. Only the owner can edit, enable, run,+and the saved name renders as a clickable mention in an agent reply. Once the+routine is deleted the mention reads `Deleted` and clicking it shows a card+instead of opening the routine. Routines do not appear in the mention menu.+Anyone signed in with the link can view its settings, instructions, and+triggers. Only the owner can edit, enable, run,duplicate, delete, or view run history; other users do not see those controls.Run conversations keep their own permissions.