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: ai shows up as "Macro (AI)" in history using AI namespace (#4640)
Wolf Mermelsteina2650250ba82
diff --git a/js/app/bun.lock b/js/app/bun.lockdeleted file mode 100644index e69de29bb2..0000000000diff --git a/js/app/packages/block-md/history/HistoryContext.tsx b/js/app/packages/block-md/history/HistoryContext.tsxindex b44a69cdc3..28d8cca1c8 100644--- a/js/app/packages/block-md/history/HistoryContext.tsx+++ b/js/app/packages/block-md/history/HistoryContext.tsx@@ -1,3 +1,5 @@+import { isAiPeer } from '@core/collab/ai-peer';+import { MACRO_AGENT_BOT_ID } from '@core/constant/macroAgent';import { tryMacroId, useDisplayName } from '@core/user';import {buildDiffState,@@ -106,6 +108,14 @@ export function HistoryProvider(props: {// Peer -> user mapping for labelling sessions; lightweight JSON.const peerMap = useDocumentPeersQuery(props.documentId);+ // AI peers are recognizable from the peer id alone (reserved block) and all+ // collapse into the single Macro identity. Checked before the peer map,+ // which may attribute them to whoever's token the AI worker connected with.+ const resolvePeerUser = (peers: Map<string, string>, peer: string): string =>+ isAiPeer(BigInt(peer))+ ? MACRO_AGENT_BOT_ID+ : (peers.get(peer) ?? 'unknown');+// One stable useDisplayName per unique userId — batched into a single fetch.const uniqueUserIds = createMemo(() =>peerMap.data ? [...new Set(peerMap.data.values())] : []@@ -123,7 +133,7 @@ export function HistoryProvider(props: {color: userColor(userId),};const userByPeer = (peerId: string): HistoryUser =>- userById(peerMap.data?.get(peerId) ?? 'unknown');+ userById(resolvePeerUser(peerMap.data ?? new Map(), peerId));const historyIndex = createMemo(() => {const doc = historyDoc();@@ -139,7 +149,7 @@ export function HistoryProvider(props: {const events: { userId: string; tMs: number }[] = [];for (const [peer, changes] of doc.getAllChanges()) {- const userId = peers.get(peer) ?? 'unknown';+ const userId = resolvePeerUser(peers, peer);for (const change of changes) {events.push({ userId, tMs: change.timestamp * 1000 });}@@ -186,7 +196,7 @@ export function HistoryProvider(props: {const peers = peerMap.data;const whoMap =doc && peers- ? buildWhoMap(doc, (peer) => peers.get(peer) ?? 'unknown')+ ? buildWhoMap(doc, (peer) => resolvePeerUser(peers, peer)): new Map<string, string>();const diffs = diffStates(before,diff --git a/js/app/packages/block-md/history/HistorySessionList.tsx b/js/app/packages/block-md/history/HistorySessionList.tsxindex 2192478ac8..2dda901cea 100644--- a/js/app/packages/block-md/history/HistorySessionList.tsx+++ b/js/app/packages/block-md/history/HistorySessionList.tsx@@ -3,7 +3,7 @@ import type { HistorySession } from '@service-sync/client';import { cn } from '@ui';import { type Accessor, createMemo, For, Show } from 'solid-js';import { buildActivityRows } from './activityRows';-import { userColor } from './utils';+import { userColor, userLabel } from './utils';type HistorySessionListProps = {sessions: readonly HistorySession[];@@ -14,7 +14,7 @@ type HistorySessionListProps = {function UserName(props: { userId: string }) {const { firstName } = useDisplayNameParts(tryMacroId(props.userId));- return <>{firstName()}</>;+ return <>{firstName() || userLabel(props.userId)}</>;}const MAX_NAMED = 3;diff --git a/js/app/packages/block-md/history/utils.ts b/js/app/packages/block-md/history/utils.tsindex f70d2eb3b2..102cf89059 100644--- a/js/app/packages/block-md/history/utils.ts+++ b/js/app/packages/block-md/history/utils.ts@@ -1,9 +1,11 @@+import { isMacroAgentId, MACRO_AGENT_NAME } from '@core/constant/macroAgent';import { macroIdToEmail, tryMacroId } from '@core/user';export { diffAuthorColor as userColor } from '@lexical-core';export function userLabel(userId: string): string {if (userId === 'unknown') return 'Unknown';+ if (isMacroAgentId(userId)) return `${MACRO_AGENT_NAME} (AI)`;const id = tryMacroId(userId);return id ? macroIdToEmail(id) : userId;}diff --git a/js/app/packages/core/collab/ai-peer.ts b/js/app/packages/core/collab/ai-peer.tsnew file mode 100644index 0000000000..3cc625da1e--- /dev/null+++ b/js/app/packages/core/collab/ai-peer.ts@@ -0,0 +1,13 @@+/**+ * AI editors connect to the sync service with peer ids drawn from a reserved+ * block, so they can be recognized from the peer id alone (no peer→user+ * mapping required).+ *+ * Keep in sync with `ai-editing-worker` (`awareness/ai-peer.ts`) and+ * `sync-service` (`ai_peer.rs`).+ */+export const AI_PEER_COUNT = 1000;+export const AI_PEER_BASE = 999_999_999_999_999_000n;++export const isAiPeer = (peer: bigint): boolean =>+ peer >= AI_PEER_BASE && peer < AI_PEER_BASE + BigInt(AI_PEER_COUNT);diff --git a/rust/cloud-storage/documents/src/outbound/editing_worker_client.rs b/rust/cloud-storage/documents/src/outbound/editing_worker_client.rsindex f52d1ac534..a7c008f15e 100644--- a/rust/cloud-storage/documents/src/outbound/editing_worker_client.rs+++ b/rust/cloud-storage/documents/src/outbound/editing_worker_client.rs@@ -53,6 +53,7 @@ impl EditingWorkerService for ReqwestEditingWorkerClient {"models": {"supervisor": [{ "provider": "anthropic", "model": "claude-opus-4-8" },+ { "provider": "anthropic", "model": "claude-sonnet-4-6" },{ "provider": "openai", "model": "gpt-5.5" },],"interpret": [