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
feat(web): open Ask Macro in a bare agent split, add it to code and image blocks (#7506)
Jacob Beckerman3587e94f4a5a
diff --git a/apps/web/src/features/block-code/component/TopBar.tsx b/apps/web/src/features/block-code/component/TopBar.tsxindex cf4a9ba62e..ab5cc62cee 100644--- a/apps/web/src/features/block-code/component/TopBar.tsx+++ b/apps/web/src/features/block-code/component/TopBar.tsx@@ -1,3 +1,8 @@+import {+ ChatWithAgentButton,+ ChatWithAgentIcon,+ openChatWithAgent,+} from '@app/features/chat/ChatWithAgentButton';import { useAnalytics } from '@app/lib/analytics/analytics-context';import type { BlockTool } from '@components/app/ResponsiveBlockToolbar';import {@@ -75,7 +80,22 @@ export const TopBar: Component<{{ op: 'delete' },];+ const chatEntity = () => ({+ type: 'document' as const,+ id: blockId,+ name: name() ?? '',+ fileType: 'code',+ });+const tools: BlockTool[] = [+ {+ label: 'Ask Macro',+ icon: ChatWithAgentIcon,+ action: () => openChatWithAgent(chatEntity()),+ buttonComponent: () => (+ <ChatWithAgentButton entity={chatEntity()} label="Ask Macro" />+ ),+ },{group: 'sharing',label: 'Share',diff --git a/apps/web/src/features/block-image/component/TopBar.tsx b/apps/web/src/features/block-image/component/TopBar.tsxindex 3a0cabd611..c37eab8644 100644--- a/apps/web/src/features/block-image/component/TopBar.tsx+++ b/apps/web/src/features/block-image/component/TopBar.tsx@@ -1,3 +1,8 @@+import {+ ChatWithAgentButton,+ ChatWithAgentIcon,+ openChatWithAgent,+} from '@app/features/chat/ChatWithAgentButton';import type { BlockTool } from '@components/app/ResponsiveBlockToolbar';import {ResponsiveBlockToolbar,@@ -60,7 +65,22 @@ export function TopBar() {{ op: 'delete' },];+ const chatEntity = () => ({+ type: 'document' as const,+ id: blockId,+ name: name() ?? '',+ fileType: 'image',+ });+const tools: BlockTool[] = [+ {+ label: 'Ask Macro',+ icon: ChatWithAgentIcon,+ action: () => openChatWithAgent(chatEntity()),+ buttonComponent: () => (+ <ChatWithAgentButton entity={chatEntity()} label="Ask Macro" />+ ),+ },{group: 'sharing',label: 'Share',diff --git a/apps/web/src/features/chat/ChatWithAgentButton.test.ts b/apps/web/src/features/chat/ChatWithAgentButton.test.tsindex 8b2c948aae..22f6382008 100644--- a/apps/web/src/features/chat/ChatWithAgentButton.test.ts+++ b/apps/web/src/features/chat/ChatWithAgentButton.test.ts@@ -52,7 +52,7 @@ describe('openChatWithAgent', () => {mocks.manager = true;});- it('opens an agent session with an unsent visible mention', async () => {+ it('opens a bare agent session, without the Agents sidebar, with an unsent visible mention', async () => {await openChatWithAgent({type: 'document',id: 'document-id',@@ -66,7 +66,7 @@ describe('openChatWithAgent', () => {'<m-document-mention>{"documentId":"document-id","documentName":"Project plan","blockName":"md","blockParams":{}}</m-document-mention> ',});expect(mocks.openWithSplit).toHaveBeenCalledWith(- { type: 'component', id: 'agents-session~agents~session-id' },+ { type: 'agent', id: 'session-id' },{ activate: true, preferNewSplit: true });});@@ -144,7 +144,7 @@ describe('openChatWithAgent', () => {initialInput: undefined,});expect(mocks.openWithSplit).toHaveBeenCalledWith(- { type: 'component', id: 'agents-session~agents~session-id' },+ { type: 'agent', id: 'session-id' },{ activate: true, preferNewSplit: true });});diff --git a/apps/web/src/features/chat/ChatWithAgentButton.tsx b/apps/web/src/features/chat/ChatWithAgentButton.tsxindex d8f67d97c1..13a44f381e 100644--- a/apps/web/src/features/chat/ChatWithAgentButton.tsx+++ b/apps/web/src/features/chat/ChatWithAgentButton.tsx@@ -69,17 +69,24 @@ async function createAndOpenAgent(seed: {...(seed.model ? { modelOverride: seed.model } : {}),...(seed.instructions ? { instructions: seed.instructions } : {}),});- const next = {- type: 'component' as const,- id: agentsRouteId({- mode: 'chat',- conversation: { type: 'agent_session', id },- }),- };if (seed.replaceSplit) {- seed.replaceSplit.replace({ next });+ // In-place handoffs (search "Ask AI") land in the full Agents workspace.+ seed.replaceSplit.replace({+ next: {+ type: 'component',+ id: agentsRouteId({+ mode: 'chat',+ conversation: { type: 'agent_session', id },+ }),+ },+ });} else {- manager?.openWithSplit(next, { activate: true, preferNewSplit: true });+ // A new split beside the source opens the bare session, without the+ // Agents workspace's conversation sidebar.+ manager?.openWithSplit(+ { type: 'agent', id },+ { activate: true, preferNewSplit: true }+ );}return true;}diff --git a/docs/AGENT_GUIDE/ai-chat.md b/docs/AGENT_GUIDE/ai-chat.mdindex 055875eed5..6533ff7db1 100644--- a/docs/AGENT_GUIDE/ai-chat.md+++ b/docs/AGENT_GUIDE/ai-chat.md@@ -121,10 +121,13 @@ or stop.**Ask AI** in search (including Tab), the command menu, and mobile search opensan agent session. A nonempty search query is sent as the first prompt once thesession is ready; an empty search opens an empty composer. Desktop search replaces-its current split, while command-menu and mobile actions open a new split.+its current split into the Agents workspace, while command-menu and mobile+actions open a new split.-**Ask Macro** and **Chat with Agent** on documents, PDFs, spreadsheets, email,-channels, calls, and projects also open agent sessions. Their entity mention stays+**Ask Macro** and **Chat with Agent** on documents, tasks, PDFs, DOCX files,+code files, images, canvases, spreadsheets, email, channels, calls, and projects+also open agent sessions. Like command-menu Ask AI, they open the bare session in+a new split, without the Agents workspace's conversation sidebar. Their entity mention staysin the composer as an unsent draft. Spreadsheet mentions retain the current sheetand selected range; channel-message actions retain the referenced message.Add a question and press Send to submit that context. These actions do not create