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(crm): open a shared pipeline link while Customers is open (#8223)
teo46843deacecd
diff --git a/apps/web/src/features/crm/crm-route.ts b/apps/web/src/features/crm/crm-route.tsindex 946b78b05f..3109a951f8 100644--- a/apps/web/src/features/crm/crm-route.ts+++ b/apps/web/src/features/crm/crm-route.ts@@ -47,6 +47,14 @@ function crmTabFromQuery(query: URLSearchParams): string | undefined {return undefined;}+/** The pipeline a shared `crmView` link shows, if any. */+export function crmViewPipelineId(query: URLSearchParams): string | undefined {+ const view = query.get(CRM_VIEW_URL_PARAM);+ return pipelineIdOfTab(+ view ? decodeCrmViewParam(view)?.activeTab : undefined+ );+}+/** A shared Customers link that shows a pipeline references the pipeline. */export function crmViewReference(query: URLSearchParamsdiff --git a/apps/web/src/features/crm/route-views.test.tsx b/apps/web/src/features/crm/route-views.test.tsxnew file mode 100644index 0000000000..296804c572--- /dev/null+++ b/apps/web/src/features/crm/route-views.test.tsx@@ -0,0 +1,75 @@+import { cleanup, render } from '@solidjs/testing-library';+import { createSignal, type JSX } from 'solid-js';+import { afterEach, expect, it, vi } from 'vitest';+import { pipelineTab } from './core/navigation';+import { encodeCrmViewParam } from './queries/saved-view-codec';+import { CompaniesRouteView } from './route-views';++const fixture = vi.hoisted(() => ({+ setSearch: vi.fn(),+ search: undefined as unknown as () => string,+}));++vi.mock('@components/app/split-layout/split-router/app-route-shell', () => ({+ withAuth: (component: () => JSX.Element) => component,+ usePageViewTracking: () => {},+ RedirectSplit: () => null,+}));+vi.mock('@core/constant/featureFlags', () => ({+ enableCrm: 'crm',+ isFeatureEnabled: () => true,+}));+vi.mock('@app/lib/split-router', async (importOriginal) => ({+ ...(await importOriginal<object>()),+ createSearchParams: () => [+ { tab: 'active', pipeline: '', seek: '' },+ fixture.setSearch,+ ],+}));+vi.mock('@solidjs/router', () => ({+ useLocation: () => ({+ get search() {+ return fixture.search();+ },+ }),+}));+vi.mock('./crm', () => ({ Crm: () => null }));++afterEach(() => {+ cleanup();+ fixture.setSearch.mockReset();+});++const pipelineId = '01a1212c-74e5-79bd-8767-0d4943d55b15';+const link = (activeTab: string) =>+ `?crmView=${encodeCrmViewParam({ kind: 'crm', activeTab })}`;++it('opens a shared pipeline link followed while Customers is open', () => {+ const [search, setSearch] = createSignal('?s0.crm.tab=people');+ fixture.search = search;+ render(() => <CompaniesRouteView />);++ setSearch(link(pipelineTab(pipelineId)));+ expect(fixture.setSearch).toHaveBeenCalledExactlyOnceWith(+ {+ tab: pipelineTab(pipelineId),+ pipeline: pipelineId,+ seek: expect.any(String),+ },+ { mode: 'merge', history: 'replace' }+ );++ // Moving between Customers tabs keeps the link in the URL.+ setSearch(`${link(pipelineTab(pipelineId))}&s0.crm.tab=people`);+ setSearch(link(pipelineTab(pipelineId)));+ expect(fixture.setSearch).toHaveBeenCalledOnce();+});++it('leaves links to other Customers views alone', () => {+ const [search, setSearch] = createSignal('');+ fixture.search = search;+ render(() => <CompaniesRouteView />);++ setSearch(link('people'));+ expect(fixture.setSearch).not.toHaveBeenCalled();+});diff --git a/apps/web/src/features/crm/route-views.tsx b/apps/web/src/features/crm/route-views.tsxindex 16579d7c5c..a39104a795 100644--- a/apps/web/src/features/crm/route-views.tsx+++ b/apps/web/src/features/crm/route-views.tsx@@ -5,10 +5,11 @@ import {withAuth,} from '@components/app/split-layout/split-router/app-route-shell';import { enableCrm, isFeatureEnabled } from '@core/constant/featureFlags';-import { lazy, untrack } from 'solid-js';+import { useLocation } from '@solidjs/router';+import { createEffect, createMemo, lazy, on, untrack } from 'solid-js';import type { CrmRouteSearch } from './context/workspace-context';import { pipelineIdOfTab, pipelineTab } from './core/navigation';-import { crmSearch } from './crm-route';+import { crmSearch, crmViewPipelineId } from './crm-route';import {CRM_VIEW_URL_PARAM,decodeCrmViewParam,@@ -31,6 +32,28 @@ export const CompaniesRouteView = withAuth(() => {const crmView = new URLSearchParams(window.location.search).get(CRM_VIEW_URL_PARAM);+ const location = useLocation();+ const linkedPipelineId = createMemo(() =>+ crmViewPipelineId(new URLSearchParams(location.search))+ );+ // A shared pipeline link followed while Customers is already open.+ createEffect(+ on(+ linkedPipelineId,+ (pipelineId) => {+ if (!pipelineId) return;+ setSearch(+ {+ tab: pipelineTab(pipelineId),+ pipeline: pipelineId,+ seek: crypto.randomUUID(),+ },+ { mode: 'merge', history: 'replace' }+ );+ },+ { defer: true }+ )+ );const routeSearch: CrmRouteSearch = {tab: () => search.tab,setTab: (diff --git a/docs/agent-guide/crm.md b/docs/agent-guide/crm.mdindex d69ade5dd1..ce8f7b6898 100644--- a/docs/agent-guide/crm.md+++ b/docs/agent-guide/crm.md@@ -184,7 +184,8 @@ The **People** list changes or removes their access. A teammate who receives a ppipeline sees it in their Customers sidebar. Only the owner sees **Team access**:choose **Edit** to share with the team or **None** to make the pipeline private.Viewers see only **Copy Link**. **Copy Link** copies a CRM link that opens this pipeline for-anyone who has access; pasted into an editor it becomes a pipeline mention (see+anyone who has access, including when followed inside a split already showing Customers;+pasted into an editor it becomes a pipeline mention (see[CRM pipeline mentions](documents.md#crm-pipeline-mentions)). On mobile, teamaccess is in the **Team** tab.