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(agents): simplify agent settings around where agents run (#8018)
Wolf Mermelsteinb940937e707a
diff --git a/apps/web/src/features/agents-view/tour.ts b/apps/web/src/features/agents-view/tour.tsindex 34b036a791..f60be9ebe0 100644--- a/apps/web/src/features/agents-view/tour.ts+++ b/apps/web/src/features/agents-view/tour.ts@@ -9,8 +9,8 @@ export const AGENTS_TOUR = defineTourTargets('agents', ['rosterNav','picker','composer',- 'agentsTab',- 'runtimesTab',+ 'agentList',+ 'agentSetup',]);const openRoster = {@@ -39,21 +39,21 @@ export const agentsTour = defineViewTour({'Open this picker to choose an agent for the current mode. In Work, Macro’s models are listed here too; each agent’s submenu lets you choose a model for that conversation.',},{- target: AGENTS_TOUR.agentsTab,+ target: AGENTS_TOUR.agentList,...openRoster,title: 'Chat agents work with your context',description:'Chat agents use instructions and connected tools to research, write, and work with your documents and conversations. Your team and private agents live here.',},{- target: AGENTS_TOUR.runtimesTab,+ target: AGENTS_TOUR.agentSetup,...openRoster,title: 'Coding agents work on code',description:- 'Coding agents run through a coding runtime, such as Cursor or a paired machine. Choose a coding agent when you need repository work rather than a regular chat.',+ 'Coding agents run in Cursor or on a machine you pair with macrod. Connect them here, then choose where each agent runs when you create it.',},{- target: AGENTS_TOUR.agentsTab,+ target: AGENTS_TOUR.agentList,...openRoster,title: 'Share agents with your team',description:diff --git a/apps/web/src/features/settings/AgentSettings.test.tsx b/apps/web/src/features/settings/AgentSettings.test.tsxindex ad8cf2109a..b004154fcd 100644--- a/apps/web/src/features/settings/AgentSettings.test.tsx+++ b/apps/web/src/features/settings/AgentSettings.test.tsx@@ -3,61 +3,107 @@*/import { cleanup, fireEvent, render, screen } from '@solidjs/testing-library';-import type { JSX } from 'solid-js';import { afterEach, describe, expect, it, vi } from 'vitest';import { AgentSettings } from './AgentSettings';+const searchParams = vi.hoisted(() => ({+ pair: undefined as string | undefined,+}));vi.mock('@solidjs/router', () => ({- useSearchParams: () => [{}],+ useSearchParams: () => [searchParams],}));-vi.mock('./components/bring-your-own-agent', () => ({- BringYourOwnAgent: () => <div>Bring your own agent</div>,+vi.mock('./Agents', () => ({+ Agents: (props: {+ onCursor: () => void;+ onSetUpRuntime: () => void;+ onManageRuntimes: () => void;+ }) => (+ <div>+ <h1>Agents page</h1>+ <button type="button" onClick={props.onCursor}>+ Connect Cursor+ </button>+ <button type="button" onClick={props.onSetUpRuntime}>+ Set up your own agent+ </button>+ <button type="button" onClick={props.onManageRuntimes}>+ Manage paired runtimes+ </button>+ </div>+ ),}));-// Each section owns a SettingsPage: the scroll container swaps with the tab.-function FakePage(props: { title: string; navigation: JSX.Element }) {- return (- <div data-settings-page>- {props.navigation}- <h1>{props.title}</h1>+vi.mock('./CursorConnectPage', () => ({+ CursorConnectPage: (props: { onClose: () => void }) => (+ <div>+ <h1>Cursor guide</h1>+ <button type="button" onClick={props.onClose}>+ Back+ </button></div>- );-}+ ),+}));-vi.mock('./Agents', () => ({- Agents: (props: { navigation: JSX.Element }) => (- <FakePage title="Team agents" navigation={props.navigation} />+vi.mock('./RuntimePairingPage', () => ({+ RuntimePairingPage: (props: { onClose: () => void }) => (+ <div>+ <h1>Pairing guide</h1>+ <button type="button" onClick={props.onClose}>+ Back+ </button>+ </div>),}));vi.mock('./Harness', () => ({- Harness: (props: { navigation: JSX.Element }) => (- <FakePage title="Built-in runtimes" navigation={props.navigation} />+ Harness: (props: { onBack?: () => void }) => (+ <div>+ <h1>Runtimes page</h1>+ <button type="button" onClick={props.onBack}>+ Back+ </button>+ </div>),}));afterEach(() => {cleanup();+ searchParams.pair = undefined;});-describe('AgentSettings section tabs', () => {- it('keeps the scroll offset when the section swaps its page', () => {+describe('AgentSettings', () => {+ it('opens each setup page from the agents page and comes back', () => {+ render(() => <AgentSettings />);+ expect(screen.getByRole('heading', { name: 'Agents page' })).toBeTruthy();++ fireEvent.click(screen.getByRole('button', { name: 'Connect Cursor' }));+ expect(screen.getByRole('heading', { name: 'Cursor guide' })).toBeTruthy();+ fireEvent.click(screen.getByRole('button', { name: 'Back' }));++ fireEvent.click(+ screen.getByRole('button', { name: 'Set up your own agent' })+ );+ expect(screen.getByRole('heading', { name: 'Pairing guide' })).toBeTruthy();+ fireEvent.click(screen.getByRole('button', { name: 'Back' }));++ fireEvent.click(+ screen.getByRole('button', { name: 'Manage paired runtimes' })+ );+ expect(screen.getByRole('heading', { name: 'Runtimes page' })).toBeTruthy();+ fireEvent.click(screen.getByRole('button', { name: 'Back' }));++ expect(screen.getByRole('heading', { name: 'Agents page' })).toBeTruthy();+ });++ it('starts on the runtimes page for the Runtimes settings tab', () => {+ render(() => <AgentSettings initialSection="runtimes" />);+ expect(screen.getByRole('heading', { name: 'Runtimes page' })).toBeTruthy();+ });++ it('starts on the runtimes page when a pairing code is in the URL', () => {+ searchParams.pair = 'KX7M-4QHD';render(() => <AgentSettings />);- const page = () =>- document.querySelector<HTMLElement>('[data-settings-page]');- const first = page();- if (!first) throw new Error('no settings page');- first.scrollTop = 260;-- fireEvent.click(screen.getByRole('button', { name: 'Runtimes' }));- expect(screen.getByText('Built-in runtimes')).toBeTruthy();- const second = page();- expect(second).not.toBe(first);- expect(second?.scrollTop).toBe(260);-- fireEvent.click(screen.getByRole('button', { name: 'Agents' }));- expect(screen.getByText('Team agents')).toBeTruthy();- expect(page()?.scrollTop).toBe(260);+ expect(screen.getByRole('heading', { name: 'Runtimes page' })).toBeTruthy();});});diff --git a/apps/web/src/features/settings/AgentSettings.tsx b/apps/web/src/features/settings/AgentSettings.tsxindex 52551b336e..bb36f80305 100644--- a/apps/web/src/features/settings/AgentSettings.tsx+++ b/apps/web/src/features/settings/AgentSettings.tsx@@ -1,68 +1,42 @@import { useSearchParams } from '@solidjs/router';-import { createSignal, Show } from 'solid-js';+import { createSignal, Match, Switch } from 'solid-js';import { Agents } from './Agents';-import {- AgentManagementNavigation,- type AgentManagementSection,-} from './components/agent-management-navigation';-import { BringYourOwnAgent } from './components/bring-your-own-agent';+import { CursorConnectPage } from './CursorConnectPage';import { Harness } from './Harness';+import { RuntimePairingPage } from './RuntimePairingPage';++export type AgentManagementSection = 'agents' | 'runtimes';++type AgentSettingsPage = AgentManagementSection | 'cursor' | 'pairing';/** One management surface, mounted by both Settings and the Agents workspace. */export function AgentSettings(props: {initialSection?: AgentManagementSection;}) {const [searchParams] = useSearchParams();- const [section, setSection] = createSignal<AgentManagementSection>(+ const [page, setPage] = createSignal<AgentSettingsPage>(searchParams.pair ? 'runtimes' : (props.initialSection ?? 'agents'));- const [startPairing, setStartPairing] = createSignal(false);- let host: HTMLDivElement | undefined;- const scrollBody = () =>- host?.querySelector<HTMLElement>('[data-settings-page]') ?? null;-- // Each section is its own SettingsPage, so switching mounts a fresh scroll- // container. Carry the offset across so the section tabs, which sit below- // the shared header, stay under the finger or pointer that chose them.- const showSection = (next: AgentManagementSection) => {- const scrollTop = scrollBody()?.scrollTop ?? 0;- setSection(next);- const body = scrollBody();- if (body) body.scrollTop = scrollTop;- };-- const navigation = () => (- <AgentManagementNavigation- section={section()}- onChange={(section) => {- setStartPairing(false);- showSection(section);- }}- />- );+ const showAgents = () => setPage('agents');return (- <div ref={host} class="contents">- <Show- when={section() === 'agents'}- fallback={- <Harness navigation={navigation()} startPairing={startPairing()} />- }- >+ <Switch>+ <Match when={page() === 'agents'}><Agents- navigation={- <>- <BringYourOwnAgent- onAddRuntime={() => {- setStartPairing(true);- showSection('runtimes');- }}- />- {navigation()}- </>- }+ onCursor={() => setPage('cursor')}+ onSetUpRuntime={() => setPage('pairing')}+ onManageRuntimes={() => setPage('runtimes')}/>- </Show>- </div>+ </Match>+ <Match when={page() === 'cursor'}>+ <CursorConnectPage onClose={showAgents} />+ </Match>+ <Match when={page() === 'pairing'}>+ <RuntimePairingPage onClose={showAgents} />+ </Match>+ <Match when={page() === 'runtimes'}>+ <Harness onBack={showAgents} />+ </Match>+ </Switch>);}diff --git a/apps/web/src/features/settings/Agents.test.tsx b/apps/web/src/features/settings/Agents.test.tsxindex 6f3e9162e3..0ee5b2e41f 100644--- a/apps/web/src/features/settings/Agents.test.tsx+++ b/apps/web/src/features/settings/Agents.test.tsx@@ -25,6 +25,12 @@ import { beforeAll, beforeEach, describe, expect, it, vi } from 'vitest';import { Agents } from './Agents';import { chooseSelectOption, selectOptions } from './tests/select-helpers';+const agentsPageProps = {+ onCursor: vi.fn(),+ onSetUpRuntime: vi.fn(),+ onManageRuntimes: vi.fn(),+};+// The real Lexical surface has its own Markdown round-trip suite.vi.mock('./components/instructions-editor', () => ({AgentInstructionsEditor: (props: {@@ -351,12 +357,11 @@ describe('Agents', () => {{ id: 'claude-default', name: 'Subscription default' },]);try {- render(() => <Agents />);- fireEvent.click(screen.getByRole('button', { name: 'New agent' }));- const option = selectOptions(- screen.getByLabelText('Runtime')- ).queryByRole('option', {- name: 'Claude Cloud',+ render(() => <Agents {...agentsPageProps} />);+ fireEvent.click(screen.getByRole('button', { name: 'Add agent' }));+ const dialog = screen.getByRole('region', { name: 'New agent' });+ const option = within(dialog).queryByRole('radio', {+ name: 'In Claude Code',});expect(Boolean(option)).toBe(enabled);const targets = vi.mocked(useAgentModelsQueries).mock.lastCall?.[0]();@@ -371,7 +376,7 @@ describe('Agents', () => {it('opens the new-agent form from a link and clears the action on cancel', () => {updateSearchParams({ createAgent: 'true' });- render(() => <Agents />);+ render(() => <Agents {...agentsPageProps} />);const dialog = screen.getByRole('region', { name: /^(New|Edit) agent$/ });expect(within(dialog).getByRole('button', { name: 'Create agent' })@@ -413,12 +418,12 @@ describe('Agents', () => {const view = render(() => (<QueryClientProvider client={client}><Suspense fallback={<p>Settings suspended</p>}>- <Agents />+ <Agents {...agentsPageProps} /></Suspense></QueryClientProvider>));- fireEvent.click(screen.getByRole('button', { name: 'New agent' }));- chooseSelectOption(screen.getByLabelText('Runtime'), 'Cursor');+ fireEvent.click(screen.getByRole('button', { name: 'Add agent' }));+ fireEvent.click(screen.getByRole('radio', { name: 'In Cursor' }));expect(screen.queryByText('Settings suspended')).toBeNull();expect(screen.getByText('Loading models…')).toBeTruthy();expect(@@ -502,14 +507,14 @@ describe('Agents', () => {const view = render(() => (<QueryClientProvider client={client}><Suspense fallback={<p>Settings suspended</p>}>- <Agents />+ <Agents {...agentsPageProps} /></Suspense></QueryClientProvider>));try {fireEvent.click(screen.getByRole('button', { name: 'Edit Bug fixer' }));- const harness = screen.getByLabelText('Runtime');- expect(harness).toHaveProperty('textContent', 'Claude Cloud');+ const claude = screen.getByRole('radio', { name: 'In Claude Code' });+ expect(claude).toHaveProperty('checked', true);expect(screen.getByText('Loading models…')).toBeTruthy();resolveModels({status: 'available',@@ -517,8 +522,10 @@ describe('Agents', () => {models: [{ id: 'claude-fable-5-1', name: 'Fable 5.1' }],});await waitFor(() => expect(screen.getByText('Fable 5.1')).toBeTruthy());- expect(harness).toHaveProperty('textContent', 'Claude Cloud');- chooseSelectOption(harness, 'Macro Agent');+ expect(+ screen.getByRole('radio', { name: 'In Claude Code' })+ ).toHaveProperty('checked', true);+ fireEvent.click(screen.getByRole('radio', { name: 'In Macro' }));await waitFor(() =>expect(screen.getByLabelText('Default model')).toHaveProperty('textContent',@@ -548,25 +555,88 @@ describe('Agents', () => {});it('lists the built-in global Macro agent as a team agent', () => {- render(() => <Agents />);-- const teamSection = screen- .getByRole('heading', { name: 'Team agents' })- .closest('section') as HTMLElement;- const privateSection = screen- .getByRole('heading', { name: 'Private agents' })- .closest('section') as HTMLElement;-- expect(within(teamSection).getByText('Macro')).toBeTruthy();- expect(within(teamSection).getByText('@macro')).toBeTruthy();- expect(within(teamSection).getByText('Team')).toBeTruthy();- expect(within(teamSection).getByText(/All channels/)).toBeTruthy();+ render(() => <Agents {...agentsPageProps} />);++ const list = screen.getByRole('region', { name: 'Your agents' });++ expect(within(list).getByText('Macro')).toBeTruthy();expect(- within(teamSection).queryByRole('button', { name: 'Delete Macro' })- ).toBeNull();+ within(list)+ .getAllByText(/^@/)+ .map((tag) => tag.textContent)+ ).toEqual(['@macro']);+ expect(within(list).getByText('Team')).toBeTruthy();expect(- within(privateSection).getByText('No private agents yet.')+ within(list).getByText('In Macro · Sonnet 5.5 · All channels')).toBeTruthy();+ expect(+ within(list).queryByRole('button', { name: 'Delete Macro' })+ ).toBeNull();+ expect(+ within(list).queryByRole('button', { name: 'Edit Macro' })+ ).toBeNull();+ });++ it('shows loading and error states in the agent list', () => {+ agentMocks.query.isPending = true;+ agentMocks.query.isSuccess = false;+ try {+ const view = render(() => <Agents {...agentsPageProps} />);+ expect(+ within(screen.getByRole('region', { name: 'Your agents' })).getByText(+ 'Loading agents…'+ )+ ).toBeTruthy();+ view.unmount();++ agentMocks.query.isPending = false;+ agentMocks.query.isError = true;+ render(() => <Agents {...agentsPageProps} />);+ expect(+ within(screen.getByRole('region', { name: 'Your agents' })).getByText(+ 'Could not load your agents. Try refreshing this page.'+ )+ ).toBeTruthy();+ } finally {+ agentMocks.query.isPending = false;+ agentMocks.query.isSuccess = true;+ }+ });++ it('offers Cursor and own-agent setup above the list', () => {+ const onCursor = vi.fn();+ const onSetUpRuntime = vi.fn();+ const onManageRuntimes = vi.fn();+ const view = render(() => (+ <Agents+ onCursor={onCursor}+ onSetUpRuntime={onSetUpRuntime}+ onManageRuntimes={onManageRuntimes}+ />+ ));+ fireEvent.click(screen.getByRole('button', { name: 'Connect Cursor' }));+ expect(onCursor).toHaveBeenCalledOnce();+ fireEvent.click(+ screen.getByRole('button', { name: 'Set up your own agent' })+ );+ expect(onSetUpRuntime).toHaveBeenCalledOnce();+ view.unmount();++ cursorMocks.status.data.registered = true;+ harnessMocks.query.data = [MACROD_HARNESS];+ render(() => (+ <Agents+ onCursor={onCursor}+ onSetUpRuntime={onSetUpRuntime}+ onManageRuntimes={onManageRuntimes}+ />+ ));+ fireEvent.click(screen.getByRole('button', { name: 'Manage Cursor' }));+ expect(onCursor).toHaveBeenCalledTimes(2);+ fireEvent.click(+ screen.getByRole('button', { name: 'Manage paired runtimes' })+ );+ expect(onManageRuntimes).toHaveBeenCalledOnce();});it('groups server agents into team and private sections', () => {@@ -609,30 +679,117 @@ describe('Agents', () => {},];- render(() => <Agents />);+ render(() => <Agents {...agentsPageProps} />);- const teamSection = screen- .getByRole('heading', { name: 'Team agents' })- .closest('section') as HTMLElement;- const privateSection = screen- .getByRole('heading', { name: 'Private agents' })- .closest('section') as HTMLElement;+ const list = screen.getByRole('region', { name: 'Your agents' });- expect(within(teamSection).getByText('Macro')).toBeTruthy();- expect(within(teamSection).getByText('Release helper')).toBeTruthy();- expect(within(teamSection).queryByText('Coordinates releases.')).toBeNull();- expect(within(teamSection).queryByText('Bug fixer')).toBeNull();+ // Macro first, then team agents, then private agents.+ expect(+ within(list)+ .getAllByText(/^@/)+ .map((tag) => tag.textContent)+ ).toEqual(['@macro', '@release-helper', '@bug-fixer']);+ expect(within(list).queryByText('Coordinates releases.')).toBeNull();+ expect(within(list).queryByText('Finds and fixes bugs.')).toBeNull();++ const releaseRow = within(list).getByText('Release helper').parentElement+ ?.parentElement as HTMLElement;+ expect(within(releaseRow).getByText('Team')).toBeTruthy();+ expect(+ within(releaseRow).getByText('In Macro · Sonnet 5.5 · #engineering')+ ).toBeTruthy();- const agentName = within(privateSection).getByText('Bug fixer');- expect(within(privateSection).getByText('@bug-fixer')).toBeTruthy();+ const bugFixerRow = within(list).getByText('Bug fixer').parentElement+ ?.parentElement as HTMLElement;+ expect(within(bugFixerRow).getByText('Private')).toBeTruthy();expect(- within(privateSection).queryByText('Finds and fixes bugs.')- ).toBeNull();- expect(within(privateSection).queryByText('Release helper')).toBeNull();+ within(bugFixerRow).getByText('In Macro · Sonnet 5.5 · All channels')+ ).toBeTruthy();+ });++ it('says where each listed agent runs', () => {+ cursorMocks.status.data.registered = true;+ harnessMocks.query.data = [MACROD_HARNESS];+ const owner = { type: 'user', user_id: 'macro|[email protected]' };+ agentMocks.query.data = [+ {+ bot: {+ id: 'agent-cursor',+ kind: 'owned',+ owner,+ name: 'Cursor helper',+ handle: 'cursor-helper',+ has_agent: true,+ },+ instructions: '',+ harness: 'cursor',+ default_model: 'cursor-small',+ channel_scope: 'all',+ channel_ids: [],+ },+ {+ bot: {+ id: 'agent-claude',+ kind: 'owned',+ owner,+ name: 'Claude helper',+ handle: 'claude-helper',+ has_agent: true,+ },+ instructions: '',+ harness: 'claude-cloud',+ default_model: 'claude-default',+ channel_scope: 'all',+ channel_ids: [],+ },+ {+ bot: {+ id: 'agent-macrod',+ kind: 'owned',+ owner,+ name: 'Harness helper',+ handle: 'harness-helper',+ has_agent: true,+ },+ instructions: '',+ harness: 'macrod',+ harness_id: MACROD_HARNESS.id,+ default_model: 'codex',+ channel_scope: 'all',+ channel_ids: [],+ },+ {+ bot: {+ id: 'agent-gone',+ kind: 'owned',+ owner,+ name: 'Orphaned helper',+ handle: 'orphaned-helper',+ has_agent: true,+ },+ instructions: '',+ harness: 'macrod',+ harness_id: 'removed-harness',+ default_model: 'codex',+ channel_scope: 'all',+ channel_ids: [],+ },+ ];++ render(() => <Agents {...agentsPageProps} />);+ const list = screen.getByRole('region', { name: 'Your agents' });+expect(- within(agentName.parentElement?.parentElement as HTMLElement).getByText(- /All channels/- )+ within(list).getByText('In Cursor · cursor-small · All channels')+ ).toBeTruthy();+ expect(+ within(list).getByText('In Claude Code · claude-default · All channels')+ ).toBeTruthy();+ expect(+ within(list).getByText('In your harness · Dev box · codex · All channels')+ ).toBeTruthy();+ expect(+ within(list).getByText('Disconnected runtime · codex · All channels')).toBeTruthy();});@@ -657,10 +814,14 @@ describe('Agents', () => {},];- render(() => <Agents />);+ render(() => <Agents {...agentsPageProps} />);expect(screen.queryByText('Shared Reviewer')).toBeNull();- expect(screen.getByText('No private agents yet.')).toBeTruthy();+ expect(+ within(screen.getByRole('region', { name: 'Your agents' }))+ .getAllByText(/^@/)+ .map((tag) => tag.textContent)+ ).toEqual(['@macro']);});it("does not list another team's mentionable agent in Settings", () => {@@ -684,7 +845,7 @@ describe('Agents', () => {},];- render(() => <Agents />);+ render(() => <Agents {...agentsPageProps} />);expect(screen.queryByText('Other Team Helper')).toBeNull();});@@ -721,7 +882,7 @@ describe('Agents', () => {existing.bot.avatar_url = params.avatarUrl;});- render(() => <Agents />);+ render(() => <Agents {...agentsPageProps} />);fireEvent.click(screen.getByRole('button', { name: 'Edit Grungus' }));const form = screen.getByRole('region', { name: 'Edit agent' });const file = new File(['avatar'], 'avatar.png', { type: 'image/png' });@@ -766,8 +927,8 @@ describe('Agents', () => {avatarMocks.upload.mockRejectedValueOnce(new Error('Failed to upload file'));- render(() => <Agents />);- fireEvent.click(screen.getByRole('button', { name: 'New agent' }));+ render(() => <Agents {...agentsPageProps} />);+ fireEvent.click(screen.getByRole('button', { name: 'Add agent' }));fireEvent.input(screen.getByLabelText('Name'), {target: { value: 'Grungus' },});@@ -816,7 +977,7 @@ describe('Agents', () => {},];- render(() => <Agents />);+ render(() => <Agents {...agentsPageProps} />);fireEvent.click(screen.getByRole('button', { name: 'Edit Bug fixer' }));const dialog = screen.getByRole('region', { name: /^(New|Edit) agent$/ });@@ -829,6 +990,7 @@ describe('Agents', () => {'value','bug-fixer');+ fireEvent.click(within(dialog).getByRole('button', { name: 'Show' }));expect(within(dialog).getByLabelText('Specific channels')).toHaveProperty('checked',true@@ -886,7 +1048,7 @@ describe('Agents', () => {},];- render(() => <Agents />);+ render(() => <Agents {...agentsPageProps} />);expect(screen.getByRole('button', { name: 'Edit Bug fixer' })).toBeTruthy();expect(@@ -931,7 +1093,7 @@ describe('Agents', () => {},];- const view = render(() => <Agents />);+ const view = render(() => <Agents {...agentsPageProps} />);fireEvent.click(screen.getByRole('button', { name: 'Edit Bug fixer' }));expect(within(@@ -942,7 +1104,7 @@ describe('Agents', () => {agentMocks.currentUserId = 'macro|[email protected]';agentMocks.isTeamOwner = true;- render(() => <Agents />);+ render(() => <Agents {...agentsPageProps} />);expect(screen.getByRole('button', { name: 'Delete Bug fixer' })).toBeTruthy();@@ -970,7 +1132,7 @@ describe('Agents', () => {},];- render(() => <Agents />);+ render(() => <Agents {...agentsPageProps} />);fireEvent.click(screen.getByRole('button', { name: 'Delete Bug fixer' }));const dialog = screen.getByRole('dialog');@@ -992,11 +1154,13 @@ describe('Agents', () => {});it('offers agent configuration without description and only connected harnesses', () => {- render(() => <Agents />);- fireEvent.click(screen.getByRole('button', { name: 'New agent' }));+ render(() => <Agents {...agentsPageProps} />);+ fireEvent.click(screen.getByRole('button', { name: 'Add agent' }));const dialog = screen.getByRole('region', { name: /^(New|Edit) agent$/ });- const harness = within(dialog).getByLabelText('Runtime');+ expect(+ screen.getByText('Name it, tell it what to do, and pick where it runs.')+ ).toBeTruthy();expect(within(dialog).getByRole('button', { name: 'Upload avatar' })@@ -1019,14 +1183,27 @@ describe('Agents', () => {expect(within(dialog).getByLabelText('@tag')).toBeTruthy();expect(within(dialog).queryByLabelText('Description')).toBeNull();expect(within(dialog).getByLabelText('Instructions')).toBeTruthy();- expect(harness).toHaveProperty('textContent', 'Macro Agent');- expect(selectOptions(harness).getAllByRole('option')).toHaveLength(1);- expect(within(dialog).getByLabelText('Default model')).toBeTruthy();expect(- within(dialog).getByRole('group', { name: 'Channels' })- ).toBeTruthy();+ within(dialog).getByRole('radio', { name: 'In Macro' })+ ).toHaveProperty('checked', true);+ expect(+ within(dialog).queryByRole('radio', { name: 'In Claude Code' })+ ).toBeNull();+ expect(+ within(dialog).getByRole('radio', { name: 'In Cursor' })+ ).toHaveProperty('disabled', true);+ expect(+ within(dialog).getByRole('radio', { name: 'In your harness' })+ ).toHaveProperty('disabled', true);+ expect(within(dialog).queryByLabelText('Harness')).toBeNull();+ expect(within(dialog).getAllByLabelText('Default model')).toHaveLength(1);+ expect(within(dialog).getByText('Who can use it')).toBeTruthy();expect(within(dialog).getByRole('group', { name: 'Share' })).toBeTruthy();+ fireEvent.click(within(dialog).getByRole('button', { name: 'Show' }));+ expect(+ within(dialog).getByRole('group', { name: 'Channels' })+ ).toBeTruthy();fireEvent.click(within(dialog).getByLabelText('Specific channels'));const channelSearch =within(dialog).getByPlaceholderText('Search channels…');@@ -1034,11 +1211,81 @@ describe('Agents', () => {expect(screen.getByRole('option', { name: 'general' })).toBeTruthy();});+ it('offers Connect Cursor instead of an unconnected Cursor option', () => {+ render(() => <Agents {...agentsPageProps} />);+ fireEvent.click(screen.getByRole('button', { name: 'Add agent' }));++ const dialog = screen.getByRole('region', { name: 'New agent' });+ const cursor = within(dialog).getByRole('radio', { name: 'In Cursor' });+ expect(cursor).toHaveProperty('disabled', true);+ expect(+ within(dialog).getByRole('button', { name: 'Connect Cursor' })+ ).toBeTruthy();+ expect(+ within(dialog).getByRole('radio', { name: 'In Macro' })+ ).toHaveProperty('checked', true);+ });++ it('offers harness setup instead of an unpaired harness option', () => {+ render(() => <Agents {...agentsPageProps} />);+ fireEvent.click(screen.getByRole('button', { name: 'Add agent' }));++ const dialog = screen.getByRole('region', { name: 'New agent' });+ const ownHarness = within(dialog).getByRole('radio', {+ name: 'In your harness',+ });+ expect(ownHarness).toHaveProperty('disabled', true);+ expect(+ within(dialog).getByRole('button', { name: 'Set up your own harness' })+ ).toBeTruthy();+ expect(within(dialog).queryByLabelText('Harness')).toBeNull();+ });++ it('keeps mention, permission, and channel choices collapsed under Advanced', () => {+ render(() => <Agents {...agentsPageProps} />);+ fireEvent.click(screen.getByRole('button', { name: 'Add agent' }));++ const dialog = screen.getByRole('region', { name: 'New agent' });+ const toggle = within(dialog).getByRole('button', { name: 'Show' });+ expect(toggle.getAttribute('aria-expanded')).toBe('false');+ expect(+ within(dialog).getByText(+ 'Chat agent · All channels · Your connected apps'+ )+ ).toBeTruthy();+ expect(within(dialog).queryByLabelText('Chat agent')).toBeNull();+ expect(+ within(dialog).queryByRole('group', { name: 'Channels' })+ ).toBeNull();++ fireEvent.click(toggle);+ expect(toggle.getAttribute('aria-expanded')).toBe('true');+ expect(toggle.textContent).toBe('Hide');+ expect(+ within(dialog).getByRole('group', { name: 'Answering a mention' })+ ).toBeTruthy();+ expect(within(dialog).getByLabelText('Chat agent')).toHaveProperty(+ 'checked',+ true+ );+ expect(+ within(dialog).getByRole('group', { name: 'Channels' })+ ).toBeTruthy();+ fireEvent.click(within(dialog).getByLabelText('Specific channels'));+ expect(+ within(dialog).getByText('Chat agent · 0 channels · Your connected apps')+ ).toBeTruthy();++ fireEvent.click(toggle);+ expect(toggle.getAttribute('aria-expanded')).toBe('false');+ expect(within(dialog).queryByLabelText('Chat agent')).toBeNull();+ });+it('explains why team sharing is disabled without a team', () => {agentMocks.currentTeam = null;- render(() => <Agents />);- fireEvent.click(screen.getByRole('button', { name: 'New agent' }));+ render(() => <Agents {...agentsPageProps} />);+ fireEvent.click(screen.getByRole('button', { name: 'Add agent' }));const dialog = screen.getByRole('region', { name: /^(New|Edit) agent$/ });const teamOption = within(dialog).getByLabelText('Team');@@ -1054,8 +1301,8 @@ describe('Agents', () => {});it('persists creation through the agents API', async () => {- render(() => <Agents />);- fireEvent.click(screen.getByRole('button', { name: 'New agent' }));+ render(() => <Agents {...agentsPageProps} />);+ fireEvent.click(screen.getByRole('button', { name: 'Add agent' }));const dialog = screen.getByRole('region', { name: /^(New|Edit) agent$/ });fireEvent.input(within(dialog).getByLabelText('Name'), {@@ -1099,15 +1346,21 @@ describe('Agents', () => {{ id: 'cursor-large', name: 'Cursor Large' },]);- render(() => <Agents />);- fireEvent.click(screen.getByRole('button', { name: 'New agent' }));+ render(() => <Agents {...agentsPageProps} />);+ fireEvent.click(screen.getByRole('button', { name: 'Add agent' }));const dialog = screen.getByRole('region', { name: /^(New|Edit) agent$/ });- const harness = within(dialog).getByLabelText('Runtime');- expect(selectOptions(harness).getAllByRole('option')).toHaveLength(2);+ const cursor = within(dialog).getByRole('radio', { name: 'In Cursor' });+ expect(cursor).toHaveProperty('disabled', false);+ expect(+ within(dialog).queryByRole('button', { name: 'Connect Cursor' })+ ).toBeNull();+ expect(+ within(dialog).getByRole('radio', { name: 'In your harness' })+ ).toHaveProperty('disabled', true);- chooseSelectOption(harness, 'Cursor');- expect(harness).toHaveProperty('textContent', 'Cursor');+ fireEvent.click(cursor);+ expect(cursor).toHaveProperty('checked', true);const defaultModel = within(dialog).getByLabelText('Default model');expect(selectOptions(defaultModel).getAllByRole('option')).toHaveLength(2);@@ -1137,12 +1390,28 @@ describe('Agents', () => {it('offers registered macrod harnesses in the harness picker', () => {harnessMocks.query.data = [MACROD_HARNESS];- render(() => <Agents />);- fireEvent.click(screen.getByRole('button', { name: 'New agent' }));+ render(() => <Agents {...agentsPageProps} />);+ fireEvent.click(screen.getByRole('button', { name: 'Add agent' }));const dialog = screen.getByRole('region', { name: /^(New|Edit) agent$/ });- const harness = within(dialog).getByLabelText('Runtime');- expect(selectOptions(harness).getAllByRole('option')).toHaveLength(2);+ expect(+ within(dialog).getByRole('radio', { name: 'In Macro' })+ ).toHaveProperty('checked', true);+ expect(+ within(dialog).getByRole('radio', { name: 'In Cursor' })+ ).toHaveProperty('disabled', true);+ const ownHarness = within(dialog).getByRole('radio', {+ name: 'In your harness',+ });+ expect(ownHarness).toHaveProperty('disabled', false);+ expect(+ within(dialog).queryByRole('button', { name: 'Set up your own harness' })+ ).toBeNull();++ fireEvent.click(ownHarness);+ const harness = within(dialog).getByLabelText('Harness');+ expect(harness).toHaveProperty('textContent', 'Dev box');+ expect(selectOptions(harness).getAllByRole('option')).toHaveLength(1);expect(selectOptions(harness).getByRole('option', { name: 'Dev box' })).toBeTruthy();@@ -1169,14 +1438,17 @@ describe('Agents', () => {const view = render(() => (<QueryClientProvider client={client}><Suspense>- <Agents />+ <Agents {...agentsPageProps} /></Suspense></QueryClientProvider>));await waitFor(() => expect(fetchHarnesses).toHaveBeenCalledOnce());- fireEvent.click(screen.getByRole('button', { name: 'New agent' }));+ fireEvent.click(screen.getByRole('button', { name: 'Add agent' }));const dialog = screen.getByRole('region', { name: /^(New|Edit) agent$/ });- const harness = within(dialog).getByLabelText('Runtime');+ fireEvent.click(+ within(dialog).getByRole('radio', { name: 'In your harness' })+ );+ const harness = within(dialog).getByLabelText('Harness');expect(selectOptions(harness).getByRole('option', { name: 'Dev box' })).toBeTruthy();@@ -1242,14 +1514,12 @@ describe('Agents', () => {refetch: vi.fn(),};- render(() => <Agents />);- fireEvent.click(screen.getByRole('button', { name: 'New agent' }));+ render(() => <Agents {...agentsPageProps} />);+ fireEvent.click(screen.getByRole('button', { name: 'Add agent' }));const dialog = screen.getByRole('region', { name: /^(New|Edit) agent$/ });- const harness = within(dialog).getByLabelText('Runtime');-expect(within(dialog).getByText('Claude Sonnet 4.5')).toBeTruthy();- chooseSelectOption(harness, 'Cursor');+ fireEvent.click(within(dialog).getByRole('radio', { name: 'In Cursor' }));expect(within(dialog).getByText(/Could not load models for Cursor/)).toBeTruthy();@@ -1258,7 +1528,12 @@ describe('Agents', () => {);expect(retry).toHaveBeenCalledOnce();- chooseSelectOption(harness, 'Dev box');+ // The first paired harness is picked when the option is chosen.+ fireEvent.click(+ within(dialog).getByRole('radio', { name: 'In your harness' })+ );+ const harness = within(dialog).getByLabelText('Harness');+ expect(harness).toHaveProperty('textContent', 'Dev box');expect(within(dialog).getByText('Model selection is unsupported by this runtime.'@@ -1279,12 +1554,13 @@ describe('Agents', () => {'codex');- render(() => <Agents />);- fireEvent.click(screen.getByRole('button', { name: 'New agent' }));+ render(() => <Agents {...agentsPageProps} />);+ fireEvent.click(screen.getByRole('button', { name: 'Add agent' }));const dialog = screen.getByRole('region', { name: /^(New|Edit) agent$/ });- const harness = within(dialog).getByLabelText('Runtime');- chooseSelectOption(harness, 'Dev box');+ fireEvent.click(+ within(dialog).getByRole('radio', { name: 'In your harness' })+ );const defaultModel = within(dialog).getByLabelText('Default model');expect(defaultModel.tagName).toBe('BUTTON');@@ -1302,10 +1578,12 @@ describe('Agents', () => {'retired-model');- render(() => <Agents />);- fireEvent.click(screen.getByRole('button', { name: 'New agent' }));+ render(() => <Agents {...agentsPageProps} />);+ fireEvent.click(screen.getByRole('button', { name: 'Add agent' }));const dialog = screen.getByRole('region', { name: /^(New|Edit) agent$/ });- chooseSelectOption(within(dialog).getByLabelText('Runtime'), 'Dev box');+ fireEvent.click(+ within(dialog).getByRole('radio', { name: 'In your harness' })+ );expect(within(dialog).getByLabelText('Default model')).toHaveProperty('textContent',@@ -1320,10 +1598,12 @@ describe('Agents', () => {'provider-default');- render(() => <Agents />);- fireEvent.click(screen.getByRole('button', { name: 'New agent' }));+ render(() => <Agents {...agentsPageProps} />);+ fireEvent.click(screen.getByRole('button', { name: 'Add agent' }));const dialog = screen.getByRole('region', { name: /^(New|Edit) agent$/ });- chooseSelectOption(within(dialog).getByLabelText('Runtime'), 'Dev box');+ fireEvent.click(+ within(dialog).getByRole('radio', { name: 'In your harness' })+ );const defaultModel = within(dialog).getByLabelText('Default model');expect(defaultModel).toHaveProperty(@@ -1344,14 +1624,16 @@ describe('Agents', () => {'claude-code');- render(() => <Agents />);- fireEvent.click(screen.getByRole('button', { name: 'New agent' }));+ render(() => <Agents {...agentsPageProps} />);+ fireEvent.click(screen.getByRole('button', { name: 'Add agent' }));const dialog = screen.getByRole('region', { name: /^(New|Edit) agent$/ });fireEvent.input(within(dialog).getByLabelText('Name'), {target: { value: 'Bug fixer' },});- chooseSelectOption(within(dialog).getByLabelText('Runtime'), 'Dev box');+ fireEvent.click(+ within(dialog).getByRole('radio', { name: 'In your harness' })+ );fireEvent.click(within(dialog).getByRole('button', { name: 'Create agent' }));@@ -1382,19 +1664,22 @@ describe('Agents', () => {'claude-code');- render(() => <Agents />);- fireEvent.click(screen.getByRole('button', { name: 'New agent' }));+ render(() => <Agents {...agentsPageProps} />);+ fireEvent.click(screen.getByRole('button', { name: 'Add agent' }));const dialog = screen.getByRole('region', { name: /^(New|Edit) agent$/ });fireEvent.input(within(dialog).getByLabelText('Name'), {target: { value: 'Chatty' },});+ fireEvent.click(within(dialog).getByRole('button', { name: 'Show' }));// Macro's in-memory runtime chats; a macrod harness codes.expect(within(dialog).getByLabelText('Chat agent')).toHaveProperty('checked',true);- chooseSelectOption(within(dialog).getByLabelText('Runtime'), 'Dev box');+ fireEvent.click(+ within(dialog).getByRole('radio', { name: 'In your harness' })+ );expect(within(dialog).getByLabelText('Coding agent')).toHaveProperty('checked',true@@ -1432,7 +1717,7 @@ describe('Agents', () => {},];- render(() => <Agents />);+ render(() => <Agents {...agentsPageProps} />);fireEvent.click(screen.getByRole('button', { name: 'Edit Bug fixer' }));const defaultModel = within(@@ -1476,14 +1761,16 @@ describe('Agents', () => {},];- render(() => <Agents />);+ render(() => <Agents {...agentsPageProps} />);fireEvent.click(screen.getByRole('button', { name: 'Edit Bug fixer' }));const dialog = screen.getByRole('region', { name: /^(New|Edit) agent$/ });- expect(within(dialog).getByLabelText('Runtime')).toHaveProperty(- 'textContent',- 'Claude Cloud'- );+ expect(+ within(dialog).getByRole('radio', { name: 'In Claude Code' })+ ).toHaveProperty('checked', true);+ expect(+ within(dialog).getByText(/Could not load models for Claude Cloud/)+ ).toBeTruthy();fireEvent.click(within(dialog).getByRole('button', { name: 'Save changes' }));@@ -1524,11 +1811,14 @@ describe('Agents', () => {},];- render(() => <Agents />);+ render(() => <Agents {...agentsPageProps} />);fireEvent.click(screen.getByRole('button', { name: 'Edit Bug fixer' }));const dialog = screen.getByRole('region', { name: /^(New|Edit) agent$/ });- expect(within(dialog).getByLabelText('Runtime')).toHaveProperty(+ expect(+ within(dialog).getByRole('radio', { name: 'In your harness' })+ ).toHaveProperty('checked', true);+ expect(within(dialog).getByLabelText('Harness')).toHaveProperty('textContent','Dev box');@@ -1566,10 +1856,14 @@ describe('Agents', () => {it('hides the Connections section when the Pipedream stack is off but keeps the selection', async () => {pipedreamMocks.enabled = false;agentMocks.query.data = [linearAgent];- render(() => <Agents />);+ render(() => <Agents {...agentsPageProps} />);fireEvent.click(screen.getByRole('button', { name: 'Edit Triage bot' }));const dialog = screen.getByRole('region', { name: /^(New|Edit) agent$/ });+ fireEvent.click(within(dialog).getByRole('button', { name: 'Show' }));+ expect(+ within(dialog).getByRole('group', { name: 'Channels' })+ ).toBeTruthy();expect(within(dialog).queryByText('Connections')).toBeNull();fireEvent.click(within(dialog).getByRole('button', { name: 'Save changes' })@@ -1585,10 +1879,16 @@ describe('Agents', () => {});it('defaults new agents to the owner connections policy', () => {- render(() => <Agents />);- fireEvent.click(screen.getByRole('button', { name: 'New agent' }));+ render(() => <Agents {...agentsPageProps} />);+ fireEvent.click(screen.getByRole('button', { name: 'Add agent' }));const dialog = screen.getByRole('region', { name: /^(New|Edit) agent$/ });+ expect(+ within(dialog).getByText(+ 'Chat agent · All channels · Your connected apps'+ )+ ).toBeTruthy();+ fireEvent.click(within(dialog).getByRole('button', { name: 'Show' }));expect(within(dialog).getByLabelText('Use my connected apps')).toHaveProperty('checked', true);@@ -1596,13 +1896,14 @@ describe('Agents', () => {});it('picks apps from the whole catalog, shows the viewer connection state, and persists them', async () => {- render(() => <Agents />);- fireEvent.click(screen.getByRole('button', { name: 'New agent' }));+ render(() => <Agents {...agentsPageProps} />);+ fireEvent.click(screen.getByRole('button', { name: 'Add agent' }));const dialog = screen.getByRole('region', { name: /^(New|Edit) agent$/ });fireEvent.input(within(dialog).getByLabelText('Name'), {target: { value: 'Triage bot' },});+ fireEvent.click(within(dialog).getByRole('button', { name: 'Show' }));fireEvent.click(within(dialog).getByLabelText('Specific apps'));// An explicit selection with nothing in it is not something to save.@@ -1655,10 +1956,14 @@ describe('Agents', () => {it('connects a picked app in place and flips its indicator without saving', async () => {agentMocks.update.mockClear();agentMocks.query.data = [linearAgent];- render(() => <Agents />);+ render(() => <Agents {...agentsPageProps} />);fireEvent.click(screen.getByRole('button', { name: 'Edit Triage bot' }));const dialog = screen.getByRole('region', { name: /^(New|Edit) agent$/ });+ expect(+ within(dialog).getByText('Chat agent · All channels · 2 selected apps')+ ).toBeTruthy();+ fireEvent.click(within(dialog).getByRole('button', { name: 'Show' }));expect(within(dialog).getByLabelText('Specific apps')).toHaveProperty('checked',true@@ -1706,10 +2011,13 @@ it('requires prompts unless the harness operator permits bypass', async () => {modelMocks.queries[`macrod:${MACROD_HARNESS.id}`] = successfulModels([{ id: 'claude-code', name: 'Claude Code' },]);- render(() => <Agents />);- fireEvent.click(screen.getByRole('button', { name: 'New agent' }));+ render(() => <Agents {...agentsPageProps} />);+ fireEvent.click(screen.getByRole('button', { name: 'Add agent' }));const dialog = screen.getByRole('region', { name: /^(New|Edit) agent$/ });- chooseSelectOption(within(dialog).getByLabelText('Runtime'), 'Dev box');+ fireEvent.click(+ within(dialog).getByRole('radio', { name: 'In your harness' })+ );+ fireEvent.click(within(dialog).getByRole('button', { name: 'Show' }));expect(within(dialog).getByLabelText('Always prompt')).toHaveProperty('checked',true@@ -1725,10 +2033,13 @@ it('offers bypass only after harness consent and resets the choice on harness chmodelMocks.queries[`macrod:${MACROD_HARNESS.id}`] = successfulModels([{ id: 'claude-code', name: 'Claude Code' },]);- render(() => <Agents />);- fireEvent.click(screen.getByRole('button', { name: 'New agent' }));+ render(() => <Agents {...agentsPageProps} />);+ fireEvent.click(screen.getByRole('button', { name: 'Add agent' }));const dialog = screen.getByRole('region', { name: /^(New|Edit) agent$/ });- chooseSelectOption(within(dialog).getByLabelText('Runtime'), 'Dev box');+ fireEvent.click(+ within(dialog).getByRole('radio', { name: 'In your harness' })+ );+ fireEvent.click(within(dialog).getByRole('button', { name: 'Show' }));expect(within(dialog).getByLabelText('Always prompt')).toHaveProperty('checked',true@@ -1738,7 +2049,7 @@ it('offers bypass only after harness consent and resets the choice on harness ch'checked',true);- chooseSelectOption(within(dialog).getByLabelText('Runtime'), 'Prompt only');+ chooseSelectOption(within(dialog).getByLabelText('Harness'), 'Prompt only');expect(within(dialog).getByLabelText('Always prompt')).toHaveProperty('checked',true@@ -1754,20 +2065,23 @@ it.each(['in-memory', 'cursor', 'claude-cloud'])({ id: 'provider-default', name: 'Provider default' },]);agentMocks.create.mockClear();- render(() => <Agents />);- fireEvent.click(screen.getByRole('button', { name: 'New agent' }));+ render(() => <Agents {...agentsPageProps} />);+ fireEvent.click(screen.getByRole('button', { name: 'Add agent' }));const dialog = screen.getByRole('region', { name: /^(New|Edit) agent$/ });fireEvent.input(within(dialog).getByLabelText('Name'), {target: { value: 'Built-in agent' },});- chooseSelectOption(- within(dialog).getByLabelText('Runtime'),- {- 'in-memory': 'Macro Agent',- cursor: 'Cursor',- 'claude-cloud': 'Claude Cloud',- }[harness]!+ fireEvent.click(+ within(dialog).getByRole('radio', {+ name: {+ 'in-memory': 'In Macro',+ cursor: 'In Cursor',+ 'claude-cloud': 'In Claude Code',+ }[harness]!,+ }));+ fireEvent.click(within(dialog).getByRole('button', { name: 'Show' }));+ expect(within(dialog).getByLabelText('Chat agent')).toBeTruthy();expect(within(dialog).queryByText('Permission requests')).toBeNull();expect(within(dialog).queryByLabelText('Always prompt')).toBeNull();expect(within(dialog).queryByLabelText('Always bypass')).toBeNull();diff --git a/apps/web/src/features/settings/Agents.tsx b/apps/web/src/features/settings/Agents.tsxindex ffcc2a8c8d..b1768cf54f 100644--- a/apps/web/src/features/settings/Agents.tsx+++ b/apps/web/src/features/settings/Agents.tsx@@ -1,5 +1,7 @@import { isCoderHarness } from '@app/features/agents-view/core/agent-kind';+import { AGENTS_TOUR } from '@app/features/agents-view/tour';import { useFeatureFlag } from '@app/lib/analytics/posthog';+import AnthropicIcon from '@core/component/AI/assets/anthropic.svg';import { ModelCatalogPicker } from '@core/component/AI/component/input/ModelCatalogPicker';import { isLargeModelCatalog } from '@core/component/AI/component/input/modelCatalog';import { MODEL_PRETTYNAME, Model } from '@core/component/AI/constant/model';@@ -13,10 +15,12 @@ import { useChannelsContext } from '@core/context/channels';import { useUserId } from '@core/context/user';import { usePipedreamMcpFlag } from '@core/pipedream/flag';import MacroLogo from '@icon/macro-logo.svg';+import CursorIcon from '@icon/wide-cursor-ide.svg';import ArrowLeftIcon from '@phosphor/arrow-left.svg';import PencilIcon from '@phosphor/pencil-simple.svg';import PlusIcon from '@phosphor/plus.svg';import AgentIcon from '@phosphor/sparkle.svg';+import TerminalIcon from '@phosphor/terminal-window.svg';import TrashIcon from '@phosphor/trash.svg';import UploadIcon from '@phosphor/upload-simple.svg';import {@@ -41,21 +45,34 @@ import type { AgentMcpServer } from '@service-storage/generated/schemas/agentMcpimport type { AgentMcpServers } from '@service-storage/generated/schemas/agentMcpServers';import { useSearchParams } from '@solidjs/router';import { Avatar, Button, Dialog, Panel } from '@ui';-import { createMemo, createSignal, For, type JSX, Show } from 'solid-js';+import { tourTarget } from '@ui/components/Tour';+import {+ createMemo,+ createSignal,+ For,+ type JSX,+ Match,+ 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 { AgentSettingsDescription } from './components/agent-settings-description';+import { CursorConnectPage } from './CursorConnectPage';+import { AgentSetupStrips } from './components/agent-setup-strips';import { CodingPreferencesSetting } from './components/coding-preferences-setting';import { AgentInstructionsEditor } from './components/instructions-editor';import { SettingsSelect } from './components/settings-select';+import { WhereItRunsOption } from './components/where-it-runs-option';import { PipedreamAppPicker } from './PipedreamAppPicker';import {ChoiceRow,SettingsCard,SettingsPage,SettingsSection,+ SettingsSurface,} from './primitives';+import { RuntimePairingPage } from './RuntimePairingPage';type AgentShare = 'Private' | 'Team';type ChannelMode = 'all' | 'selected';@@ -66,7 +83,8 @@ type AgentSummary = {tag: string;avatarUrl?: string;instructions: string;- harness: string;+ /** "In Macro", "In Cursor", … for the row's subtitle. */+ whereItRuns: string;defaultModel: string;channelSummary: string;share: AgentShare;@@ -98,14 +116,19 @@ const MACRO_AGENT: AgentSummary = {name: 'Macro',tag: 'macro',instructions: '',- harness: MACRO_HARNESS_NAME,+ whereItRuns: 'In Macro',defaultModel: MODEL_PRETTYNAME[Model.sonnet55],channelSummary: 'All channels',share: 'Team',};/** Settings page for viewing and creating persistent agents. */-export function Agents(props: { navigation?: JSX.Element } = {}) {+export function Agents(props: {+ onCursor: () => void;+ onSetUpRuntime: () => void;+ onManageRuntimes: () => void;+}) {+ const agentList = tourTarget(AGENTS_TOUR.agentList);const claudeCloudFlag = useFeatureFlag(claudeCloud);const [creating, setCreating] = createSignal(false);const [searchParams, setSearchParams] = useSearchParams();@@ -254,59 +277,33 @@ export function Agents(props: { navigation?: JSX.Element } = {}) {<Show when={!creating() && !creatingFromLink() && !editingAgent()}><SettingsPagetitle="Agents"- description={<AgentSettingsDescription />}- actions={- <Button variant="cta" size="sm" onClick={() => setCreating(true)}>- <PlusIcon />- New agent- </Button>- }+ description="Custom assistants with their own name, instructions, model, and place to run.">- {props.navigation}- <SettingsSection- title="Team agents"- description="Agents shared with your team, including Macro."- >- <SettingsCard>- <For each={teamAgents()}>- {(agent) => (- <AgentRow- agent={agent}- onEdit={- agent.editable && agent.persistedAgent- ? () => setEditingAgent(agent.persistedAgent)- : undefined- }- onDelete={- agent.persistedAgent &&- canDeleteAgent(agent.persistedAgent)- ? () => setDeletingAgent(agent.persistedAgent)- : undefined- }- />- )}- </For>- </SettingsCard>- </SettingsSection>-- <SettingsSection- title="Private agents"- description="Agents owned by you rather than your team."- >- <SettingsCard>- <Show- when={privateAgents().length > 0}- fallback={- <p class="px-6 py-4 text-sm text-ink-muted">- {agentsQuery.isPending- ? 'Loading agents…'- : agentsQuery.isError- ? 'Your agents are unavailable.'- : 'No private agents yet.'}+ <AgentSetupStrips+ onCursor={props.onCursor}+ onSetUpRuntime={props.onSetUpRuntime}+ onManageRuntimes={props.onManageRuntimes}+ />+ <section ref={agentList} aria-label="Your agents">+ <SettingsSurface class="flex flex-col gap-2 p-5 touch:p-4">+ <div class="flex flex-wrap items-start justify-between gap-3">+ <div class="flex min-w-0 flex-col gap-0.5">+ <h2 class="text-base font-medium text-ink">Your agents</h2>+ <p class="text-sm leading-relaxed text-ink/60">+ Shared with your team or private to you.</p>- }- >- <For each={privateAgents()}>+ </div>+ <Button+ variant="cta"+ size="sm"+ onClick={() => setCreating(true)}+ >+ <PlusIcon />+ Add agent+ </Button>+ </div>+ <SettingsCard>+ <For each={[...teamAgents(), ...privateAgents()]}>{(agent) => (<AgentRowagent={agent}@@ -324,14 +321,19 @@ export function Agents(props: { navigation?: JSX.Element } = {}) {/>)}</For>- </Show>- <Show when={agentsQuery.isError}>- <p class="px-6 py-4 text-xs text-negative">- Could not load your agents. Try refreshing this page.- </p>- </Show>- </SettingsCard>- </SettingsSection>+ <Show when={agentsQuery.isPending}>+ <p class="px-6 py-4 text-sm text-ink-muted">+ Loading agents…+ </p>+ </Show>+ <Show when={agentsQuery.isError}>+ <p class="px-6 py-4 text-xs text-negative">+ Could not load your agents. Try refreshing this page.+ </p>+ </Show>+ </SettingsCard>+ </SettingsSurface>+ </section><CodingPreferencesSetting /></SettingsPage>@@ -399,7 +401,7 @@ function summarizeAgent(tag: agent.bot.handle,avatarUrl: agent.bot.avatar_url ?? undefined,instructions: agent.instructions,- harness: harness?.name ?? harnessName(harnessKey),+ whereItRuns: whereItRunsLabel(harnessKey, harness),defaultModel:MODEL_PRETTYNAME[agent.default_model as Model] ?? agent.default_model,channelSummary,@@ -409,13 +411,13 @@ function summarizeAgent(};}-function harnessName(id: string): string {- if (id === 'in-memory') return MACRO_HARNESS_NAME;- if (id === 'cursor') return 'Cursor';- if (id === 'claude-cloud') return 'Claude Cloud';+function whereItRunsLabel(id: string, harness?: ConnectedHarness): string {+ if (id === 'in-memory') return 'In Macro';+ if (id === 'cursor') return 'In Cursor';+ if (id === 'claude-cloud') return 'In Claude Code';// Any other id is a registered macrod harness uuid; if it is not in the// connected list any more, the harness has been removed.- return 'Disconnected runtime';+ return harness ? `In your harness · ${harness.name}` : 'Disconnected runtime';}function AgentRow(props: {@@ -439,7 +441,7 @@ function AgentRow(props: {</span></div><p class="mt-0.5 text-xs text-ink-extra-muted">- {props.agent.harness} · {props.agent.defaultModel} ·{' '}+ {props.agent.whereItRuns} · {props.agent.defaultModel} ·{' '}{props.agent.channelSummary}</p></div>@@ -703,6 +705,133 @@ function AgentEditorPage(props: {let avatarInputRef: HTMLInputElement | undefined;let pageContentRef: HTMLDivElement | undefined;+ const [setup, setSetup] = createSignal<'cursor' | 'pairing'>();+ const [advancedOpen, setAdvancedOpen] = createSignal(false);+ const cursorHarness = () =>+ props.connectedHarnesses.find((harness) => harness.id === 'cursor');+ const macrodHarnesses = () =>+ props.connectedHarnesses.filter((harness) => harness.kind === 'macrod');+ // Claude Cloud stays behind its flag and only once it can list models.+ const claudeCloudOption = () =>+ props.connectedHarnesses.find(+ (harness) =>+ harness.id === 'claude-cloud' &&+ (harness.id === harnessId() ||+ modelDataForHarness(harness.id)?.status === 'available')+ );+ // Back from a setup guide, land on what was just set up.+ const finishSetup = () => {+ const finished = setup();+ setSetup(undefined);+ const ready =+ finished === 'cursor' ? cursorHarness() : macrodHarnesses()[0];+ if (ready) handleHarnessChange(ready.id);+ };+ const advancedSummary = () =>+ [+ isCoding() ? 'Coding agent' : 'Chat agent',+ channelMode() === 'all'+ ? 'All channels'+ : `${selectedChannelIds().length} ${selectedChannelIds().length === 1 ? 'channel' : 'channels'}`,+ ...(pipedreamMcp()+ ? [+ mcp().scope === 'owner_connections'+ ? 'Your connected apps'+ : `${selectedMcpServers().length} selected apps`,+ ]+ : []),+ ].join(' · ');+ const modelPicker = () => (+ <div class="flex min-w-0 flex-col gap-1.5">+ <span class="text-xs font-medium text-ink-muted">Model</span>+ <Show+ when={selectedModelQuery()}+ fallback={+ <p class="settings-input text-ink-muted">+ Model discovery unavailable+ </p>+ }+ keyed+ >+ {(query) => (+ <Show+ when={!query.isPending}+ fallback={+ <SettingsSelect+ label="Default model"+ options={[]}+ placeholder="Loading models…"+ onChange={setDefaultModelId}+ disabled+ />+ }+ >+ <Show+ when={!query.isError}+ fallback={+ <div class="flex items-center gap-2">+ <p class="min-w-0 flex-1 text-xs text-negative">+ Could not load models for{' '}+ {selectedHarness()?.name ?? 'this runtime'}.+ </p>+ <Button+ type="button"+ variant="outline"+ size="sm"+ aria-label={`Retry models for ${selectedHarness()?.name ?? 'this runtime'}`}+ onClick={() => void query.refetch()}+ >+ Retry+ </Button>+ </div>+ }+ >+ <Show+ when={selectedModelData()?.status === 'available'}+ fallback={+ <p class="settings-input text-ink-muted">+ Model selection is unsupported by this runtime.+ </p>+ }+ >+ <Show+ when={selectedModelOptions().length > 0}+ fallback={+ <p class="settings-input text-ink-muted">+ This runtime did not return any models.+ </p>+ }+ >+ <Show+ when={selectedHarnessUsesCatalog()}+ fallback={+ <SettingsSelect+ label="Default model"+ options={selectedModelOptions()}+ value={selectedDefaultModelId()}+ onChange={setDefaultModelId}+ />+ }+ >+ <ModelCatalogPicker+ value={selectedDefaultModelId()}+ options={selectedCatalogOptions()}+ onSelect={setDefaultModelId}+ ariaLabel="Default model"+ triggerClass="w-full justify-between"+ contentClass="overflow-hidden"+ />+ </Show>+ </Show>+ </Show>+ </Show>+ </Show>+ )}+ </Show>+ </div>+ );+ const modelField = () => <div class="max-w-[280px]">{modelPicker()}</div>;+const close = () => {if (!busy()) props.onClose();};@@ -779,456 +908,504 @@ function AgentEditorPage(props: {};return (- <SettingsPage- title={props.agent ? 'Edit agent' : 'New agent'}- showTitleInSheet- description="Give your agent an identity, instructions, and a runtime."- actions={- <Button variant="ghost" size="sm" onClick={close} disabled={busy()}>- <ArrowLeftIcon /> Back- </Button>- }- >- <section- aria-label={props.agent ? 'Edit agent' : 'New agent'}- class="@container"- ref={pageContentRef}- >- <form- id="agent-form"- class="flex flex-col gap-6"- onSubmit={(event) => {- event.preventDefault();- void submit();- }}+ <Switch>+ <Match when={setup() === 'cursor'}>+ <CursorConnectPage onClose={finishSetup} />+ </Match>+ <Match when={setup() === 'pairing'}>+ <RuntimePairingPage onClose={finishSetup} />+ </Match>+ <Match when={!setup()}>+ <SettingsPage+ title={props.agent ? 'Edit agent' : 'New agent'}+ showTitleInSheet+ description="Name it, tell it what to do, and pick where it runs."+ actions={+ <Button variant="ghost" size="sm" onClick={close} disabled={busy()}>+ <ArrowLeftIcon /> Back+ </Button>+ }>- <AgentFormSection- title="Profile"- description="How this agent appears in channels and mentions."+ <section+ aria-label={props.agent ? 'Edit agent' : 'New agent'}+ class="@container"+ ref={pageContentRef}>- <div class="flex items-center gap-3 border-b border-edge-muted pb-4">- <button- type="button"- aria-label="Upload avatar"- disabled={busy()}- class="rounded-full outline-none focus-visible:ring-2 focus-visible:ring-accent"- onClick={() => avatarInputRef?.click()}- >- <AgentAvatar- agent={{- id: 'draft',- name: name() || 'Agent',- tag: tag(),- avatarUrl: avatarUrl(),- instructions: '',- harness: '',- defaultModel: '',- channelSummary: '',- share: share(),- }}- />- </button>- <div class="min-w-0 flex-1">- <div class="text-sm font-medium text-ink">Avatar</div>- <div class="mt-0.5 text-xs text-ink-muted">- Optional · square images work best- </div>- </div>- <input- ref={avatarInputRef}- type="file"- accept="image/*"- class="hidden"- disabled={busy()}- onChange={(event) =>- void handleAvatarInput(event.currentTarget.files?.[0])- }- />- <Button- type="button"- variant="outline"- size="sm"- disabled={busy()}- onClick={() => avatarInputRef?.click()}+ <form+ id="agent-form"+ class="flex flex-col gap-6"+ onSubmit={(event) => {+ event.preventDefault();+ void submit();+ }}+ >+ <AgentFormSection+ title="Profile"+ description="How this agent appears in channels and mentions.">- <UploadIcon />- {uploadingAvatar() ? 'Uploading…' : 'Upload'}- </Button>- </div>-- <div class="mt-4 grid grid-cols-1 gap-3 @min-[440px]:grid-cols-2">- <label class="flex flex-col gap-1.5">- <span class="text-xs font-medium text-ink">Name</span>- <input- autofocus- class="settings-input w-full"- placeholder="Bug fixer"- value={name()}- onInput={(event) =>- handleNameInput(event.currentTarget.value)- }- />- </label>- <label for="agent-tag" class="flex flex-col gap-1.5">- <span class="text-xs font-medium text-ink">@tag</span>- <div class="flex items-center rounded-lg border border-edge-muted px-2 focus-within:border-accent">- <span class="text-sm text-ink-extra-muted">@</span>+ <div class="flex items-center gap-3 border-b border-edge-muted pb-4">+ <button+ type="button"+ aria-label="Upload avatar"+ disabled={busy()}+ class="rounded-full outline-none focus-visible:ring-2 focus-visible:ring-accent"+ onClick={() => avatarInputRef?.click()}+ >+ <AgentAvatar+ agent={{+ id: 'draft',+ name: name() || 'Agent',+ tag: tag(),+ avatarUrl: avatarUrl(),+ instructions: '',+ whereItRuns: '',+ defaultModel: '',+ channelSummary: '',+ share: share(),+ }}+ />+ </button>+ <div class="min-w-0 flex-1">+ <div class="text-sm font-medium text-ink">Avatar</div>+ <div class="mt-0.5 text-xs text-ink-muted">+ Optional · square images work best+ </div>+ </div><input- id="agent-tag"- aria-label="@tag"- class="min-w-0 flex-1 bg-transparent px-1.5 py-2 text-sm text-ink outline-none"- placeholder="bug-fixer"- value={tag()}- onInput={(event) => {- setTagEdited(true);- setTag(slugAgentTag(event.currentTarget.value));- }}+ ref={avatarInputRef}+ type="file"+ accept="image/*"+ class="hidden"+ disabled={busy()}+ onChange={(event) =>+ void handleAvatarInput(event.currentTarget.files?.[0])+ }/>+ <Button+ type="button"+ variant="outline"+ size="sm"+ disabled={busy()}+ onClick={() => avatarInputRef?.click()}+ >+ <UploadIcon />+ {uploadingAvatar() ? 'Uploading…' : 'Upload'}+ </Button></div>- </label>- </div>- </AgentFormSection>- <AgentFormSection- title="Instructions"- description="Instructions the agent receives at the start of every conversation."- >- <AgentInstructionsEditor- markdown={instructions()}- onChange={setInstructions}- disabled={props.pending}- class="rounded-lg border border-edge-muted bg-input px-3 py-2.5 focus-within:border-accent"- placeholder="Describe your agent’s role, how it should work, and what a good result looks like…"- />- </AgentFormSection>+ <div class="mt-4 grid grid-cols-1 gap-3 @min-[440px]:grid-cols-2">+ <label class="flex flex-col gap-1.5">+ <span class="text-xs font-medium text-ink">Name</span>+ <input+ autofocus+ class="settings-input w-full"+ placeholder="Bug fixer"+ value={name()}+ onInput={(event) =>+ handleNameInput(event.currentTarget.value)+ }+ />+ </label>+ <label for="agent-tag" class="flex flex-col gap-1.5">+ <span class="text-xs font-medium text-ink">@tag</span>+ <div class="flex items-center rounded-lg border border-edge-muted px-2 focus-within:border-accent">+ <span class="text-sm text-ink-extra-muted">@</span>+ <input+ id="agent-tag"+ aria-label="@tag"+ class="min-w-0 flex-1 bg-transparent px-1.5 py-2 text-sm text-ink outline-none"+ placeholder="bug-fixer"+ value={tag()}+ onInput={(event) => {+ setTagEdited(true);+ setTag(slugAgentTag(event.currentTarget.value));+ }}+ />+ </div>+ </label>+ </div>+ </AgentFormSection>- <AgentFormSection- title="Runtime"- description="Choose a connected runtime, then the model this agent uses."- >- <div class="grid grid-cols-1 gap-3 @min-[440px]:grid-cols-2">- <div class="flex min-w-0 flex-col gap-1.5">- <span class="text-xs font-medium text-ink">Runtime</span>- <SettingsSelect- label="Runtime"- options={props.connectedHarnesses.filter(- (harness) =>- harness.id !== 'claude-cloud' ||- harness.id === harnessId() ||- modelDataForHarness(harness.id)?.status === 'available'- )}- value={harnessId()}- onChange={handleHarnessChange}+ <AgentFormSection+ title="Instructions"+ description="Instructions the agent receives at the start of every conversation."+ >+ <AgentInstructionsEditor+ markdown={instructions()}+ onChange={setInstructions}+ disabled={props.pending}+ class="rounded-lg border border-edge-muted bg-input px-3 py-2.5 focus-within:border-accent"+ placeholder="Describe your agent’s role, how it should work, and what a good result looks like…"/>- </div>- <div class="flex min-w-0 flex-col gap-1.5">- <span class="text-xs font-medium text-ink">Default model</span>- <Show- when={selectedModelQuery()}- fallback={- <p class="settings-input text-ink-muted">- Model discovery unavailable- </p>- }- keyed- >- {(query) => (- <Show- when={!query.isPending}- fallback={+ </AgentFormSection>++ <AgentFormSection+ title="Where it runs"+ description="Pick where this agent does its work."+ >+ <fieldset class="flex flex-col gap-2">+ <legend class="sr-only">Where it runs</legend>+ <WhereItRunsOption+ value="in-memory"+ title="In Macro"+ description="Fast and built in. Uses Macro tools and your connected apps."+ icon={<MacroLogo />}+ checked={harnessId() === IN_MEMORY_HARNESS.id}+ onSelect={() => handleHarnessChange(IN_MEMORY_HARNESS.id)}+ >+ {modelField()}+ </WhereItRunsOption>+ <Show when={claudeCloudOption()}>+ {(claude) => (+ <WhereItRunsOption+ value="claude-cloud"+ title="In Claude Code"+ description="Runs Claude Code in the cloud on your Claude plan."+ icon={<AnthropicIcon />}+ checked={harnessId() === claude().id}+ onSelect={() => handleHarnessChange(claude().id)}+ >+ {modelField()}+ </WhereItRunsOption>+ )}+ </Show>+ <WhereItRunsOption+ value="cursor"+ title="In Cursor"+ description={+ cursorHarness()+ ? 'Runs as a Cursor Cloud agent on your Cursor plan.'+ : 'Connect Cursor first. Runs as a Cursor Cloud agent on your Cursor plan.'+ }+ icon={<CursorIcon />}+ checked={harnessId() === 'cursor'}+ disabled={!cursorHarness()}+ action={+ <Show when={!cursorHarness()}>+ <Button+ type="button"+ variant="ghost"+ size="sm"+ class="text-ink"+ aria-label="Connect Cursor"+ disabled={busy()}+ onClick={() => setSetup('cursor')}+ >+ Connect+ </Button>+ </Show>+ }+ onSelect={() => handleHarnessChange('cursor')}+ >+ {modelField()}+ </WhereItRunsOption>+ <WhereItRunsOption+ value="harness"+ title="In your harness"+ description="Your own agent on your own machine. Local Claude Code, Codex, or other harness, via Macrod."+ icon={<TerminalIcon />}+ checked={selectedHarness()?.kind === 'macrod'}+ disabled={macrodHarnesses().length === 0}+ action={+ <Show when={macrodHarnesses().length === 0}>+ <Button+ type="button"+ variant="ghost"+ size="sm"+ class="text-ink"+ aria-label="Set up your own harness"+ disabled={busy()}+ onClick={() => setSetup('pairing')}+ >+ Set up+ </Button>+ </Show>+ }+ onSelect={() => {+ const first = macrodHarnesses()[0];+ if (first) handleHarnessChange(first.id);+ }}+ >+ <div class="grid grid-cols-1 gap-3 @min-[440px]:grid-cols-[repeat(2,minmax(0,280px))]">+ <div class="flex min-w-0 flex-col gap-1.5">+ <span class="text-xs font-medium text-ink-muted">+ Harness+ </span><SettingsSelect- label="Default model"- options={[]}- placeholder="Loading models…"- onChange={setDefaultModelId}- disabled+ label="Harness"+ options={macrodHarnesses()}+ value={harnessId()}+ onChange={handleHarnessChange}+ />+ </div>+ {modelPicker()}+ </div>+ </WhereItRunsOption>+ </fieldset>+ </AgentFormSection>++ <AgentFormSection+ title="Who can use it"+ description="Private agents are yours. Team agents work in shared channels."+ >+ <fieldset class="grid grid-cols-1 gap-2 @min-[440px]:grid-cols-2">+ <legend class="sr-only">Share</legend>+ <ChoiceRow+ name="agent-share"+ value="private"+ checked={share() === 'Private'}+ title="Private"+ description={+ props.canMakePrivate+ ? 'Only you can use and manage this agent.'+ : 'Only the agent creator can make it private.'+ }+ disabled={!props.canMakePrivate}+ onChange={() => setShare('Private')}+ />+ <ChoiceRow+ name="agent-share"+ value="team"+ checked={share() === 'Team'}+ title="Team"+ description={+ props.canShareWithTeam+ ? 'Your team can use this agent in shared channels.'+ : 'Create or join a team before sharing agents.'+ }+ disabled={!props.canShareWithTeam}+ onChange={() => setShare('Team')}+ />+ </fieldset>+ <Show when={!props.canShareWithTeam}>+ <p class="mt-3 border-t border-edge-muted pt-3 text-xs text-ink-extra-muted">+ Team agents need a team owner. Create or join a team in Team+ settings to enable this option.+ </p>+ </Show>+ </AgentFormSection>++ <AgentFormSection+ title="Advanced"+ description={advancedSummary()}+ actions={+ <Button+ type="button"+ variant="ghost"+ size="sm"+ aria-expanded={advancedOpen()}+ aria-controls="agent-advanced"+ onClick={() => setAdvancedOpen((open) => !open)}+ >+ {advancedOpen() ? 'Hide' : 'Show'}+ </Button>+ }+ >+ <Show when={advancedOpen()}>+ <div id="agent-advanced" class="flex flex-col">+ <fieldset class="grid gap-2">+ <legend class="text-xs font-medium text-ink">+ Answering a mention+ </legend>+ <ChoiceRow+ name="agent-coding"+ value="coding"+ title="Coding agent"+ description="Posts a magic chip you can open into the live session and watch it work in a repository."+ checked={isCoding()}+ onChange={() => setCodingChoice(true)}+ />+ <ChoiceRow+ name="agent-coding"+ value="chat"+ title="Chat agent"+ description="Replies in the thread the way a person would, like @macro."+ checked={!isCoding()}+ onChange={() => setCodingChoice(false)}+ />+ </fieldset>+ <Show when={selectedHarness()?.kind === 'macrod'}>+ <fieldset class="mt-4 grid gap-2 border-t border-ink/[0.06] pt-4">+ <legend class="text-xs font-medium text-ink">+ Permission requests+ </legend>+ <ChoiceRow+ name="agent-permission-policy"+ value="prompt"+ title="Always prompt"+ description="Session editors approve or reject each permission request."+ checked={!autoAcceptPermissions()}+ onChange={() => setAutoAcceptChoice(false)}/>- }- >- <Show- when={!query.isError}- fallback={- <div class="flex items-center gap-2">- <p class="min-w-0 flex-1 text-xs text-negative">- Could not load models for{' '}- {selectedHarness()?.name ?? 'this runtime'}.- </p>- <Button- type="button"- variant="outline"- size="sm"- aria-label={`Retry models for ${selectedHarness()?.name ?? 'this runtime'}`}- onClick={() => void query.refetch()}- >- Retry- </Button>- </div>- }- ><Show- when={selectedModelData()?.status === 'available'}+ when={allowPermissionBypass()}fallback={- <p class="settings-input text-ink-muted">- Model selection is unsupported by this runtime.+ <p class="text-xs text-ink-muted">+ This runtime requires permission prompts.</p>}>- <Show- when={selectedModelOptions().length > 0}- fallback={- <p class="settings-input text-ink-muted">- This runtime did not return any models.- </p>- }- >- <Show- when={selectedHarnessUsesCatalog()}- fallback={- <SettingsSelect- label="Default model"- options={selectedModelOptions()}- value={selectedDefaultModelId()}- onChange={setDefaultModelId}- />- }- >- <ModelCatalogPicker- value={selectedDefaultModelId()}- options={selectedCatalogOptions()}- onSelect={setDefaultModelId}- ariaLabel="Default model"- triggerClass="w-full justify-between"- contentClass="overflow-hidden"- />- </Show>- </Show>+ <ChoiceRow+ name="agent-permission-policy"+ value="bypass"+ title="Always bypass"+ description="Approve tool calls without asking."+ checked={autoAcceptPermissions()}+ onChange={() => setAutoAcceptChoice(true)}+ /></Show>- </Show>+ </fieldset></Show>- )}- </Show>- </div>- </div>- <fieldset class="mt-4 grid gap-2 border-t border-ink/[0.06] pt-4">- <legend class="text-xs font-medium text-ink">- Answering a mention- </legend>- <ChoiceRow- name="agent-coding"- value="coding"- title="Coding agent"- description="Posts a magic chip you can open into the live session and watch it work in a repository."- checked={isCoding()}- onChange={() => setCodingChoice(true)}- />- <ChoiceRow- name="agent-coding"- value="chat"- title="Chat agent"- description="Replies in the thread the way a person would, like @macro."- checked={!isCoding()}- onChange={() => setCodingChoice(false)}- />- </fieldset>- <Show when={selectedHarness()?.kind === 'macrod'}>- <fieldset class="mt-4 grid gap-2 border-t border-ink/[0.06] pt-4">- <legend class="text-xs font-medium text-ink">- Permission requests- </legend>- <ChoiceRow- name="agent-permission-policy"- value="prompt"- title="Always prompt"- description="Session editors approve or reject each permission request."- checked={!autoAcceptPermissions()}- onChange={() => setAutoAcceptChoice(false)}- />- <Show- when={allowPermissionBypass()}- fallback={- <p class="text-xs text-ink-muted">- This runtime requires permission prompts.- </p>- }- >- <ChoiceRow- name="agent-permission-policy"- value="bypass"- title="Always bypass"- description="Approve tool calls without asking."- checked={autoAcceptPermissions()}- onChange={() => setAutoAcceptChoice(true)}- />- </Show>- </fieldset>- </Show>- </AgentFormSection>-- <Show when={pipedreamMcp()}>- <AgentFormSection- title="Connections"- description="Which connected apps (MCP tools) this agent can use."- >- <fieldset class="flex flex-col gap-2">- <legend class="sr-only">Connections</legend>- <ChoiceRow- name="agent-mcp-mode"- value="owner_connections"- checked={mcp().scope === 'owner_connections'}- title="Use my connected apps"- description="The agent uses whatever apps the person running it has connected."- onChange={() => setMcpScope('owner_connections')}- />- <ChoiceRow- name="agent-mcp-mode"- value="selected"- checked={mcp().scope === 'selected'}- title="Specific apps"- description="Pick apps from the catalog. Each person connects their own account."- onChange={() => setMcpScope('selected')}- />- </fieldset>- <Show when={mcp().scope === 'selected'}>- <div class="mt-3 border-t border-edge-muted pt-3">- <PipedreamAppPicker- selected={selectedMcpServers()}- onChange={setSelectedMcpServers}- connectedSlugs={connections.slugs}- connectionsReady={connections.ready}- connectContainer={() => pageContentRef}- />- </div>- </Show>+ <Show when={pipedreamMcp()}>+ <AdvancedGroup+ title="Connections"+ description="Which connected apps (MCP tools) this agent can use."+ >+ <fieldset class="flex flex-col gap-2">+ <legend class="sr-only">Connections</legend>+ <ChoiceRow+ name="agent-mcp-mode"+ value="owner_connections"+ checked={mcp().scope === 'owner_connections'}+ title="Use my connected apps"+ description="The agent uses whatever apps the person running it has connected."+ onChange={() => setMcpScope('owner_connections')}+ />+ <ChoiceRow+ name="agent-mcp-mode"+ value="selected"+ checked={mcp().scope === 'selected'}+ title="Specific apps"+ description="Pick apps from the catalog. Each person connects their own account."+ onChange={() => setMcpScope('selected')}+ />+ </fieldset>- <Show when={share() === 'Team'}>- <p class="mt-3 border-t border-edge-muted pt-3 text-xs text-ink-extra-muted">- Connections are personal. Teammates who use this agent connect- these apps under Agents → Connections; the indicators here- show only your own.- </p>- </Show>- </AgentFormSection>- </Show>+ <Show when={mcp().scope === 'selected'}>+ <div class="mt-3 border-t border-edge-muted pt-3">+ <PipedreamAppPicker+ selected={selectedMcpServers()}+ onChange={setSelectedMcpServers}+ connectedSlugs={connections.slugs}+ connectionsReady={connections.ready}+ connectContainer={() => pageContentRef}+ />+ </div>+ </Show>- <AgentFormSection- title="Channels"- description="Choose whether this agent is global or channel-specific."- >- <fieldset class="flex flex-col gap-2">- <legend class="sr-only">Channels</legend>- <ChoiceRow- name="agent-channel-mode"- value="all"- checked={channelMode() === 'all'}- title="All channels"- description="The agent can be mentioned in every channel, like @macro."- onChange={() => setChannelMode('all')}- />- <ChoiceRow- name="agent-channel-mode"- value="selected"- checked={channelMode() === 'selected'}- title="Specific channels"- description="Only members of selected channels can use this agent."- onChange={() => setChannelMode('selected')}- />- </fieldset>+ <Show when={share() === 'Team'}>+ <p class="mt-3 border-t border-edge-muted pt-3 text-xs text-ink-extra-muted">+ Connections are personal. Teammates who use this+ agent connect these apps under Agents → Connections;+ the indicators here show only your own.+ </p>+ </Show>+ </AdvancedGroup>+ </Show>- <Show when={channelMode() === 'selected'}>- <div class="mt-3 border-t border-edge-muted pt-3">- <ChannelMultiSelect- channelIds={selectedChannelIds()}- onChange={setSelectedChannelIds}- />- </div>- </Show>- </AgentFormSection>+ <AdvancedGroup+ title="Channels"+ description="Choose whether this agent is global or channel-specific."+ >+ <fieldset class="flex flex-col gap-2">+ <legend class="sr-only">Channels</legend>+ <ChoiceRow+ name="agent-channel-mode"+ value="all"+ checked={channelMode() === 'all'}+ title="All channels"+ description="The agent can be mentioned in every channel, like @macro."+ onChange={() => setChannelMode('all')}+ />+ <ChoiceRow+ name="agent-channel-mode"+ value="selected"+ checked={channelMode() === 'selected'}+ title="Specific channels"+ description="Only members of selected channels can use this agent."+ onChange={() => setChannelMode('selected')}+ />+ </fieldset>- <AgentFormSection- title="Share"- description="Choose who owns and can configure this agent."- >- <fieldset class="grid grid-cols-1 gap-2 @min-[440px]:grid-cols-2">- <legend class="sr-only">Share</legend>- <ChoiceRow- name="agent-share"- value="private"- checked={share() === 'Private'}- title="Private"- description={- props.canMakePrivate- ? 'Only you can use and manage this agent.'- : 'Only the agent creator can make it private.'- }- disabled={!props.canMakePrivate}- onChange={() => setShare('Private')}- />- <ChoiceRow- name="agent-share"- value="team"- checked={share() === 'Team'}- title="Team"- description={- props.canShareWithTeam- ? 'Your team can use this agent in shared channels.'- : 'Create or join a team before sharing agents.'- }- disabled={!props.canShareWithTeam}- onChange={() => setShare('Team')}- />- </fieldset>- <Show when={!props.canShareWithTeam}>- <p class="mt-3 border-t border-edge-muted pt-3 text-xs text-ink-extra-muted">- Team agents need a team owner. Create or join a team in Team- settings to enable this option.- </p>- </Show>- </AgentFormSection>- </form>- <div class="mt-6 flex justify-end gap-2 border-t border-edge-muted pt-4">- <Button- type="button"- variant="ghost"- size="sm"- onClick={close}- disabled={busy()}- >- Cancel- </Button>- <Button- type="submit"- form="agent-form"- variant="strong"- size="sm"- disabled={!canCreate()}- >- {props.pending- ? props.agent- ? 'Saving…'- : 'Creating…'- : props.agent- ? 'Save changes'- : 'Create agent'}- </Button>- </div>- </section>- </SettingsPage>+ <Show when={channelMode() === 'selected'}>+ <div class="mt-3 border-t border-edge-muted pt-3">+ <ChannelMultiSelect+ channelIds={selectedChannelIds()}+ onChange={setSelectedChannelIds}+ />+ </div>+ </Show>+ </AdvancedGroup>+ </div>+ </Show>+ </AgentFormSection>+ </form>+ <div class="mt-6 flex justify-end gap-2 border-t border-edge-muted pt-4">+ <Button+ type="button"+ variant="ghost"+ size="sm"+ onClick={close}+ disabled={busy()}+ >+ Cancel+ </Button>+ <Button+ type="submit"+ form="agent-form"+ variant="strong"+ size="sm"+ disabled={!canCreate()}+ >+ {props.pending+ ? props.agent+ ? 'Saving…'+ : 'Creating…'+ : props.agent+ ? 'Save changes'+ : 'Create agent'}+ </Button>+ </div>+ </section>+ </SettingsPage>+ </Match>+ </Switch>);}function AgentFormSection(props: {title: string;description: string;- children: import('solid-js').JSX.Element;+ actions?: JSX.Element;+ children: JSX.Element;}) {return (- <SettingsSection title={props.title} description={props.description}>+ <SettingsSection+ title={props.title}+ description={props.description}+ actions={props.actions}+ ><div class="pt-2">{props.children}</div></SettingsSection>);}+/** A titled group inside the Advanced section, split by a hairline. */+function AdvancedGroup(props: {+ title: string;+ description: string;+ children: JSX.Element;+}) {+ return (+ <section class="mt-4 border-t border-ink/[0.06] pt-4">+ <h3 class="text-xs font-medium text-ink">{props.title}</h3>+ <p class="mt-0.5 text-xs text-ink-muted">{props.description}</p>+ <div class="mt-2">{props.children}</div>+ </section>+ );+}+function slugAgentTag(value: string): string {return value.toLowerCase()diff --git a/apps/web/src/features/settings/CursorConnectPage.test.tsx b/apps/web/src/features/settings/CursorConnectPage.test.tsxnew file mode 100644index 0000000000..38b33dbf77--- /dev/null+++ b/apps/web/src/features/settings/CursorConnectPage.test.tsx@@ -0,0 +1,160 @@+/**+ * @vitest-environment jsdom+ */++import { fireEvent, render, screen, waitFor } from '@solidjs/testing-library';+import { beforeAll, beforeEach, describe, expect, it, vi } from 'vitest';+import { CursorConnectPage } from './CursorConnectPage';+import { chooseSelectOption } from './tests/select-helpers';++vi.mock('@ui', async (importOriginal) => ({+ ...(await importOriginal<typeof import('@ui')>()),+ confirmDialog: vi.fn(async () => true),+}));++const mocks = vi.hoisted(() => ({+ status: {+ isSuccess: true,+ isError: false,+ isPlaceholderData: false,+ data: {+ registered: false,+ defaultModelId: null as string | null,+ updatedAt: null as string | null,+ },+ },+ models: {+ data: {+ status: 'available' as const,+ currentModel: 'default-model',+ models: [+ { id: 'default-model', name: 'Default Model' },+ { id: 'composer', name: 'Composer' },+ ],+ },+ isPending: false,+ isError: false,+ isSuccess: true,+ refetch: vi.fn(),+ },+ save: vi.fn(),+ disconnect: vi.fn(),+ setDefaultModel: vi.fn(),+ toastSuccess: vi.fn(),+ toastFailure: vi.fn(),+}));++vi.mock('@queries/auth/cursor-api-key', () => ({+ useCursorApiKeyStatusQuery: () => mocks.status,+ useSaveCursorApiKey: () => ({ mutateAsync: mocks.save, isPending: false }),+ useDisconnectCursorApiKey: () => ({+ mutateAsync: mocks.disconnect,+ isPending: false,+ }),+ useSetCursorDefaultModel: () => ({+ mutateAsync: mocks.setDefaultModel,+ isPending: false,+ }),+}));++vi.mock('@queries/agents/models', () => ({+ useAgentModelsQuery: () => mocks.models,+}));++vi.mock('@core/component/Toast/Toast', () => ({+ toast: { success: mocks.toastSuccess, failure: mocks.toastFailure },+}));++beforeAll(() => {+ vi.stubGlobal('scrollTo', vi.fn());+});++beforeEach(() => {+ vi.clearAllMocks();+ mocks.status.isSuccess = true;+ mocks.status.isError = false;+ mocks.status.isPlaceholderData = false;+ mocks.status.data = {+ registered: false,+ defaultModelId: null,+ updatedAt: null,+ };+ mocks.save.mockResolvedValue(undefined);+ mocks.disconnect.mockResolvedValue(undefined);+ mocks.setDefaultModel.mockResolvedValue(undefined);+});++describe('CursorConnectPage', () => {+ it('guides a new connection: where to get the key, paste it, connect', async () => {+ render(() => <CursorConnectPage onClose={vi.fn()} />);++ expect(+ screen.getByRole('heading', { name: 'Connect Cursor' })+ ).toBeTruthy();+ expect(+ screen.getByRole('img', { name: /API & SSH Keys selected/ })+ ).toBeTruthy();+ expect(+ screen.getByRole('link', { name: /Open API & SSH Keys/ })+ ).toHaveProperty('href', 'https://cursor.com/dashboard/api');+ expect(screen.getByText('Available once Cursor is connected')).toBeTruthy();++ const apiKey = screen.getByLabelText('API key');+ await waitFor(() => expect(document.activeElement).toBe(apiKey));+ expect(apiKey).toHaveProperty('type', 'password');++ const connect = screen.getByRole('button', { name: 'Connect Cursor' });+ expect(connect).toHaveProperty('disabled', true);++ fireEvent.input(apiKey, { target: { value: 'not-a-cursor-key' } });+ fireEvent.click(connect);+ expect(mocks.save).not.toHaveBeenCalled();+ expect(mocks.toastFailure).toHaveBeenCalledWith(+ 'Cursor API keys start with grok_ or crsr_'+ );++ fireEvent.input(apiKey, { target: { value: ' grok_example ' } });+ fireEvent.click(connect);+ await waitFor(() => {+ expect(mocks.save).toHaveBeenCalledWith('grok_example');+ expect(mocks.toastSuccess).toHaveBeenCalledWith('Cursor connected');+ });+ });++ it('does not flash the key field while the connection status loads', () => {+ mocks.status.isPlaceholderData = true;+ render(() => <CursorConnectPage onClose={vi.fn()} />);++ expect(screen.queryByLabelText('API key')).toBeNull();+ expect(screen.getByText('Loading…')).toBeTruthy();+ });++ it('manages a connected Cursor: default model, disconnect, done', async () => {+ mocks.status.data = {+ registered: true,+ defaultModelId: null,+ updatedAt: '2026-08-27T12:00:00Z',+ };+ const onClose = vi.fn();+ render(() => <CursorConnectPage onClose={onClose} />);++ expect(screen.getByRole('heading', { name: 'Cursor' })).toBeTruthy();+ expect(screen.getByText('Connected')).toBeTruthy();+ expect(screen.queryByLabelText('API key')).toBeNull();++ chooseSelectOption(screen.getByLabelText('Default model'), 'Composer');+ await waitFor(() => {+ expect(mocks.setDefaultModel).toHaveBeenCalledWith('composer');+ expect(mocks.toastSuccess).toHaveBeenCalledWith('Default model updated');+ });++ fireEvent.click(screen.getByRole('button', { name: 'Disconnect' }));+ await waitFor(() => {+ expect(mocks.disconnect).toHaveBeenCalledOnce();+ expect(mocks.toastSuccess).toHaveBeenCalledWith('Cursor disconnected');+ });++ fireEvent.click(screen.getByRole('button', { name: 'Done' }));+ expect(onClose).toHaveBeenCalledOnce();+ });+});diff --git a/apps/web/src/features/settings/CursorConnectPage.tsx b/apps/web/src/features/settings/CursorConnectPage.tsxnew file mode 100644index 0000000000..414daa1c7d--- /dev/null+++ b/apps/web/src/features/settings/CursorConnectPage.tsx@@ -0,0 +1,267 @@+import { toast } from '@core/component/Toast/Toast';+import { ThrownResultError } from '@core/util/result';+import ArrowLeftIcon from '@phosphor/arrow-left.svg';+import {+ useCursorApiKeyStatusQuery,+ useDisconnectCursorApiKey,+ useSaveCursorApiKey,+} from '@queries/auth/cursor-api-key';+import { Button, confirmDialog } from '@ui';+import { createSignal, Show } from 'solid-js';+import cursorApiKeysScreenshot from './assets/cursor-api-keys.png';+import { CursorDefaultModel } from './components/cursor-default-model';+import {+ SetupField,+ SetupLink,+ SetupStep,+} from './components/runtime-setup-steps';+import {+ CURSOR_KEY_FORMAT_ERROR,+ CURSOR_KEY_PLACEHOLDER,+ isCursorApiKey,+} from './core/cursor-api-key';+import { SettingsPage, SettingsSurface } from './primitives';++const CURSOR_API_KEYS_URL = 'https://cursor.com/dashboard/api';++function failureMessage(error: unknown, fallback: string): string {+ return (error instanceof ThrownResultError && error.message) || fallback;+}++/**+ * Guided Cursor connection: where to create the key, a field to paste it, and+ * the default model once Cursor answers. Also the manage page once connected.+ */+export function CursorConnectPage(props: { onClose: () => void }) {+ const status = useCursorApiKeyStatusQuery();+ const saveKey = useSaveCursorApiKey();+ const disconnect = useDisconnectCursorApiKey();+ const [apiKey, setApiKey] = createSignal('');+ const loaded = () => status.isSuccess && !status.isPlaceholderData;+ const connected = () =>+ status.isSuccess && !status.isPlaceholderData+ ? status.data.registered+ : false;+ // The field mounts once status loads; focus it then, without scrolling the+ // guide's first step out of view.+ const focusOnMount = (input: HTMLInputElement) =>+ queueMicrotask(() => input.focus({ preventScroll: true }));++ const connect = async () => {+ const key = apiKey().trim();+ if (!key || saveKey.isPending) return;+ if (!isCursorApiKey(key)) {+ toast.failure(CURSOR_KEY_FORMAT_ERROR);+ return;+ }+ try {+ await saveKey.mutateAsync(key);+ setApiKey('');+ toast.success('Cursor connected');+ } catch (error) {+ toast.failure(+ failureMessage(error, 'Failed to save your Cursor API key')+ );+ }+ };++ const disconnectCursor = async () => {+ if (disconnect.isPending) return;+ const confirmed = await confirmDialog({+ title: 'Disconnect Cursor?',+ body: "Remove your Cursor connection from Macro? This removes Macro's copy of the API key but does not revoke it in Cursor.",+ confirmLabel: 'Disconnect',+ tone: 'danger',+ });+ if (!confirmed || disconnect.isPending) return;+ try {+ await disconnect.mutateAsync();+ toast.success('Cursor disconnected');+ } catch (error) {+ toast.failure(failureMessage(error, 'Failed to disconnect Cursor'));+ }+ };++ return (+ <SettingsPage+ title={connected() ? 'Cursor' : 'Connect Cursor'}+ showTitleInSheet+ description="Run agents on your own Cursor subscription. Sessions run in Cursor Cloud and stream into Macro."+ actions={+ <Button variant="ghost" size="sm" onClick={props.onClose}>+ <ArrowLeftIcon />+ Back+ </Button>+ }+ >+ <section aria-label="Connect Cursor">+ <SettingsSurface class="@container p-6">+ <form+ onSubmit={(event) => {+ event.preventDefault();+ void connect();+ }}+ >+ <ol aria-label="Cursor setup steps" class="list-none">+ <SetupStep number={1} title="Create an API key in Cursor">+ <p>+ In the Cursor dashboard, open{' '}+ <span class="font-medium text-ink">API & SSH Keys</span>{' '}+ and click{' '}+ <span class="font-medium text-ink">New API Key</span>.+ </p>+ <img+ src={cursorApiKeysScreenshot}+ alt="Cursor dashboard with API & SSH Keys selected and the New API Key button"+ width={1200}+ height={145}+ class="block h-auto w-full rounded-[10px] border border-ink/10"+ />+ <SetupLink href={CURSOR_API_KEYS_URL}>+ Open API & SSH Keys+ </SetupLink>+ </SetupStep>+ <SetupStep number={2} title="Paste your API key">+ <p>+ Macro stores it encrypted and only uses it to start and follow+ your Cursor sessions.+ </p>+ <Show+ when={loaded()}+ fallback={+ <p class="text-xs">+ {status.isError+ ? 'Could not load your Cursor connection. Try refreshing this page.'+ : 'Loading…'}+ </p>+ }+ >+ <Show+ when={connected()}+ fallback={+ <div class="flex flex-col gap-1.5">+ <label+ for="cursor-api-key"+ class="text-xs font-medium text-ink"+ >+ API key+ </label>+ <SetupField>+ <input+ ref={focusOnMount}+ id="cursor-api-key"+ type="password"+ autocomplete="off"+ spellcheck={false}+ aria-describedby="cursor-api-key-help"+ class="ph-no-capture min-w-0 flex-1 bg-transparent font-mono text-sm text-ink outline-none"+ placeholder={CURSOR_KEY_PLACEHOLDER}+ value={apiKey()}+ disabled={saveKey.isPending}+ onInput={(event) =>+ setApiKey(event.currentTarget.value)+ }+ />+ </SetupField>+ <p+ id="cursor-api-key-help"+ class="text-xs text-ink-extra-muted"+ >+ You can remove the key at any time from this page.+ </p>+ </div>+ }+ >+ <div class="flex flex-wrap items-center gap-3">+ <span class="inline-flex h-5 shrink-0 items-center whitespace-nowrap rounded-md bg-success-bg px-2 text-[11px]/none font-medium text-success">+ Connected+ </span>+ <Show when={status.data?.updatedAt}>+ {(updatedAt) => (+ <span class="text-xs text-ink-muted">+ Key saved{' '}+ {new Date(updatedAt()).toLocaleDateString()}+ </span>+ )}+ </Show>+ <Button+ type="button"+ variant="ghost"+ size="sm"+ class="ml-auto text-negative"+ disabled={disconnect.isPending}+ onClick={() => void disconnectCursor()}+ >+ Disconnect+ </Button>+ </div>+ </Show>+ </Show>+ </SetupStep>+ <SetupStep number={3} title="Choose default model">+ <p>+ New Cursor agents start with this model. You can change it per+ agent.+ </p>+ <div class="flex flex-col gap-1.5">+ <span class="text-xs font-medium text-ink">+ Default model+ </span>+ <Show+ when={connected()}+ fallback={+ <SetupField class="text-sm text-ink-muted">+ <span aria-disabled="true">+ Available once Cursor is connected+ </span>+ </SetupField>+ }+ >+ <CursorDefaultModel triggerClass="flex w-full items-center justify-between gap-2 rounded-lg border border-edge-muted bg-ink/[0.025] px-3 py-2 text-left text-sm text-ink outline-none transition-colors hover:border-ink/20 focus-visible:border-accent data-expanded:border-accent" />+ </Show>+ <p class="text-xs text-ink-extra-muted">+ Used when an agent doesn’t pick its own.+ </p>+ </div>+ </SetupStep>+ </ol>+ <div class="mt-6 flex justify-end gap-2 border-t border-edge-muted pt-4">+ <Show+ when={connected()}+ fallback={+ <>+ <Button+ type="button"+ variant="ghost"+ size="sm"+ onClick={props.onClose}+ >+ Cancel+ </Button>+ <Button+ type="submit"+ variant="cta"+ size="sm"+ disabled={!apiKey().trim() || saveKey.isPending}+ >+ {saveKey.isPending ? 'Connecting…' : 'Connect Cursor'}+ </Button>+ </>+ }+ >+ <Button+ type="button"+ variant="cta"+ size="sm"+ onClick={props.onClose}+ >+ Done+ </Button>+ </Show>+ </div>+ </form>+ </SettingsSurface>+ </section>+ </SettingsPage>+ );+}diff --git a/apps/web/src/features/settings/Harness.test.tsx b/apps/web/src/features/settings/Harness.test.tsxindex 5b5f74ac56..911493c7cc 100644--- a/apps/web/src/features/settings/Harness.test.tsx+++ b/apps/web/src/features/settings/Harness.test.tsx@@ -325,9 +325,6 @@ describe('Harness', () => {claude.compareDocumentPosition(cursor) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();expect(screen.getByLabelText('Anthropic')).toBeTruthy();- expect(- screen.getByRole('heading', { name: 'Bring your agent to Macro' })- ).toBeTruthy();expect(screen.getByText(/Uses official Macro tools and MCPs to get the job done/)).toBeTruthy();@@ -414,7 +411,7 @@ describe('Harness', () => {expect(screen.queryByLabelText('API key')).toBeNull();});- it('hides the empty paired runtimes section and keeps the setup guide', () => {+ it('hides the empty paired runtimes section', () => {render(() => <Harness />);expect(screen.queryByText('No paired runtimes yet')).toBeNull();@@ -424,28 +421,24 @@ describe('Harness', () => {expect(screen.queryByRole('button', { name: 'Enter pairing code' })).toBeNull();- expect(screen.getByRole('link', { name: /Setup guide/ })).toHaveProperty(- 'href',- 'https://docs.macro.com/AI/bring-your-own'- );});- it('opens pairing from the bring-your-own card', () => {+ it('opens pairing from New runtime and returns to the runtimes list', () => {render(() => <Harness />);- expect(screen.getAllByRole('button', { name: 'New runtime' })).toHaveLength(- 2- );- const card = screen- .getByRole('heading', { name: 'Bring your agent to Macro' })- .closest('section')!;- fireEvent.click(within(card).getByRole('button', { name: 'New runtime' }));+ fireEvent.click(screen.getByRole('button', { name: 'New runtime' }));expect(screen.getByRole('region', { name: 'New runtime' })).toBeTruthy();expect(screen.queryByRole('dialog')).toBeNull();fireEvent.click(screen.getByRole('button', { name: 'Cancel' }));- expect(- screen.getByRole('heading', { name: 'Bring your agent to Macro' })- ).toBeTruthy();+ expect(screen.getByRole('heading', { name: 'Runtimes' })).toBeTruthy();+ });++ it('goes back to Agents from the runtimes page', () => {+ const onBack = vi.fn();+ render(() => <Harness onBack={onBack} />);++ fireEvent.click(screen.getByRole('button', { name: 'Agents' }));+ expect(onBack).toHaveBeenCalledOnce();});it('renders a registered harness row', () => {diff --git a/apps/web/src/features/settings/Harness.tsx b/apps/web/src/features/settings/Harness.tsxindex 68b946f189..d9a94d7e4b 100644--- a/apps/web/src/features/settings/Harness.tsx+++ b/apps/web/src/features/settings/Harness.tsx@@ -1,19 +1,15 @@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';import { MACRO_HARNESS_NAME } from '@core/constant/macroAgent';import { ThrownResultError } from '@core/util/result';import CursorIcon from '@icon/wide-cursor-ide.svg';import HardDrivesIcon from '@phosphor/hard-drives.svg';import PlusIcon from '@phosphor/plus.svg';-import { useAgentModelsQuery } from '@queries/agents/models';import {useCursorApiKeyStatusQuery,useDisconnectCursorApiKey,useSaveCursorApiKey,- useSetCursorDefaultModel,} from '@queries/auth/cursor-api-key';import {useDeleteHarnessMutation,@@ -22,19 +18,19 @@ import {import type { Harness as RegisteredHarness } from '@service-storage/client';import { useSearchParams } from '@solidjs/router';import { Button, confirmDialog, Dialog, Panel } from '@ui';-import { createSignal, For, type JSX, onMount, Show } from 'solid-js';+import { createSignal, For, onMount, Show } from 'solid-js';import { ClaudeConnection } from '../claude-connection/claude-connection';import { CodexHarness } from './codex/views/CodexHarness';-import { AgentSettingsDescription } from './components/agent-settings-description';-import { BringYourOwnAgent } from './components/bring-your-own-agent';-import { SettingsSelect } from './components/settings-select';+import { CursorDefaultModel } from './components/cursor-default-model';+import {+ CURSOR_KEY_FORMAT_ERROR,+ CURSOR_KEY_PLACEHOLDER,+ isCursorApiKey,+} from './core/cursor-api-key';import { ConnectAction, HarnessIcon, StatusDot } from './integration-ui';import { SettingsCard, SettingsPage } from './primitives';import { RuntimePairingPage } from './RuntimePairingPage';-// Cursor now mints `grok_` keys; the `crsr_` keys minted before that still work.-const CURSOR_KEY_PREFIXES = ['grok_', 'crsr_'];-function failureMessage(error: unknown, fallback: string): string {return (error instanceof ThrownResultError && error.message) || fallback;}@@ -46,9 +42,7 @@ function lastConnectedText(harness: RegisteredHarness): string {}/** Settings UI for choosing and configuring the available agent harnesses. */-export function Harness(- props: { navigation?: JSX.Element; startPairing?: boolean } = {}-) {+export function Harness(props: { onBack?: () => void } = {}) {const canUseClaude = useClaudeAgentsAccess();const canUseCodex = useCodexAgentsAccess();const [cursorApiKey, setCursorApiKey] = createSignal('');@@ -64,7 +58,7 @@ export function Harness(initialCode?: string;}| undefined- >(props.startPairing ? {} : undefined);+ >(undefined);const closePairing = () => {setPairingDialog(undefined);};@@ -93,58 +87,10 @@ export function Harness(}};- const cursorModels = useAgentModelsQuery(- () => ({ harness: 'cursor' }),- cursorRegistered- );- const cursorModelData = () =>- cursorModels.isSuccess ? cursorModels.data : undefined;- const cursorModelOptions = () => {- const data = cursorModelData();- if (data?.status !== 'available') return [];- const saved = cursorStatus.data?.defaultModelId;- if (!saved || data.models.some((model) => model.id === saved)) {- return data.models;- }- return [- ...data.models,- {- id: saved,- name: `${saved} (saved, unavailable)`,- description: undefined,- group: undefined,- },- ];- };- const setCursorDefaultModel = useSetCursorDefaultModel();- const cursorCatalogOptions = () =>- cursorModelOptions().map((model) => ({- id: model.id,- label: model.name,- description: model.description ?? undefined,- group: model.group ?? undefined,- }));- const selectedCursorModelId = () =>- (cursorStatus.isSuccess ? cursorStatus.data.defaultModelId : null) ??- cursorModelData()?.currentModel ??- cursorModelOptions()[0]?.id ??- null;-- const handleCursorModelChange = async (modelId: string) => {- try {- await setCursorDefaultModel.mutateAsync(modelId);- toast.success('Default model updated');- } catch (error) {- toast.failure(failureMessage(error, 'Failed to set your default model'));- }- };-const handleSaveCursorApiKey = async () => {const apiKey = cursorApiKey().trim();- if (!CURSOR_KEY_PREFIXES.some((prefix) => apiKey.startsWith(prefix))) {- toast.failure(- `Cursor API keys start with ${CURSOR_KEY_PREFIXES.join(' or ')}`- );+ if (!isCursorApiKey(apiKey)) {+ toast.failure(CURSOR_KEY_FORMAT_ERROR);return;}@@ -181,8 +127,10 @@ export function Harness(<><Show when={!pairingDialog()}><SettingsPage- title={props.navigation ? 'Agents' : 'Runtimes'}- description={<AgentSettingsDescription />}+ title="Runtimes"+ description="Providers and machines your agents can run on."+ onBack={props.onBack}+ backLabel="Agents"actions={<Buttonvariant="cta"@@ -194,8 +142,6 @@ export function Harness(</Button>}>- <BringYourOwnAgent onAddRuntime={() => setPairingDialog({})} />- {props.navigation}<div><h2 class="mb-3 px-6 text-sm font-semibold text-ink">Built-in runtimes@@ -274,7 +220,7 @@ export function Harness(autocomplete="off"spellcheck={false}class="settings-input ph-no-capture min-w-0 flex-1"- placeholder="grok_…"+ placeholder={CURSOR_KEY_PLACEHOLDER}value={cursorApiKey()}onInput={(event) =>setCursorApiKey(event.currentTarget.value)@@ -311,77 +257,7 @@ export function Harness(<span class="text-xs font-medium text-ink">Default model</span>- <Show- when={!cursorModels.isPending}- fallback={- <SettingsSelect- label="Default model"- options={[]}- placeholder="Loading models…"- onChange={(id) =>- void handleCursorModelChange(id)- }- disabled- />- }- >- <Show- when={!cursorModels.isError}- fallback={- <div class="flex items-center gap-2">- <p class="text-xs text-negative">- Could not load Cursor models.- </p>- <Button- type="button"- variant="outline"- size="sm"- onClick={() => void cursorModels.refetch()}- >- Retry- </Button>- </div>- }- >- <Show- when={cursorModelData()?.status === 'available'}- fallback={- <p class="text-xs text-ink-muted">- Cursor does not support model selection.- </p>- }- >- <Show- when={isLargeModelCatalog(- cursorCatalogOptions()- )}- fallback={- <SettingsSelect- label="Default model"- options={cursorModelOptions()}- value={selectedCursorModelId()}- disabled={setCursorDefaultModel.isPending}- onChange={(id) =>- void handleCursorModelChange(id)- }- />- }- >- <ModelCatalogPicker- value={selectedCursorModelId()}- options={cursorCatalogOptions()}- onSelect={(id) =>- void handleCursorModelChange(id)- }- disabled={setCursorDefaultModel.isPending}- ariaLabel="Default model"- triggerClass="h-9 w-full justify-between text-base [&>span]:flex-1"- placement="bottom-start"- />- </Show>- </Show>- </Show>- </Show>+ <CursorDefaultModel /></div><p class="text-xs text-ink-extra-muted">The model new `@cursor` sessions start on. Recommendeddiff --git a/apps/web/src/features/settings/assets/cursor-api-keys.png b/apps/web/src/features/settings/assets/cursor-api-keys.pngnew file mode 100644index 0000000000..6f8fe13184Binary files /dev/null and b/apps/web/src/features/settings/assets/cursor-api-keys.png differdiff --git a/apps/web/src/features/settings/components/agent-management-navigation.tsx b/apps/web/src/features/settings/components/agent-management-navigation.tsxdeleted file mode 100644index 3420a3db5d..0000000000--- a/apps/web/src/features/settings/components/agent-management-navigation.tsx+++ /dev/null@@ -1,40 +0,0 @@-import { AGENTS_TOUR } from '@app/features/agents-view/tour';-import HardDrivesIcon from '@phosphor/hard-drives.svg';-import SparkleIcon from '@phosphor/sparkle.svg';-import { tourTarget } from '@ui/components/Tour';--export type AgentManagementSection = 'agents' | 'runtimes';--/** Section navigation shared by settings and the Agents workspace. */-export function AgentManagementNavigation(props: {- section: AgentManagementSection;- onChange: (section: AgentManagementSection) => void;-}) {- const agentsTab = tourTarget(AGENTS_TOUR.agentsTab);- const runtimesTab = tourTarget(AGENTS_TOUR.runtimesTab);- return (- <nav- aria-label="Agent management"- class="flex gap-1 border-b border-edge-muted"- >- <button- type="button"- ref={agentsTab}- aria-current={props.section === 'agents' ? 'page' : undefined}- onClick={() => props.onChange('agents')}- class="flex items-center gap-2 border-b-2 border-transparent px-4 py-3 text-sm text-ink-muted aria-[current=page]:border-accent aria-[current=page]:text-ink hover:text-ink focus-visible:outline-accent"- >- <SparkleIcon class="size-4" /> Agents- </button>- <button- type="button"- ref={runtimesTab}- aria-current={props.section === 'runtimes' ? 'page' : undefined}- onClick={() => props.onChange('runtimes')}- class="flex items-center gap-2 border-b-2 border-transparent px-4 py-3 text-sm text-ink-muted aria-[current=page]:border-accent aria-[current=page]:text-ink hover:text-ink focus-visible:outline-accent"- >- <HardDrivesIcon class="size-4" /> Runtimes- </button>- </nav>- );-}diff --git a/apps/web/src/features/settings/components/agent-settings-description.tsx b/apps/web/src/features/settings/components/agent-settings-description.tsxdeleted file mode 100644index b90ed223c7..0000000000--- a/apps/web/src/features/settings/components/agent-settings-description.tsx+++ /dev/null@@ -1,16 +0,0 @@-/** Shared explanation of agents and runtimes, kept as plain header copy. */-export function AgentSettingsDescription() {- return (- <>- <span class="block leading-relaxed">- Agents let you customize your Macro AI experience by combining a unique- name, specific instructions, default model, and harness.- </span>- <span class="mt-2 block leading-relaxed">- Runtimes are the harnesses that power agents in macro, whether our- native, fast, Macro AI harness, or coding harnesses like Cursor or your- own Claude Code.- </span>- </>- );-}diff --git a/apps/web/src/features/settings/components/agent-setup-strips.tsx b/apps/web/src/features/settings/components/agent-setup-strips.tsxnew file mode 100644index 0000000000..78eb787c5f--- /dev/null+++ b/apps/web/src/features/settings/components/agent-setup-strips.tsx@@ -0,0 +1,117 @@+import { AGENTS_TOUR } from '@app/features/agents-view/tour';+import CursorIcon from '@icon/wide-cursor-ide.svg';+import TerminalIcon from '@phosphor/terminal-window.svg';+import { useCursorApiKeyStatusQuery } from '@queries/auth/cursor-api-key';+import { useHarnessesQuery } from '@queries/harnesses/harnesses';+import { Button } from '@ui';+import { tourTarget } from '@ui/components/Tour';+import { type JSX, Show } from 'solid-js';+import { HarnessIcon } from '../integration-ui';+import { SettingsSurface } from '../primitives';++function SetupStrip(props: {+ icon: JSX.Element;+ title: string;+ /** What the action acts on, for its accessible name. */+ subject: string;+ description: string;+ status?: string;+ action: string;+ onAction: () => void;+}) {+ return (+ <SettingsSurface class="flex items-center gap-3.5 py-3 pr-4 pl-3.5">+ <HarnessIcon>{props.icon}</HarnessIcon>+ <div class="min-w-0 flex-1">+ <h3 class="text-sm font-medium text-ink">{props.title}</h3>+ <p class="mt-0.5 text-xs text-ink-muted">{props.description}</p>+ </div>+ <div class="flex shrink-0 items-center gap-2">+ <Show when={props.status}>+ {(status) => (+ <span class="inline-flex h-5 items-center whitespace-nowrap rounded-md bg-success-bg px-2 text-[11px]/none font-medium text-success">+ {status()}+ </span>+ )}+ </Show>+ <Button+ type="button"+ variant="ghost"+ size="sm"+ class="text-ink"+ aria-label={`${props.action} ${props.subject}`}+ onClick={props.onAction}+ >+ {props.action}+ </Button>+ </div>+ </SettingsSurface>+ );+}++/** Where agents can run besides Macro: Cursor, and your own paired machines. */+export function AgentSetupStrips(props: {+ onCursor: () => void;+ onSetUpRuntime: () => void;+ onManageRuntimes: () => void;+}) {+ const cursorStatus = useCursorApiKeyStatusQuery();+ const harnesses = useHarnessesQuery();+ const cursorConnected = () =>+ cursorStatus.isSuccess ? cursorStatus.data.registered : false;+ const paired = () => (harnesses.isSuccess ? harnesses.data : []);+ const setup = tourTarget(AGENTS_TOUR.agentSetup);++ return (+ <section ref={setup} aria-label="Agent setup" class="flex flex-col gap-3">+ <Show+ when={cursorConnected()}+ fallback={+ <SetupStrip+ icon={<CursorIcon />}+ title="Connect Cursor"+ subject="Cursor"+ description="Use your Cursor subscription to run agents in Macro."+ action="Connect"+ onAction={props.onCursor}+ />+ }+ >+ <SetupStrip+ icon={<CursorIcon />}+ title="Cursor"+ subject="Cursor"+ description="Runs on your Cursor plan."+ status="Connected"+ action="Manage"+ onAction={props.onCursor}+ />+ </Show>+ <Show+ when={paired().length > 0}+ fallback={+ <SetupStrip+ icon={<TerminalIcon />}+ title="Bring your own agent"+ subject="your own agent"+ description="Pair Claude Code, Codex, or another local agent with macrod."+ action="Set up"+ onAction={props.onSetUpRuntime}+ />+ }+ >+ <SetupStrip+ icon={<TerminalIcon />}+ title="Bring your own agent"+ subject="paired runtimes"+ description={paired()+ .map((harness) => harness.name)+ .join(', ')}+ status="Paired"+ action="Manage"+ onAction={props.onManageRuntimes}+ />+ </Show>+ </section>+ );+}diff --git a/apps/web/src/features/settings/components/bring-your-own-agent.css b/apps/web/src/features/settings/components/bring-your-own-agent.cssdeleted file mode 100644index 3dc18e707d..0000000000--- a/apps/web/src/features/settings/components/bring-your-own-agent.css+++ /dev/null@@ -1,23 +0,0 @@-.byoa-word {- display: inline-grid;- overflow: hidden;- vertical-align: bottom;-}--.byoa-word > span {- grid-area: 1 / 1;- opacity: 0;- animation: byoa-word-cycle 11s infinite;- animation-delay: calc(var(--word-index) * 2.75s);-}--@keyframes byoa-word-cycle {- 0% { opacity: 0; transform: translateY(55%); }- 3%, 21% { opacity: 1; transform: translateY(0); }- 25%, 100% { opacity: 0; transform: translateY(-55%); }-}--@media (prefers-reduced-motion: reduce) {- .byoa-word > span { animation: none; }- .byoa-word > span:first-child { opacity: 1; }-}diff --git a/apps/web/src/features/settings/components/bring-your-own-agent.tsx b/apps/web/src/features/settings/components/bring-your-own-agent.tsxdeleted file mode 100644index 6b1d6c918f..0000000000--- a/apps/web/src/features/settings/components/bring-your-own-agent.tsx+++ /dev/null@@ -1,58 +0,0 @@-import ArrowUpRightIcon from '@phosphor/arrow-up-right.svg';-import PlusIcon from '@phosphor/plus.svg';-import TerminalIcon from '@phosphor/terminal-window.svg';-import { Button } from '@ui';-import { For } from 'solid-js';-import './bring-your-own-agent.css';-import { SettingsSurface } from '../primitives';--const AGENTS = ['Claude Code', 'OpenCode', 'OpenClaw', 'Hermes'];--/** A quiet, CSS-only word rotation; reduced motion shows a static invitation. */-export function BringYourOwnAgent(props: { onAddRuntime: () => void }) {- return (- <section>- <SettingsSurface class="byoa-card relative overflow-hidden p-6">- <div class="mb-5 flex items-center gap-2 text-xs font-medium text-ink-muted">- <TerminalIcon class="size-4" />- Bring your own agent- </div>- <h2 class="text-xl font-medium tracking-tight text-ink">- <span class="sr-only">Bring your agent to Macro</span>- <span- aria-hidden="true"- class="flex flex-wrap items-baseline gap-x-1.5"- >- Bring- <span class="byoa-word text-center text-accent">- <For each={AGENTS}>- {(agent, index) => (- <span style={{ '--word-index': index() }}>{agent}</span>- )}- </For>- </span>- to Macro.- </span>- </h2>- <p class="mt-3 max-w-lg text-sm leading-relaxed text-ink-muted">- Your agent, on your machine. Connect a runtime with macrod, then give- your agent instructions and a place in your workspace.- </p>- <div class="mt-5 flex flex-wrap items-center gap-3">- <Button variant="outline" size="sm" onClick={props.onAddRuntime}>- <PlusIcon />- New runtime- </Button>- <a- href="https://docs.macro.com/AI/bring-your-own"- target="_blank"- rel="noopener noreferrer"- class="inline-flex items-center gap-1 text-xs text-ink-muted hover:text-ink focus-visible:outline-accent"- >- Setup guide <ArrowUpRightIcon class="size-3" />- </a>- </div>- </SettingsSurface>- </section>- );-}diff --git a/apps/web/src/features/settings/components/cursor-default-model.tsx b/apps/web/src/features/settings/components/cursor-default-model.tsxnew file mode 100644index 0000000000..b9f05c2aae--- /dev/null+++ b/apps/web/src/features/settings/components/cursor-default-model.tsx@@ -0,0 +1,139 @@+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';+import { ThrownResultError } from '@core/util/result';+import { useAgentModelsQuery } from '@queries/agents/models';+import {+ useCursorApiKeyStatusQuery,+ useSetCursorDefaultModel,+} from '@queries/auth/cursor-api-key';+import { Button } from '@ui';+import { Show } from 'solid-js';+import { SettingsSelect } from './settings-select';++/**+ * The model new Cursor sessions start on. Saves on change; renders loading,+ * error, and unsupported states in place of the picker.+ */+export function CursorDefaultModel(props: { triggerClass?: string }) {+ const cursorStatus = useCursorApiKeyStatusQuery();+ const registered = () =>+ cursorStatus.isSuccess ? cursorStatus.data.registered : false;+ const cursorModels = useAgentModelsQuery(+ () => ({ harness: 'cursor' }),+ registered+ );+ const setDefaultModel = useSetCursorDefaultModel();+ const modelData = () =>+ cursorModels.isSuccess ? cursorModels.data : undefined;+ const modelOptions = () => {+ const data = modelData();+ if (data?.status !== 'available') return [];+ const saved = cursorStatus.data?.defaultModelId;+ if (!saved || data.models.some((model) => model.id === saved)) {+ return data.models;+ }+ return [+ ...data.models,+ {+ id: saved,+ name: `${saved} (saved, unavailable)`,+ description: undefined,+ group: undefined,+ },+ ];+ };+ const catalogOptions = () =>+ modelOptions().map((model) => ({+ id: model.id,+ label: model.name,+ description: model.description ?? undefined,+ group: model.group ?? undefined,+ }));+ const selectedModelId = () =>+ (cursorStatus.isSuccess ? cursorStatus.data.defaultModelId : null) ??+ modelData()?.currentModel ??+ modelOptions()[0]?.id ??+ null;++ const changeModel = async (modelId: string) => {+ try {+ await setDefaultModel.mutateAsync(modelId);+ toast.success('Default model updated');+ } catch (error) {+ toast.failure(+ (error instanceof ThrownResultError && error.message) ||+ 'Failed to set your default model'+ );+ }+ };++ return (+ <Show+ when={!cursorModels.isPending}+ fallback={+ <SettingsSelect+ label="Default model"+ options={[]}+ placeholder="Loading models…"+ triggerClass={props.triggerClass}+ onChange={(id) => void changeModel(id)}+ disabled+ />+ }+ >+ <Show+ when={!cursorModels.isError}+ fallback={+ <div class="flex items-center gap-2">+ <p class="text-xs text-negative">Could not load Cursor models.</p>+ <Button+ type="button"+ variant="outline"+ size="sm"+ onClick={() => void cursorModels.refetch()}+ >+ Retry+ </Button>+ </div>+ }+ >+ <Show+ when={modelData()?.status === 'available'}+ fallback={+ <p class="text-xs text-ink-muted">+ Cursor does not support model selection.+ </p>+ }+ >+ <Show+ when={isLargeModelCatalog(catalogOptions())}+ fallback={+ <SettingsSelect+ label="Default model"+ options={modelOptions()}+ value={selectedModelId()}+ triggerClass={props.triggerClass}+ disabled={setDefaultModel.isPending}+ onChange={(id) => void changeModel(id)}+ />+ }+ >+ <ModelCatalogPicker+ value={selectedModelId()}+ options={catalogOptions()}+ onSelect={(id) => void changeModel(id)}+ disabled={setDefaultModel.isPending}+ ariaLabel="Default model"+ triggerClass={+ props.triggerClass ??+ 'h-9 w-full justify-between text-base [&>span]:flex-1'+ }+ placement="bottom-start"+ />+ </Show>+ </Show>+ </Show>+ </Show>+ );+}diff --git a/apps/web/src/features/settings/components/runtime-setup-steps.tsx b/apps/web/src/features/settings/components/runtime-setup-steps.tsxindex 7ad8c1c595..b3ce35fe50 100644--- a/apps/web/src/features/settings/components/runtime-setup-steps.tsx+++ b/apps/web/src/features/settings/components/runtime-setup-steps.tsx@@ -1,7 +1,9 @@import ArrowUpRightIcon from '@phosphor/arrow-up-right.svg';+import { cn } from '@ui';import type { JSX } from 'solid-js';-function SetupStep(props: {+/** One numbered step in a connection guide; steps share a connecting rail. */+export function SetupStep(props: {number: number;title: string;children: JSX.Element;@@ -24,21 +26,43 @@ function SetupStep(props: {);}+/** An external link out of a setup step, e.g. to download or a dashboard. */+export function SetupLink(props: { href: string; children: JSX.Element }) {+ return (+ <a+ href={props.href}+ target="_blank"+ rel="noopener noreferrer"+ class="inline-flex w-fit items-center gap-1.5 rounded-lg border border-edge-muted px-3 py-2 text-xs font-medium text-ink hover:bg-ink/5 focus-visible:outline-accent"+ >+ {props.children} <ArrowUpRightIcon aria-hidden="true" class="size-3.5" />+ </a>+ );+}++/** The bordered box around a guide's input, matching the pairing-code field. */+export function SetupField(props: { class?: string; children: JSX.Element }) {+ return (+ <div+ class={cn(+ 'flex min-w-0 items-center gap-2 rounded-lg border border-edge-muted bg-ink/[0.025] px-3 py-2 transition-colors focus-within:border-accent',+ props.class+ )}+ >+ {props.children}+ </div>+ );+}+/** Installation instructions surrounding the live pairing-code form. */export function RuntimeSetupSteps(props: { children: JSX.Element }) {return (<ol aria-label="Runtime setup steps" class="list-none"><SetupStep number={1} title="Install macrod"><p>Download the macrod archive for your computer, then extract it.</p>- <a- href="https://github.com/macro-inc/macro/releases"- target="_blank"- rel="noopener noreferrer"- class="inline-flex w-fit items-center gap-1.5 rounded-lg border border-edge-muted px-3 py-2 text-xs font-medium text-ink hover:bg-ink/5 focus-visible:outline-accent"- >- Download macrod{' '}- <ArrowUpRightIcon aria-hidden="true" class="size-3.5" />- </a>+ <SetupLink href="https://github.com/macro-inc/macro/releases">+ Download macrod+ </SetupLink></SetupStep><SetupStep number={2} title="Run macrod"><p>Open a terminal in the extracted folder and run:</p>diff --git a/apps/web/src/features/settings/components/settings-select.tsx b/apps/web/src/features/settings/components/settings-select.tsxindex 19c953ab58..b663a9fde1 100644--- a/apps/web/src/features/settings/components/settings-select.tsx+++ b/apps/web/src/features/settings/components/settings-select.tsx@@ -11,6 +11,7 @@ export function SettingsSelect(props: {disabled?: boolean;placeholder?: string;class?: string;+ triggerClass?: string;}) {return (<Select<SettingsOption>@@ -24,7 +25,10 @@ export function SettingsSelect(props: {placeholder={props.placeholder}disallowEmptySelection>- <Select.Trigger aria-label={props.label} class="settings-input w-full">+ <Select.Trigger+ aria-label={props.label}+ class={props.triggerClass ?? 'settings-input w-full'}+ ><Select.Value<SettingsOption>>{(state) => state.selectedOption().name}</Select.Value>diff --git a/apps/web/src/features/settings/components/where-it-runs-option.tsx b/apps/web/src/features/settings/components/where-it-runs-option.tsxnew file mode 100644index 0000000000..579d1449b4--- /dev/null+++ b/apps/web/src/features/settings/components/where-it-runs-option.tsx@@ -0,0 +1,72 @@+import { cn } from '@ui';+import { type JSX, Show } from 'solid-js';++/**+ * One place an agent can run. The selected option opens its own settings+ * (harness, model) inside the card; an unavailable one offers its setup+ * action instead of a radio that cannot be chosen.+ */+export function WhereItRunsOption(props: {+ value: string;+ title: string;+ description: string;+ icon: JSX.Element;+ checked: boolean;+ disabled?: boolean;+ /** Shown beside an unavailable option, e.g. Connect or Set up. */+ action?: JSX.Element;+ onSelect: () => void;+ /** Settings for the selected option. */+ children?: JSX.Element;+}) {+ return (+ <div+ class={cn(+ 'min-w-0 rounded-lg border',+ props.checked ? 'border-accent bg-accent-bg' : 'border-edge-muted'+ )}+ >+ <div class="flex min-w-0 items-center gap-3 pr-3">+ <label+ class={cn(+ 'flex min-w-0 flex-1 items-center gap-3 p-3',+ props.disabled && 'opacity-75'+ )}+ >+ <input+ type="radio"+ name="agent-where"+ value={props.value}+ checked={props.checked}+ disabled={props.disabled}+ onChange={props.onSelect}+ aria-label={props.title}+ class="shrink-0 accent-accent disabled:opacity-40"+ />+ <span+ aria-hidden="true"+ class="flex size-7 shrink-0 items-center justify-center rounded-lg bg-ink/4 text-ink-muted [&_svg]:size-4"+ >+ {props.icon}+ </span>+ <span class="min-w-0">+ <span class="block text-sm font-medium text-ink">+ {props.title}+ </span>+ <span class="mt-0.5 block text-xs text-ink-muted">+ {props.description}+ </span>+ </span>+ </label>+ <Show when={props.action}>+ <div class="shrink-0">{props.action}</div>+ </Show>+ </div>+ <Show when={props.checked && props.children}>+ <div class="px-3 pb-3 @min-[440px]:pl-[52px]">+ <div class="border-t border-ink/8 pt-3">{props.children}</div>+ </div>+ </Show>+ </div>+ );+}diff --git a/apps/web/src/features/settings/core/cursor-api-key.ts b/apps/web/src/features/settings/core/cursor-api-key.tsnew file mode 100644index 0000000000..8aee42704b--- /dev/null+++ b/apps/web/src/features/settings/core/cursor-api-key.ts@@ -0,0 +1,10 @@+// Cursor now mints `grok_` keys; the `crsr_` keys minted before that still work.+const CURSOR_KEY_PREFIXES = ['grok_', 'crsr_'];++export const CURSOR_KEY_PLACEHOLDER = `${CURSOR_KEY_PREFIXES[0]}…`;++export const CURSOR_KEY_FORMAT_ERROR = `Cursor API keys start with ${CURSOR_KEY_PREFIXES.join(' or ')}`;++export function isCursorApiKey(key: string): boolean {+ return CURSOR_KEY_PREFIXES.some((prefix) => key.startsWith(prefix));+}diff --git a/docs/AGENT_GUIDE/ai-chat.md b/docs/AGENT_GUIDE/ai-chat.mdindex 261253859b..2a72a60700 100644--- a/docs/AGENT_GUIDE/ai-chat.md+++ b/docs/AGENT_GUIDE/ai-chat.md@@ -435,15 +435,31 @@ the shimmer.its mode and conversation. Newly created sessions replace their temporaryURL with the real id without remounting the composer or adding a temporaryhistory step.-- **Agents page** uses the same **Agents** management screen as Settings.- **Agents** lists Team and Private agents with Edit / Delete actions; **Runtimes**- configures built-in providers and paired machines. **New agent** and **New runtime**- replace the list with full-page forms, not dialogs. Back/Cancel returns to the list;- use **New conversation** in the sidebar to return to the composer. The animated- **Bring your own agent** card appears only in **Runtimes**, below the tabs and- above the runtime lists. It links directly to runtime pairing and its setup guide.- The **Paired runtimes** section appears once you have a paired runtime; an empty- list does not repeat the pairing action from **Bring your own agent**.+- **Agents page** uses the same **Agents** management screen as Settings. Two+ slim strips sit above the list: **Connect Cursor** (**Manage** once connected)+ and **Bring your own agent** (**Set up**, or **Paired** + **Manage** once a+ machine is paired). One **Your agents** list shows Macro, team agents, then+ private agents, each with a TEAM/PRIVATE pill and an "In Macro / In Cursor /+ In your harness · model · channels" subtitle, plus Edit / Delete actions.+ **Add agent**, the setup strips, and Edit replace the list with full pages,+ not dialogs; Back/Cancel returns to the list. Use **New conversation** in the+ sidebar to return to the composer.+ The agent editor has Profile, Instructions, **Where it runs** (In Macro, In+ Cursor, In your harness; In Claude Code too with the `claude-cloud` flag once+ Claude lists models) and **Who can use it** (Private / Team). The selected+ place opens its Model picker inside its card; In your harness adds a Harness+ picker beside it. An unconnected Cursor or unpaired harness is disabled with+ **Connect** / **Set up**, which open the setup guide in place and return to the+ editor with that option selected. Mention style, permission requests,+ connections, and channels sit in a collapsed **Advanced** section whose+ description summarizes the current choices.+ **Connect Cursor** is a three-step guide: a screenshot of Cursor's API & SSH+ Keys page with **Open API & SSH Keys** (cursor.com/dashboard/api), an API key+ field focused on open, and a default model picker that enables once the key is+ saved. Connected, the same page shows the saved date, **Disconnect**, and+ **Done**. **Manage** on a paired machine opens **Runtimes** (Back returns to+ Agents): built-in providers, **New runtime**, and the **Paired runtimes** list,+ which appears once you have a paired runtime.**New runtime** shows three steps: install macrod from the linked release,run `./macrod` and configure your agent in Quickstart, then enter your pairingcode and click **Look up**. Review the request and click **Approve** to connect.diff --git a/docs/AGENT_GUIDE/navigation.md b/docs/AGENT_GUIDE/navigation.mdindex 74783231e1..987b48d689 100644--- a/docs/AGENT_GUIDE/navigation.md+++ b/docs/AGENT_GUIDE/navigation.md@@ -814,7 +814,7 @@ restart rules still apply.- In any text surface: `@` mentions (bidirectional links), `#` tags, `/` block commands,`:` emoji. Clicking a rendered tag opens a Search split filtered to that tag.-Settings → Agents → Agents / Runtimes render while their requests are pending.+Settings → Agents, its Cursor guide, and Runtimes render while their requests are pending.A pending Cursor model catalog shows `Loading models…` beside a disabled modelpicker; a failed catalog shows an inline error. The rest of settings stays usable.Settings → Agents → Agents ends with **Coding sessions**: per-user **Create@@ -822,8 +822,8 @@ tasks** and **Open pull requests** switches, both off by default. Each saves ontoggle and reverts with a toast if the save fails.With the `claude-cloud` feature flag enabled, Claude Cloud connection setup is in-Settings → Agents → Runtimes, above Cursor, with the-Anthropic logo. Settings → Agents → Agents selects an agent's runtime but does not host+Settings → Agents → Runtimes (Manage on Bring your own agent), above Cursor, with the+Anthropic logo. The agent editor's Where it runs offers In Claude Code but does not hostClaude's connection form. **Connect Claude** starts authorization and opens sign-inon the first click; a fallback link remains if the browser blocks the tab.Approve on Claude's page, copy the complete `code#state`, then use **Finishdiff --git a/docs/AGENT_GUIDE/view-tours.md b/docs/AGENT_GUIDE/view-tours.mdindex 7b60385990..eaba80917e 100644--- a/docs/AGENT_GUIDE/view-tours.md+++ b/docs/AGENT_GUIDE/view-tours.md@@ -36,7 +36,8 @@ and highlights.- **Agents:** the Work / Code switch (beacon on the sidebar toggle), then theagent and model picker (beacon on New conversation), then the- agents and Runtimes tabs (beacon on Agents), then Create for automations.+ Your agents list and the Cursor / Bring your own agent strips (beacon on+ Agents), then Create for automations.- **Channels:** channels and DMs, creation, then threads, @mentions, and calls,which wait on the channel list until a conversation is open. No Slack action.- **Email:** Signal/Noise, tags, then keyboard shortcuts.