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 referenced tasks in the task view (#8102)
gbirman6f10eca0f11d
diff --git a/apps/web/src/features/crm/record-tasks-adapter.test.tsx b/apps/web/src/features/crm/record-tasks-adapter.test.tsxnew file mode 100644index 0000000000..3b3fd8b59b--- /dev/null+++ b/apps/web/src/features/crm/record-tasks-adapter.test.tsx@@ -0,0 +1,74 @@+import type { TasksViewProviderProps } from '@app/features/tasks-view/tasks-view-context';+import { cleanup, fireEvent, render, screen } from '@solidjs/testing-library';+import type { ParentProps } from 'solid-js';+import { afterEach, expect, it, vi } from 'vitest';+import type { CrmRecordScope } from './core/record';+import { CrmRecordTasks } from './record-tasks-adapter';++const { openWithSplit } = vi.hoisted(() => ({ openWithSplit: vi.fn() }));++vi.mock('@components/app/split-layout/layout', () => ({+ useSplitLayout: () => ({ openWithSplit }),+}));+vi.mock('@property/tags/tag-sets-context', () => ({+ TagSetsQueryProvider: (props: ParentProps) => props.children,+}));+vi.mock('@app/features/tasks-view/tasks-view-context', () => ({+ TasksViewProvider: (props: TasksViewProviderProps) => (+ <button+ type="button"+ onClick={(event) => props.onOpenTask?.({ id: 'task-1' }, { event })}+ >+ Open task+ </button>+ ),+}));+vi.mock('@app/features/tasks-view/components/TasksControls', () => ({+ TasksControls: () => null,+}));+vi.mock('@app/features/tasks-view/components/task-list/TaskList', () => ({+ TaskList: () => null,+}));+vi.mock('@app/features/tasks-view/queries/use-tasks-query', () => ({+ useTasksDataSource: vi.fn(),+}));+vi.mock('@block-md/util/taskComposerProperties', () => ({+ createTaskWithProperties: vi.fn(),+}));+vi.mock('@ui', () => ({ Button: () => null }));+vi.mock('./components/record-section', () => ({ RecordSection: () => null }));++afterEach(() => {+ cleanup();+ vi.clearAllMocks();+});++const scopes: CrmRecordScope[] = [+ {+ type: 'contact',+ id: 'contact-1',+ email: '[email protected]',+ companyId: 'company-1',+ },+ { type: 'company', id: 'company-1', domains: ['example.com'] },+];++it.each(scopes)('opens a task from a $type in the task view', (scope) => {+ render(() => <CrmRecordTasks scope={scope} />);+ fireEvent.click(screen.getByRole('button', { name: 'Open task' }));+ expect(openWithSplit).toHaveBeenCalledExactlyOnceWith(+ { type: 'task', id: 'task-1' },+ { preferNewSplit: false }+ );+});++it('preserves the request to open a task in a new split', () => {+ render(() => <CrmRecordTasks scope={scopes[0]} />);+ fireEvent.click(screen.getByRole('button', { name: 'Open task' }), {+ shiftKey: true,+ });+ expect(openWithSplit).toHaveBeenCalledExactlyOnceWith(+ { type: 'task', id: 'task-1' },+ { preferNewSplit: true }+ );+});diff --git a/apps/web/src/features/crm/record-tasks-adapter.tsx b/apps/web/src/features/crm/record-tasks-adapter.tsxindex cb960e2a08..522e6450bc 100644--- a/apps/web/src/features/crm/record-tasks-adapter.tsx+++ b/apps/web/src/features/crm/record-tasks-adapter.tsx@@ -35,7 +35,7 @@ export function CrmRecordTasks(props: { scope: CrmRecordScope }) {scopeKey={`crm:${scope.type}:${scope.id}:tasks`}onOpenTask={(task, options) => {layout.openWithSplit(- { type: 'md', id: task.id },+ { type: 'task', id: task.id },{ preferNewSplit: options?.event?.shiftKey });return true;diff --git a/docs/agent-guide/crm.md b/docs/agent-guide/crm.mdindex dfed0ede81..6aaf94e752 100644--- a/docs/agent-guide/crm.md+++ b/docs/agent-guide/crm.md@@ -131,6 +131,11 @@ Files also includes attachments of emails with its address. Tasks created from acontact also reference its company. The side panel keeps Sharing (admins only)and adds References.+In a company or contact's Tasks tab, clicking a task (or pressing Enter on its+focused row) opens the task detail view at `/app/tasks/<task-id>`, including on+mobile. Shift-click opens it in a separate split. Verify that the task's status+and properties appear, rather than the regular Drive markdown editor.+Mentioning a company or contact with `@` in a document or task records it as areference of that record (removing the chip removes it) without sharing thedocument, inviting anyone, or notifying the contact; channel and Discussion