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
web: draw first-party bot brand marks on every avatar surface (#6963)
teoe77e17973135
diff --git a/apps/web/src/features/channel/Message/SenderIcon.test.tsx b/apps/web/src/features/channel/Message/SenderIcon.test.tsxnew file mode 100644index 0000000000..0089b4d652--- /dev/null+++ b/apps/web/src/features/channel/Message/SenderIcon.test.tsx@@ -0,0 +1,75 @@+import { CURSOR_BOT_PRINCIPAL_ID } from '@core/constant/cursorAgent';+import { MACRO_AGENT_PRINCIPAL_ID } from '@core/constant/macroAgent';+import { MACRO_NEW_PRINCIPAL_ID } from '@core/constant/macroNew';+import type { MessageData } from '@core/messages/types';+import { cleanup, render } from '@solidjs/testing-library';+import { afterEach, describe, expect, it, vi } from 'vitest';+import { MessageProvider } from './context';+import { SenderIcon } from './SenderIcon';++vi.mock('@core/component/UserIcon', () => ({+ UserIcon: (props: { id: string }) => (+ <span data-testid="user-icon">{props.id}</span>+ ),+}));+vi.mock('./BotIcon', () => ({+ BotIcon: (props: { name?: string | null; avatarUrl?: string | null }) => (+ <span data-testid="bot-icon" data-avatar={props.avatarUrl ?? ''}>+ {props.name}+ </span>+ ),+}));++afterEach(cleanup);++const TEAM_BOT_ID = '11111111-2222-3333-4444-555555555555';++const message = (senderId: string, sender?: MessageData['sender']) =>+ ({+ id: 'message-1',+ content: 'hi',+ sender_id: senderId,+ sender,+ }) as unknown as MessageData;++const renderSender = (data: MessageData) =>+ render(() => (+ <MessageProvider value={() => data}>+ <SenderIcon />+ </MessageProvider>+ ));++describe('SenderIcon', () => {+ it('draws first-party bots through UserIcon so they keep their brand mark', () => {+ for (const id of [+ MACRO_AGENT_PRINCIPAL_ID,+ MACRO_NEW_PRINCIPAL_ID,+ CURSOR_BOT_PRINCIPAL_ID,+ ]) {+ const { getByTestId, queryByTestId } = renderSender(message(id));+ expect(getByTestId('user-icon').textContent).toBe(id);+ expect(queryByTestId('bot-icon')).toBeNull();+ cleanup();+ }+ });++ it('draws a team bot with its own uploaded avatar', () => {+ const { getByTestId, queryByTestId } = renderSender(+ message(`bot|${TEAM_BOT_ID}`, {+ type: 'bot',+ id: TEAM_BOT_ID,+ name: 'Helper',+ avatar_url: 'https://cdn/helper.png',+ })+ );+ const icon = getByTestId('bot-icon');+ expect(icon.textContent).toBe('Helper');+ expect(icon.dataset.avatar).toBe('https://cdn/helper.png');+ expect(queryByTestId('user-icon')).toBeNull();+ });++ it('draws people through UserIcon', () => {+ const { getByTestId } = renderSender(message('macro|[email protected]'));+ expect(getByTestId('user-icon').textContent).toBe('macro|[email protected]');+ });+});diff --git a/apps/web/src/features/channel/Message/SenderIcon.tsx b/apps/web/src/features/channel/Message/SenderIcon.tsxindex 8b2c40f13c..a75eac8274 100644--- a/apps/web/src/features/channel/Message/SenderIcon.tsx+++ b/apps/web/src/features/channel/Message/SenderIcon.tsx@@ -1,5 +1,5 @@+import { firstPartyBotMark } from '@core/component/firstPartyBotMark';import { UserIcon } from '@core/component/UserIcon';-import { isMacroAgentId } from '@core/constant/macroAgent';import { senderFromStorageId } from '@queries/messages/message-sender';import type { ApiMessageSender } from '@service-storage/generated/schemas/apiMessageSender';import { cn } from '@ui';@@ -15,11 +15,12 @@ type SenderIconProps = {export function SenderIcon(props: SenderIconProps) {const message = useMessage();- // Bot senders render their own avatar; Macro AI keeps its dedicated logo- // rendering inside UserIcon.+ // Team bots render their uploaded avatar; first-party bots have none and+ // keep their brand mark, which UserIcon draws the same way the mention menu+ // does.const botSender = (): ApiMessageSender | undefined => {const sender = message().sender ?? senderFromStorageId(message().sender_id);- if (sender.type !== 'bot' || isMacroAgentId(sender.id)) return undefined;+ if (sender.type !== 'bot' || firstPartyBotMark(sender.id)) return undefined;return sender;};diff --git a/apps/web/src/features/next-soup/soup-view/views/inbox/inbox-card-layouts.tsx b/apps/web/src/features/next-soup/soup-view/views/inbox/inbox-card-layouts.tsxindex ddce496242..e0d241fe75 100644--- a/apps/web/src/features/next-soup/soup-view/views/inbox/inbox-card-layouts.tsx+++ b/apps/web/src/features/next-soup/soup-view/views/inbox/inbox-card-layouts.tsx@@ -4,6 +4,10 @@ import { formatCallDuration } from '@block-call/utils';import { BotIcon } from '@channel/Message/BotIcon';import { MACRO_AI_BOT_ID, MACRO_AI_NAME } from '@channel/macroAi';import { EntityIcon, getEntityIconType } from '@core/component/EntityIcon';+import {+ firstPartyBotMark,+ firstPartyBotMarkTone,+} from '@core/component/firstPartyBotMark';import { ItemPreview } from '@core/component/ItemPreview';import { StaticMarkdown } from '@core/component/LexicalMarkdown/component/core/StaticMarkdown';import {@@ -11,7 +15,6 @@ import {unifiedListMarkdownTheme,} from '@core/component/LexicalMarkdown/theme';import { UserIcon } from '@core/component/UserIcon';-import { isMacroAgentId } from '@core/constant/macroAgent';import { useUserId } from '@core/context/user';import { getDisplayName, tryMacroId } from '@core/user';import { formatRelativeDay } from '@core/util/dateParser';@@ -26,7 +29,6 @@ import {type WithNotification,} from '@entity';import { formatCompactRelativeTimestamp } from '@entity/utils/timestamp';-import MacroLogo from '@icon/macro-logo.svg';import GithubIcon from '@icon/mcp-github.svg';import { formatCalendarReminderTime } from '@notifications';import { getNotificationSenderFallbackName } from '@notifications/notification-sender';@@ -156,12 +158,13 @@ type SenderIconProps = {};export function SenderIcon(props: SenderIconProps) {- // Bot senders render their own avatar; Macro AI keeps its dedicated logo.+ // Team bots render their uploaded avatar; first-party bots keep their brand+ // mark, which UserIcon draws.const botSender = () => {const sender = props.senderId? senderFromStorageId(props.senderId): undefined;- if (sender?.type !== 'bot' || isMacroAgentId(sender.id)) return;+ if (sender?.type !== 'bot' || firstPartyBotMark(sender.id)) return;return sender;};@@ -188,9 +191,9 @@ function InboxAvatar(props: {}) {const parsedSender = () =>props.senderId ? senderFromStorageId(props.senderId) : undefined;- const isMacroAgent = () => {+ const botMark = () => {const sender = parsedSender();- return sender?.type === 'bot' && isMacroAgentId(sender.id);+ return sender?.type === 'bot' ? firstPartyBotMark(sender.id) : undefined;};return (@@ -204,8 +207,13 @@ function InboxAvatar(props: {<Match when={props.imageUrl}>{(url) => <img src={url()} alt="" class="size-full object-cover" />}</Match>- <Match when={isMacroAgent()}>- <MacroLogo class="m-auto size-1/2 text-accent" />+ <Match when={botMark()} keyed>+ {(mark) => (+ <Dynamic+ component={mark.Icon}+ class={cn('m-auto size-1/2', firstPartyBotMarkTone(mark))}+ />+ )}</Match><Match when={props.senderId}>{(senderId) => <SenderIcon senderId={senderId()} />}diff --git a/apps/web/src/lib/core/component/UserIcon.tsx b/apps/web/src/lib/core/component/UserIcon.tsxindex 26d336c85b..6e6f70590d 100644--- a/apps/web/src/lib/core/component/UserIcon.tsx+++ b/apps/web/src/lib/core/component/UserIcon.tsx@@ -1,8 +1,6 @@import { useSplitLayout } from '@components/app/split-layout/layout';import { ENABLE_PROFILE_PICTURES } from '@core/constant/featureFlags';-import { isBotPrincipalId, isMacroAgentId } from '@core/constant/macroAgent';-import { isMacroCoderId } from '@core/constant/macroCoder';-import { isMacroNewId } from '@core/constant/macroNew';+import { isBotPrincipalId } from '@core/constant/macroAgent';import { staticFileSizedUrl } from '@core/constant/servers';import { internalDrag } from '@core/directive/internalDragState';import { isTouchDevice } from '@core/mobile/isTouchDevice';@@ -15,12 +13,13 @@ import {tryMacroId,useIsConnectedSecondaryInbox,} from '@core/user';-import MacroLogo from '@icon/macro-logo.svg';import RobotIcon from '@phosphor/robot.svg';import Trash from '@phosphor-icons/core/regular/trash.svg?component-solid';import { useGetOrCreateDirectMessageMutation } from '@queries/channel/get-or-create-dm';import { Avatar, type AvatarSize, cn } from '@ui';import { createMemo, Match, Show, Switch } from 'solid-js';+import { Dynamic } from 'solid-js/web';+import { firstPartyBotMark, firstPartyBotMarkTone } from './firstPartyBotMark';import { UserCardTrigger } from './UserCardTrigger';export type UserIconSize = AvatarSize;@@ -175,21 +174,21 @@ export function UserIcon(props: UserIconProps) {return (<Switch>- <Match- when={- isMacroAgentId(props.id) ||- isMacroCoderId(props.id) ||- isMacroNewId(props.id)- }- >- <Avatar- size={size()}- class={cn('bg-surface text-accent ring ring-edge-muted', props.class)}- >- <Avatar.Fallback>- <MacroLogo class="size-[62%]" />- </Avatar.Fallback>- </Avatar>+ <Match when={firstPartyBotMark(props.id)} keyed>+ {(mark) => (+ <Avatar+ size={size()}+ class={cn(+ 'bg-surface ring ring-edge-muted',+ firstPartyBotMarkTone(mark),+ props.class+ )}+ >+ <Avatar.Fallback>+ <Dynamic component={mark.Icon} class="size-[62%]" />+ </Avatar.Fallback>+ </Avatar>+ )}</Match><Match when={isBotPrincipalId(props.id)}>diff --git a/apps/web/src/lib/core/component/firstPartyBotMark.test.tsx b/apps/web/src/lib/core/component/firstPartyBotMark.test.tsxnew file mode 100644index 0000000000..ad2f4572e9--- /dev/null+++ b/apps/web/src/lib/core/component/firstPartyBotMark.test.tsx@@ -0,0 +1,96 @@+import { CLAUDE_BOT_PRINCIPAL_ID } from '@core/constant/claudeAgent';+import { CODEX_BOT_PRINCIPAL_ID } from '@core/constant/codexAgent';+import {+ CURSOR_BOT_ID,+ CURSOR_BOT_PRINCIPAL_ID,+} from '@core/constant/cursorAgent';+import { MACRO_AGENT_PRINCIPAL_ID } from '@core/constant/macroAgent';+import { MACRO_CODER_PRINCIPAL_ID } from '@core/constant/macroCoder';+import { MACRO_NEW_PRINCIPAL_ID } from '@core/constant/macroNew';+import MacroLogo from '@icon/macro-logo.svg';+import ClaudeIcon from '@icon/wide-claude.svg';+import CodexIcon from '@icon/wide-codex-ide.svg';+import CursorIcon from '@icon/wide-cursor-ide.svg';+import { cleanup, render } from '@solidjs/testing-library';+import { afterEach, describe, expect, it, vi } from 'vitest';+import { firstPartyBotMark } from './firstPartyBotMark';+import { UserIcon } from './UserIcon';++vi.mock('@components/app/split-layout/layout', () => ({+ useSplitLayout: () => ({ openWithSplit: vi.fn() }),+}));+vi.mock('@queries/channel/get-or-create-dm', () => ({+ useGetOrCreateDirectMessageMutation: () => ({ mutate: vi.fn() }),+}));+vi.mock('@core/user', () => ({+ getDisplayName: () => undefined,+ getDisplayNameParts: () => ({ firstName: '', lastName: '' }),+ getInitials: () => '?',+ macroIdToEmail: (id: string) => id,+ tryMacroId: () => undefined,+ useIsConnectedSecondaryInbox: () => () => false,+}));+vi.mock('@core/signal/profilePicture', () => ({+ useProfilePictureUrl: () => [() => undefined],+}));++afterEach(cleanup);++describe('firstPartyBotMark', () => {+ it('gives both Macro bots and the coder the Macro logo', () => {+ for (const id of [+ MACRO_AGENT_PRINCIPAL_ID,+ MACRO_NEW_PRINCIPAL_ID,+ MACRO_CODER_PRINCIPAL_ID,+ ]) {+ expect(firstPartyBotMark(id)).toEqual({+ Icon: MacroLogo,+ tone: 'accent',+ });+ }+ });++ it('gives the partner agents their own marks', () => {+ expect(firstPartyBotMark(CURSOR_BOT_PRINCIPAL_ID)?.Icon).toBe(CursorIcon);+ expect(firstPartyBotMark(CURSOR_BOT_ID)?.Icon).toBe(CursorIcon);+ expect(firstPartyBotMark(CLAUDE_BOT_PRINCIPAL_ID)?.Icon).toBe(ClaudeIcon);+ expect(firstPartyBotMark(CODEX_BOT_PRINCIPAL_ID)?.Icon).toBe(CodexIcon);+ });++ it('has no mark for team bots or people', () => {+ expect(+ firstPartyBotMark('bot|11111111-2222-3333-4444-555555555555')+ ).toBeUndefined();+ expect(firstPartyBotMark('macro|[email protected]')).toBeUndefined();+ expect(firstPartyBotMark(undefined)).toBeUndefined();+ });+});++describe('UserIcon for first-party bots', () => {+ const svgOf = (container: HTMLElement) => container.querySelector('svg');++ it('draws the Cursor mark for the Cursor bot rather than a robot', () => {+ const { container: cursor } = render(() => (+ <UserIcon id={CURSOR_BOT_PRINCIPAL_ID} />+ ));+ const { container: reference } = render(() => <CursorIcon />);+ expect(svgOf(cursor)?.innerHTML).toBe(svgOf(reference)?.innerHTML);+ });++ it('draws the Macro logo for the agent-session Macro bot', () => {+ const { container: macro } = render(() => (+ <UserIcon id={MACRO_NEW_PRINCIPAL_ID} />+ ));+ const { container: reference } = render(() => <MacroLogo />);+ expect(svgOf(macro)?.innerHTML).toBe(svgOf(reference)?.innerHTML);+ });++ it('keeps the generic robot for a team bot without an avatar', () => {+ const { container: bot } = render(() => (+ <UserIcon id="bot|11111111-2222-3333-4444-555555555555" />+ ));+ const { container: reference } = render(() => <CursorIcon />);+ expect(svgOf(bot)).not.toBeNull();+ expect(svgOf(bot)?.innerHTML).not.toBe(svgOf(reference)?.innerHTML);+ });+});diff --git a/apps/web/src/lib/core/component/firstPartyBotMark.ts b/apps/web/src/lib/core/component/firstPartyBotMark.tsnew file mode 100644index 0000000000..6afa946a86--- /dev/null+++ b/apps/web/src/lib/core/component/firstPartyBotMark.ts@@ -0,0 +1,54 @@+import { isClaudeBotId } from '@core/constant/claudeAgent';+import { isCodexBotId } from '@core/constant/codexAgent';+import { isCursorBotId } from '@core/constant/cursorAgent';+import { isMacroAgentId } from '@core/constant/macroAgent';+import { isMacroCoderId } from '@core/constant/macroCoder';+import { isMacroNewId } from '@core/constant/macroNew';+import { isMacroSystemId } from '@core/constant/macroSystem';+import MacroLogo from '@icon/macro-logo.svg';+import ClaudeIcon from '@icon/wide-claude.svg';+import CodexIcon from '@icon/wide-codex-ide.svg';+import CursorIcon from '@icon/wide-cursor-ide.svg';+import type { Component, ComponentProps } from 'solid-js';++/** The brand mark a first-party bot wears wherever an avatar is drawn. */+export type FirstPartyBotMark = {+ Icon: Component<ComponentProps<'svg'>>;+ /** Macro's own marks take the accent color; partner marks stay ink. */+ tone: 'accent' | 'ink';+};++const MACRO_MARK: FirstPartyBotMark = { Icon: MacroLogo, tone: 'accent' };+const CURSOR_MARK: FirstPartyBotMark = { Icon: CursorIcon, tone: 'ink' };+const CLAUDE_MARK: FirstPartyBotMark = { Icon: ClaudeIcon, tone: 'ink' };+const CODEX_MARK: FirstPartyBotMark = { Icon: CodexIcon, tone: 'ink' };++/**+ * The avatar mark for a first-party bot (bare UUID or `bot|<uuid>`). System+ * bots have no `bots` row and therefore no `avatar_url`; their picture is the+ * mark the client ships, so every surface (mention menu, message sender,+ * inbox) resolves it here rather than falling back to an initial or a generic+ * robot. Undefined for team bots, which carry their own avatar.+ */+export function firstPartyBotMark(+ id: string | undefined+): FirstPartyBotMark | undefined {+ if (!id) return undefined;+ if (+ isMacroAgentId(id) ||+ isMacroNewId(id) ||+ isMacroCoderId(id) ||+ isMacroSystemId(id)+ ) {+ return MACRO_MARK;+ }+ if (isCursorBotId(id)) return CURSOR_MARK;+ if (isClaudeBotId(id)) return CLAUDE_MARK;+ if (isCodexBotId(id)) return CODEX_MARK;+ return undefined;+}++/** Text color class for a mark's tone. */+export function firstPartyBotMarkTone(mark: FirstPartyBotMark): string {+ return mark.tone === 'accent' ? 'text-accent' : 'text-ink';+}