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): separate CRM records from people (#9390)
gbirman57930bf172d4
diff --git a/apps/web/AGENTS.md b/apps/web/AGENTS.mdindex 09a39799d4..5f5e9fa1a4 100644--- a/apps/web/AGENTS.md+++ b/apps/web/AGENTS.md@@ -143,7 +143,11 @@ menus rank loaded entity sources together with `MENTION_RANKING_CONFIG` in`MentionsMenu/utils/mention-ranking.ts`: name relevance, viewed recency,brevity, and type boosts. Task projects use the `initiative` bucket; `project`means a Drive folder. Preserve broader cache/server matches and the existing-People preview/pinning. The channel browser suite below also checks project+People preview/pinning. Group company and contact records under+Contacts & Companies, separate from People; keep contact selection as a CRM link+even for a matching Macro user.+Only Macro users and groups participate in mobile People pinning.+The channel browser suite below also checks projectranking and insertion on desktop and phone.Channel composer draft persistence has a backend-free browser regression:diff --git a/apps/web/src/features/block-database/core/native-mentions.ts b/apps/web/src/features/block-database/core/native-mentions.tsindex acdd60fc41..40f879ef7e 100644--- a/apps/web/src/features/block-database/core/native-mentions.ts+++ b/apps/web/src/features/block-database/core/native-mentions.ts@@ -61,7 +61,7 @@ export function databaseMentionScope(.with('USER', () => ({ sources: ['users'] })).with('CHANNEL', () => ({ sources: ['channels'] })).with('THREAD', () => ({ sources: ['emails'] }))- .with('COMPANY', () => ({ sources: ['companies'] }))+ .with('COMPANY', () => ({ sources: ['crm'] })).with('CONTACT', () => documentScope(['crm_contact'])).with('TASK', () => documentScope(['task'])).with('DOCUMENT', () => documentScope(['note', 'snippet', 'document']))diff --git a/apps/web/src/features/channel/Input/browser-test/README.md b/apps/web/src/features/channel/Input/browser-test/README.mdindex 2691809415..86a585a700 100644--- a/apps/web/src/features/channel/Input/browser-test/README.md+++ b/apps/web/src/features/channel/Input/browser-test/README.md@@ -29,3 +29,7 @@ The code-paste regression types three backticks to open a code block in theproduction composer and pastes a Macro link, then Markdown. Both land as literalcode text: the link used to become a mention the code block dropped, and theMarkdown used to lose its syntax.++The CRM mention regression uses the real menu and contact query with controlled+pages. It selects a CRM contact whose email also belongs to a Macro user,+verifies the stored contact link, and pages CRM results on desktop and phone.diff --git a/apps/web/src/features/channel/Input/browser-test/crm-mentions.browser.e2e.ts b/apps/web/src/features/channel/Input/browser-test/crm-mentions.browser.e2e.tsnew file mode 100644index 0000000000..901a4f0c3f--- /dev/null+++ b/apps/web/src/features/channel/Input/browser-test/crm-mentions.browser.e2e.ts@@ -0,0 +1,128 @@+import { expect, test } from '@playwright/test';++for (const mobile of [false, true]) {+ test(`CRM records remain record links beside matching people on ${mobile ? 'phone' : 'desktop'}`, async ({+ browser,+ }, testInfo) => {+ const context = await browser.newContext({+ viewport: mobile+ ? { width: 390, height: 844 }+ : { width: 1280, height: 900 },+ isMobile: mobile,+ hasTouch: mobile,+ });+ const page = await context.newPage();+ const errors: string[] = [];+ page.on('pageerror', (error) => errors.push(error.message));+ const contactQueries: string[] = [];+ await page.route('**/*', async (route) => {+ const request = route.request();+ const url = new URL(request.url());+ if (request.postData()?.includes('query CrmContacts')) {+ const body = request.postDataJSON();+ const cursor = body.variables.input.continuation?.cursor;+ contactQueries.push(cursor ?? 'first');+ const index = cursor ? 2 : 1;+ const contact = {+ __typename: 'GraphqlSoupCrmContact',+ id: `contact-${index}`,+ contactTeamId: 'team',+ companyId: 'company',+ companyName: 'Acme company',+ crmContactName: `Acme contact ${index}`,+ email: index === 1 ? '[email protected]' : '[email protected]',+ hidden: false,+ firstInteraction: null,+ lastInteraction: null,+ createdAt: '2026-01-01T00:00:00Z',+ updatedAt: '2026-01-01T00:00:00Z',+ viewedAt: null,+ };+ const items = [contact];+ if (cursor) {+ items.push({+ ...contact,+ id: 'contact-0',+ crmContactName: 'Acme duplicate',+ email: '[email protected]',+ updatedAt: '2025-01-01T00:00:00Z',+ });+ }+ await route.fulfill({+ json: {+ data: {+ user: {+ id: 'viewer',+ soup: {+ items,+ nextCursor: cursor ? null : 'next-page',+ },+ },+ },+ },+ });+ } else if (+ url.hostname === 'localhost' &&+ !url.pathname.startsWith('/__macro_dev/')+ ) {+ await route.continue();+ } else {+ await route.fulfill({+ status: 401,+ contentType: 'application/json',+ body: '{"responses":[]}',+ });+ }+ });+ await page.routeWebSocket('**/*', (socket) => socket.close());+ await page.goto(+ `http://localhost:${process.env.CHANNEL_DRAFT_TEST_PORT ?? '3006'}/src/features/channel/Input/browser-test/mention-ranking.html?crm`+ );+ const editor = page.locator('[data-markdown-editable]');+ await expect(editor).toBeVisible({ timeout: 60_000 });+ await editor.click();+ await page.keyboard.type('@acme');+ const menu = page.locator('.menu-surface');+ await expect(menu.getByTitle('Acme contact 1')).toBeVisible({+ timeout: 15_000,+ });+ await expect(menu.getByTitle('Acme member')).toBeVisible();+ await expect(menu.getByText('Acme company', { exact: true })).toBeVisible();+ if (!mobile) {+ await page.screenshot({+ path: testInfo.outputPath('crm-mentions-desktop.png'),+ });+ // Expanding CRM must page contacts and exclude user mentions.+ await menu+ .getByText('Contacts & Companies', { exact: true })+ .locator('..')+ .getByRole('button', { name: /View all/ })+ .click();+ await expect(menu.getByTitle('Acme contact 2')).toBeVisible();+ await expect(menu.getByTitle('Acme member')).toHaveCount(0);+ await expect(+ menu.getByText('Contacts & Companies (3)', { exact: true })+ ).toBeVisible();+ } else {+ await expect(menu.locator('.group').first()).toContainText('Acme member');+ await expect(menu.getByTitle('Acme contact 2')).toBeVisible();+ await page.screenshot({+ path: testInfo.outputPath('crm-mentions-phone.png'),+ });+ }+ expect(contactQueries).toContain('next-page');+ await expect(menu.getByTitle('Acme duplicate')).toHaveCount(0);+ const contact = menu.getByTitle('Acme contact 1');+ if (mobile) await contact.tap();+ else await contact.click();+ await expect(menu).toHaveCount(0);+ const chip = editor.locator('[data-document-mention][data-document-id]');+ await expect(chip).toHaveAttribute('data-document-id', 'contact-1');+ await expect(chip).toHaveAttribute('data-block-name', 'contact');+ await expect(page.getByTestId('draft')).toContainText(+ '"blockName":"contact"'+ );+ expect(errors).toEqual([]);+ await context.close();+ });+}diff --git a/apps/web/src/features/channel/Input/browser-test/mention-ranking.tsx b/apps/web/src/features/channel/Input/browser-test/mention-ranking.tsxindex 610c2d4b31..c7b68e1e4a 100644--- a/apps/web/src/features/channel/Input/browser-test/mention-ranking.tsx+++ b/apps/web/src/features/channel/Input/browser-test/mention-ranking.tsx@@ -26,41 +26,62 @@ import { makeInputValuePersistenceKey } from '../utils/persistence';const CHANNEL_ID = 'mention-fixture-channel';// Render the stored chip without a backend preview or app navigation host.setDecorator(DocumentMentionNode, DocumentMentionStatic);-const ITEMS: EntityItem[] = [- ...Array.from(- { length: 500 },- (_, index): EntityItem => ({- id: `task-${index}`,- kind: 'entity',- bucket: 'task',- searchText: `Track task changes ${index}`,- sortTimestamp: Date.now(),- timestamps: { viewedAt: new Date() },- data: {- type: 'document',- id: `task-${index}`,- name: `Track task changes ${index}`,- ownerId: 'owner',- fileType: 'md',- subType: { type: 'task' },+const CRM_SCENARIO = new URLSearchParams(location.search).has('crm');+const ITEMS: EntityItem[] = CRM_SCENARIO+ ? [+ {+ id: 'company',+ kind: 'entity',+ bucket: 'crm_company',+ searchText: 'Acme company',+ sortTimestamp: 0,+ timestamps: {},+ data: {+ type: 'crm_company',+ id: 'company',+ name: 'Acme company',+ teamId: 'team',+ hidden: false,+ ownerId: 'owner',+ domains: [],+ },},- })- ),- {- id: 'project',- kind: 'entity',- bucket: 'initiative',- searchText: 'Task planning',- sortTimestamp: 0,- timestamps: {},- data: {- type: 'initiative',- id: 'project',- name: 'Task planning',- ownerId: 'owner',- },- },-];+ ]+ : [+ ...Array.from(+ { length: 500 },+ (_, index): EntityItem => ({+ id: `task-${index}`,+ kind: 'entity',+ bucket: 'task',+ searchText: `Track task changes ${index}`,+ sortTimestamp: Date.now(),+ timestamps: { viewedAt: new Date() },+ data: {+ type: 'document',+ id: `task-${index}`,+ name: `Track task changes ${index}`,+ ownerId: 'owner',+ fileType: 'md',+ subType: { type: 'task' },+ },+ })+ ),+ {+ id: 'project',+ kind: 'entity',+ bucket: 'initiative',+ searchText: 'Task planning',+ sortTimestamp: 0,+ timestamps: {},+ data: {+ type: 'initiative',+ id: 'project',+ name: 'Task planning',+ ownerId: 'owner',+ },+ },+ ];// Reproduce the production merge: cached tasks first, the project appended.// Query filtering stays source-owned; the real menu owns all ranking/selection.@@ -113,7 +134,11 @@ function Fixture() {<ChannelsContextProvider><QuickAccessContextProvider value={QUICK_ACCESS}><main class="min-h-screen bg-page p-4 text-ink space-y-4 flex flex-col justify-end">- <h1>Project mention ranking</h1>+ <h1>+ {CRM_SCENARIO+ ? 'CRM mentions'+ : 'Project mention ranking'}+ </h1><output data-testid="draft" hidden>{draft()}</output>@@ -126,7 +151,17 @@ function Fixture() {id: `channel-input-${CHANNEL_ID}`,placeholder: 'Message #planning',}}- participants={() => []}+ participants={() =>+ CRM_SCENARIO+ ? [+ {+ id: 'macro|[email protected]',+ email: '[email protected]',+ name: 'Acme member',+ },+ ]+ : []+ }bots={() => []}persistenceKey={makeInputValuePersistenceKey({channelId: CHANNEL_ID,diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/MentionsMenu.test.tsx b/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/MentionsMenu.test.tsxindex 774f719732..c8a2301f06 100644--- a/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/MentionsMenu.test.tsx+++ b/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/MentionsMenu.test.tsx@@ -373,8 +373,7 @@ it('only paginates an open mobile menu and resumes on reopen', async () => {menu={menu}editor={editor}users={() => []}- sources={['users']}- includeContacts+ sources={['crm']}/>));expect(mocks.loadMoreContacts).not.toHaveBeenCalled();diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/MentionsMenu.tsx b/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/MentionsMenu.tsxindex 15efa62e3f..af82a5fcea 100644--- a/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/MentionsMenu.tsx+++ b/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/MentionsMenu.tsx@@ -2,6 +2,7 @@ import { useCrmContactMentionSource } from '@app/features/crm/record-adapter';import { externalChatApi } from '@app/features/external-chat/queries/production-api';import { useRoutineMentionSource } from '@app/features/routines/routine-mentions';import { useAnalytics } from '@app/lib/analytics/analytics-context';+import { t } from '@app/lib/i18n';import { globalSplitManager } from '@app/signal/splitLayout';import type { BlockName } from '@core/block';import { useMaybeBlockId, useMaybeBlockName } from '@core/block';@@ -17,6 +18,7 @@ import {type EntityItem,useQuickAccess,} from '@core/context/quickAccess';+import { deduplicateContactItems } from '@core/context/quickAccess/crm-contacts';import { useUserId } from '@core/context/user';import clickOutside from '@core/directive/clickOutside';import { isMobile } from '@core/mobile/isMobile';@@ -72,9 +74,9 @@ import {import { useUsersMention } from './hooks/useUsersMention';import type { BucketConfig, MentionBucketId } from './MentionsMenuController';import { useMentionsMenuController } from './MentionsMenuController';+import { rankMentions } from './utils/mention-ranking';import { createItemHandler } from './utils/mentionHandlers';import { sortMobileMentions } from './utils/mobileSort';-import { mergePeopleMentions } from './utils/people-mentions';const TARGET_ITEMS = 8;const VIRTUAL_ITEM_HEIGHT = 36;@@ -170,7 +172,7 @@ function MentionsMenuInner(props: MentionsMenuProps) {const legacyBlockId = useMaybeBlockId();const blockId = props.sourceDocumentId ?? legacyBlockId;- const { usersAndGroups, groups, availableUsers } = useUsersMention({+ const { usersAndGroups, groups } = useUsersMention({users: props.users,searchTerm,isChannelBlock: props.block === 'channel',@@ -226,10 +228,10 @@ function MentionsMenuInner(props: MentionsMenuProps) {searchTerm: activeSearchTerm,})): undefined;- const companies = () => companyMention?.entities() ?? [];+ const sourceEnabled = (source: MentionBucketId) =>+ !props.sources || props.sources.includes(source);const contactsEnabled = () =>- props.includeContacts ??- !(props.sources?.length === 1 && props.sources[0] === 'users');+ props.includeContacts !== false && sourceEnabled('crm');const contactMention = isFeatureEnabled(enableCrm)? props.entities? useEntityMentionFromList({@@ -239,13 +241,37 @@ function MentionsMenuInner(props: MentionsMenuProps) {}): useCrmContactMentionSource(activeSearchTerm,- () =>- props.menu.isOpen() &&- contactsEnabled() &&- (!props.sources || props.sources.includes('users'))+ () => props.menu.isOpen() && contactsEnabled()): undefined;+ const crmItems = createLazyMemo(() =>+ rankMentions(+ deduplicateContactItems([+ ...(companyMention?.entities() ?? []),+ ...(contactsEnabled() ? (contactMention?.entities() ?? []) : []),+ ]),+ searchTerm(),+ true+ )+ );+ const crmMention = {+ entities: crmItems,+ totalCount: () => crmItems().length,+ hasMore: () =>+ (companyMention?.hasMore() ?? false) ||+ (contactsEnabled() && (contactMention?.hasMore() ?? false)),+ isLoadingMore: () =>+ (companyMention?.isLoadingMore() ?? false) ||+ (contactsEnabled() && (contactMention?.isLoadingMore() ?? false)),+ loadMore: async () => {+ await Promise.all([+ companyMention?.loadMore(),+ contactsEnabled() && contactMention?.loadMore(),+ ]);+ },+ };+const {emails,totalCount: totalEmailCount,@@ -376,15 +402,9 @@ function MentionsMenuInner(props: MentionsMenuProps) {const [mountSelection, setMountSelection] = createSignal<Selection | null>();const mentionUsers = () =>- mergePeopleMentions(- (usersAndGroups() ?? []).filter(- (item) => props.includeGroups !== false || item.kind !== 'group'- ),- contactsEnabled() ? (contactMention?.entities() ?? []) : [],- availableUsers()+ (usersAndGroups() ?? []).filter(+ (item) => props.includeGroups !== false || item.kind !== 'group');- const sourceEnabled = (source: MentionBucketId) =>- !props.sources || props.sources.includes(source);const mobileAllItems = createLazyMemo((): MentionItem[] => {const users = sourceEnabled('users') ? mentionUsers() : [];const combined: MentionItem[] = [@@ -395,7 +415,7 @@ function MentionsMenuInner(props: MentionsMenuProps) {...externalChats(),...routines(),...(sourceEnabled('agentSessions') ? agentSessions() : []),- ...(sourceEnabled('companies') ? (companies() ?? []) : []),+ ...(sourceEnabled('crm') ? crmMention.entities() : []),...(sourceEnabled('emails') ? (emails() ?? []) : []),...(sourceEnabled('calendarEvents') ? calendarEvents() : []),...(sourceEnabled('dates') ? (dates() ?? []) : []),@@ -422,38 +442,25 @@ function MentionsMenuInner(props: MentionsMenuProps) {(sourceEnabled('channels') ? channelsMention.totalCount() : 0) +externalChats().length +routines().length +- (sourceEnabled('companies')- ? (companyMention?.totalCount() ?? 0)- : 0) ++ (sourceEnabled('crm') ? crmMention.totalCount() : 0) +(sourceEnabled('emails') ? totalEmailCount() : 0) +(sourceEnabled('calendarEvents') ? calendarEvents().length : 0) +(sourceEnabled('dates') ? (dates()?.length ?? 0) : 0),hasMore: () =>- (sourceEnabled('users') &&- contactsEnabled() &&- (contactMention?.hasMore() ?? false)) ||(sourceEnabled('documents') && docsMention.hasMore()) ||(sourceEnabled('channels') && channelsMention.hasMore()) ||- (sourceEnabled('companies') &&- (companyMention?.hasMore() ?? false)) ||+ (sourceEnabled('crm') && crmMention.hasMore()) ||(sourceEnabled('emails') && hasMoreEmails()),isLoadingMore: () =>- (sourceEnabled('users') &&- contactsEnabled() &&- (contactMention?.isLoadingMore() ?? false)) ||(sourceEnabled('documents') && docsMention.isLoadingMore()) ||(sourceEnabled('channels') && channelsMention.isLoadingMore()) ||- (sourceEnabled('companies') &&- (companyMention?.isLoadingMore() ?? false)) ||+ (sourceEnabled('crm') && crmMention.isLoadingMore()) ||(sourceEnabled('emails') && isLoadingMoreEmails()),loadMore: async () => {await Promise.all([- sourceEnabled('users') &&- contactsEnabled() &&- contactMention?.loadMore(),sourceEnabled('documents') && docsMention.loadMore(),sourceEnabled('channels') && channelsMention.loadMore(),- sourceEnabled('companies') && companyMention?.loadMore(),+ sourceEnabled('crm') && crmMention.loadMore(),sourceEnabled('emails') && loadMoreEmails(),]);},@@ -476,13 +483,6 @@ function MentionsMenuInner(props: MentionsMenuProps) {: 'People',getData: mentionUsers,getFullCount: () => mentionUsers().length,- hasMore: () =>- contactsEnabled() && (contactMention?.hasMore() ?? false),- isLoadingMore: () =>- contactsEnabled() && (contactMention?.isLoadingMore() ?? false),- loadMore: async () => {- if (contactsEnabled()) await contactMention?.loadMore();- },},{id: 'documents',@@ -521,13 +521,13 @@ function MentionsMenuInner(props: MentionsMenuProps) {getFullCount: () => agentSessions().length,},{- id: 'companies',- label: 'Companies',- getData: () => companies() ?? [],- getFullCount: () => companyMention?.totalCount() ?? 0,- hasMore: () => companyMention?.hasMore() ?? false,- isLoadingMore: () => companyMention?.isLoadingMore() ?? false,- loadMore: async () => companyMention?.loadMore(),+ id: 'crm',+ label: t('common.contactsAndCompanies'),+ getData: crmMention.entities,+ getFullCount: crmMention.totalCount,+ hasMore: crmMention.hasMore,+ isLoadingMore: crmMention.isLoadingMore,+ loadMore: crmMention.loadMore,},{id: 'emails',@@ -868,6 +868,7 @@ function MentionsMenuInner(props: MentionsMenuProps) {binType={bucket().config.id}totalCount={bucket().config.getFullCount()}showingCount={bucket().bucketItems.length}+ isNextPage={bucket().config.hasMore}onViewAll={handleViewAll}isSelected={controller.selectedCategory() ===diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/MentionsMenuController.test.ts b/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/MentionsMenuController.test.tsindex e40c777691..2c1df82fe6 100644--- a/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/MentionsMenuController.test.ts+++ b/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/MentionsMenuController.test.ts@@ -41,7 +41,7 @@ it('keeps the same people visible and selected as delayed categories arrive', ()bucket('documents', items('doc', 74)),bucket('channels', items('channel', 24)),bucket('agentSessions', items('session', 3)),- bucket('companies', items('company', 8)),+ bucket('crm', items('company', 8)),bucket('emails', items('email', 3)),]);expect(menu.combinedItems().slice(0, 3)).toEqual(people.slice(0, 3));@@ -132,7 +132,7 @@ it('keeps every category reachable when stable People rows exceed the preview ta'documents','channels','agentSessions',- 'companies',+ 'crm','emails','dates',];diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/MentionsMenuController.ts b/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/MentionsMenuController.tsindex 554bc0eb85..84fe16d757 100644--- a/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/MentionsMenuController.ts+++ b/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/MentionsMenuController.ts@@ -11,7 +11,7 @@ export type MentionBucketId =| 'routines'| 'agentSessions'| 'channels'- | 'companies'+ | 'crm'| 'emails'| 'dates'| 'openTabs'diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/hooks/useUsersMention.ts b/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/hooks/useUsersMention.tsindex d4eda7519c..42dfb25fec 100644--- a/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/hooks/useUsersMention.ts+++ b/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/hooks/useUsersMention.ts@@ -21,7 +21,6 @@ type UseUsersMentionOptions = {};type UseUsersMentionResult = {- availableUsers: Accessor<UserItem[]>;users: Accessor<UserItem[]>;currentUserDomain: Accessor<string | undefined>;groups: Accessor<GroupMentionItem[]>;@@ -127,7 +126,6 @@ export function useUsersMention(});return {- availableUsers: usersList,users,currentUserDomain,groups,diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/utils/people-mentions.test.ts b/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/utils/people-mentions.test.tsdeleted file mode 100644index a8e021e4b6..0000000000--- a/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/utils/people-mentions.test.ts+++ /dev/null@@ -1,64 +0,0 @@-import type { EntityItem, UserItem } from '@core/context/quickAccess';-import type { CrmContactEntity } from '@entity';-import { expect, it } from 'vitest';-import { mergePeopleMentions } from './people-mentions';--const contact = (- id: string,- email: string,- timestamp = 1,- hidden = false-): EntityItem<CrmContactEntity> => ({- kind: 'entity',- bucket: 'crm_contact',- id,- sortTimestamp: timestamp,- searchText: 'Pat',- timestamps: {},- data: {- type: 'crm_contact',- id,- ownerId: '',- companyId: `company-${id}`,- email,- name: 'Pat',- hidden,- },-});-const user: UserItem = {- kind: 'user',- bucket: 'person',- id: 'macro|[email protected]',- sortTimestamp: 0,- searchText: 'Pat',- timestamps: {},- data: {- id: 'macro|[email protected]',- email: '[email protected]',- name: 'Macro Pat',- },-};--it('collapses full lowercased emails, keeps plus aliases, and picks a recent visible team record', () => {- const result = mergePeopleMentions(- [],- [- contact('old', '[email protected]'),- contact('a', ' [email protected] ', 3),- contact('z', '[email protected]', 3),- contact('hidden', '[email protected]', 9, true),- contact('plus', '[email protected]'),- ],- []- );- expect(result.map((item) => item.id)).toEqual(['z', 'plus']);-});--it('prefers a Macro user even when only their CRM name matches the search', () => {- expect(- mergePeopleMentions([], [contact('crm', '[email protected]')], [user])- ).toEqual([user]);- expect(- mergePeopleMentions([user], [contact('crm', '[email protected]')], [user])- ).toEqual([user]);-});diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/utils/people-mentions.ts b/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/utils/people-mentions.tsdeleted file mode 100644index 303a3da233..0000000000--- a/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/utils/people-mentions.ts+++ /dev/null@@ -1,30 +0,0 @@-import type { EntityItem, UserItem } from '@core/context/quickAccess';-import { resolveContactPeople } from '@core/context/quickAccess/crm-contacts';-import { crmContactEmailKey } from '@entity/types/entity';-import type { GroupMentionItem } from '../../../../utils/mentionsUtils';--/** Preserve real user mentions; CRM duplicates retain one navigable team record. */-export function mergePeopleMentions(- usersAndGroups: (UserItem | GroupMentionItem)[],- contacts: EntityItem[],- availableUsers: UserItem[]-): (UserItem | GroupMentionItem | EntityItem)[] {- const seen = new Set(- usersAndGroups.flatMap((item) =>- item.kind === 'user' ? [crmContactEmailKey(item.data.email)] : []- )- );- const result: (UserItem | GroupMentionItem | EntityItem)[] = [- ...usersAndGroups,- ];- for (const { contact, user } of resolveContactPeople(- contacts,- availableUsers- )) {- const key = crmContactEmailKey(contact.data.email);- if (seen.has(key)) continue;- seen.add(key);- result.push(user ?? contact);- }- return result;-}diff --git a/apps/web/src/lib/i18n/locales/en/common.ts b/apps/web/src/lib/i18n/locales/en/common.tsindex 2a0abc8993..d4615bb816 100644--- a/apps/web/src/lib/i18n/locales/en/common.ts+++ b/apps/web/src/lib/i18n/locales/en/common.ts@@ -25,5 +25,6 @@ export default {more: 'More',search: 'Search',selectItem: 'Select item',+ contactsAndCompanies: 'Contacts & Companies',settings: 'Settings',};diff --git a/docs/agent-guide/documents.md b/docs/agent-guide/documents.mdindex 6f05418315..d99ba95102 100644--- a/docs/agent-guide/documents.md+++ b/docs/agent-guide/documents.md@@ -2481,10 +2481,14 @@ To verify nesting, give a list item a child and grandchild, then swipe theparent right and left: all three should shift one level together, preservingtheir relative depths and order.-## CRM company mentions+## CRM company and contact mentionsWith CRM enabled, type `@` followed by a company name or domain in an editor or-composer. Companies appear in their own mention bucket. With+composer. Companies and contacts appear together under **Contacts & Companies**;+**People** holds Macro users and groups only. Selecting a CRM contact inserts+its record link, including when its email matches a Macro user. User-only pickers+exclude CRM records. On mobile, the single list includes both CRM record types, while only+Macro people and groups are pinned. With`ENABLE_GRAPHQL_SOUP` enabled, results include cached companies even if they areabsent from the first 500 companies in the REST Quick Access feed; the REST feedremains a fallback. Cache search covers synchronized companies, not the entire CRM.@@ -2550,11 +2554,12 @@ With CRM enabled, any task, document or call can point at CRM records through th`Companies` and `Contacts` system properties: side panel `Properties` →`Add property`. Both pickers list Quick Access records: the team's companies andits most recently interacted contacts, filtered by name, domain or email. CRM-contacts have their own Quick Access bucket, apart from people, and are not-offered in `@` mentions or the command menu. Values show the-record's name and open the company or contact. An entity can carry the property-without listing it (set at creation or through the API); adding that property-pins the existing value rather than clearing it. Calls are linked automatically+contacts have their own Quick Access bucket, apart from people. They appear+under **Contacts & Companies** in `@` mentions and under **People** in the+command menu. Values show the record's name and open the company or contact.+An entity can carry the property without listing it (set at creation or through+the API); adding that property pins the existing value rather than clearing it.+Calls are linked automaticallywhen they end, from their participants and the invitees of the calendar eventcarrying the meeting link; verify on a finished call's `Properties`.diff --git a/docs/agent-guide/navigation.md b/docs/agent-guide/navigation.mdindex 3bef9303c8..9848fe0c3d 100644--- a/docs/agent-guide/navigation.md+++ b/docs/agent-guide/navigation.md@@ -1327,15 +1327,17 @@ its requested cache buckets, so a document-only category must not read the emailcatalog. Switching categories still discovers previously unopened buckets;renames, subtype moves, DM priority, and stable tie ordering remain unchanged.-With CRM enabled, normal `@` menus include CRM contacts under **People** in-documents, channels, discussions, and composers. Contact search loads paged+With CRM enabled, normal `@` menus include companies and contacts under+**Contacts & Companies** in documents, channels, discussions, and composers.+**People** contains only Macro users and groups. Contact search loads pagedGraphQL results from all accessible CRM-enabled teams, excludes hidden contacts-and companies, and collapses duplicate full email addresses case-insensitively.-The most recently active visible team record represents each email. An eligible-Macro user with the same email takes precedence and keeps normal user-mention-notifications. External contacts insert a link to their original CRM record;-they do not invite or notify that email address. Assignee and other user-only-pickers continue to list Macro users only.+and companies, and+collapses duplicate full email addresses case-insensitively. The most recently+active visible team record represents each email. Picking a CRM contact inserts+a link to that original CRM record, even if a Macro user shares its email; it+does not invite or notify that email address. Assignee and other user-only+pickers continue to list Macro users only. Mobile keeps a single list, with+only Macro users and groups pinned ahead of ranked entity results.Typed Cmd+K **People** and **All** queries find known Macro users, includingteammates supplied by the contacts service, before their first DM and without a