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(md): parse text paste for new agent mentions (#6887)
Seamus7887e90651a8
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.tsnew file mode 100644index 0000000000..417298290d--- /dev/null+++ b/apps/web/src/lib/core/component/LexicalMarkdown/plugins/text-paste/textPastePlugin.test.ts@@ -0,0 +1,45 @@+import { describe, expect, it, vi } from 'vitest';+import { parseMacroAppUrl } from './textPastePlugin';++// Keep the parser tests independent of application boot and editor UI wiring.+vi.mock('@core/internal/BlockLoader', () => ({}));+vi.mock('../../utils', () => ({}));+vi.mock('../mentions', () => ({}));++const sessionId = '019507e8-14a3-7bc1-8610-419f16bd03a8';++describe('parseMacroAppUrl', () => {+ it.each(['agents', 'agent'])(+ 'recognizes %s session links as agent mentions',+ (route) => {+ expect(+ parseMacroAppUrl(+ `https://dev.macro.com/app/${route}/${sessionId}?message=target&referral_code=ignored`+ )+ ).toEqual({+ isValid: true,+ id: sessionId,+ block: 'agent',+ params: { message: 'target' },+ });+ }+ );++ it.each(['md', 'channel', 'task', 'pr'])(+ 'preserves existing %s links',+ (block) => {+ expect(+ parseMacroAppUrl(`https://dev.macro.com/app/${block}/${sessionId}`)+ ).toEqual({ isValid: true, id: sessionId, block, params: {} });+ }+ );++ it.each([+ 'https://dev.macro.com/app/agents',+ 'https://dev.macro.com/app/agents/not-a-uuid',+ `https://example.com/app/agents/${sessionId}`,+ `https://dev.macro.com/app/unknown-route/${sessionId}`,+ ])('does not convert invalid or foreign links: %s', (url) => {+ expect(parseMacroAppUrl(url).isValid).toBe(false);+ });+});diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/plugins/text-paste/textPastePlugin.ts b/apps/web/src/lib/core/component/LexicalMarkdown/plugins/text-paste/textPastePlugin.tsindex 27d83a4fd0..ccdd5f3c41 100644--- a/apps/web/src/lib/core/component/LexicalMarkdown/plugins/text-paste/textPastePlugin.ts+++ b/apps/web/src/lib/core/component/LexicalMarkdown/plugins/text-paste/textPastePlugin.ts@@ -69,8 +69,9 @@ export function parseMacroAppUrl(text: string): MacroAppUrlParsed {};}- const _block: string = pathParts[1];- if (!ValidBlockNames.includes(_block as any)) {+ const routeBlock = pathParts[1] === 'agents' ? 'agent' : pathParts[1];+ const block = ValidBlockNames.find((name) => name === routeBlock);+ if (!block) {return {isValid: false,id: undefined,@@ -78,7 +79,6 @@ export function parseMacroAppUrl(text: string): MacroAppUrlParsed {params: undefined,};}- const block: BlockName | BlockAlias = _block as BlockName | BlockAlias;const idRegex =/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;diff --git a/docs/AGENT_GUIDE/documents.md b/docs/AGENT_GUIDE/documents.mdindex 5a55dc363c..04b99f38a3 100644--- a/docs/AGENT_GUIDE/documents.md+++ b/docs/AGENT_GUIDE/documents.md@@ -281,6 +281,10 @@ service; the frontend alone cannot test their hosted path.## Create and type+Pasting a Macro `/app/agents/<uuid>` session URL into a Markdown editor converts+it to an agent mention, just like the legacy `/app/agent/<uuid>` URL. Link query+parameters are retained, except for referral codes.+1. `Create` → `Document D`. The app navigates to `/app/md/<uuid>` with the **title fieldfocused**.2. `type_text` the title, then `submitKey: "Enter"` to drop into the body.