Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

feat(agents): open agent settings from its user card (#8439)

Wolf Mermelsteinb1a6b2f13297
diff --git a/apps/web/src/features/settings/AgentSettings.tsx b/apps/web/src/features/settings/AgentSettings.tsx
index 6d07a87331..13c3a339da 100644
--- a/apps/web/src/features/settings/AgentSettings.tsx
+++ b/apps/web/src/features/settings/AgentSettings.tsx
@@ -1,7 +1,8 @@
import type { AgentKind } from '@app/features/agents-view/core/agent-kind';
import { useSearchParams } from '@solidjs/router';
-import { createSignal, Match, Switch } from 'solid-js';
+import { createEffect, createSignal, Match, on, Switch } from 'solid-js';
import { Agents } from './Agents';
+import { agentSettingsRequest } from './agentSettingsState';
import { CursorConnectPage } from './CursorConnectPage';
import { Harness } from './Harness';
import { RuntimePairingPage } from './RuntimePairingPage';
@@ -26,6 +27,13 @@ export function AgentSettings(props: {
};
const showAgents = () => navigate('agents');
const activePage = () => (props.createKind ? 'agents' : page());
+ // An agent opened from elsewhere lands in its editor, which lives on the
+ // agents page; `Agents` consumes the request.
+ createEffect(
+ on(agentSettingsRequest, (request) => {
+ if (request) showAgents();
+ })
+ );
return (
<Switch>
diff --git a/apps/web/src/features/settings/Agents.test.tsx b/apps/web/src/features/settings/Agents.test.tsx
index 1b86958b14..d31e07cd83 100644
--- a/apps/web/src/features/settings/Agents.test.tsx
+++ b/apps/web/src/features/settings/Agents.test.tsx
@@ -23,6 +23,7 @@ import { Suspense } from 'solid-js';
import { createStore } from 'solid-js/store';
import { beforeAll, beforeEach, describe, expect, it, vi } from 'vitest';
import { Agents } from './Agents';
+import { agentSettingsRequest, requestAgentDetail } from './agentSettingsState';
import {
chooseModelOption,
chooseSelectOption,
@@ -905,6 +906,34 @@ describe('Agents', () => {
});
});
+ it("opens an agent's editor when asked to from its user card", () => {
+ agentMocks.query.data = [
+ {
+ bot: {
+ id: 'agent-1',
+ kind: 'owned',
+ owner: { type: 'user', user_id: 'macro|[email protected]' },
+ name: 'Bug fixer',
+ handle: 'bug-fixer',
+ has_agent: true,
+ created_at: '2026-08-27T12:00:00Z',
+ updated_at: '2026-08-27T12:00:00Z',
+ },
+ instructions: 'Fix the root cause.',
+ harness: 'in-memory',
+ default_model: Model.sonnet55,
+ channel_scope: 'all',
+ channel_ids: [],
+ },
+ ];
+ requestAgentDetail('agent-1');
+
+ render(() => <Agents {...agentsPageProps} />);
+
+ expect(screen.getByRole('heading', { name: 'Edit agent' })).toBeTruthy();
+ expect(agentSettingsRequest()).toBeUndefined();
+ });
+
it('lets team members edit without deleting or privatizing another creator agent', () => {
agentMocks.query.data = [
{
diff --git a/apps/web/src/features/settings/Agents.tsx b/apps/web/src/features/settings/Agents.tsx
index 71cac51206..a0c45785e7 100644
--- a/apps/web/src/features/settings/Agents.tsx
+++ b/apps/web/src/features/settings/Agents.tsx
@@ -61,17 +61,23 @@ import { useSearchParams } from '@solidjs/router';
import { ApiKeyInput, Avatar, Button, Dialog, Panel } from '@ui';
import { tourTarget } from '@ui/components/Tour';
import {
+ createEffect,
createMemo,
createSignal,
For,
type JSX,
Match,
+ on,
Show,
Switch,
} from 'solid-js';
import { botAssignableChannelOptions } from '../channel/Bots/botChannelOptions';
import { canDeleteBot, canManageAgent } from '../channel/Bots/botPermissions';
import { ChannelMultiSelect } from '../channel/Bots/ChannelMultiSelect';
+import {
+ agentSettingsRequest,
+ consumeAgentSettingsRequest,
+} from './agentSettingsState';
import { CursorConnectPage } from './CursorConnectPage';
import { AgentSetupStrips } from './components/agent-setup-strips';
import { CodingPreferencesSetting } from './components/coding-preferences-setting';
@@ -247,6 +253,22 @@ export function Agents(props: {
agents().filter((agent) => agent.share === 'Private')
);
+ // Opened from an agent's user card: wait for the list, then show that
+ // agent's editor if it is one the viewer manages.
+ createEffect(
+ on([agentSettingsRequest, () => agentsQuery.isPending], ([request]) => {
+ if (!request || agentsQuery.isPending) return;
+ const agent = agents().find(
+ (candidate) => candidate.id === request.agentId
+ );
+ if (agent?.editable && agent.persistedAgent) {
+ setCreating(false);
+ setEditingAgent(agent.persistedAgent);
+ }
+ consumeAgentSettingsRequest(request.id);
+ })
+ );
+
const createAgent = async (agent: CreateAgentParams) => {
try {
const created = await createAgentMutation.mutateAsync(agent);
diff --git a/apps/web/src/features/settings/agentSettingsState.ts b/apps/web/src/features/settings/agentSettingsState.ts
new file mode 100644
index 0000000000..e621fb23c9
--- /dev/null
+++ b/apps/web/src/features/settings/agentSettingsState.ts
@@ -0,0 +1,18 @@
+import { createSignal } from 'solid-js';
+
+/** Asks the Agents settings page to open one agent's editor. */
+export type AgentSettingsRequest = { id: number; agentId: string };
+
+const [agentSettingsRequest, setAgentSettingsRequest] =
+ createSignal<AgentSettingsRequest>();
+let nextRequestId = 0;
+
+export { agentSettingsRequest };
+
+export function requestAgentDetail(agentId: string) {
+ setAgentSettingsRequest({ id: ++nextRequestId, agentId });
+}
+
+export function consumeAgentSettingsRequest(id: number) {
+ if (agentSettingsRequest()?.id === id) setAgentSettingsRequest(undefined);
+}
diff --git a/apps/web/src/features/settings/bot-settings-user-action.ts b/apps/web/src/features/settings/bot-settings-user-action.ts
new file mode 100644
index 0000000000..be2ec084af
--- /dev/null
+++ b/apps/web/src/features/settings/bot-settings-user-action.ts
@@ -0,0 +1,98 @@
+import { requestBotDetail } from '@app/features/channel/Bots/botSettingsState';
+import { useFeatureFlag } from '@app/lib/analytics/posthog';
+import type { UserCardAction } from '@core/component/userCardActions';
+import { botManagement, enableChatV3Agents } from '@core/constant/featureFlags';
+import { isBotPrincipalId, isMacroAgentId } from '@core/constant/macroAgent';
+import { isMacroNewId } from '@core/constant/macroNew';
+import { useSettingsState } from '@core/constant/SettingsState';
+import { useUserId } from '@core/context/user';
+import GearIcon from '@phosphor/gear.svg';
+import { useAgentsQuery } from '@queries/agents/agents';
+import { useBotsQuery } from '@queries/bots/bots';
+import { useCurrentTeamQuery } from '@queries/team/teams';
+import type { Accessor } from 'solid-js';
+import { match } from 'ts-pattern';
+import { canManageAgent } from '../channel/Bots/botPermissions';
+import { requestAgentDetail } from './agentSettingsState';
+
+type BotSettingsDestination =
+ | { type: 'agents' }
+ | { type: 'agent'; agentId: string }
+ | { type: 'bot'; botId: string };
+
+/**
+ * The user card's way into Settings for an agent or bot: the agent's editor
+ * when the viewer can configure it, the bot's page under Bots otherwise, and
+ * the Agents list for Macro, which has no editor of its own.
+ */
+export function createBotSettingsUserCardAction(
+ principalId: Accessor<string | undefined>
+): Accessor<UserCardAction | undefined> {
+ const agentsFlag = useFeatureFlag(enableChatV3Agents);
+ const botsFlag = useFeatureFlag(botManagement);
+ const { openSettings } = useSettingsState();
+ const currentUserId = useUserId();
+ const isBot = () => isBotPrincipalId(principalId());
+ // Only a bot's card needs these lists, so a person's card never fetches
+ // them. Guarded reads: an unguarded `data` suspends the card.
+ const agentsQuery = useAgentsQuery(() => isBot() && agentsFlag().enabled);
+ const botsQuery = useBotsQuery(() => isBot() && botsFlag().enabled);
+ const currentTeamQuery = useCurrentTeamQuery(
+ () => isBot() && agentsFlag().enabled
+ );
+
+ const destination = (): BotSettingsDestination | undefined => {
+ const id = principalId();
+ if (!id || !isBot()) return undefined;
+ const botId = id.startsWith('bot|') ? id.slice('bot|'.length) : id;
+
+ if (agentsFlag().enabled) {
+ if (isMacroAgentId(botId) || isMacroNewId(botId)) {
+ return { type: 'agents' };
+ }
+ const agents = agentsQuery.isSuccess ? agentsQuery.data : [];
+ const teamId = currentTeamQuery.isSuccess
+ ? currentTeamQuery.data?.team.id
+ : undefined;
+ const agent = agents.find((candidate) => candidate.bot.id === botId);
+ if (agent) {
+ return canManageAgent(agent.bot, currentUserId(), teamId)
+ ? { type: 'agent', agentId: botId }
+ : undefined;
+ }
+ }
+
+ const bots =
+ botsFlag().enabled && botsQuery.isSuccess ? botsQuery.data : [];
+ if (bots.some((bot) => bot.id === botId)) return { type: 'bot', botId };
+ return undefined;
+ };
+
+ const open = (event: MouseEvent, target: BotSettingsDestination) => {
+ event.preventDefault();
+ event.stopPropagation();
+ match(target)
+ .with({ type: 'agents' }, () => openSettings('Agents'))
+ .with({ type: 'agent' }, ({ agentId }) => {
+ requestAgentDetail(agentId);
+ openSettings('Agents');
+ })
+ .with({ type: 'bot' }, ({ botId }) => {
+ requestBotDetail(botId);
+ openSettings('Bots');
+ })
+ .exhaustive();
+ };
+
+ return () => {
+ const target = destination();
+ return target
+ ? {
+ id: 'open-settings',
+ label: 'Settings',
+ icon: GearIcon,
+ onSelect: (event) => open(event, target),
+ }
+ : undefined;
+ };
+}
diff --git a/apps/web/src/lib/core/component/UserCardDrawer.test.tsx b/apps/web/src/lib/core/component/UserCardDrawer.test.tsx
index 533e39df72..1e467ab215 100644
--- a/apps/web/src/lib/core/component/UserCardDrawer.test.tsx
+++ b/apps/web/src/lib/core/component/UserCardDrawer.test.tsx
@@ -57,6 +57,10 @@ vi.mock('@queries/team/teams', () => ({
useCurrentTeamQuery: () => ({ isSuccess: false, data: undefined }),
}));
+vi.mock('@app/features/settings/bot-settings-user-action', () => ({
+ createBotSettingsUserCardAction: () => () => undefined,
+}));
+
vi.mock('./UserIcon', () => ({
UserIcon: () => <div data-testid="user-icon" />,
}));
diff --git a/apps/web/src/lib/core/component/UserTooltip.test.tsx b/apps/web/src/lib/core/component/UserTooltip.test.tsx
index 631ac154cf..a6995f969d 100644
--- a/apps/web/src/lib/core/component/UserTooltip.test.tsx
+++ b/apps/web/src/lib/core/component/UserTooltip.test.tsx
@@ -2,6 +2,8 @@
* @vitest-environment jsdom
*/
+import { agentSettingsRequest } from '@app/features/settings/agentSettingsState';
+import { botSettingsRequest } from '@channel/Bots/botSettingsState';
import { render, screen, waitFor } from '@solidjs/testing-library';
import userEvent from '@testing-library/user-event';
import type { JSX } from 'solid-js';
@@ -16,11 +18,21 @@ const mocks = vi.hoisted(() => ({
onClose: vi.fn(),
toastSuccess: vi.fn(),
toastFailure: vi.fn(),
+ openSettings: vi.fn(),
+ agents: [] as Array<{
+ bot: {
+ id: string;
+ owner:
+ | { type: 'team'; team_id: string }
+ | { type: 'user'; user_id: string };
+ };
+ }>,
+ bots: [] as Array<{ id: string }>,
}));
vi.mock('@app/lib/analytics/posthog', () => ({
- useFeatureFlag: () => () => ({
- enabled: mocks.crmFlagEnabled,
+ useFeatureFlag: (flag: { key: string }) => () => ({
+ enabled: flag.key === 'enable-crm' ? mocks.crmFlagEnabled : true,
payload: undefined,
}),
}));
@@ -78,6 +90,18 @@ vi.mock('@ui', () => ({
),
}));
+vi.mock('@core/constant/SettingsState', () => ({
+ useSettingsState: () => ({ openSettings: mocks.openSettings }),
+}));
+
+vi.mock('@queries/agents/agents', () => ({
+ useAgentsQuery: () => ({ isSuccess: true, data: mocks.agents }),
+}));
+
+vi.mock('@queries/bots/bots', () => ({
+ useBotsQuery: () => ({ isSuccess: true, data: mocks.bots }),
+}));
+
vi.mock('./UserIcon', () => ({
UserIcon: () => <div data-testid="user-icon" />,
}));
@@ -90,6 +114,9 @@ beforeEach(() => {
mocks.onClose.mockReset();
mocks.toastSuccess.mockReset();
mocks.toastFailure.mockReset();
+ mocks.openSettings.mockReset();
+ mocks.agents = [];
+ mocks.bots = [];
});
describe('UserTooltip clipboard action', () => {
@@ -250,3 +277,84 @@ describe('UserTooltip CRM contact action', () => {
expect(screen.queryByRole('button', { name: 'Open contact' })).toBeNull();
});
});
+
+describe('UserTooltip settings action', () => {
+ const agentId = '0190f3a1-0000-7000-8000-00000000a9e1';
+
+ it("opens a team agent's editor in Settings", async () => {
+ const user = userEvent.setup({ skipHover: true });
+ mocks.agents = [
+ { bot: { id: agentId, owner: { type: 'team', team_id: 'team-1' } } },
+ ];
+ render(() => (
+ <UserTooltip
+ displayName="Researcher"
+ id={`bot|${agentId}`}
+ onClose={mocks.onClose}
+ />
+ ));
+
+ await user.click(screen.getByRole('button', { name: 'Settings' }));
+
+ expect(mocks.openSettings).toHaveBeenCalledWith('Agents');
+ expect(agentSettingsRequest()?.agentId).toBe(agentId);
+ expect(mocks.onClose).toHaveBeenCalledOnce();
+ });
+
+ it("opens a bot's page under Bots when it is not an agent", async () => {
+ const user = userEvent.setup({ skipHover: true });
+ mocks.bots = [{ id: agentId }];
+ render(() => (
+ <UserTooltip displayName="Deploy bot" id={`bot|${agentId}`} />
+ ));
+
+ await user.click(screen.getByRole('button', { name: 'Settings' }));
+
+ expect(mocks.openSettings).toHaveBeenCalledWith('Bots');
+ expect(botSettingsRequest()).toMatchObject({
+ type: 'detail',
+ botId: agentId,
+ });
+ });
+
+ it('opens the Agents list for Macro', async () => {
+ const user = userEvent.setup({ skipHover: true });
+ render(() => (
+ <UserTooltip
+ displayName="Macro"
+ id="bot|00000000-0000-0000-0000-00000000a1a1"
+ />
+ ));
+
+ await user.click(screen.getByRole('button', { name: 'Settings' }));
+
+ expect(mocks.openSettings).toHaveBeenCalledWith('Agents');
+ });
+
+ it("offers no settings for another user's private agent", () => {
+ mocks.agents = [
+ {
+ bot: {
+ id: agentId,
+ owner: { type: 'user', user_id: 'macro|[email protected]' },
+ },
+ },
+ ];
+ mocks.bots = [{ id: agentId }];
+ render(() => <UserTooltip displayName="Theirs" id={`bot|${agentId}`} />);
+
+ expect(screen.queryByRole('button', { name: 'Settings' })).toBeNull();
+ });
+
+ it('offers no settings for a person', () => {
+ render(() => (
+ <UserTooltip
+ displayName="Jane Doe"
+ id="macro|[email protected]"
+ />
+ ));
+
+ expect(screen.queryByRole('button', { name: 'Settings' })).toBeNull();
+ });
+});
diff --git a/apps/web/src/lib/core/component/userCardActions.tsx b/apps/web/src/lib/core/component/userCardActions.tsx
index eafe8d925d..f18f9b50a8 100644
--- a/apps/web/src/lib/core/component/userCardActions.tsx
+++ b/apps/web/src/lib/core/component/userCardActions.tsx
@@ -1,4 +1,5 @@
import { createCrmUserCardAction } from '@app/features/crm/crm-user-action';
+import { createBotSettingsUserCardAction } from '@app/features/settings/bot-settings-user-action';
import { useSplitLayout } from '@components/app/split-layout/layout';
import { toast } from '@core/component/Toast/Toast';
import { isBotPrincipalId } from '@core/constant/macroAgent';
@@ -28,6 +29,7 @@ type UserCardActionId =
| 'copy-email'
| 'copy-name'
| 'open-contact'
+ | 'open-settings'
| 'dm'
| 'assign-task';
@@ -83,6 +85,7 @@ export function useUserCardActions(
canTreatAsUser() && !isBotPrincipalId(userId());
const contactAction = createCrmUserCardAction(() => target().email);
+ const settingsAction = createBotSettingsUserCardAction(userId);
const copyAction = (
id: UserCardActionId,
@@ -152,6 +155,9 @@ export function useUserCardActions(
const contact = contactAction();
if (contact) actions.push(contact);
+ const settings = settingsAction();
+ if (settings) actions.push(settings);
+
if (canDirectMessage() && userId() !== currentUserId()) {
actions.push({
id: 'dm',
diff --git a/docs/agent-guide/navigation.md b/docs/agent-guide/navigation.md
index aa0ea0dec5..5c82194358 100644
--- a/docs/agent-guide/navigation.md
+++ b/docs/agent-guide/navigation.md
@@ -959,7 +959,10 @@ on desktop, including task, project, calendar event, skill, and agent session co
Hovering an `@user` mention or a profile picture on desktop opens the user card:
the person's name and email above Copy email, Copy name, Open contact (CRM teams
-only), DM, and Assign task. Touch devices have no hover, so tapping the mention
+only), DM, and Assign task. An agent's or bot's card offers Settings instead of
+DM when the viewer can configure it: Macro opens Settings → Agents, an agent the
+viewer manages opens straight into its Edit agent form, and a plain bot opens
+its page under Settings → Bots. Touch devices have no hover, so tapping the mention
or the picture opens that same card as a bottom sheet; any action there runs and
dismisses the sheet. Desktop keeps click-to-DM on the picture itself, which touch
drops in favour of the card's DM action.
diff --git a/docs/agent-guide/ui-conventions.md b/docs/agent-guide/ui-conventions.md
index 06fc7ed4a6..58984ded7c 100644
--- a/docs/agent-guide/ui-conventions.md
+++ b/docs/agent-guide/ui-conventions.md
@@ -140,8 +140,8 @@ data unless authorized.
Avatar and user-mention cards open on hover on pointer devices and as a bottom
sheet on touch devices. With a keyboard on a touch device, Tab to the trigger and
press Enter or Space; verify focus enters the sheet and returns to the opener
-after dismissal or copying, including after reopening. DM, Open contact, and
-Assign task should leave focus in their destination when the sheet closes.
+after dismissal or copying, including after reopening. DM, Open contact, Assign
+task, and Settings should leave focus in their destination when the sheet closes.
On pointer devices, avatars should stay out of the Tab order while still opening
their cards on hover. Copy email/name confirms only after the clipboard
write succeeds: the hover card shows a checkmark, while the sheet closes. A failed