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(references): open a referencing task as a task (#9470)
gbirman3ee78db88e8d
diff --git a/apps/web/src/lib/core/component/References.test.tsx b/apps/web/src/lib/core/component/References.test.tsxnew file mode 100644index 0000000000..7a6f8ea96b--- /dev/null+++ b/apps/web/src/lib/core/component/References.test.tsx@@ -0,0 +1,129 @@+import type { PreviewItem } from '@queries/preview/types';+import { cleanup, fireEvent, render, screen } from '@solidjs/testing-library';+import { afterEach, describe, expect, it, vi } from 'vitest';++const mocks = vi.hoisted(() => ({+ references: [] as unknown[],+ previews: new Map<string, unknown>(),+ openWithSplit: vi.fn(),+ toastFailure: vi.fn(),+}));++vi.mock('@queries/storage/attachment-references', () => ({+ useAttachmentReferencesQuery: () => ({ data: mocks.references }),+}));+vi.mock('@queries/preview', () => ({+ isAccessiblePreviewItem: (item: PreviewItem) =>+ !item.loading && item.access === 'access',+ useItemPreview: (args: () => { id: string }) => [+ () => mocks.previews.get(args().id),+ ],+}));+vi.mock('@components/app/split-layout/layout', () => ({+ useSplitLayout: () => ({ openWithSplit: mocks.openWithSplit }),+}));+vi.mock('@components/app/GlobalAppState', () => ({+ useGlobalBlockOrchestrator: () => ({}),+}));+vi.mock('@core/component/Toast/Toast', () => ({+ toast: { failure: mocks.toastFailure },+}));+vi.mock('@core/user', () => ({+ getDisplayNameParts: () => ({ firstName: 'Ada', fullName: 'Ada Lovelace' }),+ tryMacroId: (id: string) => id,+}));+vi.mock('@entity', () => ({ formatRelativeTimestamp: () => 'now' }));+vi.mock('./ItemPreview', () => ({+ InlineItemPreview: (props: { id: string }) => <span>{props.id}</span>,+}));+vi.mock('./UserIcon', () => ({ UserIcon: () => null }));+vi.mock('./LexicalMarkdown/component/core/StaticMarkdown', () => ({+ StaticMarkdown: () => null,+}));+vi.mock('./LexicalMarkdown/component/core/BlockLink', () => ({+ openDocument: vi.fn(),+}));+vi.mock('./LexicalMarkdown/theme', () => ({ twoLineClampMarkdownTheme: {} }));+vi.mock('@block-channel/utils/link', () => ({+ navigateToChannelMessage: vi.fn(),+}));+vi.mock('@app/features/projects/open-project', () => ({+ openProject: vi.fn(),+}));+vi.mock('@app/features/notifications/document-comment-location', () => ({+ documentCommentLocation: vi.fn(),+}));+vi.mock('@block-call/call-route', () => ({+ callDetailSearch: { namespace: 'call', defaults: {} },+ callDetailSearchCodec: { serialize: () => '' },+}));++import { References } from './References';++function genericReference(sourceId: string) {+ return {+ reference_type: 'generic',+ entity_type: 'document',+ entity_id: 'referenced-doc',+ source_entity_type: 'document',+ source_entity_id: sourceId,+ user_id: 'macro|[email protected]',+ created_at: '2026-11-03T20:00:00Z',+ };+}++function documentPreview(+ id: string,+ subType?: { type: 'task'; is_completed: boolean }+): PreviewItem {+ return {+ id,+ type: 'document',+ access: 'access',+ loading: false,+ name: id,+ rawName: id,+ fileType: 'md',+ subType,+ };+}++afterEach(() => {+ cleanup();+ mocks.references = [];+ mocks.previews.clear();+ mocks.openWithSplit.mockReset();+ mocks.toastFailure.mockReset();+});++describe('References generic rows', () => {+ it('opens a referencing task as a task', () => {+ mocks.references = [genericReference('task-1')];+ mocks.previews.set(+ 'task-1',+ documentPreview('task-1', { type: 'task', is_completed: false })+ );++ render(() => <References documentId="referenced-doc" />);+ fireEvent.click(screen.getByRole('button'));++ expect(mocks.openWithSplit).toHaveBeenCalledWith(+ { type: 'task', id: 'task-1' },+ { preferNewSplit: true }+ );+ expect(mocks.toastFailure).not.toHaveBeenCalled();+ });++ it('opens a referencing markdown document as a document', () => {+ mocks.references = [genericReference('doc-1')];+ mocks.previews.set('doc-1', documentPreview('doc-1'));++ render(() => <References documentId="referenced-doc" />);+ fireEvent.click(screen.getByRole('button'));++ expect(mocks.openWithSplit).toHaveBeenCalledWith(+ { type: 'md', id: 'doc-1' },+ { preferNewSplit: true }+ );+ });+});diff --git a/apps/web/src/lib/core/component/References.tsx b/apps/web/src/lib/core/component/References.tsxindex a8440ca9ba..4df4a01995 100644--- a/apps/web/src/lib/core/component/References.tsx+++ b/apps/web/src/lib/core/component/References.tsx@@ -9,7 +9,7 @@ import { useGlobalBlockOrchestrator } from '@components/app/GlobalAppState';import { useSplitLayout } from '@components/app/split-layout/layout';import type { BlockAlias, BlockName } from '@core/block';import { toast } from '@core/component/Toast/Toast';-import { fileTypeToBlockName } from '@core/constant/allBlocks';+import { itemToBlockName } from '@core/constant/allBlocks';import { COMMENT_LINK_PARAM } from '@core/messages/comment-link';import { getDisplayNameParts, tryMacroId } from '@core/user';import { compareDateDesc, type DateValue } from '@core/util/date';@@ -389,12 +389,10 @@ export function References(props: ReferenceProps) {event?: KeyboardEvent | MouseEvent) => {if (isAccessiblePreviewItem(item) && item.type === 'document') {- const blockId = item.id;- const blockType = fileTypeToBlockName(item.fileType);navigateToItem({event,- blockName: blockType,- blockId,+ blockName: itemToBlockName(item),+ blockId: item.id,});} else {toast.failure('Failed to open reference');