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.

fix(agents): gate @claude and @codex behind their rollout flags (#8032)

teo20e872df04a8
diff --git a/apps/web/src/features/channel/Input/tests/input-slots.test.tsx b/apps/web/src/features/channel/Input/tests/input-slots.test.tsx
index b2c96fb9a2..2112099ff3 100644
--- a/apps/web/src/features/channel/Input/tests/input-slots.test.tsx
+++ b/apps/web/src/features/channel/Input/tests/input-slots.test.tsx
@@ -13,6 +13,8 @@ import { beforeEach, describe, expect, it, vi } from 'vitest';
const editorMocks = vi.hoisted(() => ({
agentsEnabled: false,
+ claudeEnabled: false,
+ codexEnabled: false,
cursorEnabled: false,
clear: vi.fn(),
focus: vi.fn(),
@@ -115,11 +117,14 @@ vi.mock('@core/util/upload', () => ({
}));
vi.mock('@core/codex/flag', () => ({
- useCodexAgentsAccess: () => () => false,
+ useCodexAgentsAccess: () => () => editorMocks.codexEnabled,
}));
vi.mock('@core/cursor/flag', () => ({
useCursorAgentsAccess: () => () => editorMocks.cursorEnabled,
}));
+vi.mock('@core/claude/flag', () => ({
+ useClaudeAgentsAccess: () => () => editorMocks.claudeEnabled,
+}));
vi.mock('../../use-chat-v3-agents-flag', () => ({
useChatV3AgentsFlag: () => () => editorMocks.agentsEnabled,
}));
@@ -364,7 +369,11 @@ vi.mock('@queries/messages/typing', () => ({
import { MACRO_AGENT_PRINCIPAL_ID } from '@core/constant/macroAgent';
import { MACRO_NEW_PRINCIPAL_ID } from '@core/constant/macroNew';
-import { cursorMentionUser } from '../../macroAi';
+import {
+ claudeMentionUser,
+ codexMentionUser,
+ cursorMentionUser,
+} from '../../macroAi';
import { ThreadReplyChannelInput } from '../../Thread/ThreadReplyChannelInput';
import { createInputAttachmentTracker } from '../attachment-tracker';
import { ChannelInput } from '../ChannelInput';
@@ -396,6 +405,8 @@ function render(ui: () => JSX.Element) {
describe('Input slots', () => {
beforeEach(() => {
editorMocks.agentsEnabled = false;
+ editorMocks.claudeEnabled = false;
+ editorMocks.codexEnabled = false;
editorMocks.cursorEnabled = false;
editorMocks.clear.mockClear();
editorMocks.focus.mockClear();
@@ -481,8 +492,10 @@ describe('Input slots', () => {
expect(screen.queryByRole('group', { name: 'Dictation' })).toBeNull();
});
- it('offers Cursor within its rollout before account setup', () => {
+ it('offers Cursor, Claude, and Codex within their rollouts before account setup', () => {
editorMocks.cursorEnabled = true;
+ editorMocks.claudeEnabled = true;
+ editorMocks.codexEnabled = true;
render(() => <ChannelInput input={baseInput} />);
expect(editorMocks.mentionUsers?.().map((user) => user.name)).toEqual(
expect.arrayContaining(['Cursor', 'Claude', 'Codex'])
@@ -538,17 +551,19 @@ describe('Input slots', () => {
]);
});
- it('hides Cursor outside its rollout, including supplied bot entries', () => {
+ it('hides Cursor, Claude, and Codex outside their rollouts, including supplied bot entries', () => {
+ const builtIns = () => [
+ cursorMentionUser(),
+ claudeMentionUser(),
+ codexMentionUser(),
+ ];
render(() => (
- <ChannelInput
- input={baseInput}
- participants={() => [cursorMentionUser()]}
- bots={() => [cursorMentionUser()]}
- />
+ <ChannelInput input={baseInput} participants={builtIns} bots={builtIns} />
));
const names = editorMocks.mentionUsers?.().map((user) => user.name);
expect(names).not.toContain('Cursor');
- expect(names).toEqual(expect.arrayContaining(['Claude', 'Codex']));
+ expect(names).not.toContain('Claude');
+ expect(names).not.toContain('Codex');
});
it('does not start typing when the editor hydrates an empty composer', async () => {
diff --git a/apps/web/src/features/channel/use-agent-mention-users.test.ts b/apps/web/src/features/channel/use-agent-mention-users.test.ts
index 52cbd35374..7e537aabb5 100644
--- a/apps/web/src/features/channel/use-agent-mention-users.test.ts
+++ b/apps/web/src/features/channel/use-agent-mention-users.test.ts
@@ -1,3 +1,5 @@
+import { CLAUDE_BOT_PRINCIPAL_ID } from '@core/constant/claudeAgent';
+import { CODEX_BOT_PRINCIPAL_ID } from '@core/constant/codexAgent';
import {
MACRO_AGENT_NAME,
MACRO_AGENT_PRINCIPAL_ID,
@@ -11,20 +13,31 @@ import { MACRO_NEW_PRINCIPAL_ID } from '@core/constant/macroNew';
import type { IUser } from '@core/user/types';
import { createRoot, createSignal } from 'solid-js';
import { beforeEach, describe, expect, it, vi } from 'vitest';
+import { claudeMentionUser, codexMentionUser } from './macroAi';
import { useAgentMentionUsers } from './use-agent-mention-users';
const flags = vi.hoisted(() => ({
agents: (): boolean => false,
+ claude: (): boolean => false,
+ codex: (): boolean => false,
cursor: (): boolean => false,
}));
vi.mock('@core/constant/featureFlags', () => ({
+ claudeCloud: { key: 'claude-cloud' },
enableChatV3Agents: { key: 'enable-chat-v3-agents' },
+ enableCodexAgents: { key: 'enable-codex-agents' },
enableCursorAgents: { key: 'enable-cursor-agents' },
}));
vi.mock('@app/lib/analytics/posthog', () => ({
useFeatureFlag: (flag: { key: string }) => () => ({
enabled:
- flag.key === 'enable-chat-v3-agents' ? flags.agents() : flags.cursor(),
+ flag.key === 'enable-chat-v3-agents'
+ ? flags.agents()
+ : flag.key === 'claude-cloud'
+ ? flags.claude()
+ : flag.key === 'enable-codex-agents'
+ ? flags.codex()
+ : flags.cursor(),
}),
}));
@@ -35,9 +48,46 @@ function macroEntries(users: IUser[]): IUser[] {
describe('useAgentMentionUsers', () => {
beforeEach(() => {
flags.agents = () => false;
+ flags.claude = () => false;
+ flags.codex = () => false;
flags.cursor = () => false;
});
+ it('offers Codex only within the agents and Codex rollouts, even when it is a participant', () => {
+ createRoot((dispose) => {
+ const [codex, setCodex] = createSignal(false);
+ flags.agents = () => true;
+ flags.codex = codex;
+ const users = useAgentMentionUsers(() => [codexMentionUser()]);
+ const codexIds = () =>
+ users()
+ .map((user) => user.id)
+ .filter((id) => id === CODEX_BOT_PRINCIPAL_ID);
+ expect(codexIds()).toEqual([]);
+ setCodex(true);
+ expect(codexIds()).toEqual([CODEX_BOT_PRINCIPAL_ID]);
+ flags.agents = () => false;
+ expect(codexIds()).toEqual([]);
+ dispose();
+ });
+ });
+
+ it('offers Claude only within its rollout, even when it is a participant', () => {
+ createRoot((dispose) => {
+ const [enabled, setEnabled] = createSignal(false);
+ flags.claude = enabled;
+ const users = useAgentMentionUsers(() => [claudeMentionUser()]);
+ const claudeIds = () =>
+ users()
+ .map((user) => user.id)
+ .filter((id) => id === CLAUDE_BOT_PRINCIPAL_ID);
+ expect(claudeIds()).toEqual([]);
+ setEnabled(true);
+ expect(claudeIds()).toEqual([CLAUDE_BOT_PRINCIPAL_ID]);
+ dispose();
+ });
+ });
+
it('offers the classic Macro bot as the only Macro entry without the rollout', () => {
createRoot((dispose) => {
const users = useAgentMentionUsers(() => []);
diff --git a/apps/web/src/features/channel/use-agent-mention-users.ts b/apps/web/src/features/channel/use-agent-mention-users.ts
index e7f5c55528..58e05dcb7b 100644
--- a/apps/web/src/features/channel/use-agent-mention-users.ts
+++ b/apps/web/src/features/channel/use-agent-mention-users.ts
@@ -1,3 +1,5 @@
+import { useClaudeAgentsAccess } from '@core/claude/flag';
+import { useCodexAgentsAccess } from '@core/codex/flag';
import { isClaudeBotId } from '@core/constant/claudeAgent';
import { isCodexBotId } from '@core/constant/codexAgent';
import { isCursorBotId } from '@core/constant/cursorAgent';
@@ -20,8 +22,9 @@ import { useChatV3AgentsFlag } from './use-chat-v3-agents-flag';
* Built-in agent entries shared by every message composer. Account setup does
* not hide a mention: the harness answers with a connection prompt in the
* thread when setup is needed, so replies link to Settings → Harness rather
- * than the entry disappearing. The built-in Cursor entry follows the Cursor
- * rollout flag. Mentions are re-tagged as bot mentions at send time.
+ * than the entry disappearing. The built-in Cursor, Codex, and Claude entries
+ * follow their rollout flags. Mentions are re-tagged as bot mentions at send
+ * time.
*
* Macro gets exactly one entry. Both Macro bots are dropped from the incoming
* list first, so a stray participant or channel-bot row cannot put a second
@@ -33,6 +36,8 @@ export function useAgentMentionUsers(
enabled: Accessor<boolean> = () => true
): Accessor<IUser[]> {
const canUseCursor = useCursorAgentsAccess();
+ const canUseCodex = useCodexAgentsAccess();
+ const canUseClaude = useClaudeAgentsAccess();
const canUseAgents = useChatV3AgentsFlag();
return () => {
@@ -42,16 +47,18 @@ export function useAgentMentionUsers(
const base = mentionable.filter(
(user) =>
(canUseCursor() || !isCursorBotId(user.id)) &&
+ (canUseCodex() || !isCodexBotId(user.id)) &&
+ (canUseClaude() || !isClaudeBotId(user.id)) &&
!isMacroAiId(user.id) &&
!isMacroNewId(user.id)
);
if (canUseCursor() && !base.some((user) => isCursorBotId(user.id))) {
base.unshift(cursorMentionUser());
}
- if (!base.some((user) => isCodexBotId(user.id))) {
+ if (canUseCodex() && !base.some((user) => isCodexBotId(user.id))) {
base.unshift(codexMentionUser());
}
- if (!base.some((user) => isClaudeBotId(user.id))) {
+ if (canUseClaude() && !base.some((user) => isClaudeBotId(user.id))) {
base.unshift(claudeMentionUser());
}
base.unshift(macroMentionUser(canUseAgents()));
diff --git a/apps/web/src/features/property/queries/agent-assignees.test.ts b/apps/web/src/features/property/queries/agent-assignees.test.ts
index a267e961fd..89a285e1af 100644
--- a/apps/web/src/features/property/queries/agent-assignees.test.ts
+++ b/apps/web/src/features/property/queries/agent-assignees.test.ts
@@ -14,11 +14,15 @@ const fixture = vi.hoisted(() => ({
bots: [] as Bot[],
pending: false,
agentRollout: false,
+ claudeRollout: false,
+ codexRollout: false,
cursorRollout: false,
}));
vi.mock('@core/constant/featureFlags', () => ({
+ claudeCloud: { key: 'claude-cloud' },
enableChatV3Agents: { key: 'enable-chat-v3-agents' },
+ enableCodexAgents: { key: 'enable-codex-agents' },
enableCursorAgents: { key: 'enable-cursor-agents' },
}));
vi.mock('@app/lib/analytics/posthog', () => ({
@@ -26,7 +30,11 @@ vi.mock('@app/lib/analytics/posthog', () => ({
enabled:
flag.key === 'enable-chat-v3-agents'
? fixture.agentRollout
- : fixture.cursorRollout,
+ : flag.key === 'claude-cloud'
+ ? fixture.claudeRollout
+ : flag.key === 'enable-codex-agents'
+ ? fixture.codexRollout
+ : fixture.cursorRollout,
}),
}));
@@ -80,6 +88,8 @@ beforeEach(() => {
fixture.bots = [];
fixture.pending = false;
fixture.agentRollout = false;
+ fixture.claudeRollout = false;
+ fixture.codexRollout = false;
fixture.cursorRollout = false;
});
@@ -96,12 +106,7 @@ describe('task agent assignees', () => {
fixture.bots = [owned.bot, team.bot, inactive.bot, deleted.bot];
createRoot((dispose) => {
const users = useAgentAssignees(() => true);
- expect(users().map(({ id }) => id)).toEqual([
- CLAUDE_BOT_PRINCIPAL_ID,
- CODEX_BOT_PRINCIPAL_ID,
- 'bot|owned',
- 'bot|team',
- ]);
+ expect(users().map(({ id }) => id)).toEqual(['bot|owned', 'bot|team']);
expect(users().find(({ id }) => id === 'bot|owned')).toEqual({
id: 'bot|owned',
name: 'Research agent',
@@ -114,10 +119,10 @@ describe('task agent assignees', () => {
it('does not suspend people selection while agents are pending, or expose agents to other properties', () => {
fixture.pending = true;
+ fixture.claudeRollout = true;
createRoot((dispose) => {
expect(useAgentAssignees(() => true)().map(({ id }) => id)).toEqual([
CLAUDE_BOT_PRINCIPAL_ID,
- CODEX_BOT_PRINCIPAL_ID,
]);
expect(useAgentAssignees(() => false)()).toEqual([]);
dispose();
@@ -126,6 +131,8 @@ describe('task agent assignees', () => {
it('reuses system session-agent rollout and excludes classic Macro', () => {
fixture.agentRollout = true;
+ fixture.claudeRollout = true;
+ fixture.codexRollout = true;
fixture.cursorRollout = true;
createRoot((dispose) => {
const ids = useAgentAssignees(() => true)().map(({ id }) => id);
diff --git a/apps/web/src/features/settings/Harness.test.tsx b/apps/web/src/features/settings/Harness.test.tsx
index 7b530bdb2b..5b5f74ac56 100644
--- a/apps/web/src/features/settings/Harness.test.tsx
+++ b/apps/web/src/features/settings/Harness.test.tsx
@@ -225,23 +225,23 @@ beforeEach(() => {
describe('Harness', () => {
it.each([false, true])(
- 'offers Codex settings even when rollout access is %s',
+ 'shows Codex settings only within its rollout (access %s)',
(enabled) => {
codexAccess.enabled = enabled;
render(() => <Harness />);
- expect(screen.getByTestId('codex-harness')).toBeTruthy();
+ expect(Boolean(screen.queryByTestId('codex-harness'))).toBe(enabled);
}
);
- it('offers Claude connection when the rollout flag is off', () => {
+ it('hides the Claude connection outside its rollout', () => {
claudeFlag.enabled = false;
claudeFlag.source.mockClear();
try {
render(() => <Harness />);
expect(
screen.queryByRole('region', { name: 'Claude Cloud connection' })
- ).toBeTruthy();
- expect(claudeFlag.source).toHaveBeenCalled();
+ ).toBeNull();
+ expect(claudeFlag.source).not.toHaveBeenCalled();
expect(screen.getByRole('heading', { name: 'Cursor' })).toBeTruthy();
} finally {
claudeFlag.enabled = true;
diff --git a/apps/web/src/features/settings/Harness.tsx b/apps/web/src/features/settings/Harness.tsx
index 5bca21a97b..68b946f189 100644
--- a/apps/web/src/features/settings/Harness.tsx
+++ b/apps/web/src/features/settings/Harness.tsx
@@ -1,3 +1,5 @@
+import { useClaudeAgentsAccess } from '@core/claude/flag';
+import { useCodexAgentsAccess } from '@core/codex/flag';
import { ModelCatalogPicker } from '@core/component/AI/component/input/ModelCatalogPicker';
import { isLargeModelCatalog } from '@core/component/AI/component/input/modelCatalog';
import { toast } from '@core/component/Toast/Toast';
@@ -47,6 +49,8 @@ function lastConnectedText(harness: RegisteredHarness): string {
export function Harness(
props: { navigation?: JSX.Element; startPairing?: boolean } = {}
) {
+ const canUseClaude = useClaudeAgentsAccess();
+ const canUseCodex = useCodexAgentsAccess();
const [cursorApiKey, setCursorApiKey] = createSignal('');
const cursorStatus = useCursorApiKeyStatusQuery();
const saveCursorApiKey = useSaveCursorApiKey();
@@ -217,7 +221,9 @@ export function Harness(
</div>
</section>
- <ClaudeConnection />
+ <Show when={canUseClaude()}>
+ <ClaudeConnection />
+ </Show>
<section class="flex gap-4 px-6 py-5">
<HarnessIcon>
@@ -406,7 +412,9 @@ export function Harness(
</div>
</section>
- <CodexHarness />
+ <Show when={canUseCodex()}>
+ <CodexHarness />
+ </Show>
</SettingsCard>
</div>
diff --git a/apps/web/src/lib/core/claude/flag.ts b/apps/web/src/lib/core/claude/flag.ts
new file mode 100644
index 0000000000..0fcf94cbf2
--- /dev/null
+++ b/apps/web/src/lib/core/claude/flag.ts
@@ -0,0 +1,9 @@
+import { useFeatureFlag } from '@app/lib/analytics/posthog';
+import { claudeCloud } from '@core/constant/featureFlags';
+import type { Accessor } from 'solid-js';
+
+/** Whether the built-in Claude agent is included in this user's rollout. */
+export function useClaudeAgentsAccess(): Accessor<boolean> {
+ const flag = useFeatureFlag(claudeCloud);
+ return () => flag().enabled;
+}
diff --git a/apps/web/src/lib/core/constant/featureFlags.ts b/apps/web/src/lib/core/constant/featureFlags.ts
index 9eb1c88651..1aaacf155d 100644
--- a/apps/web/src/lib/core/constant/featureFlags.ts
+++ b/apps/web/src/lib/core/constant/featureFlags.ts
@@ -170,8 +170,9 @@ export const enableTasksReviews = defineFlag({
default: onInDev,
});
-// Claude Cloud demo onboarding and harness/model discovery. Off until PostHog
-// enables it, including in dev; override locally with VITE_CLAUDE_CLOUD.
+// Claude Cloud: the built-in @claude mention and agent assignee, its Runtimes
+// connection card, and harness/model discovery. Off until PostHog enables it,
+// including in dev; override locally with VITE_CLAUDE_CLOUD.
export const claudeCloud = defineFlag({
key: 'claude-cloud',
env: 'CLAUDE_CLOUD',
diff --git a/docs/AGENT_GUIDE/channels.md b/docs/AGENT_GUIDE/channels.md
index fd71f693fc..ca46f85bfa 100644
--- a/docs/AGENT_GUIDE/channels.md
+++ b/docs/AGENT_GUIDE/channels.md
@@ -287,13 +287,18 @@ Draft PRs, PRs with no checks, and PRs whose checks are still running or failing
show no Merge button. Merged and closed PRs show no Merge button. Expanded session mentions retain their
collapse control. The card never expands in place.
-`@codex` and `@claude` are offered to every user before account setup. The built-in
-`@cursor` entry requires the `enable-cursor-agents` rollout flag (local override:
-`VITE_ENABLE_CURSOR_AGENTS`). Custom agents keep their channel visibility rules
+Built-in provider agents are offered before account setup, each within its own
+rollout: `@cursor` requires the `enable-cursor-agents` flag (local override:
+`VITE_ENABLE_CURSOR_AGENTS`), `@claude` requires the `claude-cloud` flag
+(local override: `VITE_CLAUDE_CLOUD`), and `@codex` requires both
+`enable-chat-v3-agents` and `enable-codex-agents` (local override:
+`VITE_ENABLE_CODEX_AGENTS`). Outside a rollout the entry is absent from
+the mention menu and from task agent assignees, even when that bot is already a
+channel participant. Custom agents keep their channel visibility rules
regardless of which harness they use.
A mention without a connected account creates no session and replies in the thread
with a **Connect Cursor**, **Connect Codex**, or **Connect Claude** chip. Each chip
-opens Settings → Agents → Runtimes, where all three connection cards are visible. The same
+opens Settings → Agents → Runtimes, where the connection cards in the reader's rollout are visible. The same
chip reads **connected** after setup; mention the bot again to start a session.
Codex also prompts for a cloud environment when ChatGPT is connected but no
environment has been saved. New sessions use that environment on
diff --git a/docs/AGENT_GUIDE/surfaces.md b/docs/AGENT_GUIDE/surfaces.md
index e909a62987..59bc10ae3b 100644
--- a/docs/AGENT_GUIDE/surfaces.md
+++ b/docs/AGENT_GUIDE/surfaces.md
@@ -2674,7 +2674,7 @@ New macrod sessions use the agent's saved model before sending the first prompt.
Changing that default applies to new sessions; existing sessions keep their selected model.
If the runtime rejects the saved model, the prompt fails instead of using a different model.
-The `Runtimes` section shows built-in Macro, Cursor, Claude, and Codex configuration, followed by paired macrod runtimes. The “Bring your own agent” card sits above the Agents / Runtimes navigation and is visible on both sections. It rotates Claude Code, OpenCode, OpenClaw, and Hermes; reduced motion keeps a static name. Its `New runtime` action opens the full-page pairing flow from either section: enter the code, look up the request, review the machine, name, sharing and permission consent, then Approve and Done. Back/Cancel returns to the runtime list. Destructive removal still requires confirmation. `/settings/runtimes` opens this section; legacy `/settings/harness?pair=…` links remain supported.
+The `Runtimes` section shows built-in Macro, Cursor, Claude, and Codex configuration, followed by paired macrod runtimes. Claude's card appears only with the `claude-cloud` flag, and Codex's only within the agents and Codex rollouts. The “Bring your own agent” card sits above the Agents / Runtimes navigation and is visible on both sections. It rotates Claude Code, OpenCode, OpenClaw, and Hermes; reduced motion keeps a static name. Its `New runtime` action opens the full-page pairing flow from either section: enter the code, look up the request, review the machine, name, sharing and permission consent, then Approve and Done. Back/Cancel returns to the runtime list. Destructive removal still requires confirmation. `/settings/runtimes` opens this section; legacy `/settings/harness?pair=…` links remain supported.
Connection chips in agent replies open this page, including before any account is connected. Cursor's default-model picker uses
the same live model discovery and retains its existing save action.