Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

feat(settings): add agent editor page with tools picker

Steven Enamakel1f9d402aa33c
diff --git a/app/src/components/settings/hooks/useSettingsNavigation.ts b/app/src/components/settings/hooks/useSettingsNavigation.ts
index 2e497e80e5..41c12fa38a 100644
--- a/app/src/components/settings/hooks/useSettingsNavigation.ts
+++ b/app/src/components/settings/hooks/useSettingsNavigation.ts
@@ -15,7 +15,6 @@ const log = debug('settings:nav');
type SettingsRoute =
| 'home'
- | 'agents'
| 'agent-access'
| 'account'
| 'privacy'
@@ -70,7 +69,7 @@ interface SettingsNavigationHook {
/** Extract the settings sub-path from a full pathname. */
const extractSettingsSlug = (pathname: string): string => {
// Strip the leading /settings/ and take the first path segment.
- // e.g. /settings/agents/edit/123 → 'agents'
+ // e.g. /settings/team/manage/123 → 'team'
const match = /^\/settings\/(.+)$/.exec(pathname);
if (!match) return '';
return match[1];
@@ -80,9 +79,6 @@ const getCurrentRoute = (pathname: string): SettingsRoute => {
const slug = extractSettingsSlug(pathname);
if (!slug) return 'home';
- // --- agent editor sub-routes ---
- if (/^agents\/(new|edit)/.test(slug)) return 'agents';
-
// --- exact first-segment lookup via registry ---
const firstSegment = slug.split('/')[0];
diff --git a/app/src/components/settings/panels/AgentEditorPage.test.tsx b/app/src/components/settings/panels/AgentEditorPage.test.tsx
deleted file mode 100644
index acd60c5c25..0000000000
--- a/app/src/components/settings/panels/AgentEditorPage.test.tsx
+++ /dev/null
@@ -1,315 +0,0 @@
-import { fireEvent, render, screen, waitFor } from '@testing-library/react';
-import { MemoryRouter, Route, Routes } from 'react-router-dom';
-import { beforeEach, describe, expect, it, vi } from 'vitest';
-
-import { agentRegistryApi, type AgentRegistryEntry } from '../../../services/api/agentRegistryApi';
-import { listProviderModels } from '../../../services/api/aiSettingsApi';
-import AgentEditorPage from './AgentEditorPage';
-
-vi.mock('../../../services/api/agentRegistryApi', () => ({
- agentRegistryApi: {
- list: vi.fn(),
- get: vi.fn(),
- availableTools: vi.fn(),
- createCustom: vi.fn(),
- update: vi.fn(),
- setEnabled: vi.fn(),
- remove: vi.fn(),
- },
-}));
-
-vi.mock('../../../services/api/aiSettingsApi', () => ({ listProviderModels: vi.fn() }));
-
-const mockNavigate = vi.fn();
-vi.mock('react-router-dom', async importOriginal => {
- const actual = await importOriginal<typeof import('react-router-dom')>();
- return { ...actual, useNavigate: () => mockNavigate };
-});
-
-const mockGet = vi.mocked(agentRegistryApi.get);
-const mockAvailableTools = vi.mocked(agentRegistryApi.availableTools);
-const mockCreate = vi.mocked(agentRegistryApi.createCustom);
-const mockUpdate = vi.mocked(agentRegistryApi.update);
-const mockListProviderModels = vi.mocked(listProviderModels);
-
-function agent(overrides: Partial<AgentRegistryEntry> = {}): AgentRegistryEntry {
- return {
- id: 'finance',
- name: 'Finance',
- description: 'Crunches numbers.',
- source: 'custom',
- enabled: true,
- model: 'hint:reasoning',
- system_prompt: 'Be precise.',
- tool_allowlist: ['memory.search'],
- ...overrides,
- };
-}
-
-function renderAt(path: string) {
- return render(
- <MemoryRouter initialEntries={[path]}>
- <Routes>
- <Route path="/settings/agents/new" element={<AgentEditorPage />} />
- <Route path="/settings/agents/edit/:id" element={<AgentEditorPage />} />
- </Routes>
- </MemoryRouter>
- );
-}
-
-describe('AgentEditorPage', () => {
- beforeEach(() => {
- vi.clearAllMocks();
- mockListProviderModels.mockResolvedValue([]);
- mockAvailableTools.mockResolvedValue([
- { name: 'web_search', description: 'Search the web for information.' },
- { name: 'memory.search', description: 'Search the user memory store.' },
- ]);
- });
-
- it('creates a custom agent from the form', async () => {
- mockCreate.mockResolvedValue(agent({ id: 'helper', name: 'Helper' }));
- renderAt('/settings/agents/new');
-
- fireEvent.change(screen.getByLabelText('Name'), { target: { value: 'Helper' } });
- fireEvent.change(screen.getByLabelText('Description'), { target: { value: 'Helps out.' } });
- // Model dropdown offers the workload role hints.
- expect(screen.getByRole('option', { name: 'hint:reasoning' })).toBeInTheDocument();
- fireEvent.change(screen.getByRole('combobox'), { target: { value: 'hint:coding' } });
-
- fireEvent.click(screen.getByRole('button', { name: /Create agent/ }));
-
- await waitFor(() => expect(mockCreate).toHaveBeenCalledTimes(1));
- const arg = mockCreate.mock.calls[0][0];
- expect(arg.id).toBe('helper'); // auto-slugified from name
- expect(arg.name).toBe('Helper');
- expect(arg.model).toBe('hint:coding');
- expect(mockNavigate).toHaveBeenCalledWith('/settings/agents');
- });
-
- it('offers the vision tier + hint as model options', async () => {
- mockCreate.mockResolvedValue(agent({ id: 'looker', name: 'Looker' }));
- // The tier alias is a managed model, not a hardcoded hint: it reaches the
- // dropdown through `listProviderModels`, so it needs its own resolution
- // here. The suite default is an empty list, under which the managed
- // optgroup does not render at all.
- mockListProviderModels.mockResolvedValue([{ id: 'vision-v1' }]);
- renderAt('/settings/agents/new');
-
- fireEvent.change(screen.getByLabelText('Name'), { target: { value: 'Looker' } });
- fireEvent.change(screen.getByLabelText('Description'), {
- target: { value: 'Looks at images.' },
- });
- // Both the vision hint and the resolved tier alias are selectable. The hint
- // is synchronous; the tier alias has to be awaited, since it only appears
- // once the managed-model fetch resolves.
- expect(screen.getByRole('option', { name: 'hint:vision' })).toBeInTheDocument();
- expect(await screen.findByRole('option', { name: 'vision-v1' })).toBeInTheDocument();
- fireEvent.change(screen.getByRole('combobox'), { target: { value: 'hint:vision' } });
-
- fireEvent.click(screen.getByRole('button', { name: /Create agent/ }));
- await waitFor(() => expect(mockCreate).toHaveBeenCalledTimes(1));
- expect(mockCreate.mock.calls[0][0].model).toBe('hint:vision');
- });
-
- it('picks tools from the searchable modal and shows chips', async () => {
- renderAt('/settings/agents/new');
-
- fireEvent.click(screen.getByText('Add tools'));
- await waitFor(() => expect(mockAvailableTools).toHaveBeenCalled());
-
- // Tool descriptions are shown in the modal.
- expect(await screen.findByText('Search the web for information.')).toBeInTheDocument();
-
- // Search filters the list.
- fireEvent.change(screen.getByLabelText('Search tools…'), { target: { value: 'web' } });
- expect(screen.queryByText('Search the user memory store.')).not.toBeInTheDocument();
-
- fireEvent.click(screen.getByText('web_search'));
- fireEvent.click(screen.getByRole('button', { name: 'Done' }));
-
- // Chip for the selected tool appears on the page.
- await waitFor(() => expect(screen.getAllByText('web_search').length).toBeGreaterThan(0));
- });
-
- it('loads an existing agent for editing with a read-only name', async () => {
- mockGet.mockResolvedValue(agent());
- renderAt('/settings/agents/edit/finance');
-
- await waitFor(() => expect(mockGet).toHaveBeenCalledWith('finance'));
- // Name is read-only in edit mode — no editable Name input is rendered.
- expect(screen.queryByLabelText('Name')).toBeNull();
- expect(screen.getByDisplayValue('Crunches numbers.')).toBeInTheDocument();
- expect((screen.getByRole('combobox') as HTMLSelectElement).value).toBe('hint:reasoning');
-
- fireEvent.change(screen.getByLabelText('Description'), { target: { value: 'Updated.' } });
- fireEvent.click(screen.getByRole('button', { name: /^Save$/ }));
- await waitFor(() => expect(mockUpdate).toHaveBeenCalledWith('finance', expect.any(Object)));
- });
-
- it('shows a read-only notice for built-in agents instead of the form', async () => {
- mockGet.mockResolvedValue(agent({ id: 'researcher', name: 'Researcher', source: 'default' }));
- renderAt('/settings/agents/edit/researcher');
-
- await waitFor(() => expect(mockGet).toHaveBeenCalledWith('researcher'));
- expect(screen.getByText(/Built-in agents can.t be edited/)).toBeInTheDocument();
- // No editable form fields are rendered.
- expect(screen.queryByLabelText('Description')).toBeNull();
- expect(screen.queryByRole('button', { name: /^Save$/ })).toBeNull();
- });
-
- it('shows source badge (custom/default) next to name in edit mode (line 259)', async () => {
- mockGet.mockResolvedValue(agent({ source: 'custom' }));
- renderAt('/settings/agents/edit/finance');
-
- await waitFor(() => expect(mockGet).toHaveBeenCalled());
- // Custom agents show their source badge
- expect(await screen.findByText('Custom')).toBeInTheDocument();
- });
-
- it('auto-slugifies the ID field from the Name field on create (lines 280-282)', () => {
- renderAt('/settings/agents/new');
-
- // The Name input is present on create
- fireEvent.change(screen.getByLabelText('Name'), { target: { value: 'My Cool Agent' } });
-
- // ID is auto-derived from name via slugify — until user touches it
- const idInput = screen.getByLabelText('ID') as HTMLInputElement;
- expect(idInput.value).toBe('my-cool-agent');
- });
-
- it('allows manual ID override once the ID field is touched (lines 280-282)', () => {
- renderAt('/settings/agents/new');
-
- const idInput = screen.getByLabelText('ID');
- fireEvent.change(idInput, { target: { value: 'custom-id' } });
-
- // After touching, changing name should NOT overwrite the custom ID
- fireEvent.change(screen.getByLabelText('Name'), { target: { value: 'New Name' } });
- expect((screen.getByLabelText('ID') as HTMLInputElement).value).toBe('custom-id');
- });
-
- it('shows custom model text input when __custom__ model is selected (line 350)', () => {
- renderAt('/settings/agents/new');
-
- // Select the custom model option
- fireEvent.change(screen.getByRole('combobox'), { target: { value: '__custom__' } });
-
- // A custom model text input appears with the custom placeholder as aria-label
- // The en.ts label is: 'settings.agents.editor.modelCustomPlaceholder': 'e.g. anthropic/claude-sonnet-4'
- const customInput = screen.getByLabelText(/e\.g\. anthropic/i);
- expect(customInput).toBeInTheDocument();
- });
-
- it('updates system prompt textarea on change (line 373)', () => {
- renderAt('/settings/agents/new');
-
- // The label uses t('settings.agents.editor.systemPrompt') → 'System prompt (optional)'
- const promptArea = screen.getByLabelText('System prompt (optional)') as HTMLTextAreaElement;
- fireEvent.change(promptArea, { target: { value: 'Be helpful and precise.' } });
-
- expect(promptArea.value).toBe('Be helpful and precise.');
- });
-
- it('shows All Tools chip when toolAllowlist contains "*" (line 390)', async () => {
- renderAt('/settings/agents/new');
-
- // Open tool picker via the Add tools button
- fireEvent.click(screen.getByText('Add tools'));
- await waitFor(() => expect(mockAvailableTools).toHaveBeenCalled());
- await screen.findByText('Search the web for information.');
-
- // Toggle all tools via the "Allow all tools (*)" button
- fireEvent.click(screen.getByRole('button', { name: /Allow all tools/i }));
- fireEvent.click(screen.getByRole('button', { name: 'Done' }));
-
- // The "All tools" chip should appear (toolsAllSelected branch)
- await waitFor(() => {
- expect(screen.getByText('All tools')).toBeInTheDocument();
- });
- });
-
- it('removes a selected tool chip via its X button (line 410)', async () => {
- renderAt('/settings/agents/new');
-
- // Open picker and select a tool
- fireEvent.click(screen.getByText('Add tools'));
- await waitFor(() => expect(mockAvailableTools).toHaveBeenCalled());
- await screen.findByText('Search the web for information.');
-
- fireEvent.click(screen.getByText('web_search'));
- fireEvent.click(screen.getByRole('button', { name: 'Done' }));
-
- // Chip for web_search appears
- await waitFor(() => expect(screen.getAllByText('web_search').length).toBeGreaterThan(0));
-
- // Click the X remove button on the chip — the aria-label is 'Remove web_search'
- // since t('settings.agents.editor.removeToolAria') = 'Remove {tool}'
- const removeBtn = screen.getByRole('button', { name: 'Remove web_search' });
- fireEvent.click(removeBtn);
-
- // The chip remove button should be gone
- await waitFor(() => {
- expect(screen.queryByRole('button', { name: 'Remove web_search' })).not.toBeInTheDocument();
- });
- });
-
- /**
- * The agent's model is the persistent default for its chats, unlike the
- * composer picker which only overrides the current conversation. Managed
- * catalog models must therefore be selectable here, labelled by name and
- * charged price rather than a bare slug.
- */
- it('offers managed catalog models and saves one as the agent default', async () => {
- mockListProviderModels.mockResolvedValue([
- {
- id: 'openrouter/deepseek/deepseek-v4-flash',
- owned_by: 'openrouter',
- display_name: 'DeepSeek V4 Flash',
- input_per_1m: 0.44,
- output_per_1m: 1.32,
- },
- ]);
- mockCreate.mockResolvedValue(agent({ id: 'helper', name: 'Helper' }));
- renderAt('/settings/agents/new');
-
- // Fetched with the managed slug, not a BYOK provider id.
- await waitFor(() => expect(mockListProviderModels).toHaveBeenCalledWith('openhuman'));
-
- const option = await screen.findByRole('option', {
- name: /DeepSeek V4 Flash — \$0.44\/\$1.32 per 1M/,
- });
- expect(option).toBeInTheDocument();
-
- fireEvent.change(screen.getByLabelText('Name'), { target: { value: 'Helper' } });
- fireEvent.change(screen.getByLabelText('Description'), { target: { value: 'Helps out.' } });
- fireEvent.change(screen.getByRole('combobox'), {
- target: { value: 'openrouter/deepseek/deepseek-v4-flash' },
- });
- fireEvent.click(screen.getByRole('button', { name: /Create agent/ }));
-
- await waitFor(() => expect(mockCreate).toHaveBeenCalledTimes(1));
- expect(mockCreate.mock.calls[0][0].model).toBe('openrouter/deepseek/deepseek-v4-flash');
- });
-
- /**
- * A saved catalog id is not in KNOWN_MODELS, so the initial load flips the
- * editor into free-text "custom" mode. The catalog arrives after that load, so
- * without a re-check the user sees a raw id in a text box instead of the
- * entry selected in the dropdown.
- */
- it('selects a saved managed model in the dropdown rather than the custom text box', async () => {
- mockGet.mockResolvedValue(agent({ model: 'openrouter/deepseek/deepseek-v4-flash' }));
- mockListProviderModels.mockResolvedValue([
- { id: 'openrouter/deepseek/deepseek-v4-flash', owned_by: 'openrouter' },
- ]);
- renderAt('/settings/agents/edit/finance');
-
- await waitFor(() =>
- expect(screen.getByRole('combobox')).toHaveValue('openrouter/deepseek/deepseek-v4-flash')
- );
- // The custom free-text box is the fallback for an id the catalog lacks; it
- // must not be showing for a model we can offer properly.
- expect(screen.queryByLabelText(/Custom model id/i)).toBeNull();
- });
-});
diff --git a/app/src/components/settings/panels/AgentEditorPage.tsx b/app/src/components/settings/panels/AgentEditorPage.tsx
deleted file mode 100644
index d67bd01e12..0000000000
--- a/app/src/components/settings/panels/AgentEditorPage.tsx
+++ /dev/null
@@ -1,450 +0,0 @@
-/**
- * AgentEditorPage — Settings > Agents > (New | Edit).
- *
- * Full-page editor for a registry agent (replaces the old in-panel modal).
- * Routes: `/settings/agents/new` (create) and `/settings/agents/edit/:id`
- * (edit a default override or a custom agent).
- *
- * Field rules:
- * - Name is the page title; it is editable only when creating. On edit it is
- * shown read-only (the agent's identity stays stable).
- * - Description is a textarea.
- * - Model is a dropdown of known route hints / tiers, with a custom-id escape
- * hatch for BYOK provider model ids. Empty = inherit (no override).
- * - Allowed tools open a searchable modal with chip-style selection; each tool
- * shows its description. `["*"]` means "all tools".
- */
-import { useCallback, useEffect, useRef, useState } from 'react';
-import { useLocation, useNavigate, useParams } from 'react-router-dom';
-
-import { useT } from '../../../lib/i18n/I18nContext';
-import { agentRegistryApi, type AgentRegistryEntry } from '../../../services/api/agentRegistryApi';
-import { listProviderModels, type ModelInfo } from '../../../services/api/aiSettingsApi';
-import { Alert, AlertDescription } from '../../ui/Alert';
-import Badge from '../../ui/Badge';
-import Button from '../../ui/Button';
-import Card from '../../ui/Card';
-import Field from '../../ui/Field';
-import { CenteredLoadingState } from '../../ui/LoadingState';
-import NativeSelect from '../../ui/NativeSelect';
-import TextArea from '../../ui/TextArea';
-import TextField from '../../ui/TextField';
-import SettingsPanel from '../layout/SettingsPanel';
-import { AgentEditorToolsField } from './AgentEditorToolsPicker';
-
-// Known model options — the workload role hints the core routes on
-// (crates/openhuman-core/src/inference/provider/factory/tiers.rs). Empty string
-// means "inherit" (no override). Any other value not in this list is a concrete
-// model id: a managed catalog model or a raw BYOK provider model (custom).
-const MODEL_HINTS = [
- 'hint:reasoning',
- 'hint:chat',
- 'hint:agentic',
- 'hint:burst',
- 'hint:coding',
- 'hint:summarization',
- 'hint:vision',
-];
-const KNOWN_MODELS = new Set(MODEL_HINTS);
-const CUSTOM_MODEL = '__custom__';
-
-/**
- * `cloud_providers` slug of the managed backend, used to list the models it can
- * serve. Pinning one here sets the agent's persistent default — unlike the
- * composer's picker, which only overrides the current conversation.
- *
- * The listing is the OpenRouter passthrough catalog and is empty unless the
- * backend has `OPENROUTER_PASSTHROUGH_ENABLED` on, so the optgroup simply does
- * not render against a backend without it.
- */
-const MANAGED_PROVIDER_SLUG = 'openhuman';
-
-/** `Display Name — $in/$out per 1M`, falling back to the bare id. */
-const managedOptionLabel = (m: ModelInfo): string => {
- const name = m.display_name?.trim() || m.id;
- const inPrice = m.input_per_1m;
- const outPrice = m.output_per_1m;
- if (typeof inPrice !== 'number' || typeof outPrice !== 'number') return name;
- const fmt = (n: number) =>
- n === 0 ? '$0' : `$${n < 1 ? n.toFixed(3).replace(/0+$/, '') : n.toFixed(2)}`;
- return `${name} — ${fmt(inPrice)}/${fmt(outPrice)} per 1M`;
-};
-
-function slugify(name: string): string {
- return name
- .trim()
- .toLowerCase()
- .replace(/[^a-z0-9_-]+/g, '-')
- .replace(/^-+|-+$/g, '');
-}
-
-const AgentEditorPage = () => {
- const { t } = useT();
- const navigate = useNavigate();
- const location = useLocation();
- const { id: routeId } = useParams<{ id: string }>();
- const backToList = useCallback(() => navigate('/settings/agents'), [navigate, location]);
- const isCreate = !routeId;
-
- const [loading, setLoading] = useState(!isCreate);
- const [loadError, setLoadError] = useState<string | null>(null);
- const [isCustom, setIsCustom] = useState(true);
-
- // Form state.
- const [name, setName] = useState('');
- const [agentId, setAgentId] = useState('');
- const [idTouched, setIdTouched] = useState(!isCreate);
- const [description, setDescription] = useState('');
- const [model, setModel] = useState('');
- const [customModelMode, setCustomModelMode] = useState(false);
- const [managedModels, setManagedModels] = useState<ModelInfo[]>([]);
- const [systemPrompt, setSystemPrompt] = useState('');
- const [toolAllowlist, setToolAllowlist] = useState<string[]>([]);
-
- const [submitting, setSubmitting] = useState(false);
- const [error, setError] = useState<string | null>(null);
- const mountedRef = useRef(true);
-
- useEffect(() => {
- mountedRef.current = true;
- return () => {
- mountedRef.current = false;
- };
- }, []);
-
- useEffect(() => {
- if (isCreate || !routeId) return;
- let cancelled = false;
- const load = async () => {
- setLoading(true);
- setLoadError(null);
- try {
- const agent = await agentRegistryApi.get(routeId);
- if (cancelled) return;
- if (!agent) {
- setLoadError(t('settings.agents.editor.notFound'));
- return;
- }
- populate(agent);
- } catch (err) {
- if (!cancelled) setLoadError(err instanceof Error ? err.message : String(err));
- } finally {
- if (!cancelled) setLoading(false);
- }
- };
-
- const populate = (agent: AgentRegistryEntry) => {
- setIsCustom(agent.source === 'custom');
- setName(agent.name);
- setAgentId(agent.id);
- setDescription(agent.description);
- const m = agent.model ?? '';
- setModel(m);
- setCustomModelMode(m !== '' && !KNOWN_MODELS.has(m));
- setSystemPrompt(agent.system_prompt ?? '');
- setToolAllowlist(agent.tool_allowlist ?? []);
- };
-
- void load();
- return () => {
- cancelled = true;
- };
- }, [isCreate, routeId, t]);
-
- const handleName = (value: string) => {
- setName(value);
- if (isCreate && !idTouched) setAgentId(slugify(value));
- };
-
- const canSubmit =
- !submitting &&
- description.trim().length > 0 &&
- (isCreate ? name.trim().length > 0 && agentId.trim().length > 0 : true);
-
- const handleSubmit = async () => {
- if (!canSubmit) return;
- setSubmitting(true);
- setError(null);
- const trimmedModel = model.trim();
- try {
- let saved: AgentRegistryEntry;
- if (isCreate) {
- saved = await agentRegistryApi.createCustom({
- id: agentId.trim() || slugify(name),
- name: name.trim(),
- description: description.trim(),
- model: trimmedModel || null,
- system_prompt: systemPrompt.trim() || null,
- tool_allowlist: toolAllowlist,
- });
- } else {
- saved = await agentRegistryApi.update(routeId, {
- description: description.trim(),
- // Always send a string so "inherit" (empty) clears any prior override.
- model: trimmedModel,
- system_prompt: systemPrompt.trim() || null,
- tool_allowlist: toolAllowlist,
- });
- }
- if (mountedRef.current && saved) backToList();
- } catch (err) {
- if (mountedRef.current) setError(err instanceof Error ? err.message : String(err));
- } finally {
- if (mountedRef.current) setSubmitting(false);
- }
- };
-
- // Managed catalog for the optgroup below. A failure or an empty result is not
- // an error worth surfacing here: the backend returns an empty list when the
- // passthrough is off or the session is stale, and the rest of the editor is
- // unaffected — the optgroup just does not render.
- useEffect(() => {
- let active = true;
- void listProviderModels(MANAGED_PROVIDER_SLUG)
- .then(models => {
- if (active) setManagedModels(models);
- })
- .catch(() => {
- if (active) setManagedModels([]);
- });
- return () => {
- active = false;
- };
- }, []);
-
- // A saved managed-catalog id is not in KNOWN_MODELS, so the load above flips
- // the editor into free-text "custom" mode for it. The catalog arrives after
- // that load, so re-check once it does and select the entry properly instead of
- // showing a raw id in a text box. Only ever clears custom mode — a genuine
- // BYOK id the catalog does not contain keeps its text box.
- useEffect(() => {
- if (model && managedModels.some(m => m.id === model)) setCustomModelMode(false);
- }, [managedModels, model]);
-
- const selectValue = customModelMode ? CUSTOM_MODEL : model;
-
- const onModelSelect = (value: string) => {
- if (value === CUSTOM_MODEL) {
- setCustomModelMode(true);
- setModel('');
- } else {
- setCustomModelMode(false);
- setModel(value);
- }
- };
-
- return (
- <SettingsPanel
- title={isCreate ? t('settings.agents.newAgent') : name || t('settings.agents.newAgent')}
- description={t('settings.agents.subtitle')}>
- {loading ? (
- <CenteredLoadingState label={t('common.loading')} className="py-12" />
- ) : loadError ? (
- <Alert variant="destructive">
- <AlertDescription>
- {t('settings.agents.loadError')}: {loadError}
- </AlertDescription>
- </Alert>
- ) : !isCreate && !isCustom ? (
- // Built-in agents can't be edited; they may only be enabled/disabled
- // or reset from the agents list.
- <div className="space-y-3">
- <Alert variant="default">
- <AlertDescription>{t('settings.agents.editor.builtInReadonly')}</AlertDescription>
- </Alert>
- <Button type="button" variant="secondary" size="sm" onClick={backToList}>
- {t('common.back')}
- </Button>
- </div>
- ) : (
- <div className="space-y-4">
- {/* Name — editable only on create; read-only identity on edit. */}
- <Card>
- {isCreate ? (
- <Field
- htmlFor="agent-name"
- label={t('settings.agents.editor.name')}
- stacked
- control={
- <TextField
- id="agent-name"
- autoFocus
- value={name}
- onChange={e => handleName(e.target.value)}
- aria-label={t('settings.agents.editor.name')}
- />
- }
- />
- ) : (
- <Field
- label={t('settings.agents.editor.name')}
- control={
- <div className="flex items-center gap-2">
- <span className="text-sm font-semibold text-content">{name}</span>
- <Badge variant="neutral">
- {isCustom
- ? t('settings.agents.sourceCustom')
- : t('settings.agents.sourceDefault')}
- </Badge>
- </div>
- }
- />
- )}
-
- {/* ID — editable only on create. */}
- {isCreate ? (
- <Field
- htmlFor="agent-id"
- label={t('settings.agents.editor.id')}
- description={t('settings.agents.editor.idHint')}
- stacked
- control={
- <TextField
- id="agent-id"
- mono
- value={agentId}
- onChange={e => {
- setIdTouched(true);
- setAgentId(e.target.value);
- }}
- aria-label={t('settings.agents.editor.id')}
- />
- }
- />
- ) : (
- <Field
- label={t('settings.agents.editor.id')}
- control={<code className="font-mono text-xs text-content-muted">{agentId}</code>}
- />
- )}
- </Card>
-
- <Card>
- <Field
- htmlFor="agent-description"
- label={t('settings.agents.editor.description')}
- stacked
- control={
- <TextArea
- id="agent-description"
- value={description}
- onChange={e => setDescription(e.target.value)}
- rows={3}
- aria-label={t('settings.agents.editor.description')}
- />
- }
- />
- </Card>
-
- {/* Model — dropdown of known hints/tiers + custom escape hatch. */}
- <Card>
- <Field
- htmlFor="agent-model"
- label={t('settings.agents.editor.model')}
- stacked
- control={
- <div className="space-y-2">
- <NativeSelect
- id="agent-model"
- value={selectValue}
- onChange={e => onModelSelect(e.target.value)}
- aria-label={t('settings.agents.editor.model')}
- className="w-full">
- <option value="">{t('settings.agents.editor.modelInherit')}</option>
- <optgroup label={t('settings.agents.editor.modelHints')}>
- {MODEL_HINTS.map(h => (
- <option key={h} value={h}>
- {h}
- </option>
- ))}
- </optgroup>
- {managedModels.length > 0 && (
- <optgroup label={t('settings.agents.editor.modelManaged')}>
- {managedModels.map(m => (
- <option key={m.id} value={m.id}>
- {managedOptionLabel(m)}
- </option>
- ))}
- </optgroup>
- )}
- <option value={CUSTOM_MODEL}>{t('settings.agents.editor.modelCustom')}</option>
- </NativeSelect>
- {customModelMode && (
- <TextField
- mono
- value={model}
- onChange={e => setModel(e.target.value)}
- placeholder={t('settings.agents.editor.modelCustomPlaceholder')}
- aria-label={t('settings.agents.editor.modelCustomPlaceholder')}
- />
- )}
- </div>
- }
- />
- </Card>
-
- <Card>
- <Field
- htmlFor="agent-system-prompt"
- label={t('settings.agents.editor.systemPrompt')}
- stacked
- control={
- <TextArea
- id="agent-system-prompt"
- value={systemPrompt}
- onChange={e => setSystemPrompt(e.target.value)}
- rows={4}
- aria-label={t('settings.agents.editor.systemPrompt')}
- />
- }
- />
- </Card>
-
- {/* Allowed tools — chips + modal picker. */}
- <Card>
- <Field
- label={t('settings.agents.editor.tools')}
- description={t('settings.agents.editor.toolsHint')}
- stacked
- control={
- <AgentEditorToolsField toolAllowlist={toolAllowlist} onChange={setToolAllowlist} />
- }
- />
- </Card>
-
- {!isCreate && !isCustom && (
- <p className="text-[11px] text-content-faint">
- {t('settings.agents.editor.defaultsNote')}
- </p>
- )}
-
- {error && (
- <Alert variant="destructive" className="px-3 py-2 text-xs">
- <AlertDescription className="text-xs">{error}</AlertDescription>
- </Alert>
- )}
-
- <div className="flex justify-end gap-2 pt-1">
- <Button type="button" variant="secondary" size="sm" onClick={backToList}>
- {t('common.cancel')}
- </Button>
- <Button
- type="button"
- variant="primary"
- size="sm"
- onClick={() => void handleSubmit()}
- disabled={!canSubmit}>
- {submitting
- ? t('settings.agents.editor.saving')
- : isCreate
- ? t('settings.agents.editor.create')
- : t('settings.agents.editor.save')}
- </Button>
- </div>
- </div>
- )}
- </SettingsPanel>
- );
-};
-
-export default AgentEditorPage;
diff --git a/app/src/components/settings/panels/AgentEditorToolsPicker.test.tsx b/app/src/components/settings/panels/AgentEditorToolsPicker.test.tsx
deleted file mode 100644
index 3b551de64a..0000000000
--- a/app/src/components/settings/panels/AgentEditorToolsPicker.test.tsx
+++ /dev/null
@@ -1,74 +0,0 @@
-/**
- * AgentEditorToolsPicker — chip row + "Add tools" modal for the agent editor's
- * tool allowlist. Covers the "Allow all" control, now a `Toggle` primitive.
- *
- * `useT` falls back to the English map without a provider (see
- * `lib/i18n/I18nContext.tsx`), so these render bare, and queries use the
- * rendered English copy rather than raw translation keys.
- */
-import { act, fireEvent, render, screen, waitFor } from '@testing-library/react';
-import { describe, expect, it, vi } from 'vitest';
-
-import { agentRegistryApi } from '../../../services/api/agentRegistryApi';
-import { AgentEditorToolsField } from './AgentEditorToolsPicker';
-
-vi.mock('../../../services/api/agentRegistryApi', () => ({
- agentRegistryApi: { availableTools: vi.fn() },
-}));
-
-const mockAvailableTools = vi.mocked(agentRegistryApi.availableTools);
-
-describe('AgentEditorToolsField', () => {
- it('shows the none-selected hint when the allowlist is empty', () => {
- render(<AgentEditorToolsField toolAllowlist={[]} onChange={vi.fn()} />);
- expect(screen.getByText('No tools selected')).toBeInTheDocument();
- });
-
- it('renders selected tools as chips', () => {
- render(
- <AgentEditorToolsField toolAllowlist={['memory_search', 'web_fetch']} onChange={vi.fn()} />
- );
- expect(screen.getByText('memory_search')).toBeInTheDocument();
- expect(screen.getByText('web_fetch')).toBeInTheDocument();
- });
-
- it('opens the picker modal and toggles "Allow all" on and off', async () => {
- mockAvailableTools.mockResolvedValue([
- { name: 'memory_search', description: 'Search memory' },
- { name: 'web_fetch', description: 'Fetch a URL' },
- ]);
- const onChange = vi.fn();
- render(<AgentEditorToolsField toolAllowlist={[]} onChange={onChange} />);
-
- fireEvent.click(screen.getByLabelText('Add tools'));
-
- await waitFor(() => {
- expect(screen.getByTestId('agent-tools-allow-all-toggle')).toBeInTheDocument();
- });
-
- const allowAllToggle = screen.getByTestId('agent-tools-allow-all-toggle');
- expect(allowAllToggle).toHaveAttribute('aria-pressed', 'false');
- expect(allowAllToggle).toHaveAttribute('data-state', 'off');
-
- await act(async () => {
- fireEvent.click(allowAllToggle);
- });
-
- expect(onChange).toHaveBeenCalledWith(['*']);
- });
-
- it('reflects an already-all-selected allowlist as pressed', async () => {
- mockAvailableTools.mockResolvedValue([{ name: 'memory_search', description: 'Search memory' }]);
- render(<AgentEditorToolsField toolAllowlist={['*']} onChange={vi.fn()} />);
-
- expect(screen.getByText('All tools')).toBeInTheDocument();
-
- fireEvent.click(screen.getByLabelText('Add tools'));
-
- await waitFor(() => {
- const toggle = screen.getByTestId('agent-tools-allow-all-toggle');
- expect(toggle).toHaveAttribute('aria-pressed', 'true');
- expect(toggle).toHaveAttribute('data-state', 'on');
- });
- });
-});
diff --git a/app/src/components/settings/panels/AgentEditorToolsPicker.tsx b/app/src/components/settings/panels/AgentEditorToolsPicker.tsx
deleted file mode 100644
index 42a733b0b9..0000000000
--- a/app/src/components/settings/panels/AgentEditorToolsPicker.tsx
+++ /dev/null
@@ -1,262 +0,0 @@
-/**
- * AgentEditorToolsPicker — the "Allowed tools" field for AgentEditorPage.
- *
- * Renders the current selection as chips (or an "all tools" badge) plus an
- * "Add tools" trigger, and owns the searchable modal used to edit the
- * allowlist. Split out of AgentEditorPage.tsx to keep that file under the
- * repo's ~500-line guideline.
- */
-import { useCallback, useEffect, useId, useMemo, useState } from 'react';
-import { LuPlus, LuSearch } from 'react-icons/lu';
-
-import { cn } from '../../../lib/cn';
-import { useT } from '../../../lib/i18n/I18nContext';
-import { agentRegistryApi, type AgentToolInfo } from '../../../services/api/agentRegistryApi';
-import Badge from '../../ui/Badge';
-import Button from '../../ui/Button';
-import { CheckIcon, CloseIcon } from '../../ui/icons';
-import { CenteredLoadingState } from '../../ui/LoadingState';
-import { ModalShell } from '../../ui/ModalShell';
-import TextField from '../../ui/TextField';
-import Toggle from '../../ui/Toggle';
-
-const ALL_TOOLS = '*';
-
-/**
- * A decorative "is selected" indicator for a fully clickable row.
- *
- * Not `ui/Checkbox`: that renders a real `<input type="checkbox">`, and these
- * rows are themselves `Button`s — nesting an interactive form control inside
- * a button is invalid HTML. The row's own click/keyboard handling already
- * carries the toggle semantics, so this mark is purely visual and
- * `aria-hidden`.
- */
-function ToggleMark({ checked, className }: { checked: boolean; className?: string }) {
- return (
- <span
- aria-hidden="true"
- className={cn(
- 'flex h-4 w-4 flex-none items-center justify-center rounded border transition-colors',
- checked
- ? 'border-primary-500 bg-primary-500 text-content-inverted'
- : 'border-line-strong bg-surface',
- className
- )}>
- {checked && <CheckIcon className="h-3 w-3" />}
- </span>
- );
-}
-
-export interface AgentEditorToolsFieldProps {
- toolAllowlist: string[];
- onChange: (next: string[]) => void;
-}
-
-/** Chip row + "Add tools" trigger; opens `ToolsPickerModal` on demand. */
-export function AgentEditorToolsField({ toolAllowlist, onChange }: AgentEditorToolsFieldProps) {
- const { t } = useT();
- const [toolsOpen, setToolsOpen] = useState(false);
- const allToolsSelected = toolAllowlist.length === 1 && toolAllowlist[0] === ALL_TOOLS;
-
- return (
- <div className="rounded-md border border-line p-2 dark:border-line-strong">
- <div className="flex flex-wrap items-center gap-1.5">
- {allToolsSelected ? (
- <Badge variant="primary">{t('settings.agents.editor.toolsAllSelected')}</Badge>
- ) : toolAllowlist.length === 0 ? (
- <span className="px-1 py-1 text-xs text-content-faint">
- {t('settings.agents.editor.toolsNoneSelected')}
- </span>
- ) : (
- toolAllowlist.map(tool => (
- <Badge key={tool} variant="neutral" className="gap-1 font-mono">
- {tool}
- <Button
- iconOnly
- variant="tertiary"
- size="xs"
- aria-label={t('settings.agents.editor.removeToolAria').replace('{tool}', tool)}
- onClick={() => onChange(toolAllowlist.filter(x => x !== tool))}
- className="h-3 w-3 min-w-0 rounded-full bg-transparent p-0 text-content-faint hover:bg-transparent hover:text-coral-600 dark:hover:text-coral-300">
- <CloseIcon className="h-3 w-3" />
- </Button>
- </Badge>
- ))
- )}
- <Button
- variant="tertiary"
- size="xs"
- aria-label={t('settings.agents.editor.selectTools')}
- onClick={() => setToolsOpen(true)}
- leadingIcon={<LuPlus className="h-3 w-3" />}
- className="h-auto gap-1 rounded-full border border-dashed border-line-strong bg-transparent px-2.5 py-1 text-xs font-medium text-content-secondary hover:border-primary-400 hover:bg-transparent hover:text-primary-600 dark:hover:border-primary-500 dark:hover:text-primary-300">
- {t('settings.agents.editor.selectTools')}
- </Button>
- </div>
-
- {toolsOpen && (
- <ToolsPickerModal
- allToolsSelected={allToolsSelected}
- selected={toolAllowlist}
- onToggleAll={() => onChange(toolAllowlist[0] === ALL_TOOLS ? [] : [ALL_TOOLS])}
- onToggleTool={tool => {
- const base = toolAllowlist[0] === ALL_TOOLS ? [] : toolAllowlist;
- onChange(base.includes(tool) ? base.filter(x => x !== tool) : [...base, tool]);
- }}
- onClose={() => setToolsOpen(false)}
- />
- )}
- </div>
- );
-}
-
-function ToolsPickerModal({
- allToolsSelected,
- selected,
- onToggleAll,
- onToggleTool,
- onClose,
-}: {
- allToolsSelected: boolean;
- selected: string[];
- onToggleAll: () => void;
- onToggleTool: (tool: string) => void;
- onClose: () => void;
-}) {
- const { t } = useT();
- const titleId = useId();
- const [tools, setTools] = useState<AgentToolInfo[]>([]);
- const [loading, setLoading] = useState(true);
- const [error, setError] = useState<string | null>(null);
- const [query, setQuery] = useState('');
-
- const load = useCallback(async () => {
- setLoading(true);
- setError(null);
- try {
- const list = await agentRegistryApi.availableTools();
- setTools(list);
- } catch (err) {
- setError(err instanceof Error ? err.message : String(err));
- } finally {
- setLoading(false);
- }
- }, []);
-
- useEffect(() => {
- void load();
- }, [load]);
-
- const filtered = useMemo(() => {
- const q = query.trim().toLowerCase();
- if (!q) return tools;
- return tools.filter(
- tool => tool.name.toLowerCase().includes(q) || tool.description.toLowerCase().includes(q)
- );
- }, [tools, query]);
-
- const selectedCount = allToolsSelected ? tools.length : selected.length;
-
- return (
- <ModalShell
- title={t('settings.agents.editor.toolsModalTitle')}
- titleId={titleId}
- subtitle={t('settings.agents.editor.toolsSelectedCount').replace(
- '{count}',
- String(selectedCount)
- )}
- onClose={onClose}
- maxWidthClassName="max-w-lg"
- panelClassName="flex max-h-[calc(100vh-3rem)] flex-col"
- contentClassName="flex min-h-0 flex-1 flex-col p-0"
- footer={
- <div className="flex justify-end">
- <Button type="button" variant="primary" size="sm" onClick={onClose}>
- {t('settings.agents.editor.toolsDone')}
- </Button>
- </div>
- }>
- <>
- <div className="border-b border-line px-4 py-3">
- <div className="relative">
- <LuSearch className="pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-content-faint" />
- <TextField
- autoFocus
- value={query}
- onChange={e => setQuery(e.target.value)}
- placeholder={t('settings.agents.editor.toolsSearchPlaceholder')}
- aria-label={t('settings.agents.editor.toolsSearchPlaceholder')}
- className="pl-8"
- />
- </div>
-
- <Toggle
- variant="secondary"
- pressed={allToolsSelected}
- onPressedChange={onToggleAll}
- data-testid="agent-tools-allow-all-toggle"
- className={
- 'mt-2 h-auto w-full items-start justify-between gap-2 rounded-md px-3 py-2 text-left font-normal ' +
- (allToolsSelected
- ? 'border-primary-400 bg-primary-50 dark:border-primary-500/40 dark:bg-primary-500/10'
- : 'hover:bg-surface-hover')
- }>
- <span>
- <span className="block text-xs font-semibold text-content">
- {t('settings.agents.editor.toolsAllowAll')}
- </span>
- <span className="block text-[11px] text-content-faint">
- {t('settings.agents.editor.toolsAllowAllHint')}
- </span>
- </span>
- <ToggleMark checked={allToolsSelected} className="mt-0.5" />
- </Toggle>
- </div>
-
- <div className="min-h-32 flex-1 overflow-y-auto px-2 py-2">
- {loading ? (
- <CenteredLoadingState
- label={t('settings.agents.editor.toolsLoading')}
- className="py-10"
- />
- ) : error ? (
- <p className="px-2 py-6 text-center text-sm text-coral-600 dark:text-coral-300">
- {t('settings.agents.editor.toolsLoadError')}: {error}
- </p>
- ) : filtered.length === 0 ? (
- <p className="px-2 py-6 text-center text-sm text-content-faint">
- {t('settings.agents.editor.toolsEmpty')}
- </p>
- ) : (
- <ul>
- {filtered.map(tool => {
- const checked = allToolsSelected || selected.includes(tool.name);
- return (
- <li key={tool.name}>
- <Button
- type="button"
- variant="tertiary"
- disabled={allToolsSelected}
- aria-pressed={checked}
- onClick={() => onToggleTool(tool.name)}
- className="h-auto w-full items-start justify-start gap-3 rounded-md px-2 py-2 text-left font-normal disabled:cursor-not-allowed disabled:opacity-50">
- <ToggleMark checked={checked} className="mt-0.5" />
- <span className="min-w-0">
- <span className="block font-mono text-xs font-medium text-content">
- {tool.name}
- </span>
- <span className="block wrap-break-word text-[11px] leading-snug text-content-muted">
- {tool.description}
- </span>
- </span>
- </Button>
- </li>
- );
- })}
- </ul>
- )}
- </div>
- </>
- </ModalShell>
- );
-}
diff --git a/app/src/components/settings/panels/AgentsPanel.removal.test.tsx b/app/src/components/settings/panels/AgentsPanel.removal.test.tsx
deleted file mode 100644
index f4266258ab..0000000000
--- a/app/src/components/settings/panels/AgentsPanel.removal.test.tsx
+++ /dev/null
@@ -1,190 +0,0 @@
-import { fireEvent, render, screen, waitFor } from '@testing-library/react';
-import { MemoryRouter } from 'react-router-dom';
-import { beforeEach, describe, expect, it, vi } from 'vitest';
-
-import { agentRegistryApi, type AgentRegistryEntry } from '../../../services/api/agentRegistryApi';
-import AgentsPanel from './AgentsPanel';
-
-/**
- * The destructive half of `AgentsPanel`.
- *
- * `handleRemove` (panel :75-90) was an entirely uncovered function, and it is
- * the one that deletes a registry entry. The same handler backs two differently
- * labelled buttons — "Delete" for a custom agent, "Reset" for a built-in
- * (:210-216) — so the copy is the only thing telling a user which of those two
- * things they are about to do.
- *
- * Also covers the failure arms of both `handleRemove` and `handleToggle`,
- * including their non-`Error` fallbacks onto `settings.agents.actionFailed`.
- *
- * NOT covered, deliberately: `handleToggle`'s `agent.id === ORCHESTRATOR_ID`
- * early return (:56). The orchestrator's switch is rendered `disabled`
- * (:175, `disabled={busy || isOrchestrator}`), so the guard is a second line of
- * defence that a click cannot reach. The existing suite asserts the reachable
- * half — that the switch is disabled — which is the right assertion.
- */
-
-vi.mock('../../../services/api/agentRegistryApi', () => ({
- agentRegistryApi: {
- list: vi.fn(),
- get: vi.fn(),
- availableTools: vi.fn(),
- createCustom: vi.fn(),
- update: vi.fn(),
- setEnabled: vi.fn(),
- remove: vi.fn(),
- },
-}));
-
-const mockNavigate = vi.fn();
-vi.mock('react-router-dom', async importOriginal => {
- const actual = await importOriginal<typeof import('react-router-dom')>();
- return { ...actual, useNavigate: () => mockNavigate };
-});
-
-vi.mock('../hooks/useSettingsNavigation', () => ({
- useSettingsNavigation: () => ({
- navigateBack: vi.fn(),
- navigateToSettings: vi.fn(),
- breadcrumbs: [],
- }),
-}));
-
-const mockList = vi.mocked(agentRegistryApi.list);
-const mockSetEnabled = vi.mocked(agentRegistryApi.setEnabled);
-const mockRemove = vi.mocked(agentRegistryApi.remove);
-
-function agent(overrides: Partial<AgentRegistryEntry> = {}): AgentRegistryEntry {
- return {
- id: 'researcher',
- name: 'Researcher',
- description: 'Looks things up.',
- source: 'default',
- enabled: true,
- tool_allowlist: ['*'],
- ...overrides,
- };
-}
-
-const renderPanel = () =>
- render(
- <MemoryRouter>
- <AgentsPanel />
- </MemoryRouter>
- );
-
-/** [orchestrator, researcher (built-in), finance (custom)] */
-const defaultList = () => [
- agent({ id: 'orchestrator', name: 'Orchestrator' }),
- agent({ id: 'researcher', name: 'Researcher' }),
- agent({ id: 'finance', name: 'Finance', source: 'custom' }),
-];
-
-const deleteButtons = () => screen.getAllByRole('button', { name: /delete/i });
-const resetButtons = () => screen.getAllByRole('button', { name: /reset/i });
-
-beforeEach(() => {
- vi.clearAllMocks();
- mockList.mockResolvedValue(defaultList());
- // `agentRegistryApi.remove` returns Promise<boolean> (agentRegistryApi.ts:147-154),
- // so the success fixture must resolve `true`. Resolving `undefined as never`
- // modelled a value the API cannot return, and the `as never` cast was the
- // tell — it silenced the type error that was pointing this out. It also hid
- // whether the panel handles a `false` (refused) result differently from a
- // `true` one. Caught in review by `coderabbitai`.
- mockRemove.mockResolvedValue(true);
- mockSetEnabled.mockResolvedValue(agent({ id: 'researcher', enabled: false }));
-});
-
-describe('AgentsPanel — removing an agent', () => {
- it('removes the agent the button belongs to, then reloads the list', async () => {
- renderPanel();
- await waitFor(() => expect(screen.getByText('Finance')).toBeInTheDocument());
- expect(mockList).toHaveBeenCalledTimes(1);
-
- fireEvent.click(deleteButtons()[0]);
-
- await waitFor(() => expect(mockRemove).toHaveBeenCalledWith('finance'));
- // The list must be re-fetched, not patched locally: a removal can cascade.
- await waitFor(() => expect(mockList).toHaveBeenCalledTimes(2));
- });
-
- it('resets a built-in agent through the same removal call', async () => {
- renderPanel();
- await waitFor(() => expect(screen.getByText('Researcher')).toBeInTheDocument());
-
- // "Reset" on a built-in is the same destructive RPC as "Delete"; only the
- // copy differs, so this pins that the right id is sent.
- fireEvent.click(resetButtons()[0]);
- await waitFor(() => expect(mockRemove).toHaveBeenCalledWith('orchestrator'));
- });
-
- it('labels the action Delete for custom agents and Reset for built-ins', async () => {
- renderPanel();
- await waitFor(() => expect(screen.getByText('Finance')).toBeInTheDocument());
-
- // Two built-ins (orchestrator, researcher) and one custom (finance).
- expect(resetButtons()).toHaveLength(2);
- expect(deleteButtons()).toHaveLength(1);
- });
-
- it('surfaces the failure message when removal rejects', async () => {
- mockRemove.mockRejectedValue(new Error('agent is referenced by a flow'));
- renderPanel();
- await waitFor(() => expect(screen.getByText('Finance')).toBeInTheDocument());
-
- fireEvent.click(deleteButtons()[0]);
- expect(await screen.findByText(/agent is referenced by a flow/)).toBeInTheDocument();
- // A failed removal must not be reported as done.
- expect(mockList).toHaveBeenCalledTimes(1);
- });
-
- it('falls back to the generic copy when removal rejects with a non-Error', async () => {
- mockRemove.mockRejectedValue({ code: 500 });
- renderPanel();
- await waitFor(() => expect(screen.getByText('Finance')).toBeInTheDocument());
-
- fireEvent.click(deleteButtons()[0]);
- expect(await screen.findByText(/Couldn.t update the agent/)).toBeInTheDocument();
- });
-});
-
-describe('AgentsPanel — toggle failures', () => {
- it('surfaces the failure message when setEnabled rejects', async () => {
- mockSetEnabled.mockRejectedValue(new Error('registry is read-only'));
- renderPanel();
- await waitFor(() => expect(screen.getByText('Researcher')).toBeInTheDocument());
-
- // Index 1 — the orchestrator's switch at index 0 is disabled.
- fireEvent.click(screen.getAllByRole('switch')[1]);
- expect(await screen.findByText(/registry is read-only/)).toBeInTheDocument();
- });
-
- it('falls back to the generic copy when setEnabled rejects with a non-Error', async () => {
- mockSetEnabled.mockRejectedValue('nope');
- renderPanel();
- await waitFor(() => expect(screen.getByText('Researcher')).toBeInTheDocument());
-
- fireEvent.click(screen.getAllByRole('switch')[1]);
- expect(await screen.findByText(/Couldn.t update the agent/)).toBeInTheDocument();
- });
-
- // Regression guard rather than a mutation-proven test: this panel has no
- // optimistic update to begin with (`setAgents` runs only on success), so
- // "the row did not move" cannot be broken by a one-line change. Kept because
- // it pins that difference from AgentAccessPanel, which DOES update
- // optimistically and rolls back — the two panels must not be assumed alike.
- it('leaves the row untouched when the toggle fails', async () => {
- mockSetEnabled.mockRejectedValue(new Error('registry is read-only'));
- renderPanel();
- await waitFor(() => expect(screen.getByText('Researcher')).toBeInTheDocument());
-
- const before = screen.getAllByRole('switch')[1].getAttribute('aria-checked');
- fireEvent.click(screen.getAllByRole('switch')[1]);
- await screen.findByText(/registry is read-only/);
-
- // No optimistic update to roll back — the switch must still reflect the
- // server state, not the click.
- expect(screen.getAllByRole('switch')[1]).toHaveAttribute('aria-checked', before as string);
- });
-});
diff --git a/app/src/components/settings/panels/AgentsPanel.test.tsx b/app/src/components/settings/panels/AgentsPanel.test.tsx
deleted file mode 100644
index a1feeddbca..0000000000
--- a/app/src/components/settings/panels/AgentsPanel.test.tsx
+++ /dev/null
@@ -1,223 +0,0 @@
-import { fireEvent, render, screen, waitFor } from '@testing-library/react';
-import { MemoryRouter } from 'react-router-dom';
-import { beforeEach, describe, expect, it, vi } from 'vitest';
-
-import { agentRegistryApi, type AgentRegistryEntry } from '../../../services/api/agentRegistryApi';
-import AgentsPanel from './AgentsPanel';
-
-vi.mock('../../../services/api/agentRegistryApi', () => ({
- agentRegistryApi: {
- list: vi.fn(),
- get: vi.fn(),
- availableTools: vi.fn(),
- createCustom: vi.fn(),
- update: vi.fn(),
- setEnabled: vi.fn(),
- remove: vi.fn(),
- },
-}));
-
-const mockNavigate = vi.fn();
-vi.mock('react-router-dom', async importOriginal => {
- const actual = await importOriginal<typeof import('react-router-dom')>();
- return { ...actual, useNavigate: () => mockNavigate };
-});
-
-const mockNavigateToSettings = vi.fn();
-vi.mock('../hooks/useSettingsNavigation', () => ({
- useSettingsNavigation: () => ({
- navigateBack: vi.fn(),
- navigateToSettings: mockNavigateToSettings,
- breadcrumbs: [],
- }),
-}));
-
-const mockList = vi.mocked(agentRegistryApi.list);
-const mockSetEnabled = vi.mocked(agentRegistryApi.setEnabled);
-const mockRemove = vi.mocked(agentRegistryApi.remove);
-
-const renderPanel = () =>
- render(
- <MemoryRouter>
- <AgentsPanel />
- </MemoryRouter>
- );
-
-function agent(overrides: Partial<AgentRegistryEntry> = {}): AgentRegistryEntry {
- return {
- id: 'researcher',
- name: 'Researcher',
- description: 'Looks things up.',
- source: 'default',
- enabled: true,
- tool_allowlist: ['*'],
- ...overrides,
- };
-}
-
-describe('AgentsPanel', () => {
- beforeEach(() => {
- vi.clearAllMocks();
- mockList.mockResolvedValue([
- agent({ id: 'orchestrator', name: 'Orchestrator' }),
- agent({ id: 'researcher', name: 'Researcher' }),
- agent({
- id: 'finance',
- name: 'Finance',
- source: 'custom',
- tool_allowlist: ['memory.search'],
- }),
- ]);
- });
-
- it('lists agents with their source badges', async () => {
- renderPanel();
- await waitFor(() => expect(screen.getByText('Researcher')).toBeInTheDocument());
- expect(screen.getByText('Orchestrator')).toBeInTheDocument();
- expect(screen.getByText('Finance')).toBeInTheDocument();
- expect(screen.getByText('Custom')).toBeInTheDocument();
- expect(screen.getAllByText('Built-in').length).toBe(2);
- });
-
- it('toggles a non-orchestrator agent via setEnabled', async () => {
- mockSetEnabled.mockResolvedValue(agent({ id: 'researcher', enabled: false }));
- renderPanel();
- await waitFor(() => expect(screen.getByText('Researcher')).toBeInTheDocument());
-
- const switches = screen.getAllByRole('switch');
- // Order matches list order: [orchestrator, researcher, finance].
- expect(switches[0]).toBeDisabled(); // orchestrator is always enabled
- fireEvent.click(switches[1]);
-
- await waitFor(() => expect(mockSetEnabled).toHaveBeenCalledWith('researcher', false));
- });
-
- it('navigates to the create editor page', async () => {
- renderPanel();
- await waitFor(() => expect(screen.getByText('Researcher')).toBeInTheDocument());
- fireEvent.click(screen.getByRole('button', { name: /New agent/ }));
- // Routes through useSettingsNavigation so the desktop modal backdrop is
- // preserved; the hook prefixes `/settings/`.
- expect(mockNavigateToSettings).toHaveBeenCalledWith('agents/new');
- });
-
- it('only offers Edit for custom agents and navigates to the edit page', async () => {
- renderPanel();
- await waitFor(() => expect(screen.getByText('Finance')).toBeInTheDocument());
- // Two built-ins (orchestrator, researcher) + one custom (finance) — only the
- // custom agent exposes an Edit button.
- const editButtons = screen.getAllByRole('button', { name: /Edit/ });
- expect(editButtons).toHaveLength(1);
- fireEvent.click(editButtons[0]);
- expect(mockNavigateToSettings).toHaveBeenCalledWith('agents/edit/finance');
- });
-
- it('shows an error when loading fails', async () => {
- mockList.mockRejectedValueOnce(new Error('boom'));
- renderPanel();
- await waitFor(() => expect(screen.getByText(/Couldn't load agents/)).toBeInTheDocument());
- });
- // --- Paths the original five cases left uncovered -----------------------
- //
- // Coverage before these: 79.03% stmts / 62.50% branch, with lines 65-66
- // (the toggle failure branch), 77-87 (`handleRemove` in full) and 131 (its
- // wiring) unexecuted. `handleRemove` is the destructive action on this
- // panel and had no test at all.
-
- it('surfaces the API error message when a toggle fails', async () => {
- // The catch branch prefers `err.message` over the generic i18n fallback,
- // so a caller sees *why* it failed rather than "Couldn't update the agent".
- mockSetEnabled.mockRejectedValueOnce(new Error('registry is read-only'));
- renderPanel();
- await waitFor(() => expect(screen.getByText('Researcher')).toBeInTheDocument());
-
- fireEvent.click(screen.getAllByRole('switch')[1]);
-
- await waitFor(() => expect(screen.getByText('registry is read-only')).toBeInTheDocument());
- // The row must not be left stuck in its busy state after a failure.
- await waitFor(() => expect(screen.getAllByRole('switch')[1]).not.toBeDisabled());
- });
-
- it('falls back to the generic message when a toggle rejects a non-Error', async () => {
- // `err instanceof Error` is the branch under test: a string rejection
- // must not render "undefined" into the banner.
- mockSetEnabled.mockRejectedValueOnce('nope');
- renderPanel();
- await waitFor(() => expect(screen.getByText('Researcher')).toBeInTheDocument());
-
- fireEvent.click(screen.getAllByRole('switch')[1]);
-
- await waitFor(() => expect(screen.getByText("Couldn't update the agent")).toBeInTheDocument());
- });
-
- it('deletes a custom agent and reloads the list', async () => {
- mockRemove.mockResolvedValue(true);
- renderPanel();
- await waitFor(() => expect(screen.getByText('Finance')).toBeInTheDocument());
-
- // Built-ins offer "Reset to default"; only the custom agent offers Delete.
- const deleteButtons = screen.getAllByRole('button', { name: /^Delete$/ });
- expect(deleteButtons).toHaveLength(1);
- fireEvent.click(deleteButtons[0]);
-
- await waitFor(() => expect(mockRemove).toHaveBeenCalledWith('finance'));
- // `handleRemove` re-runs `load()` rather than patching state locally, so a
- // reset built-in comes back with its server-side defaults.
- await waitFor(() => expect(mockList).toHaveBeenCalledTimes(2));
- });
-
- it('resets a built-in agent through the same remove endpoint', async () => {
- // Built-ins are not deleted — the panel labels the action "Reset to
- // default" but routes it through `remove`, which restores the shipped
- // definition. Worth pinning: the label and the call diverge on purpose.
- mockRemove.mockResolvedValue(true);
- renderPanel();
- await waitFor(() => expect(screen.getByText('Researcher')).toBeInTheDocument());
-
- const resetButtons = screen.getAllByRole('button', { name: /Reset to default/ });
- // orchestrator + researcher are both built-in.
- expect(resetButtons).toHaveLength(2);
- fireEvent.click(resetButtons[1]);
-
- await waitFor(() => expect(mockRemove).toHaveBeenCalledWith('researcher'));
- });
-
- it('shows an error and stops reloading when a delete fails', async () => {
- mockRemove.mockRejectedValueOnce(new Error('agent is in use'));
- renderPanel();
- await waitFor(() => expect(screen.getByText('Finance')).toBeInTheDocument());
-
- fireEvent.click(screen.getAllByRole('button', { name: /^Delete$/ })[0]);
-
- await waitFor(() => expect(screen.getByText('agent is in use')).toBeInTheDocument());
- // A failed remove must NOT reload: reloading would redraw the row as if
- // nothing happened and drop the error the user needs to read.
- expect(mockList).toHaveBeenCalledTimes(1);
- });
-
- it('renders the orchestrator switch disabled so it cannot be toggled', async () => {
- // Scope correction, from review: an earlier version of this case claimed to
- // cover `handleToggle`'s ORCHESTRATOR_ID early-return (AgentsPanel.tsx:56)
- // by clicking the switch as well as asserting it disabled. It does not —
- // `AgentRow` renders the orchestrator's SettingsSwitch `disabled`, so the
- // click never reaches the handler and removing the guard alone would not
- // fail this test.
- //
- // My revert-proof did not catch that because the mutation removed the guard
- // AND the `disabled` prop together, so the case went red for the second
- // reason. A fault that changes two things proves neither individually.
- //
- // What this case honestly covers is the disabled control, which is the
- // user-facing protection; the handler guard behind it is defence in depth
- // and would need an enabled seam to exercise. Renamed to say so.
- renderPanel();
- await waitFor(() => expect(screen.getByText('Orchestrator')).toBeInTheDocument());
-
- const orchestratorSwitch = screen.getAllByRole('switch')[0];
- expect(orchestratorSwitch).toBeDisabled();
- fireEvent.click(orchestratorSwitch);
-
- await waitFor(() => expect(screen.getByText('Researcher')).toBeInTheDocument());
- expect(mockSetEnabled).not.toHaveBeenCalled();
- });
-});
diff --git a/app/src/components/settings/panels/AgentsPanel.tsx b/app/src/components/settings/panels/AgentsPanel.tsx
deleted file mode 100644
index 4bbc1484eb..0000000000
--- a/app/src/components/settings/panels/AgentsPanel.tsx
+++ /dev/null
@@ -1,223 +0,0 @@
-/**
- * AgentsPanel — Settings > Agents.
- *
- * Surfaces the user-facing agent registry (`openhuman.agent_registry_*`):
- * shipped built-in agents plus user-authored custom agents. Users can
- * enable/disable agents, create custom agents, edit any agent (editing a
- * built-in saves an override), and delete a custom agent / reset a built-in
- * override.
- */
-import { useCallback, useEffect, useRef, useState } from 'react';
-import { LuPencil, LuPlus, LuRotateCcw, LuTrash2 } from 'react-icons/lu';
-
-import { useT } from '../../../lib/i18n/I18nContext';
-import { agentRegistryApi, type AgentRegistryEntry } from '../../../services/api/agentRegistryApi';
-import { Alert, AlertDescription, CenteredLoadingState } from '../../ui';
-import Button from '../../ui/Button';
-import { SettingsBadge, SettingsEmptyState, SettingsSwitch } from '../controls';
-import { useSettingsNavigation } from '../hooks/useSettingsNavigation';
-import SettingsPanel from '../layout/SettingsPanel';
-
-const ORCHESTRATOR_ID = 'orchestrator';
-
-const AgentsPanel = () => {
- const { t } = useT();
- const { navigateToSettings } = useSettingsNavigation();
-
- const [agents, setAgents] = useState<AgentRegistryEntry[]>([]);
- const [loading, setLoading] = useState(true);
- const [error, setError] = useState<string | null>(null);
- const [actionError, setActionError] = useState<string | null>(null);
- const [busyId, setBusyId] = useState<string | null>(null);
- const mountedRef = useRef(true);
-
- const load = useCallback(async () => {
- setError(null);
- try {
- const list = await agentRegistryApi.list(true);
- if (mountedRef.current) setAgents(list);
- } catch (err) {
- if (mountedRef.current) setError(err instanceof Error ? err.message : String(err));
- } finally {
- if (mountedRef.current) setLoading(false);
- }
- }, []);
-
- useEffect(() => {
- mountedRef.current = true;
- void load();
- return () => {
- mountedRef.current = false;
- };
- }, [load]);
-
- const handleToggle = useCallback(
- async (agent: AgentRegistryEntry) => {
- if (agent.id === ORCHESTRATOR_ID) return;
- setActionError(null);
- setBusyId(agent.id);
- try {
- const updated = await agentRegistryApi.setEnabled(agent.id, !agent.enabled);
- if (mountedRef.current) {
- setAgents(prev => prev.map(a => (a.id === updated.id ? updated : a)));
- }
- } catch (err) {
- if (mountedRef.current) {
- setActionError(err instanceof Error ? err.message : t('settings.agents.actionFailed'));
- }
- } finally {
- if (mountedRef.current) setBusyId(null);
- }
- },
- [t]
- );
-
- const handleRemove = useCallback(
- async (agent: AgentRegistryEntry) => {
- setActionError(null);
- setBusyId(agent.id);
- try {
- await agentRegistryApi.remove(agent.id);
- await load();
- } catch (err) {
- if (mountedRef.current) {
- setActionError(err instanceof Error ? err.message : t('settings.agents.actionFailed'));
- }
- } finally {
- if (mountedRef.current) setBusyId(null);
- }
- },
- [load, t]
- );
-
- return (
- <SettingsPanel
- description={t('settings.agents.subtitle')}
- action={
- <Button
- type="button"
- variant="primary"
- size="xs"
- onClick={() => navigateToSettings('agents/new')}>
- <LuPlus className="h-3.5 w-3.5 mr-1" />
- {t('settings.agents.newAgent')}
- </Button>
- }>
- {actionError && (
- <Alert variant="destructive" density="compact" className="mb-3">
- <AlertDescription>{actionError}</AlertDescription>
- </Alert>
- )}
-
- {loading ? (
- <CenteredLoadingState label={t('common.loading')} className="py-12" />
- ) : error ? (
- <Alert variant="destructive">
- <AlertDescription>
- {t('settings.agents.loadError')}: {error}
- </AlertDescription>
- </Alert>
- ) : agents.length === 0 ? (
- <SettingsEmptyState label={t('settings.agents.empty')} />
- ) : (
- <ul className="divide-y divide-line overflow-hidden rounded-xl border border-line">
- {agents.map(agent => (
- <AgentRow
- key={agent.id}
- agent={agent}
- busy={busyId === agent.id}
- onToggle={() => handleToggle(agent)}
- onEdit={() => navigateToSettings(`agents/edit/${agent.id}`)}
- onRemove={() => handleRemove(agent)}
- />
- ))}
- </ul>
- )}
- </SettingsPanel>
- );
-};
-
-function AgentRow({
- agent,
- busy,
- onToggle,
- onEdit,
- onRemove,
-}: {
- agent: AgentRegistryEntry;
- busy: boolean;
- onToggle: () => void;
- onEdit: () => void;
- onRemove: () => void;
-}) {
- const { t } = useT();
- const isCustom = agent.source === 'custom';
- const isOrchestrator = agent.id === ORCHESTRATOR_ID;
- const tools = agent.tool_allowlist ?? [];
- const toolsLabel = tools.includes('*')
- ? t('settings.agents.toolsAll')
- : t('settings.agents.toolsCount').replace('{count}', String(tools.length));
-
- return (
- <li className={`bg-surface px-4 py-3 ${agent.enabled ? '' : 'opacity-70'}`}>
- <div className="flex items-center justify-between gap-3">
- <div className="flex min-w-0 flex-wrap items-center gap-2">
- <h3 className="truncate text-sm font-semibold text-content">{agent.name}</h3>
- <SettingsBadge variant={isCustom ? 'primary' : 'neutral'}>
- {isCustom ? t('settings.agents.sourceCustom') : t('settings.agents.sourceDefault')}
- </SettingsBadge>
- </div>
-
- <SettingsSwitch
- id={`agent-toggle-${agent.id}`}
- checked={agent.enabled}
- onCheckedChange={onToggle}
- disabled={busy || isOrchestrator}
- aria-label={agent.enabled ? t('settings.agents.disable') : t('settings.agents.enable')}
- />
- </div>
-
- <p className="mt-1 wrap-break-word text-xs leading-snug text-content-muted">
- {agent.description}
- </p>
- <div className="mt-1.5 flex flex-wrap gap-x-3 gap-y-1 text-[11px] text-content-faint">
- <code className="font-mono">{agent.id}</code>
- {agent.model && (
- <span>
- {t('settings.agents.modelLabel')}: {agent.model}
- </span>
- )}
- <span>
- {t('settings.agents.toolsLabel')}: {toolsLabel}
- </span>
- </div>
-
- <div className="mt-2 flex items-center justify-end gap-1">
- {/* Built-in agents can't be edited — only custom agents expose Edit.
- Built-ins keep the toggle (enable/disable) and Reset (clear override). */}
- {isCustom && (
- <Button type="button" variant="tertiary" size="xs" onClick={onEdit}>
- <LuPencil className="h-3 w-3 mr-1" />
- {t('settings.agents.edit')}
- </Button>
- )}
- <Button
- type="button"
- variant="secondary"
- tone="danger"
- size="xs"
- disabled={busy}
- onClick={onRemove}>
- {isCustom ? (
- <LuTrash2 className="h-3 w-3 mr-1" />
- ) : (
- <LuRotateCcw className="h-3 w-3 mr-1" />
- )}
- {isCustom ? t('settings.agents.delete') : t('settings.agents.reset')}
- </Button>
- </div>
- </li>
- );
-}
-
-export default AgentsPanel;
diff --git a/app/src/components/settings/settingsRouteElements.tsx b/app/src/components/settings/settingsRouteElements.tsx
index eeb995ed12..561141a7a0 100644
--- a/app/src/components/settings/settingsRouteElements.tsx
+++ b/app/src/components/settings/settingsRouteElements.tsx
@@ -6,8 +6,6 @@ import SettingsIndexRedirect from './layout/SettingsIndexRedirect';
import AboutPanel from './panels/AboutPanel';
import AccountPanel from './panels/AccountPanel';
import AgentAccessPanel from './panels/AgentAccessPanel';
-import AgentEditorPage from './panels/AgentEditorPage';
-import AgentsPanel from './panels/AgentsPanel';
import AppearancePanel from './panels/AppearancePanel';
import ApprovalHistoryPanel from './panels/ApprovalHistoryPanel';
import CoreConnectionPanel from './panels/CoreConnectionPanel';
@@ -115,15 +113,14 @@ export function settingsRouteElements(): ReactNode {
<Route path="personality" element={<PersonalityRoute />} />
<Route path="face" element={wrapSettingsPage(<MascotPanel />)} />
<Route path="language" element={<SettingsRedirect to="/settings/account" />} />
- <Route path="agents" element={wrapSettingsPage(<AgentsPanel />)} />
- <Route path="agents/new" element={wrapSettingsPage(<AgentEditorPage />)} />
- <Route path="agents/edit/:id" element={wrapSettingsPage(<AgentEditorPage />)} />
+ {/* The Agents list and editor were removed; old links land on Tools. */}
+ <Route path="agents/*" element={<SettingsRedirect to="/settings/tools" />} />
<Route path="agent-access" element={wrapSettingsPage(<AgentAccessPanel />)} />
{/* Agent activity level (medulla/subconscious background-AI knob) was
retired along with medulla/subconscious themselves. The slug
- redirects so any old deep link lands on Agents rather than falling
+ redirects so any old deep link lands on Tools rather than falling
through to the settings index. */}
- <Route path="activity-level" element={<SettingsRedirect to="/settings/agents" />} />
+ <Route path="activity-level" element={<SettingsRedirect to="/settings/tools" />} />
<Route path="sandbox-settings" element={wrapSettingsPage(<SandboxSettingsPanel />)} />
<Route path="approval-history" element={wrapSettingsPage(<ApprovalHistoryPanel />)} />
@@ -203,7 +200,7 @@ export function settingsRouteElements(): ReactNode {
{/* ── Legacy slugs → redirects (deep-link compatibility) ──── */}
{/* Old hub pages */}
<Route path="ai" element={<Navigate to="/connections?tab=llm" replace />} />
- <Route path="agents-settings" element={<SettingsRedirect to="/settings/agents" />} />
+ <Route path="agents-settings" element={<SettingsRedirect to="/settings/tools" />} />
<Route path="crypto" element={<Navigate to="/connections?tab=wallet" replace />} />
<Route path="notifications-hub" element={<SettingsRedirect to="/settings/account" />} />
{/* Composio (API key + routing) moved to Connections → API keys. */}
diff --git a/app/src/components/settings/settingsRouteRegistry.ts b/app/src/components/settings/settingsRouteRegistry.ts
index defdf776f8..9a237e2191 100644
--- a/app/src/components/settings/settingsRouteRegistry.ts
+++ b/app/src/components/settings/settingsRouteRegistry.ts
@@ -14,7 +14,6 @@ import debug from 'debug';
// 'home' → top-level home menu entry (Settings breadcrumb only)
// 'account' → Settings → Account
// 'ai' → Settings → AI & Models
-// 'agents' → Settings → Agents
// 'features' → Settings → Features
// 'crypto' → Settings → Crypto
// 'developer' → Settings → Developer & Diagnostics (devOnly entries)
@@ -390,15 +389,6 @@ export const SETTINGS_ROUTE_REGISTRY: SettingsRegistryEntry[] = [
// =========================================================================
// AGENTS section leaf panels
// =========================================================================
- {
- id: 'agents',
- titleKey: 'settings.agents.title',
- descriptionKey: 'settings.agents.subtitle',
- section: 'agents',
- searchKeywords: ['agent', 'profiles'],
- navGroup: 'agentsAutonomy',
- navOrder: 0,
- },
{
// agent-access also hosts the autonomy rate-limit section (formerly the
// standalone /settings/autonomy page — that slug redirects here).
diff --git a/app/src/services/analyticsRoutes.ts b/app/src/services/analyticsRoutes.ts
index bad94933e9..d855c45ba9 100644
--- a/app/src/services/analyticsRoutes.ts
+++ b/app/src/services/analyticsRoutes.ts
@@ -30,9 +30,6 @@ export function normalizeAnalyticsPagePath(path: string): string {
if (/^\/settings\/team\/manage\/[^/]+$/.test(pathname)) {
return '/settings/team/manage/:teamId';
}
- if (/^\/settings\/agents\/edit\/[^/]+$/.test(pathname)) {
- return '/settings/agents/edit/:id';
- }
if (/^\/settings\/profiles\/edit\/[^/]+$/.test(pathname)) {
return '/settings/profiles/edit/:id';
}