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(projects): share and paste projects as mention links (#8675)
gbirman62ed31d4d003
diff --git a/apps/web/src/components/app/split-layout/split-router/legacy-route.test.ts b/apps/web/src/components/app/split-layout/split-router/legacy-route.test.tsindex d1fbbb60f8..db7e8915ea 100644--- a/apps/web/src/components/app/split-layout/split-router/legacy-route.test.ts+++ b/apps/web/src/components/app/split-layout/split-router/legacy-route.test.ts@@ -4,6 +4,7 @@ import {createRoutesManifest,createSolidRouterHistory,createSplitRouter,+ decodePane,parseLocation,type SplitRoutes,} from '@app/lib/split-router';@@ -22,6 +23,7 @@ import { createRoot } from 'solid-js';import { afterEach, describe, expect, it, vi } from 'vitest';import { createAppSplitRouterMiddleware } from './app-middleware';import { resolveContentLocation, upgradeLegacyPath } from './legacy-route';+import { createMacroMentionLinkResolver } from './mention-links';vi.mock('@components/app/split-layout/componentRegistry', () => ({resolveComponent: vi.fn(() => ({ type: 'mock-component' })),@@ -95,6 +97,69 @@ describe('upgradeLegacyPath', () => {});});+describe('legacy link mentions', () => {+ const resolveMention = createMacroMentionLinkResolver(routes);+ const projectId = '01a15f1b-5b91-7aa3-885d-7d31fcc5a776';+ const appUrl = (path: string) => `${window.location.origin}/app${path}`;++ it.each([+ `/component/initiative-view~${projectId}~overview?referral_code=abc`,+ `/component/initiative-view~${projectId}~tasks`,+ `/home/~/component/initiative-view~${projectId}~overview`,+ ])('pastes a shared project link %s as a project mention', (path) => {+ expect(resolveMention(appUrl(path))).toEqual({+ id: projectId,+ block: 'initiative',+ params: {},+ });+ });++ it('opens a shared project link in Tasks', () => {+ const middleware = createAppSplitRouterMiddleware({+ isTouchDevice: () => false,+ });+ const results = middleware.map((handler) => {+ const result = handler({+ routes,+ from: undefined,+ to: {+ id: 'entry',+ location: { route: decodePane(routes, ['initiative', projectId])! },+ },+ path: '',+ cause: 'navigate',+ signal: new AbortController().signal,+ redirect: (path) => ({ type: 'redirect', to: path }),+ cancel: () => ({ type: 'cancel' }),+ });+ if (result instanceof Promise) throw new Error('Unexpected async');+ return result;+ });+ const redirect = results.find((result) => result !== undefined);+ if (redirect?.type !== 'redirect') throw new Error('Expected a redirect');+ expect(new URL(redirect.to, window.location.origin).pathname).toBe(+ `/tasks/projects/${projectId}/overview`+ );+ });++ it('pastes a legacy block pane as a mention of its block', () => {+ expect(resolveMention(appUrl(`/home/~/md/${projectId}`))).toEqual({+ id: projectId,+ block: 'md',+ params: {},+ });+ });++ it.each([+ '/component/initiative-view~not-a-uuid~overview',+ `/component/initiative-view~${projectId}~overview~${projectId}`,+ '/component/settings',+ '/md/not-a-uuid',+ ])('leaves %s as a link', (path) => {+ expect(resolveMention(appUrl(path))).toBeUndefined();+ });+});+describe('opening an app URL', () => {it('opens a bare Calendar path at the preferred period with its event', async () => {vi.useFakeTimers();diff --git a/apps/web/src/features/next-soup/utils.ts b/apps/web/src/features/next-soup/utils.tsindex 7b31be48d8..556e61955d 100644--- a/apps/web/src/features/next-soup/utils.ts+++ b/apps/web/src/features/next-soup/utils.ts@@ -263,9 +263,7 @@ export const openEntityInNewTab = ({location ??= getRowClickFallbackLocation(entity);// Build URL for the entitylet entityPath: string;- if (entity.type === 'initiative') {- entityPath = `/app/component/${projectRouteId({ id: entity.id, section: 'overview' })}`;- } else if (entity.type === 'calendar_event') {+ if (entity.type === 'calendar_event') {entityPath = `/app${calendarPath(getPreferredCalendarPeriodView())}`;} else if (entity.type === 'document') {const { fileType, subType } = entity;diff --git a/apps/web/src/features/projects/project-detail.tsx b/apps/web/src/features/projects/project-detail.tsxindex 0b09c63708..6c8cacd466 100644--- a/apps/web/src/features/projects/project-detail.tsx+++ b/apps/web/src/features/projects/project-detail.tsx@@ -42,7 +42,7 @@ import {type ProjectDetail as ProjectDetailData,type ProjectSection,} from './core/project';-import { type ProjectRoute, projectRouteId } from './core/route';+import type { ProjectRoute } from './core/route';import { openProject } from './open-project';import { ProjectDiscussion } from './project-collaboration';import { ProjectDescription } from './project-description';@@ -168,10 +168,7 @@ function ProjectTitleMenu(props: {}onCopyLink={(row) =>fireAndForget(- copyLink.executeByBlock(- projectRouteId({ id: row.project.id, section: 'overview' }),- 'component'- ),+ copyLink.executeByBlock(row.project.id, 'initiative'),'projects')}diff --git a/apps/web/src/features/projects/projects.tsx b/apps/web/src/features/projects/projects.tsxindex 71a032bb73..a524e0c7cb 100644--- a/apps/web/src/features/projects/projects.tsx+++ b/apps/web/src/features/projects/projects.tsx@@ -38,7 +38,6 @@ import {ProjectsProvider,useProjectsContext,} from './context/projects-context';-import { projectRouteId } from './core/route';import {createProjectCollection,type ProjectListActivation,@@ -198,13 +197,7 @@ function ProjectsCollectionHost(props: ProjectsTabProps) {globalSplitManager()?.canAppendSplit() ?? false}onCopyLink={(id) =>- fireAndForget(- copyLink.executeByBlock(- projectRouteId({ id, section: 'overview' }),- 'component'- ),- 'projects'- )+ fireAndForget(copyLink.executeByBlock(id, 'initiative'), 'projects')}onCopyId={(id) => fireAndForget(copyId.executeById(id), 'projects')}onShare={(projectId) => setSharing(projectId)}diff --git a/apps/web/src/lib/core/component/TopBar/ShareButton.test.tsx b/apps/web/src/lib/core/component/TopBar/ShareButton.test.tsxindex 748672f7c2..c67a604eb4 100644--- a/apps/web/src/lib/core/component/TopBar/ShareButton.test.tsx+++ b/apps/web/src/lib/core/component/TopBar/ShareButton.test.tsx@@ -1638,7 +1638,7 @@ describe('native project sharing', () => {);});- it('copies the project route instead of a block URL', () => {+ it('copies the project link that pastes as a mention', () => {mocks.inBlock = false;render(() => (<ShareTrigger@@ -1649,7 +1649,7 @@ describe('native project sharing', () => {));fireEvent.click(screen.getByRole('button', { name: 'Copy Share Link' }));expect(mocks.copyLink).toHaveBeenCalledWith(- 'https://macro.com/app/component/initiative-view~initiative-1~overview'+ 'https://macro.com/app/initiative/initiative-1');});});diff --git a/apps/web/src/lib/core/component/TopBar/ShareButton.tsx b/apps/web/src/lib/core/component/TopBar/ShareButton.tsxindex aa5e404d99..fec5cc69d9 100644--- a/apps/web/src/lib/core/component/TopBar/ShareButton.tsx+++ b/apps/web/src/lib/core/component/TopBar/ShareButton.tsx@@ -19,7 +19,6 @@ import {updatePipelineSharePermissions,updatePipelineTeamShare,} from '@app/features/crm/sharing-adapter';-import { projectRouteId } from '@app/features/projects/core/route';import { useAnalytics } from '@app/lib/analytics/analytics-context';import { useFeatureFlag } from '@app/lib/analytics/posthog';import { useChannelParticipants } from '@channel/use-channel-participants';@@ -181,11 +180,7 @@ type ShareBlockType = BlockName | BlockAlias | 'initiative' | 'external_chat';function shareUrl(type: ShareBlockType, id: string): string {if (type === 'external_chat')return buildSimpleEntityUrl({ type: 'external/whatsapp', id });- if (type !== 'initiative') return buildSimpleEntityUrl({ type, id });- return buildSimpleEntityUrl({- type: 'component',- id: projectRouteId({ id, section: 'overview' }),- });+ return buildSimpleEntityUrl({ type, id });}/**diff --git a/apps/web/src/routes/routes.ts b/apps/web/src/routes/routes.tsindex d4dd774563..8a8f54a0e3 100644--- a/apps/web/src/routes/routes.ts+++ b/apps/web/src/routes/routes.ts@@ -31,6 +31,7 @@ import {homeBaseBlockType,homePreviewRouteParams,} from '@app/features/home/home-route-schema';+import { parseProjectRoute } from '@app/features/projects/core/route';import { reviewsTabSearch } from '@app/features/reviews-view/reviews-tab-search';import {ROUTINE_CREATE_ROUTE_ID,@@ -807,6 +808,14 @@ export const legacyContentRoute = defineRoute({id: `${content.aliasContext?.baseType ?? content.type}:${id}`,};},+ toReference: ({ type, id }) => {+ const project = type === 'component' ? parseProjectRoute(id) : undefined;+ // A project mention opens the project, not one of its discussions.+ if (project?.discussionId) return;+ return project+ ? uuidRouteReference(project.id, 'initiative')+ : uuidRouteReference(id, type);+ },});/** Catches any pane path no other route matches; listed last. */diff --git a/docs/agent-guide/navigation.md b/docs/agent-guide/navigation.mdindex 0b33bc2942..254a948387 100644--- a/docs/agent-guide/navigation.md+++ b/docs/agent-guide/navigation.md@@ -191,6 +191,7 @@ successfully rather than hashing the empty JavaScript placeholder.| `/app/tasks/projects/<uuid>/overview` | Project detail in Tasks, with breadcrumbs, properties, description, and discussions; replace `overview` with `tasks` for the task list || `/app/component/project-compose` | Native project composer, sharing the task composer layout and property controls || `/app/component/new-project` | Alias for the project composer; existing links remain valid |+| `/app/initiative/<uuid>` | Shared project link; opens the project in Tasks || `/app/component/initiative-view~<uuid>~overview` | Compatibility link that opens the project in Tasks || `/app/agents/<uuid>` | Chat agent session with the Agents sidebar || `/app/coders/<uuid>` | Code session with the Agents sidebar |diff --git a/docs/agent-guide/tasks.md b/docs/agent-guide/tasks.mdindex 6ee4c11fb4..4015236197 100644--- a/docs/agent-guide/tasks.md+++ b/docs/agent-guide/tasks.md@@ -732,7 +732,11 @@ horizontally in narrow splits, keeping list controls, Add existing tasks, and Netask accessible. Opening an associated task extends the breadcrumb trail; choosethe project breadcrumb to return, or Projects to restore the collection and itsfilters, groups, and scroll position. Project URLs retain identity and section:-`/app/component/initiative-view~<project-id>~overview` (or `tasks`).+`/app/tasks/projects/<project-id>/overview` (or `tasks`). Share, and Copy Link+in the project title and Projects row menus, copy `/app/initiative/<project-id>`,+which opens the project in Tasks; pasting it, or an older+`/app/component/initiative-view~<project-id>~overview` link, into a markdown+editor inserts a project mention. A link to a project discussion stays a link.Project properties live in the shared floating information panel and honorproject access. Editors can rename the project; its owner can delete it.Deleting a project leaves its tasks in the workspace.