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(routines): let routine prompts mention agents without invoking them (#9589)
Eric Hayesfe7cd0f05890
diff --git a/apps/web/src/features/routines/routine-prompt-editor.tsx b/apps/web/src/features/routines/routine-prompt-editor.tsxindex 819ddbee1b..59e267fd8a 100644--- a/apps/web/src/features/routines/routine-prompt-editor.tsx+++ b/apps/web/src/features/routines/routine-prompt-editor.tsx@@ -1,6 +1,7 @@import { useMacroMentionLinkResolver } from '@components/app/split-layout/split-router/mention-links';import { EditorConfigBuilder } from '@core/component/LexicalMarkdown/builder/MarkdownConfigBuilder';import { MarkdownShell } from '@core/component/LexicalMarkdown/builder/MarkdownShell';+import { useRoutinePromptMentionUsers } from './routine-prompt-mention-users';export function RoutinePromptEditor(props: {initialValue: string;@@ -12,7 +13,7 @@ export function RoutinePromptEditor(props: {.namespace('routine-prompt').withHistory().withLinks()- .withMentions()+ .withMentions({ users: useRoutinePromptMentionUsers() }).onChange(props.onChange);return (diff --git a/apps/web/src/features/routines/routine-prompt-mention-users.test.ts b/apps/web/src/features/routines/routine-prompt-mention-users.test.tsnew file mode 100644index 0000000000..8a449fe1ed--- /dev/null+++ b/apps/web/src/features/routines/routine-prompt-mention-users.test.ts@@ -0,0 +1,91 @@+import { MACRO_AGENT_PRINCIPAL_ID } from '@core/constant/macroAgent';+import { createRoot } from 'solid-js';+import { beforeEach, describe, expect, it, vi } from 'vitest';+import { useRoutinePromptMentionUsers } from './routine-prompt-mention-users';++const state = vi.hoisted(() => ({+ agents: undefined as unknown[] | undefined,+ people: [] as { data: { id: string; name: string; email: string } }[],+}));++vi.mock('@core/context/quickAccess', () => ({+ useQuickAccess: () => ({+ useList: () => ({ items: () => state.people }),+ }),+}));+vi.mock('@core/cursor/flag', () => ({+ useCursorAgentsAccess: () => () => false,+}));+vi.mock('@core/codex/flag', () => ({+ useCodexAgentsAccess: () => () => false,+}));+vi.mock('@channel/use-chat-v3-agents-flag', () => ({+ useChatV3AgentsFlag: () => () => false,+}));+vi.mock('@queries/agents/agents', () => ({+ useAgentsQuery: () => ({+ get data() {+ return state.agents;+ },+ }),+}));+vi.mock('@queries/agents/offline-runtimes', () => ({+ useOfflineAgentBotIds: () => () => new Set(['offline-agent']),+}));+vi.mock('@queries/channel/channel-bots', () => ({+ useChannelBotsQuery: () => ({ data: [] }),+}));+vi.mock('@queries/gate', () => ({+ queryReadyGate: (query: { data?: unknown }) => query.data !== undefined,+}));++function savedAgent(id: string, name: string, channelScope: string) {+ return {+ channel_scope: channelScope,+ bot: { id, name, has_agent: true },+ };+}++describe('useRoutinePromptMentionUsers', () => {+ beforeEach(() => {+ state.agents = undefined;+ state.people = [+ {+ data: {+ id: 'macro|[email protected]',+ name: 'Person',+ email: '[email protected]',+ },+ },+ ];+ });++ it('keeps people while agents load, then offers their saved agents', () => {+ createRoot((dispose) => {+ const users = useRoutinePromptMentionUsers();+ expect(users().map((user) => user.id)).toEqual([+ 'macro|[email protected]',+ MACRO_AGENT_PRINCIPAL_ID,+ ]);++ state.agents = [savedAgent('saved-agent', 'Saved', 'none')];+ expect(users().map((user) => user.id)).toEqual([+ 'macro|[email protected]',+ MACRO_AGENT_PRINCIPAL_ID,+ 'bot|saved-agent',+ ]);+ dispose();+ });+ });++ it('leaves an agent whose runtime is away pickable', () => {+ createRoot((dispose) => {+ state.agents = [savedAgent('offline-agent', 'Away', 'all')];+ const users = useRoutinePromptMentionUsers();+ expect(+ users().find((user) => user.id === 'bot|offline-agent')?.offline+ ).toBeUndefined();+ dispose();+ });+ });+});diff --git a/apps/web/src/features/routines/routine-prompt-mention-users.ts b/apps/web/src/features/routines/routine-prompt-mention-users.tsnew file mode 100644index 0000000000..d05bc68d19--- /dev/null+++ b/apps/web/src/features/routines/routine-prompt-mention-users.ts@@ -0,0 +1,34 @@+import { useAgentMentionUsers } from '@channel/use-agent-mention-users';+import { availableBotMentionUsers } from '@channel/use-channel-bot-mention-users';+import { useQuickAccess } from '@core/context/quickAccess';+import { useCursorAgentsAccess } from '@core/cursor/flag';+import type { IUser } from '@core/user/types';+import { uniqueByKey } from '@core/util/compareUtils';+import { useAgentsQuery } from '@queries/agents/agents';+import { queryReadyGate } from '@queries/gate';+import type { Accessor } from 'solid-js';++/**+ * Workspace people and agents for a routine prompt's `@` menu. A prompt mention+ * only names its agent: nothing here dispatches on it. An agent whose runtime is+ * away stays pickable, because the routine can name it before it next runs.+ */+export function useRoutinePromptMentionUsers(): Accessor<IUser[]> {+ const people = useQuickAccess().useList('person').items;+ const savedAgents = useAgentsQuery();+ const canUseCursor = useCursorAgentsAccess();+ const agents = useAgentMentionUsers(() =>+ availableBotMentionUsers(+ [],+ queryReadyGate(savedAgents) ? savedAgents.data : [],+ canUseCursor(),+ 'document'+ )+ );++ return () =>+ uniqueByKey(+ [...people().map((person) => person.data), ...agents()],+ (user) => user.id+ );+}diff --git a/docs/agent-guide/navigation.md b/docs/agent-guide/navigation.mdindex e735df2938..d2aa667af6 100644--- a/docs/agent-guide/navigation.md+++ b/docs/agent-guide/navigation.md@@ -1115,6 +1115,8 @@ lists them on Home and in Agents like the owner's own sessions. The settingapplies to runs that start after it changes. A run that finishes normally sendsno notification; a failed or cut-short run, a question the agent asks, a held toolapproval, and people the routine's prompt mentions still notify.+The prompt's `@` menu also lists agents. Mentioning one only names it for the+routine: it doesn't start the agent or notify anyone.**Create → Routine** (U) and **Create Routine** open the same popover host as taskand project creation. Enter a name and instructions, then choose a model or agent