Skip to content

armgit / macro

Public Imported from GitHub
0

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

fix(mentions): open a deleted or inaccessible chip's card on click and tap, worded for its item (#8757)

gbirmana68d6fd048e9
diff --git a/apps/web/src/lib/core/component/AccessErrorViews/Unauthorized.tsx b/apps/web/src/lib/core/component/AccessErrorViews/Unauthorized.tsx
index e0edc7ca49..f6faff9401 100644
--- a/apps/web/src/lib/core/component/AccessErrorViews/Unauthorized.tsx
+++ b/apps/web/src/lib/core/component/AccessErrorViews/Unauthorized.tsx
@@ -7,8 +7,9 @@ import { openLoginModal } from '../TopBar/LoginButton';
/**
* @description This is the view for when a user tries to access an item that returns a 401 indicating they do not have permission to access it.
+ * `noun` names the item when it is not a file, such as an event.
*/
-export default function Unauthorized(props: ParentProps) {
+export default function Unauthorized(props: ParentProps<{ noun?: string }>) {
const currentUserEmail = useEmail();
const isAuthenticated = useIsAuthenticated();
@@ -23,7 +24,7 @@ export default function Unauthorized(props: ParentProps) {
centered
graphic={NoAccessGraphic}
graphicClass="mb-6"
- title="You don't have access to this file"
+ title={`You don't have access to this ${props.noun ?? 'file'}`}
description={
currentUserEmail() ? `Signed in as ${currentUserEmail()}` : undefined
}
diff --git a/apps/web/src/lib/core/component/DocumentPreview.test.tsx b/apps/web/src/lib/core/component/DocumentPreview.test.tsx
index 1967e5f2f8..5cf56a35b9 100644
--- a/apps/web/src/lib/core/component/DocumentPreview.test.tsx
+++ b/apps/web/src/lib/core/component/DocumentPreview.test.tsx
@@ -49,7 +49,9 @@ vi.mock('@service-connection/websocket', () => ({
}));
vi.mock('@solidjs/router', () => ({ useNavigate: () => vi.fn() }));
vi.mock('./AccessErrorViews/Unauthorized', () => ({
- default: () => <p>You don't have access to this file</p>,
+ default: (props: { noun?: string }) => (
+ <p>You don't have access to this {props.noun ?? 'file'}</p>
+ ),
}));
vi.mock('./AccessErrorViews/NotFound', () => ({
default: (props: { message?: string }) => (
@@ -171,7 +173,9 @@ describe('calendar mention preview card', () => {
} satisfies PreviewItem;
const view = renderCard();
- expect(screen.getByText("You don't have access to this file")).toBeTruthy();
+ expect(
+ screen.getByText("You don't have access to this event")
+ ).toBeTruthy();
expect(view.container.textContent).not.toContain('Pilates');
});
@@ -327,3 +331,55 @@ describe('calendar mention card for a meeting the viewer holds', () => {
expect(screen.getByRole('button', { name: 'Pilates' })).toBeTruthy();
});
});
+
+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."],
+ ] as const)('names a deleted %s', (blockName, type, message) => {
+ mocks.item = {
+ id: 'mentioned-item',
+ type,
+ access: 'does_not_exist',
+ loading: false,
+ } satisfies PreviewItem;
+ render(() => (
+ <DocumentPreviewContent
+ documentInfo={{
+ id: 'mentioned-item',
+ type: blockName,
+ params: {},
+ isOpenable: true,
+ }}
+ />
+ ));
+
+ expect(screen.getByText(message)).toBeTruthy();
+ });
+
+ it.each([
+ ['md', 'document', 'document'],
+ ['channel', 'channel', 'channel'],
+ ] as const)('names a %s the viewer can’t open', (blockName, type, noun) => {
+ mocks.item = {
+ id: 'mentioned-item',
+ type,
+ access: 'no_access',
+ loading: false,
+ } satisfies PreviewItem;
+ render(() => (
+ <DocumentPreviewContent
+ documentInfo={{
+ id: 'mentioned-item',
+ type: blockName,
+ params: {},
+ isOpenable: true,
+ }}
+ />
+ ));
+
+ expect(
+ screen.getByText(`You don't have access to this ${noun}`)
+ ).toBeTruthy();
+ });
+});
diff --git a/apps/web/src/lib/core/component/DocumentPreview.tsx b/apps/web/src/lib/core/component/DocumentPreview.tsx
index e3dcd51dce..25a4516723 100644
--- a/apps/web/src/lib/core/component/DocumentPreview.tsx
+++ b/apps/web/src/lib/core/component/DocumentPreview.tsx
@@ -95,6 +95,7 @@ import {
TaskPropertiesPreview,
TaskPropertiesPreviewProvider,
} from './TaskPropertiesPreview';
+import { getShareItemNoun } from './TopBar/linkShare';
/**
* Returns the appropriate icon component based on the icon name
@@ -559,6 +560,14 @@ export function DocumentPreviewContent(props: DocumentPreviewContentProps) {
return props.documentInfo.type;
});
+ // 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 deletedMessage = () =>
+ itemPreviewEntity().type === 'calendar_event'
+ ? 'This event was deleted or cancelled.'
+ : `This ${itemNoun()} was deleted or doesn't exist.`;
+
// Derived state
const canOpenInChat = createCallback(() => {
if (blockName && ['chat'].includes(blockName)) {
@@ -1097,11 +1106,9 @@ export function DocumentPreviewContent(props: DocumentPreviewContentProps) {
fallback={
<div class="text-sm p-4">
{noAccessItem().access === 'no_access' ? (
- <Unauthorized />
- ) : targetBlockType() === 'calendar' ? (
- <NotFound message="This event was deleted or cancelled." />
+ <Unauthorized noun={itemNoun()} />
) : (
- <NotFound />
+ <NotFound message={deletedMessage()} />
)}
</div>
}
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.tsx
index cd6c7849ac..7de89e2ec6 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
@@ -750,25 +750,26 @@ function DocumentMentionInner(props: DocumentMentionDecoratorProps) {
: undefined
);
- // A just-created mention can briefly preview as missing; it still opens
- // the calendar rather than reading as deleted.
- const isDeletedCalendarEvent = () => {
+ // A deleted or inaccessible item has nothing to open. A just-created
+ // mention can briefly preview as missing; it still opens rather than
+ // reading as deleted.
+ const isUnavailable = () => {
const i = item();
+ if (i.loading) return false;
return (
- verifyBlockName(props.blockName) === 'calendar' &&
- !i.loading &&
- i.access === 'does_not_exist' &&
- !isRecentMention()
+ i.access === 'no_access' ||
+ (i.access === 'does_not_exist' && !isRecentMention())
);
};
const showsPreviewOnOpen = () =>
- calendarOpen()?.kind === 'read_only' || isDeletedCalendarEvent();
+ calendarOpen()?.kind === 'read_only' || isUnavailable();
const open = createCallback((e: MouseEvent | KeyboardEvent | null) => {
// The calendar is a singleton block: open it aimed at the viewer's own
// copy of the meeting. A meeting shared through the channel but absent
- // from the viewer's calendars, or one that is gone, has nothing to open,
- // so its preview card is shown instead, as a sheet on touch devices.
+ // from the viewer's calendars, like any item that is gone or hidden from
+ // the viewer, has nothing to open, so its preview card is shown instead,
+ // as a sheet on touch devices.
if (showsPreviewOnOpen()) {
if (isTouchDevice()) setPreviewSheetOpen(true);
else setPreviewCardOpen(true);
@@ -864,7 +865,7 @@ function DocumentMentionInner(props: DocumentMentionDecoratorProps) {
e.stopPropagation();
const i = item();
if (
- isDeletedCalendarEvent() ||
+ isUnavailable() ||
(!i.loading &&
(i.access === 'access' ||
shouldUseFallbackForRecentMention(i, isRecentMention())))
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/browser-test/calendar-mention.browser.e2e.ts b/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/browser-test/calendar-mention.browser.e2e.ts
deleted file mode 100644
index b2890bf6eb..0000000000
--- a/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/browser-test/calendar-mention.browser.e2e.ts
+++ /dev/null
@@ -1,43 +0,0 @@
-import { expect, test } from '@playwright/test';
-
-const fixture =
- '/src/lib/core/component/LexicalMarkdown/component/decorator/browser-test/calendar-mention.html';
-const gone = 'This event was deleted or cancelled.';
-
-test('clicking a deleted calendar mention keeps its card open', async ({
- page,
-}) => {
- await page.goto(fixture);
- const chip = page.getByRole('link', { name: 'Deleted' });
- await expect(chip).toBeVisible();
-
- await chip.click();
- await expect(page.getByText(gone, { exact: true })).toBeVisible();
- await expect(page.getByText(/file exists/)).toBeHidden();
-
- await page.keyboard.press('Escape');
- await expect(page.getByText(gone, { exact: true })).toBeHidden();
-});
-
-test.describe('on a phone', () => {
- test.use({
- viewport: { width: 390, height: 844 },
- hasTouch: true,
- isMobile: true,
- });
-
- test('tapping a deleted calendar mention opens its card as a sheet', async ({
- page,
- }) => {
- await page.goto(fixture);
- const chip = page.getByRole('link', { name: 'Deleted' });
- await expect(chip).toBeVisible();
-
- // The hover card marks its trigger aria-disabled on touch, where it shows
- // nothing; a real tap still reaches the chip.
- await chip.tap({ force: true });
- const sheet = page.getByRole('dialog', { name: 'Preview' });
- await expect(sheet).toBeVisible();
- await expect(sheet.getByText(gone, { exact: true })).toBeVisible();
- });
-});
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/browser-test/calendar-mention.html b/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/browser-test/calendar-mention.html
deleted file mode 100644
index f39843d9b1..0000000000
--- a/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/browser-test/calendar-mention.html
+++ /dev/null
@@ -1,5 +0,0 @@
-<!doctype html>
-<html lang="en">
- <head><meta charset="UTF-8"><title>Calendar mention fixture</title></head>
- <body><div id="root"></div><script type="module" src="./calendar-mention.tsx"></script></body>
-</html>
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/browser-test/calendar-mention.tsx b/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/browser-test/calendar-mention.tsx
deleted file mode 100644
index ce7a7fd91a..0000000000
--- a/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/browser-test/calendar-mention.tsx
+++ /dev/null
@@ -1,58 +0,0 @@
-import '@app/index.css';
-import { AnalyticsContextProvider } from '@app/lib/analytics/analytics-context';
-import { PosthogProvider } from '@app/lib/analytics/posthog';
-import { queryClient } from '@queries/client';
-import { previewKeys } from '@queries/preview/keys';
-import type { PreviewItem } from '@queries/preview/types';
-import { MemoryRouter, Route } from '@solidjs/router';
-import { QueryClientProvider } from '@tanstack/solid-query';
-import { render } from 'solid-js/web';
-import { channelTheme } from '../../../theme';
-import { StaticMarkdownContext } from '../../core/StaticMarkdown';
-import { DocumentMention } from '../DocumentMention';
-
-const id = '01a16d55-0000-7000-8000-000000000001';
-
-// The preview API answers does_not_exist for a meeting deleted or cancelled
-// since it was mentioned.
-queryClient.setQueryData(previewKeys.item(id).queryKey, {
- id,
- type: 'calendar_event',
- access: 'does_not_exist',
- loading: false,
-} satisfies PreviewItem);
-
-function Fixture() {
- return (
- <main class="p-4 text-ink bg-page">
- <p>
- Shared earlier:{' '}
- <DocumentMention
- key="deleted-event"
- theme={channelTheme}
- documentId={id}
- documentName="Planning"
- blockName="calendar"
- createdAt={Date.now() - 10 * 60 * 1000}
- />
- </p>
- </main>
- );
-}
-
-render(
- () => (
- <AnalyticsContextProvider>
- <PosthogProvider>
- <QueryClientProvider client={queryClient}>
- <StaticMarkdownContext theme={channelTheme}>
- <MemoryRouter>
- <Route path="*" component={Fixture} />
- </MemoryRouter>
- </StaticMarkdownContext>
- </QueryClientProvider>
- </PosthogProvider>
- </AnalyticsContextProvider>
- ),
- document.getElementById('root')!
-);
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.ts
new file mode 100644
index 0000000000..df2a1d1216
--- /dev/null
+++ b/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/browser-test/unavailable-mention.browser.e2e.ts
@@ -0,0 +1,76 @@
+import { expect, type Page, test } from '@playwright/test';
+
+const fixture =
+ '/src/lib/core/component/LexicalMarkdown/component/decorator/browser-test/unavailable-mention.html';
+
+const cases = [
+ ['Deleted event', 'Deleted', 'This event was deleted or cancelled.'],
+ [
+ 'Deleted document',
+ 'Deleted',
+ "This document was deleted or doesn't exist.",
+ ],
+ ['Deleted channel', 'Deleted', "This channel was deleted or doesn't exist."],
+ ['Hidden event', 'No Access', "You don't have access to this event"],
+] as const;
+
+function chip(page: Page, label: string, name: string) {
+ return page
+ .getByRole('paragraph')
+ .filter({ hasText: `${label}:` })
+ .getByRole('link', { name });
+}
+
+for (const [label, name, card] of cases) {
+ test(`clicking the ${label.toLowerCase()} chip keeps its card open`, async ({
+ page,
+ }) => {
+ await page.goto(fixture);
+ await expect(chip(page, label, name)).toBeVisible();
+
+ await chip(page, label, name).click();
+ await expect(page.getByText(card, { exact: true })).toBeVisible();
+ await expect(page.getByText(/file/)).toBeHidden();
+
+ await page.keyboard.press('Escape');
+ await expect(page.getByText(card, { exact: true })).toBeHidden();
+ });
+}
+
+test('Enter on a selected deleted chip keeps its card open', 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();
+
+ expect(
+ await page.evaluate(() => window.pressEnterOnSelectedMention?.())
+ ).toBe(true);
+ await expect(page.getByText(card, { exact: true })).toBeVisible();
+ await expect(page.getByText(/file/)).toBeHidden();
+});
+
+test.describe('on a phone', () => {
+ test.use({
+ viewport: { width: 390, height: 844 },
+ hasTouch: true,
+ isMobile: true,
+ });
+
+ for (const [label, name, card] of cases) {
+ test(`tapping the ${label.toLowerCase()} chip opens its card as a sheet`, async ({
+ page,
+ }) => {
+ await page.goto(fixture);
+ await expect(chip(page, label, name)).toBeVisible();
+
+ // The hover card marks its trigger aria-disabled on touch, where it
+ // shows nothing; a real tap still reaches the chip.
+ await chip(page, label, name).tap({ force: true });
+ const sheet = page.getByRole('dialog', { name: 'Preview' });
+ await expect(sheet).toBeVisible();
+ await expect(sheet.getByText(card, { exact: true })).toBeVisible();
+ });
+ }
+});
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/browser-test/unavailable-mention.html b/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/browser-test/unavailable-mention.html
new file mode 100644
index 0000000000..e9ef603213
--- /dev/null
+++ b/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/browser-test/unavailable-mention.html
@@ -0,0 +1,5 @@
+<!doctype html>
+<html lang="en">
+ <head><meta charset="UTF-8"><title>Unavailable mention fixture</title></head>
+ <body><div id="root"></div><script type="module" src="./unavailable-mention.tsx"></script></body>
+</html>
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.tsx
new file mode 100644
index 0000000000..0ac270be5e
--- /dev/null
+++ b/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/browser-test/unavailable-mention.tsx
@@ -0,0 +1,170 @@
+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 { UserContextProvider } from '@core/context/user';
+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 { 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 { render } from 'solid-js/web';
+import { LexicalWrapperContext } from '../../../context/LexicalWrapperContext';
+import type { PluginManager, SelectionData } from '../../../plugins';
+import { channelTheme } from '../../../theme';
+import { StaticMarkdownContext } from '../../core/StaticMarkdown';
+import { DocumentMention } from '../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 = [
+ {
+ label: 'Deleted event',
+ id: '01a16d55-0000-7000-8000-000000000001',
+ blockName: 'calendar',
+ preview: { type: 'calendar_event', access: 'does_not_exist' },
+ },
+ {
+ label: 'Deleted document',
+ id: '01a16d55-0000-7000-8000-000000000002',
+ blockName: 'md',
+ preview: { type: 'document', access: 'does_not_exist' },
+ },
+ {
+ label: 'Deleted channel',
+ id: '01a16d55-0000-7000-8000-000000000003',
+ blockName: 'channel',
+ preview: { type: 'channel', access: 'does_not_exist' },
+ },
+ {
+ label: 'Hidden event',
+ id: '01a16d55-0000-7000-8000-000000000004',
+ blockName: 'calendar',
+ preview: { type: 'calendar_event', access: 'no_access' },
+ },
+] as const satisfies ReadonlyArray<{
+ label: string;
+ id: string;
+ blockName: BlockName;
+ preview: Pick<PreviewItemNoAccess, 'type' | 'access'>;
+}>;
+
+for (const mention of mentions) {
+ queryClient.setQueryData(previewKeys.item(mention.id).queryKey, {
+ id: mention.id,
+ ...mention.preview,
+ 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,
+ email: '[email protected]',
+} as UserInfoData);
+
+declare global {
+ interface Window {
+ pressEnterOnSelectedMention?: () => boolean;
+ }
+}
+
+// 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;
+ 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>
+ );
+}
+
+function Fixture() {
+ return (
+ <main class="p-4 text-ink bg-page space-y-2">
+ <For each={mentions}>
+ {(mention) => (
+ <p>
+ {mention.label}:{' '}
+ <DocumentMention
+ key={mention.id}
+ theme={channelTheme}
+ documentId={mention.id}
+ documentName="Planning"
+ blockName={mention.blockName}
+ createdAt={Date.now() - 10 * 60 * 1000}
+ />
+ </p>
+ )}
+ </For>
+ <p>
+ Selected in an editor: <SelectedMention />
+ </p>
+ </main>
+ );
+}
+
+render(
+ () => (
+ <AnalyticsContextProvider>
+ <PosthogProvider>
+ <QueryClientProvider client={queryClient}>
+ <UserContextProvider>
+ <StaticMarkdownContext theme={channelTheme}>
+ <MemoryRouter>
+ <Route path="*" component={Fixture} />
+ </MemoryRouter>
+ </StaticMarkdownContext>
+ </UserContextProvider>
+ </QueryClientProvider>
+ </PosthogProvider>
+ </AnalyticsContextProvider>
+ ),
+ document.getElementById('root')!
+);
diff --git a/apps/web/src/lib/core/component/TopBar/linkShare.ts b/apps/web/src/lib/core/component/TopBar/linkShare.ts
index 1d14ae641c..16684356b9 100644
--- a/apps/web/src/lib/core/component/TopBar/linkShare.ts
+++ b/apps/web/src/lib/core/component/TopBar/linkShare.ts
@@ -2,6 +2,7 @@ import type { ItemType } from '@service-storage/client';
import type { AccessLevel } from '@service-storage/generated/schemas/accessLevel';
import type { LinkShare } from '@service-storage/generated/schemas/linkShare';
import type { UpdateSharePermissionRequestV2 } from '@service-storage/generated/schemas/updateSharePermissionRequestV2';
+import { match } from 'ts-pattern';
export const NO_LINK_SHARE = 'NONE' as const;
@@ -23,22 +24,34 @@ export function isTeamShareSupportedForItem(itemType: ShareItemType): boolean {
return TEAM_SHAREABLE_ITEM_TYPES.has(itemType);
}
-/** Human noun for share-modal copy such as "Share this chat with the owner's team." */
+/**
+ * Human noun for copy such as "Share this chat with the owner's team." or a
+ * mention card's "You don't have access to this event".
+ */
export function getShareItemNoun(itemType: ShareItemType): string {
- switch (itemType) {
- case 'email':
- return 'email thread';
- case 'agent_session':
- return 'agent session';
- case 'project':
- return 'folder';
- case 'initiative':
- return 'project';
- case 'crm_pipeline':
- return 'pipeline';
- default:
- return itemType;
- }
+ return match(itemType)
+ .with('email', () => 'email thread')
+ .with('agent_session', () => 'agent session')
+ .with('project', () => 'folder')
+ .with('initiative', () => 'project')
+ .with('crm_pipeline', () => 'pipeline')
+ .with('crm_company', () => 'company')
+ .with('crm_contact', () => 'contact')
+ .with('calendar_event', () => 'event')
+ .with('channel_message', () => 'message')
+ .with('channel_thread', () => 'thread')
+ .with('foreign', () => 'item')
+ .with(
+ 'document',
+ 'chat',
+ 'channel',
+ 'call',
+ 'database',
+ 'form',
+ 'routine',
+ (noun) => noun
+ )
+ .exhaustive();
}
export type LinkShareScope = LinkShare | typeof NO_LINK_SHARE;
diff --git a/docs/agent-guide/calendar.md b/docs/agent-guide/calendar.md
index e787f8f2c5..057fc5bde9 100644
--- a/docs/agent-guide/calendar.md
+++ b/docs/agent-guide/calendar.md
@@ -671,7 +671,8 @@ with a channel you belong to, and that are on none of your calendars, follow you
in that list without a marker, as documents shared that way sit beside your own; their chip
names the shared event, so it opens for whoever can already see it. Posting it elsewhere does
not share it on (only someone holding the event on their own calendar can), so people without
-access see `No Access`, like any other mention they cannot open.
+access see `No Access`, like any other mention they cannot open; clicking it (a tap on a phone,
+which opens a sheet) shows `You don't have access to this event`.
A calendar event mentioned in a channel message opens the calendar focused on the viewer's
own copy of the meeting. When a person holds the event on their own calendar and posts the
mention, it is shared read-only with the channel's current members: a member without a copy of
diff --git a/docs/agent-guide/documents.md b/docs/agent-guide/documents.md
index cfab6c534b..0ba2f688e3 100644
--- a/docs/agent-guide/documents.md
+++ b/docs/agent-guide/documents.md
@@ -2536,6 +2536,14 @@ not open their previews. Click outside or press Escape to dismiss the menu;
other references can then be hovered again. Images use an inset frame and task chips
appear below the header. Long titles wrap in place without a full-name tooltip.
+A reference to something deleted reads `Deleted`, and one the viewer can't open
+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 names
+the item: `This document was deleted or doesn't exist.`, `This channel was deleted
+or 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.
+
With `ENABLE_GRAPHQL_SOUP` enabled, the popup reuses the reference's live `ItemPreviews`
batch, including task properties and viewer permission, without another fetch.
Explicit refreshes may revalidate that batch, but requests must settle while the