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
feat(mentions): paste CRM pipeline links as mentions (#8066)
teo133f05006708
diff --git a/apps/web/src/components/app/split-layout/split-router/app-middleware.ts b/apps/web/src/components/app/split-layout/split-router/app-middleware.tsindex a006bfe1f3..f70b469994 100644--- a/apps/web/src/components/app/split-layout/split-router/app-middleware.ts+++ b/apps/web/src/components/app/split-layout/split-router/app-middleware.ts@@ -6,6 +6,7 @@ import {} from '@app/features/calendar-view/calendar-url';import { CALENDAR_VIEW_ID } from '@app/features/calendar-view/types';import { channelsSearch } from '@app/features/channels-view/channels-route';+import { crmPipelineSearch } from '@app/features/crm/crm-route';import {driveDocumentFromContent,drivePath,@@ -84,6 +85,12 @@ function redirectLegacyRoutes(.with({ type: 'component' }, ({ id }) =>routes.byId.has(`view-${id}`) ? `/${id}` : undefined)+ // A pipeline has no view of its own; Customers opens on it, on touch too.+ .with({ type: 'pipeline' }, ({ id }) => {+ const query = new URLSearchParams();+ replacePaneSearchParams(query, [crmPipelineSearch(id)]);+ return `/companies?${query}`;+ }).when(() => isTouch,() => undefineddiff --git a/apps/web/src/components/app/split-layout/split-router/mention-links.ts b/apps/web/src/components/app/split-layout/split-router/mention-links.tsindex 415cf7e915..c983037bec 100644--- a/apps/web/src/components/app/split-layout/split-router/mention-links.ts+++ b/apps/web/src/components/app/split-layout/split-router/mention-links.ts@@ -68,18 +68,20 @@ export function createMacroMentionLinkResolver(const leaf = route.matches.at(-1);if (!leaf) return;+ const query = new URLSearchParams(link.query);const reference = routes.byId.get(leaf.id)- ?.definition.toReference?.(leaf.params);+ ?.definition.toReference?.(leaf.params, query);if (!isBlockRouteReference(reference)) return;const mention: MacroMentionLink = {id: reference.id,block: reference.type,- params: {},+ params: { ...reference.params },};+ if (reference.params) return mention;const entry: Entry = { id: 'mention', location: { route } };const externalKeys = new Set(externalSearchKeys(routes, [entry]));- new URLSearchParams(link.query).forEach((value, key) => {+ query.forEach((value, key) => {if (key !== 'referral_code' && externalKeys.has(key)) {mention.params[key] = value;}diff --git a/apps/web/src/features/block-pipeline/component/PipelineBlock.tsx b/apps/web/src/features/block-pipeline/component/PipelineBlock.tsxnew file mode 100644index 0000000000..6828db0ae5--- /dev/null+++ b/apps/web/src/features/block-pipeline/component/PipelineBlock.tsx@@ -0,0 +1,17 @@+import { crmPipelineSearch } from '@app/features/crm/crm-route';+import { RedirectSplit } from '@components/app/split-layout/split-router/app-route-shell';+import { useBlockId } from '@core/block';++/** Routed opens redirect before mounting this; anything else lands here. */+export default function PipelineBlock() {+ return (+ <RedirectSplit+ to={{+ type: 'component',+ id: 'companies',+ entryMetadata: { search: crmPipelineSearch(useBlockId()) },+ }}+ mergeHistory+ />+ );+}diff --git a/apps/web/src/features/block-pipeline/definition.ts b/apps/web/src/features/block-pipeline/definition.tsnew file mode 100644index 0000000000..408b9644f8--- /dev/null+++ b/apps/web/src/features/block-pipeline/definition.ts@@ -0,0 +1,18 @@+import { defineBlock, LoadErrors } from '@core/block';+import { ok } from 'neverthrow';+import { lazy } from 'solid-js';++/** A CRM pipeline, which opens in the Customers view. */+export const definition = defineBlock({+ name: 'pipeline',+ description: 'View a CRM pipeline',+ component: lazy(() => import('./component/PipelineBlock')),+ liveTrackingEnabled: false,+ async load(source, _intent) {+ if (source.type === 'dss') {+ return ok({ id: source.id });+ }+ return LoadErrors.MISSING;+ },+ accepted: {},+});diff --git a/apps/web/src/features/crm/components/crm-mobile-tabs.tsx b/apps/web/src/features/crm/components/crm-mobile-tabs.tsxindex 5bd8634df8..c0404ec5bc 100644--- a/apps/web/src/features/crm/components/crm-mobile-tabs.tsx+++ b/apps/web/src/features/crm/components/crm-mobile-tabs.tsx@@ -1,6 +1,6 @@import { type PillTabItem, PillTabs } from '@components/app/mobile/PillTabs';import type { JSX } from 'solid-js';-import { CRM_RECORDS } from '../core/navigation';+import { CRM_RECORDS, pipelineTab } from '../core/navigation';export function CrmMobileTabs(props: {active: string;@@ -15,7 +15,7 @@ export function CrmMobileTabs(props: {label: record.label,})),...props.pipelines.map((pipeline) => ({- value: `pipeline:${pipeline.id}`,+ value: pipelineTab(pipeline.id),label: pipeline.name,})),...props.lists.map((list) => ({diff --git a/apps/web/src/features/crm/context/workspace-context.tsx b/apps/web/src/features/crm/context/workspace-context.tsxindex 0c80529c97..ce0ed66879 100644--- a/apps/web/src/features/crm/context/workspace-context.tsx+++ b/apps/web/src/features/crm/context/workspace-context.tsx@@ -9,6 +9,14 @@ import type { EntityActionListState } from '../../next-soup/actions/entity-actioimport type { SoupState } from '../../next-soup/create-soup-state';import type { QueryStore } from '../../next-soup/filters/filter-store/query-store';+/** A pipeline another view asked the workspace to show. */+export type CrmPipelineRequest = {+ /** A new `seek` repeats a request for the same pipeline. */+ current: Accessor<{ pipelineId: string; seek: string } | undefined>;+ /** Forgets the request once the workspace shows something else. */+ release(): void;+};+/** Collection capabilities consumed by CRM views, supplied by the host adapter. */export type CrmWorkspace = {host: {@@ -19,6 +27,7 @@ export type CrmWorkspace = {openCompany(entity: EntityData, newSplit: boolean): void;openSettings(): void;openTeamSettings(): void;+ pipelineRequest: CrmPipelineRequest['current'];};soup: EntityActionListState & {diff --git a/apps/web/src/features/crm/core/navigation.ts b/apps/web/src/features/crm/core/navigation.tsindex a937a13325..fc27dd1ea9 100644--- a/apps/web/src/features/crm/core/navigation.ts+++ b/apps/web/src/features/crm/core/navigation.ts@@ -4,6 +4,20 @@ export const CRM_RECORDS = [{ id: 'people', label: 'People' },] as const;+const PIPELINE_TAB_PREFIX = 'pipeline:';++/** The workspace tab that shows a pipeline. */+export function pipelineTab(pipelineId: string): string {+ return `${PIPELINE_TAB_PREFIX}${pipelineId}`;+}++/** The pipeline a workspace tab shows, if any. */+export function pipelineIdOfTab(tab: string | undefined): string | undefined {+ return tab?.startsWith(PIPELINE_TAB_PREFIX)+ ? tab.slice(PIPELINE_TAB_PREFIX.length)+ : undefined;+}+export type CrmListConfig = {kind: 'crm-list';teamId: string;diff --git a/apps/web/src/features/crm/crm-route.test.ts b/apps/web/src/features/crm/crm-route.test.tsnew file mode 100644index 0000000000..5c954721f1--- /dev/null+++ b/apps/web/src/features/crm/crm-route.test.ts@@ -0,0 +1,108 @@+import {+ createRoutesManifest,+ type Entry,+ type SplitRoutes,+} from '@app/lib/split-router';+import { paneRoute } from '@app/routes/app-route';+import {+ appRoute,+ companiesRoute,+ legacyContentRoute,+ notFoundRoute,+} from '@app/routes/routes';+import { createAppSplitRouterMiddleware } from '@components/app/split-layout/split-router/app-middleware';+import { createMacroMentionLinkResolver } from '@components/app/split-layout/split-router/mention-links';+import { describe, expect, it, vi } from 'vitest';+import { pipelineTab } from './core/navigation';+import type { CrmViewConfig } from './core/saved-view';+import { encodeCrmViewParam } from './queries/saved-view-codec';++vi.mock('@components/app/split-layout/componentRegistry', () => ({+ resolveComponent: vi.fn(() => ({ type: 'mock-component' })),+}));+vi.mock('@service-storage/websocket', () => ({+ storageWS: { reconnectIfDisconnected: vi.fn() },+ createWebSocketJob: vi.fn(),+}));+vi.mock('@service-connection/websocket', () => ({+ ws: { addEventListener: vi.fn(), send: vi.fn() },+ state: () => 'closed',+ createConnectionBlockWebsocketEffect: vi.fn(),+ createConnectionWebsocketEffect: vi.fn(),+}));++const pipelineId = '01a1212c-74e5-79bd-8767-0d4943d55b15';+const routes = createRoutesManifest({+ definitions: [+ {+ ...appRoute,+ children: [companiesRoute, legacyContentRoute, notFoundRoute],+ },+ ],+ defaultRoute: () => paneRoute({ id: companiesRoute.id, params: {} }),+} satisfies SplitRoutes);+const resolveMention = createMacroMentionLinkResolver(routes);++const crmViewLink = (view: CrmViewConfig) =>+ `${window.location.origin}/app/companies?crmView=${encodeCrmViewParam(view)}`;++describe('pipeline links', () => {+ it('pastes a copied pipeline link as a mention of the pipeline', () => {+ expect(+ resolveMention(+ crmViewLink({ kind: 'crm', activeTab: pipelineTab(pipelineId) })+ )+ ).toEqual({ id: pipelineId, block: 'pipeline', params: {} });+ });++ it.each([+ crmViewLink({ kind: 'crm', activeTab: 'active' }),+ crmViewLink({ kind: 'crm', activeTab: 'list:favorites' }),+ crmViewLink({ kind: 'crm', activeTab: pipelineTab('not-a-uuid') }),+ `${window.location.origin}/app/companies?crmView=garbage`,+ `${window.location.origin}/app/companies`,+ ])('leaves other Customers links as links: %s', (url) => {+ expect(resolveMention(url)).toBeUndefined();+ });++ it.each([false, true])(+ 'opens a pipeline in Customers, on that pipeline (touch: %s)',+ (touch) => {+ const [redirectLegacy] = createAppSplitRouterMiddleware({+ isTouchDevice: () => touch,+ });+ const to: Entry = {+ id: 'entry',+ location: {+ route: paneRoute({+ id: legacyContentRoute.id,+ params: { type: 'pipeline', id: pipelineId },+ }),+ },+ };+ const open = () => {+ const result = redirectLegacy!({+ routes,+ from: undefined,+ to,+ path: `/pipeline/${pipelineId}`,+ cause: 'navigate',+ signal: new AbortController().signal,+ redirect: (path) => ({ type: 'redirect', to: path }),+ cancel: () => ({ type: 'cancel' }),+ });+ if (!result || result instanceof Promise || result.type !== 'redirect')+ throw new Error('Expected a redirect');+ return new URL(result.to, window.location.origin);+ };++ const first = open();+ expect(first.pathname).toBe('/companies');+ expect(first.searchParams.get('s0.crm.pipeline')).toBe(pipelineId);+ // Opening the same pipeline again is a new request.+ expect(open().searchParams.get('s0.crm.seek')).not.toBe(+ first.searchParams.get('s0.crm.seek')+ );+ }+ );+});diff --git a/apps/web/src/features/crm/crm-route.ts b/apps/web/src/features/crm/crm-route.tsnew file mode 100644index 0000000000..5699779326--- /dev/null+++ b/apps/web/src/features/crm/crm-route.ts@@ -0,0 +1,43 @@+import {+ createSearchParamsCodec,+ type SplitReference,+ type SplitSearchState,+} from '@app/lib/split-router';+import { uuidRouteReference } from '@components/app/split-layout/split-router/mention-links';+import { z } from 'zod';+import { pipelineIdOfTab } from './core/navigation';+import {+ CRM_VIEW_URL_PARAM,+ decodeCrmViewParam,+} from './queries/saved-view-codec';++/** A pipeline another view asked Customers to show; a new `seek` repeats the request. */+export const crmSearch = {+ namespace: 'crm',+ schema: z.object({ pipeline: z.string(), seek: z.string() }),+ defaults: { pipeline: '', seek: '' },+};++const crmSearchCodec = createSearchParamsCodec(crmSearch);++/** The Customers pane search that opens it on `pipelineId`. */+export function crmPipelineSearch(pipelineId: string): SplitSearchState {+ return {+ [crmSearch.namespace]:+ crmSearchCodec.serialize({+ pipeline: pipelineId,+ seek: crypto.randomUUID(),+ }) ?? {},+ };+}++/** A shared Customers link that shows a pipeline references the pipeline. */+export function crmViewReference(+ query: URLSearchParams+): SplitReference | undefined {+ const view = query.get(CRM_VIEW_URL_PARAM);+ const tab = view ? decodeCrmViewParam(view)?.activeTab : undefined;+ const reference = uuidRouteReference(pipelineIdOfTab(tab), 'pipeline');+ // The rest of the shared view state is no place within the pipeline.+ return reference && { ...reference, params: {} };+}diff --git a/apps/web/src/features/crm/crm.tsx b/apps/web/src/features/crm/crm.tsxindex f80bd2ebfd..0a5f259084 100644--- a/apps/web/src/features/crm/crm.tsx+++ b/apps/web/src/features/crm/crm.tsx@@ -2,7 +2,10 @@ import { Show } from 'solid-js';import { SoupViewStateProvider } from '../next-soup/soup-view/soup-view-context';import { ViewTour } from '../tours/ViewTour';import { CrmProvider } from './context/crm-context';-import { CrmWorkspaceProvider } from './context/workspace-context';+import {+ type CrmPipelineRequest,+ CrmWorkspaceProvider,+} from './context/workspace-context';import type { CrmViewConfig } from './core/saved-view';import { createAppCrmContext } from './crm-adapter';import { companiesTour } from './tour';@@ -10,9 +13,16 @@ import { Companies } from './views/companies';import { CrmDefaultViewLoader } from './views/default-view';import { createCrmWorkspace } from './workspace-adapter';-export function Crm(props: { initialView?: CrmViewConfig }) {+export function Crm(props: {+ initialView?: CrmViewConfig;+ pipelineRequest?: CrmPipelineRequest;+}) {const crm = createAppCrmContext();- const workspace = createCrmWorkspace(crm, props.initialView);+ const workspace = createCrmWorkspace(+ crm,+ props.initialView,+ props.pipelineRequest+ );return (<CrmProvider value={crm}><SoupViewStateProvider state={workspace.state}>diff --git a/apps/web/src/features/crm/preview-adapter.ts b/apps/web/src/features/crm/preview-adapter.tsindex 0cde3695b2..7d9e814dbd 100644--- a/apps/web/src/features/crm/preview-adapter.ts+++ b/apps/web/src/features/crm/preview-adapter.ts@@ -1,6 +1,7 @@import { storageServiceClient } from '@service-storage/client';import {fetchCrmContactPreviews as fetchContacts,+ fetchCrmPipelinePreviews as fetchPipelines,fetchCrmCompanyPreviews as fetchPreviews,} from './queries/previews';export function fetchCrmCompanyPreviews(ids: string[]) {@@ -10,3 +11,7 @@ export function fetchCrmCompanyPreviews(ids: string[]) {export function fetchCrmContactPreviews(ids: string[]) {return fetchContacts((input) => storageServiceClient.getContact(input), ids);}++export function fetchCrmPipelinePreviews(ids: string[]) {+ return fetchPipelines((id) => storageServiceClient.getCrmPipeline(id), ids);+}diff --git a/apps/web/src/features/crm/queries/previews.ts b/apps/web/src/features/crm/queries/previews.tsindex 4b7cfaee72..63a6d798ad 100644--- a/apps/web/src/features/crm/queries/previews.ts+++ b/apps/web/src/features/crm/queries/previews.ts@@ -49,6 +49,37 @@ export async function fetchCrmCompanyPreviews();}+/** A pipeline previews from its own read; one gone or trashed reads as deleted. */+export async function fetchCrmPipelinePreviews(+ getPipeline: typeof storageServiceClient.getCrmPipeline,+ pipelineIds: string[]+): Promise<PreviewItem[]> {+ return await Promise.all(+ pipelineIds.map(async (id): Promise<PreviewItem> => {+ const base = { id, type: 'crm_pipeline', loading: false } as const;+ const result = await getPipeline(id);+ if (result.isErr())+ return {+ ...base,+ access: result.error.some(+ (error) => error.code === 'NOT_FOUND' || error.code === 'GONE'+ )+ ? 'does_not_exist'+ : 'no_access',+ };+ const pipeline = result.value;+ if (pipeline.trashedAt) return { ...base, access: 'does_not_exist' };+ return {+ ...base,+ access: 'access',+ rawName: pipeline.name,+ name: pipeline.name,+ owner: pipeline.userId,+ };+ })+ );+}+/** Contact titles use the same role-aware REST boundary as contact details. */export async function fetchCrmContactPreviews(getContact: typeof storageServiceClient.getContact,diff --git a/apps/web/src/features/crm/route-views.tsx b/apps/web/src/features/crm/route-views.tsxindex f1c7747e12..d499b4b530 100644--- a/apps/web/src/features/crm/route-views.tsx+++ b/apps/web/src/features/crm/route-views.tsx@@ -1,10 +1,13 @@+import { createSearchParams } from '@app/lib/split-router';import {RedirectSplit,usePageViewTracking,withAuth,} from '@components/app/split-layout/split-router/app-route-shell';import { enableCrm, isFeatureEnabled } from '@core/constant/featureFlags';-import { lazy } from 'solid-js';+import { lazy, untrack } from 'solid-js';+import { pipelineTab } from './core/navigation';+import { crmSearch } from './crm-route';import {CRM_VIEW_URL_PARAM,decodeCrmViewParam,@@ -18,10 +21,28 @@ export const CompaniesRouteView = withAuth(() => {if (!isFeatureEnabled(enableCrm))return <RedirectSplit to={{ type: 'component', id: 'home' }} />;usePageViewTracking('companies');+ const [search, setSearch] = createSearchParams(crmSearch);+ const pipelineRequest = () =>+ search.pipeline+ ? { pipelineId: search.pipeline, seek: search.seek }+ : undefined;+ const requested = untrack(pipelineRequest);const crmView = new URLSearchParams(window.location.search).get(CRM_VIEW_URL_PARAM);return (- <Crm initialView={crmView ? decodeCrmViewParam(crmView) : undefined} />+ <Crm+ initialView={+ requested+ ? { kind: 'crm', activeTab: pipelineTab(requested.pipelineId) }+ : crmView+ ? decodeCrmViewParam(crmView)+ : undefined+ }+ pipelineRequest={{+ current: pipelineRequest,+ release: () => setSearch({}, { mode: 'replace', history: 'replace' }),+ }}+ />);});diff --git a/apps/web/src/features/crm/views/crm-workspace.test.tsx b/apps/web/src/features/crm/views/crm-workspace.test.tsxindex a67765217e..9b22cacccb 100644--- a/apps/web/src/features/crm/views/crm-workspace.test.tsx+++ b/apps/web/src/features/crm/views/crm-workspace.test.tsx@@ -199,6 +199,9 @@ function setup(initialTab = 'active') {const [activeTab, setActiveTab] = createSignal<string | undefined>(initialTab);+ const [pipelineRequest, setPipelineRequest] = createSignal<+ { pipelineId: string; seek: string } | undefined+ >();fixture.workspace = {activeTab,setActiveTab,@@ -206,6 +209,7 @@ function setup(initialTab = 'active') {scopeId: 'crm',isActive: () => true,captureEntryState: vi.fn(),+ pipelineRequest,},source: {},queryFilters: { state: { include: {} } },@@ -213,7 +217,7 @@ function setup(initialTab = 'active') {render(() => (<CrmWorkspaceView>{() => <div>Record list</div>}</CrmWorkspaceView>));- return { activeTab };+ return { activeTab, setPipelineRequest };}it('keeps sidebar destinations in the mobile header when switching records, pipelines and lists', () => {@@ -263,6 +267,17 @@ it('shows the company of a pipeline row in place of the pipeline on desktop', ()expect(fixture.openWithSplit).not.toHaveBeenCalled();});+it('shows a pipeline another view asks for, in place of an open record', () => {+ fixture.touch = false;+ const { activeTab, setPipelineRequest } = setup('pipeline:sales');+ fireEvent.click(screen.getByRole('button', { name: 'Open Acme' }));+ expect(screen.queryByText('Sales table')).toBeNull();+ setPipelineRequest({ pipelineId: 'sales', seek: 'first' });+ expect(activeTab()).toBe('pipeline:sales');+ expect(screen.getByText('Sales table')).toBeTruthy();+ expect(screen.queryByText('Sales record company:acme')).toBeNull();+});+it('opens the company of a pipeline row in its own split on touch', () => {setup('pipeline:sales');fireEvent.click(screen.getByRole('button', { name: 'Open Acme' }));diff --git a/apps/web/src/features/crm/views/crm-workspace.tsx b/apps/web/src/features/crm/views/crm-workspace.tsxindex a126748f8a..fc8cfcb3e9 100644--- a/apps/web/src/features/crm/views/crm-workspace.tsx+++ b/apps/web/src/features/crm/views/crm-workspace.tsx@@ -27,8 +27,10 @@ import PlusIcon from '@phosphor/plus.svg';import { Button, Dropdown, Tooltip } from '@ui';import { tourTarget } from '@ui/components/Tour';import {+ createEffect,createSignal,type JSX,+ on,onCleanup,onMount,Show,@@ -41,7 +43,7 @@ import { PipelineDialog } from '../components/pipeline-dialog';import { PipelineSidebar } from '../components/pipeline-sidebar';import { useCrmContext } from '../context/crm-context';import { useCrmWorkspace } from '../context/workspace-context';-import { CRM_RECORDS } from '../core/navigation';+import { CRM_RECORDS, pipelineIdOfTab, pipelineTab } from '../core/navigation';import { createCrmExportLoader } from '../primitives/export-source';import { useApplyCrmView } from './apply-view';import { CrmExport } from './export-companies';@@ -250,15 +252,23 @@ export function CrmWorkspaceView(props: {);const [creatingPipeline, setCreatingPipeline] = createSignal(false);const pipelineId = () =>- pipelinesEnabled() && view.activeTab()?.startsWith('pipeline:')- ? view.activeTab()?.slice('pipeline:'.length)- : undefined;+ pipelinesEnabled() ? pipelineIdOfTab(view.activeTab()) : undefined;const activePipeline = () =>pipelines.pipelines().find((pipeline) => pipeline.id === pipelineId());const selectPipeline = (id: string) => {closeRecord();- view.setActiveTab(`pipeline:${id}`);+ view.setActiveTab(pipelineTab(id));};+ // The first request already chose the initial tab.+ createEffect(+ on(+ view.host.pipelineRequest,+ (request) => {+ if (request) selectPipeline(request.pipelineId);+ },+ { defer: true }+ )+ );const listsEnabled = useCrmContext().listsEnabled();const lists = useCrmLists(() => (listsEnabled() ? teamId() : undefined));const [editing, setEditing] = createSignal<{@@ -273,12 +283,11 @@ export function CrmWorkspaceView(props: {const activeList = () =>lists.lists().find((list) => `list:${list.id}` === active());// Every other tab (hidden companies, saved or shared views) is a company view.- const activeRecord = () =>- pipelineId()- ? `pipeline:${pipelineId()}`- : active().startsWith('list:') || peopleActive()- ? active()- : 'active';+ const activeRecord = () => {+ const id = pipelineId();+ if (id) return pipelineTab(id);+ return active().startsWith('list:') || peopleActive() ? active() : 'active';+ };const title = () =>activeList()?.name ??CRM_RECORDS.find((record) => record.id === activeRecord())?.label ??@@ -380,11 +389,11 @@ export function CrmWorkspaceView(props: {active={activeRecord()}pipelines={pipelinesEnabled() ? pipelines.pipelines() : []}lists={listsEnabled() ? lists.lists() : []}- onNavigate={(id) =>- id.startsWith('pipeline:')- ? selectPipeline(id.slice('pipeline:'.length))- : navigate(id)- }+ onNavigate={(id) => {+ const pipeline = pipelineIdOfTab(id);+ if (pipeline) selectPipeline(pipeline);+ else navigate(id);+ }}leading={<Show when={!peopleActive() && !pipelineId()}><Suspense>@@ -427,7 +436,7 @@ export function CrmWorkspaceView(props: {onCopyLink={() =>copyViewLink({kind: 'crm',- activeTab: `pipeline:${id}`,+ activeTab: pipelineTab(id),})}onTrashed={() => navigate('active')}diff --git a/apps/web/src/features/crm/workspace-adapter.tsx b/apps/web/src/features/crm/workspace-adapter.tsxindex edce303490..bca270664d 100644--- a/apps/web/src/features/crm/workspace-adapter.tsx+++ b/apps/web/src/features/crm/workspace-adapter.tsx@@ -5,7 +5,7 @@ import { idToDisplayName } from '@core/user/util';import { type EntityData, isCrmCompanyEntity } from '@entity';import { COMPANY_STAGE_OPTIONS } from '@entity/utils/task-properties';import { SYSTEM_PROPERTY_IDS } from '@property/constants';-import { batch, createEffect, createRenderEffect, on } from 'solid-js';+import { batch, createEffect, createRenderEffect, on, untrack } from 'solid-js';import type { Query } from '../next-soup/filters/filter-store';import type { SetPredicatesInput } from '../next-soup/filters/filter-store/predicates-store';import {@@ -18,7 +18,11 @@ import { useSoupFilterPersistence } from '../next-soup/use-soup-filter-persistenimport { openEntityInSplitFromUnifiedList } from '../next-soup/utils';import type { CrmContext } from './context/crm-context';import type { DealStages } from './context/crm-sources';-import type { CrmWorkspace } from './context/workspace-context';+import type {+ CrmPipelineRequest,+ CrmWorkspace,+} from './context/workspace-context';+import { pipelineIdOfTab } from './core/navigation';import type { CrmViewConfig } from './core/saved-view';import { createCrmCollectionFilters } from './filter-adapter';import { COMPANY_GROUP_OPTIONS } from './group-options';@@ -36,7 +40,8 @@ function stageFilterResolvers(stages: DealStages) {export function createCrmWorkspace(crm: CrmContext,- sharedView?: CrmViewConfig+ sharedView?: CrmViewConfig,+ pipelineRequest?: CrmPipelineRequest) {const soup = useSoup();const panel = useSplitPanelOrThrow();@@ -181,6 +186,19 @@ export function createCrmWorkspace(panel.handle.setDisplayName('Customers');});+ // Only a tab change releases: a new request arrives before its tab does.+ createEffect(+ on(+ soupView.activeTab,+ (tab) => {+ const request = untrack(() => pipelineRequest?.current());+ if (request && pipelineIdOfTab(tab) !== request.pipelineId)+ pipelineRequest?.release();+ },+ { defer: true }+ )+ );+// Bridge live soup sort state back to preferences. `defer: true` skips the// initial run on mount, so we only write when the user actually changes it.createEffect(@@ -208,6 +226,7 @@ export function createCrmWorkspace(},openSettings: () => openSettings('CRM'),openTeamSettings: () => openSettings('Team'),+ pipelineRequest: () => pipelineRequest?.current(),},};return { state, context, applyDefaultCrmView };diff --git a/apps/web/src/features/entity/queries/rename.ts b/apps/web/src/features/entity/queries/rename.tsindex 6af6bebf06..7ce6ad0c6b 100644--- a/apps/web/src/features/entity/queries/rename.ts+++ b/apps/web/src/features/entity/queries/rename.ts@@ -62,7 +62,7 @@ type RenameRollbackContext = {type EntityRenameData = {id: string;- itemType: ItemType;+ itemType: EntityData['type'];oldName: string;newName: string;};diff --git a/apps/web/src/features/entity/utils/buildEntityData.ts b/apps/web/src/features/entity/utils/buildEntityData.tsindex 98ea973727..f643125a30 100644--- a/apps/web/src/features/entity/utils/buildEntityData.ts+++ b/apps/web/src/features/entity/utils/buildEntityData.ts@@ -188,10 +188,11 @@ export function buildEntityData(})// The singleton calendar block has no entity-shaped block id..with('calendar', (): undefined => undefined)- // Databases and forms use REST; CRM records and initiatives come from Soup.+ // Databases, forms and pipelines use REST; CRM records and initiatives come from Soup..with('database','form',+ 'pipeline','company','contact','initiative',diff --git a/apps/web/src/features/tasks-view/route.test.tsx b/apps/web/src/features/tasks-view/route.test.tsxindex c07ff5fbed..95387b3d27 100644--- a/apps/web/src/features/tasks-view/route.test.tsx+++ b/apps/web/src/features/tasks-view/route.test.tsx@@ -58,7 +58,9 @@ describe('project routes in Tasks', () => {expect(claimOf(manifest, route)).toBe(`block:initiative:${projectId}`);const leaf = route.matches.at(-1)!;expect(- manifest.byId.get(leaf.id)?.definition.toReference?.(leaf.params)+ manifest.byId+ .get(leaf.id)+ ?.definition.toReference?.(leaf.params, new URLSearchParams())).toEqual({ type: 'initiative', id: projectId });});diff --git a/apps/web/src/lib/constants/block-registry.ts b/apps/web/src/lib/constants/block-registry.tsindex bff2a6208f..e0cdb97a0e 100644--- a/apps/web/src/lib/constants/block-registry.ts+++ b/apps/web/src/lib/constants/block-registry.ts@@ -33,6 +33,8 @@ export const BlockRegistry = ['agent',// A task project (`project` is a folder).'initiative',+ // A CRM pipeline, shown in the Customers view.+ 'pipeline',] as const;/** Aliases for block types that share a concrete block implementation. */diff --git a/apps/web/src/lib/core/block.ts b/apps/web/src/lib/core/block.tsindex 3d564d0019..bbb26a9125 100644--- a/apps/web/src/lib/core/block.ts+++ b/apps/web/src/lib/core/block.ts@@ -84,6 +84,7 @@ export const NonDocumentBlockTypes = ['pr','agent','initiative',+ 'pipeline',] as const as (BlockName | BlockAlias)[];/**@@ -150,6 +151,7 @@ const _ValidBlockCombinations: BlockCombinationRules = {pr: allBlockNames,agent: allBlockNames,initiative: allBlockNames,+ pipeline: allBlockNames,} as const;// maps block name to valid parents@@ -186,6 +188,7 @@ export const ValidNestingCombinations: BlockCombinationRules = {pr: new Set([]),agent: new Set([]),initiative: new Set([]),+ pipeline: new Set([]),};export const LoadErrors = {diff --git a/apps/web/src/lib/core/blockMethodRegistry.ts b/apps/web/src/lib/core/blockMethodRegistry.tsindex b7bf08219e..2c4d93f0b3 100644--- a/apps/web/src/lib/core/blockMethodRegistry.ts+++ b/apps/web/src/lib/core/blockMethodRegistry.ts@@ -48,6 +48,7 @@ export interface BlockMethodRegistry {pr: EmptySpec;agent: EmptySpec;initiative: EmptySpec;+ pipeline: EmptySpec;}// Type helper to get the method spec for a block namediff --git a/apps/web/src/lib/core/component/EntityIcon.tsx b/apps/web/src/lib/core/component/EntityIcon.tsxindex bf84e16c21..23c701d8a2 100644--- a/apps/web/src/lib/core/component/EntityIcon.tsx+++ b/apps/web/src/lib/core/component/EntityIcon.tsx@@ -52,6 +52,7 @@ import PhoneCall from '@phosphor/phone-call.svg';import Shapes from '@phosphor/shapes.svg';import Sparkle from '@phosphor/sparkle.svg';import Stack from '@phosphor/stack.svg';+import Table from '@phosphor/table.svg';import Users from '@phosphor/users.svg';import UsersThree from '@phosphor/users-three.svg';import AddressBookBold from '@phosphor-icons/core/bold/address-book-bold.svg';@@ -92,6 +93,7 @@ import PhoneCallBold from '@phosphor-icons/core/bold/phone-call-bold.svg';import ShapesBold from '@phosphor-icons/core/bold/shapes-bold.svg';import SparkleBold from '@phosphor-icons/core/bold/sparkle-bold.svg';import StackBold from '@phosphor-icons/core/bold/stack-bold.svg';+import TableBold from '@phosphor-icons/core/bold/table-bold.svg';import UsersBold from '@phosphor-icons/core/bold/users-bold.svg';import UsersThreeBold from '@phosphor-icons/core/bold/users-three-bold.svg';import type { PreviewItem } from '@queries/preview';@@ -482,6 +484,13 @@ export const ENTITY_ICON_CONFIGS: Record<EntityWithValidIcon, IconConfig> = {background: 'bg-default/20',prettyName: 'Company',},+ pipeline: {+ icon: Table,+ boldIcon: TableBold,+ foreground: 'text-default',+ background: 'bg-default/20',+ prettyName: 'Pipeline',+ },reminder: {icon: BellSimple,boldIcon: BellSimpleBold,@@ -708,6 +717,9 @@ export function getPreviewItemIconType(item: PreviewItem): EntityWithValidIcon {if (item.loading || item.access !== 'access') {return 'default';}+ // A pipeline previews like an entity but is not one.+ const { type } = item;+ if (type === 'crm_pipeline') return 'pipeline';- return getEntityIconType(item);+ return getEntityIconType({ ...item, type });}diff --git a/apps/web/src/lib/core/component/FileList/constants.tsx b/apps/web/src/lib/core/component/FileList/constants.tsxindex e65ed00ae8..16525fd918 100644--- a/apps/web/src/lib/core/component/FileList/constants.tsx+++ b/apps/web/src/lib/core/component/FileList/constants.tsx@@ -89,4 +89,5 @@ const _fileTypeColors: Record<BlockName | BlockAlias | 'default', string> = {pr: defaultFileColor,agent: defaultFileColor,initiative: defaultFileColor,+ pipeline: defaultFileColor,};diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/plugins/mentions/mentionsPlugin.ts b/apps/web/src/lib/core/component/LexicalMarkdown/plugins/mentions/mentionsPlugin.tsindex 5d86756f44..0696d21d15 100644--- a/apps/web/src/lib/core/component/LexicalMarkdown/plugins/mentions/mentionsPlugin.ts+++ b/apps/web/src/lib/core/component/LexicalMarkdown/plugins/mentions/mentionsPlugin.ts@@ -156,6 +156,7 @@ export type ItemMention = {| 'routine'| 'crm_company'| 'crm_contact'+ | 'crm_pipeline'| 'skill';itemId: string;fileType?: string;@@ -251,6 +252,9 @@ function $mentionItemFromNode(node: MentionNode): ItemMention {} else if (blockName === 'contact') {fileType = 'contact';itemType = 'crm_contact';+ } else if (blockName === 'pipeline') {+ fileType = 'pipeline';+ itemType = 'crm_pipeline';} else if (blockName === 'unknown') {fileType = 'unknown';}@@ -359,6 +363,7 @@ const blockItemType = (blockName: string): ItemMention['itemType'] => {}).with('crm_company', () => 'crm_company').with('crm_contact', () => 'crm_contact')+ .with('crm_pipeline', () => 'crm_pipeline').exhaustive();};diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/plugins/text-paste/textPastePlugin.test.ts b/apps/web/src/lib/core/component/LexicalMarkdown/plugins/text-paste/textPastePlugin.test.tsindex 1a3ec653e4..f7daae6e0b 100644--- a/apps/web/src/lib/core/component/LexicalMarkdown/plugins/text-paste/textPastePlugin.test.ts+++ b/apps/web/src/lib/core/component/LexicalMarkdown/plugins/text-paste/textPastePlugin.test.ts@@ -30,7 +30,7 @@ describe('parseMacroAppUrl', () => {});- it.each(['md', 'channel', 'task', 'pr', 'initiative'])(+ it.each(['md', 'channel', 'task', 'pr', 'initiative', 'pipeline'])('preserves existing %s links',(block) => {expect(diff --git a/apps/web/src/lib/core/constant/allBlocks.ts b/apps/web/src/lib/core/constant/allBlocks.tsindex c7075cfc6e..b9598a4d01 100644--- a/apps/web/src/lib/core/constant/allBlocks.ts+++ b/apps/web/src/lib/core/constant/allBlocks.ts@@ -192,6 +192,7 @@ export function fileTypeToBlockName(// CRM entity types map to their dedicated blocks (entity type !== block name).if (blockOrFiletype === 'crm_company') return 'company';if (blockOrFiletype === 'crm_contact') return 'contact';+ if (blockOrFiletype === 'crm_pipeline') return 'pipeline';if (blockOrFiletype === 'docx' || blockOrFiletype === 'write') {if (isFeatureEnabled(enableDocxEditor)) return 'write';diff --git a/apps/web/src/lib/core/internal/trackBlockOpened.ts b/apps/web/src/lib/core/internal/trackBlockOpened.tsindex 4a43dea352..b374bdda33 100644--- a/apps/web/src/lib/core/internal/trackBlockOpened.ts+++ b/apps/web/src/lib/core/internal/trackBlockOpened.ts@@ -32,6 +32,7 @@ function isSoupEntityTag('foreign','crm_company','crm_contact',+ 'crm_pipeline','initiative',() => false)diff --git a/apps/web/src/lib/queries/preview/fetchers.ts b/apps/web/src/lib/queries/preview/fetchers.tsindex 8ab38a5584..a11d6b6640 100644--- a/apps/web/src/lib/queries/preview/fetchers.ts+++ b/apps/web/src/lib/queries/preview/fetchers.ts@@ -1,6 +1,7 @@import {fetchCrmCompanyPreviews,fetchCrmContactPreviews,+ fetchCrmPipelinePreviews,} from '@app/features/crm/preview-adapter';import { QUERY_FILTERS_BASE } from '@app/features/next-soup/filters/query-filters';import { itemToSafeName } from '@core/constant/allBlocks';@@ -508,6 +509,7 @@ export async function fetchRestPreviewBatch(doFetch(fetchEmailPreviews, filterMapToId(items, 'email')),doFetch(fetchCrmCompanyPreviews, filterMapToId(items, 'crm_company')),doFetch(fetchCrmContactPreviews, filterMapToId(items, 'crm_contact')),+ doFetch(fetchCrmPipelinePreviews, filterMapToId(items, 'crm_pipeline')),doFetch(fetchCalendarEventPreviews, filterMapToId(items, 'calendar_event')),doFetch(fetchDatabasePreviews, filterMapToId(items, 'database')),doFetch(fetchFormPreviews, filterMapToId(items, 'form')),diff --git a/apps/web/src/lib/queries/preview/tests/pipeline-fetcher.test.ts b/apps/web/src/lib/queries/preview/tests/pipeline-fetcher.test.tsnew file mode 100644index 0000000000..39f799551d--- /dev/null+++ b/apps/web/src/lib/queries/preview/tests/pipeline-fetcher.test.ts@@ -0,0 +1,73 @@+import { err, ok } from 'neverthrow';+import { expect, it, vi } from 'vitest';++const getCrmPipeline = vi.hoisted(() => vi.fn());+vi.mock('@service-storage/client', () => ({+ storageServiceClient: { getCrmPipeline },+}));+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';++const pipeline = {+ id: 'sales',+ name: 'Sales',+ userId: 'macro|[email protected]',+ trashedAt: null,+};++it('previews a pipeline by name, and a trashed or missing one as deleted', async () => {+ getCrmPipeline.mockResolvedValueOnce(ok(pipeline));+ const visible = await fetchRestPreviewBatch([+ { type: 'crm_pipeline', id: 'sales' },+ ]);+ expect(getCrmPipeline).toHaveBeenCalledWith('sales');+ expect(visible.get('sales')).toEqual({+ id: 'sales',+ type: 'crm_pipeline',+ access: 'access',+ loading: false,+ rawName: 'Sales',+ name: 'Sales',+ owner: 'macro|[email protected]',+ });++ getCrmPipeline.mockResolvedValueOnce(+ ok({ ...pipeline, trashedAt: '2026-10-01T00:00:00Z' })+ );+ const trashed = await fetchRestPreviewBatch([+ { type: 'crm_pipeline', id: 'sales' },+ ]);+ expect(trashed.get('sales')).toMatchObject({ access: 'does_not_exist' });++ getCrmPipeline.mockResolvedValueOnce(+ err([{ code: 'NOT_FOUND', message: 'Resource not found' }])+ );+ const missing = await fetchRestPreviewBatch([+ { type: 'crm_pipeline', id: 'gone' },+ ]);+ expect(missing.get('gone')).toMatchObject({ access: 'does_not_exist' });+});++it('previews a pipeline the viewer cannot read as no access', async () => {+ getCrmPipeline.mockResolvedValueOnce(+ err([{ code: 'FORBIDDEN', message: 'Forbidden' }])+ );+ const denied = await fetchRestPreviewBatch([+ { type: 'crm_pipeline', id: 'private' },+ ]);+ expect(denied.get('private')).toEqual({+ id: 'private',+ type: 'crm_pipeline',+ access: 'no_access',+ loading: false,+ });+});diff --git a/apps/web/src/lib/service-clients/service-storage/itemType.ts b/apps/web/src/lib/service-clients/service-storage/itemType.tsindex ed725178b6..d6d29a9084 100644--- a/apps/web/src/lib/service-clients/service-storage/itemType.ts+++ b/apps/web/src/lib/service-clients/service-storage/itemType.ts@@ -18,6 +18,7 @@ export type ItemType =| 'foreign'| 'crm_company'| 'crm_contact'+ | 'crm_pipeline'| 'initiative';/** Item type assumed when a surface has no better information. */@@ -84,6 +85,7 @@ export function blockNameToItemType(.with('calendar', () => 'calendar_event').with('company', () => 'crm_company').with('contact', () => 'crm_contact')+ .with('pipeline', () => 'crm_pipeline').with('pr', () => 'foreign').otherwise(() => DEFAULT_ITEM_TYPE);}diff --git a/apps/web/src/lib/split-router/routes/define.ts b/apps/web/src/lib/split-router/routes/define.tsindex 7f0c5af6dd..18fdad07dc 100644--- a/apps/web/src/lib/split-router/routes/define.ts+++ b/apps/web/src/lib/split-router/routes/define.ts@@ -38,7 +38,10 @@ type SplitRouteDefinitionConstraint = {type RouteParamCallbacks<TParams> = {serializeParams?: (params: TParams) => SplitRouteRawParams;claim?: (params: TParams) => SplitRouteClaim | undefined;- toReference?: (params: TParams) => SplitReference | undefined;+ toReference?: (+ params: TParams,+ query: URLSearchParams+ ) => SplitReference | undefined;remountKey?: (params: TParams,context: SplitRouteRemountContextdiff --git a/apps/web/src/lib/split-router/routes/types.ts b/apps/web/src/lib/split-router/routes/types.tsindex 79d18a5932..bcafe68dd1 100644--- a/apps/web/src/lib/split-router/routes/types.ts+++ b/apps/web/src/lib/split-router/routes/types.ts@@ -54,6 +54,8 @@ export type SplitRouteClaim = {export type SplitReference = {type: string;id: string;+ /** Location within the entity; omitted, hosts take the link's external query keys. */+ params?: Record<string, string>;};/** Route metadata. Hosts extend this interface through declaration merging. */@@ -84,6 +86,13 @@ type SplitRouteParamCallback<TParams, TResult> = {bivarianceHack(params: TParams): TResult;}['bivarianceHack'];+type SplitRouteReferenceCallback<TParams> = {+ bivarianceHack(+ params: TParams,+ query: URLSearchParams+ ): SplitReference | undefined;+}['bivarianceHack'];+export type SplitRouteRemountContext = {entryId: string;};@@ -123,10 +132,12 @@ export type SplitRouteDefinition<StandardSchemaV1.InferOutput<TParamsSchema>,SplitRouteClaim | undefined>;- /** The entity this route shows, for hosts that link to it; the router never reads it. */- toReference?: SplitRouteParamCallback<- StandardSchemaV1.InferOutput<TParamsSchema>,- SplitReference | undefined+ /**+ * The entity a link to this route shows, read from its params and the+ * link's unprefixed query. For hosts that link to it; the router never reads it.+ */+ toReference?: SplitRouteReferenceCallback<+ StandardSchemaV1.InferOutput<TParamsSchema>>;/*** Pane search namespaces this route adds, or `'*'` for every namespace.diff --git a/apps/web/src/routes/routes.ts b/apps/web/src/routes/routes.tsindex 8708698a50..e0d54bcf07 100644--- a/apps/web/src/routes/routes.ts+++ b/apps/web/src/routes/routes.ts@@ -9,6 +9,7 @@ import {} from '@app/features/calendar-view/calendar-url';import { CALENDAR_VIEW_ID } from '@app/features/calendar-view/types';import { changesSearch } from '@app/features/changes/changes-search';+import { crmViewReference } from '@app/features/crm/crm-route';import { driveDetailTrailSchema } from '@app/features/drive-view/primitives/drive-detail-trail';import {DRIVE_DOCUMENT_TYPES,@@ -596,6 +597,7 @@ export const companiesRoute = defineRoute({search: '*' as const,externalSearch: ['crmView'],claim: () => ({ namespace: 'component', id: 'companies' }),+ toReference: (_, query) => crmViewReference(query),});export const foldersRoute = defineRoute({diff --git a/crates/prompt/src/lib.rs b/crates/prompt/src/lib.rsindex 345d84e697..a4c2b71665 100644--- a/crates/prompt/src/lib.rs+++ b/crates/prompt/src/lib.rs@@ -333,6 +333,7 @@ mod tests {assert!(instructions.contains("\"expanded\":true"));assert!(instructions.contains("\"blockName\":\"skill\""));assert!(instructions.contains("\"blockName\":\"initiative\""));+ assert!(instructions.contains("\"blockName\":\"pipeline\""));}#[test]diff --git a/crates/prompt/src/mentions.rs b/crates/prompt/src/mentions.rsindex 76dfe1d006..950ebacf52 100644--- a/crates/prompt/src/mentions.rs+++ b/crates/prompt/src/mentions.rs@@ -42,12 +42,14 @@ Use `<m-document-mention>` with the right `blockName` (and `blockParams` when ne- Automation mention: `<m-document-mention>{"documentId":"{id}","documentName":"","blockName":"automation","blockParams":{}}</m-document-mention>`- Snippet mention: `<m-document-mention>{"documentId":"{id}","documentName":"","blockName":"snippet","blockParams":{}}</m-document-mention>`- CRM company mention: `<m-document-mention>{"documentId":"{id}","documentName":"","blockName":"company","blockParams":{}}</m-document-mention>`+- CRM pipeline mention: `<m-document-mention>{"documentId":"{pipeline_id}","documentName":"","blockName":"pipeline","blockParams":{}}</m-document-mention>`- Database mention: `<m-document-mention>{"documentId":"{database_id}","documentName":"","blockName":"database","blockParams":{}}</m-document-mention>`- Form mention: `<m-document-mention>{"documentId":"{form_id}","documentName":"","blockName":"form","blockParams":{}}</m-document-mention>`The `blockName` for a Macro database is always exactly `database` — never `md` or `document`; a database id mentioned as a document renders as deleted. `documentId` is the database id a database tool returned.The `blockName` for a form is always exactly `form` — never `md` or `document`. `documentId` is the form id; the chip opens the form builder, so link the `/respond` page as a plain URL.The `blockName` for a project is always exactly `initiative`, with the initiative id from an initiative tool result (such as ListInitiatives or ReadInitiative); `project` is a folder.+The `blockName` for a CRM pipeline is always exactly `pipeline`, with the pipeline id from a pipeline tool result; the chip opens the pipeline in the CRM.The `blockName` for an email thread is always exactly `email` — never `thread` or `email_thread`, which the frontend cannot resolve.The `blockName` for a calendar event is always exactly `calendar` — never `calendar_event`, which the frontend cannot resolve. `documentId` is the `eventId` a calendar tool returned. To point at one instance of a recurring event, pass that occurrence's `recurrenceId` from ListCalendarEvents as the `occurrenceKey` block param; otherwise omit it and the mention previews the nearest instance. A calendar event mention opens for people who have that event on their own calendar. After it is shared with a channel, current members who do not have a copy see a read-only preview instead. Private and confidential events are never shared.When a tool returns both a channel id and a channel message id, link the specific message using the channel message mention format. Do not link only the channel unless you are referring to the whole channel.diff --git a/docs/AGENT_GUIDE/documents.md b/docs/AGENT_GUIDE/documents.mdindex ab201436eb..c7839a05c4 100644--- a/docs/AGENT_GUIDE/documents.md+++ b/docs/AGENT_GUIDE/documents.md@@ -2101,6 +2101,32 @@ mention opens the right project, rename the project and reload to see the nameupdate, and delete the mention. Discard unsent test drafts rather than sendingthem.+## CRM pipeline mentions++Pipelines are not in the `@` menu or the command menu. Pasting a pipeline link+into an editor or composer inserts a document mention with a table icon and the+pipeline's current name: the pipeline's copy-link action+(`/app/companies?crmView=…` whose view is that pipeline) and+`/app/pipeline/<id>` both work. Copied Customers links for other views+(Companies, People, lists) stay plain links. A pipeline you cannot read shows+**No Access**; a trashed one shows **Deleted**.++Clicking the mention, or pressing Enter on it, opens Customers on the pipeline+(on touch devices too). If Customers is already open in a split, that split+switches to the pipeline instead of a second one opening. The request travels+as the Customers pane search `crm.pipeline` (with a `crm.seek` that makes a+repeat click a new request), which Customers drops once you leave the+pipeline.++The mention is stored as+`<m-document-mention>{"documentId":"<pipeline id>","blockName":"pipeline",…}</m-document-mention>`.+Like a project mention, it is never a channel-message reference, so mentioning+a pipeline in a channel does not share it with the channel's members.++To verify, copy a pipeline's link in Customers, paste it into a document,+check the chip's name, click it with Customers closed and again with Customers+open on Companies, and open `/app/pipeline/<id>` directly.+## CRM associationsWith CRM enabled, any task, document or call can point at CRM records through thediff --git a/docs/AGENT_GUIDE/surfaces.md b/docs/AGENT_GUIDE/surfaces.mdindex 385e086bc8..2f778b3c13 100644--- a/docs/AGENT_GUIDE/surfaces.md+++ b/docs/AGENT_GUIDE/surfaces.md@@ -2148,7 +2148,9 @@ editable table. Team members can edit shared pipelines; the creator owns themand can change access later through the standard **Share** dialog. Under**Team access**, choose **Edit** to share with the team or **None** to make thepipeline private. **Copy Link** copies a CRM link that opens this pipeline for-anyone who has access. On mobile, team access is in the **Team** tab.+anyone who has access; pasted into an editor it becomes a pipeline mention (see+[CRM pipeline mentions](documents.md#crm-pipeline-mentions)). On mobile, team+access is in the **Team** tab.The first column is a required company/contact reference. Clicking a filledreference, or pressing Enter on it, opens that company or contact; on desktop itdiff --git a/packages/lexical-core/tests/channel-mentions.test.ts b/packages/lexical-core/tests/channel-mentions.test.tsindex a92f997fdb..15281c0a81 100644--- a/packages/lexical-core/tests/channel-mentions.test.ts+++ b/packages/lexical-core/tests/channel-mentions.test.ts@@ -59,6 +59,14 @@ describe('extractChannelMentionsFromMarkdown', () => {).toEqual([{ entityType: 'document', entityId: 'doc-1' }]);});+ it('never sends a pipeline mention as a channel reference', () => {+ expect(+ extractChannelMentionsFromMarkdown(+ `${documentMention('pipeline-1', 'pipeline')} ${documentMention('doc-1', 'md')}`+ )+ ).toEqual([{ entityType: 'document', entityId: 'doc-1' }]);+ });+it('extracts user mentions and re-tags bot principals', () => {const markdown ='<m-user-mention>{"userId":"macro|[email protected]","email":"[email protected]"}</m-user-mention> and ' +diff --git a/packages/lexical-core/utils/mentions.ts b/packages/lexical-core/utils/mentions.tsindex 0f2a6318d5..bc3240dce5 100644--- a/packages/lexical-core/utils/mentions.ts+++ b/packages/lexical-core/utils/mentions.ts@@ -116,6 +116,8 @@ function documentMentionEntityType(blockName: string): string {.with('contact', () => 'crm_contact')// A task project. Not a message reference type, so it is dropped below..with('initiative', () => 'initiative')+ // Dropped below for the same reason.+ .with('pipeline', () => 'crm_pipeline').with(P._, () => 'document').exhaustive());@@ -126,8 +128,9 @@ function documentMentionEntityType(blockName: string): string {* the way the web editor tracks them while composing a channel message.* Document mentions map by block name; user mentions are re-tagged `bot`* when they target a bot principal. Contact, date, and PR mentions- * carry no referencable entity and are skipped. Project (initiative) mentions- * are skipped too: channel references auto-share their target with members.+ * carry no referencable entity and are skipped. Project (initiative) and CRM+ * pipeline mentions are skipped too: channel references auto-share their+ * target with members.* Authored group mentions are preserved. Duplicates are dropped.*/export function $extractChannelMentions(): ChannelMention[] {