Open-source agentic AI Search Execution Platform. Track AI visibility, find opportunities, and let agents turn signals into prioritized actions and drafted fixes across ChatGPT, Claude, Gemini, Google AI Overviews, Google AI Mode, Perplexity, Grok, and Microsoft Copilot.
TypeScript aeoai-agentai-searchanswer-engine-optimizationbrand-monitoringchatgptclaudecopilotdockergeminigeogoogle-ai-overviewsgrokmcpnextjsopen-sourceperplexityseosupabasetypescript
feat(settings): rename Agent to AI Providers and give each settings section its own address (#1209)
Cihan1cbf64752011
diff --git a/web/messages/en.json b/web/messages/en.jsonindex 8a89652a7..a44db9e8a 100644--- a/web/messages/en.json+++ b/web/messages/en.json@@ -4280,7 +4280,7 @@"customPlanDescription": "Get unlimited brands, custom integrations, dedicated support, and more.","contactUs": "Contact Us","integrations": "Integrations",- "agent": "Agent",+ "aiProviders": "AI Providers","revokeApiKey": "Revoke API key","revokeApiKeyConfirm": "Revoke this API key? Clients using it will lose access immediately.","revoke": "Revoke",@@ -4316,7 +4316,7 @@"zed": "Add to your Zed settings.json."},"apiKeys_name": "Name",- "agent_description": "Bring your own Anthropic API key. The in-product agent uses your key to call Claude directly — usage is billed to your Anthropic account, not to Ansvisor.",+ "agent_description": "Ansvisor's Chat answers with an AI model on your own account with its provider. Add your Anthropic API key: Chat calls Claude with it, the usage is billed to your Anthropic account rather than to Ansvisor, and the key is stored encrypted.","agent_keyConfigured": "Key configured","agent_savedAt": "Saved {date}","agent_savedBy": "by {email}",diff --git a/web/src/app/[locale]/(dashboard)/dashboard/agent/page.tsx b/web/src/app/[locale]/(dashboard)/dashboard/agent/page.tsxindex dc8cd70bb..9152eed3a 100644--- a/web/src/app/[locale]/(dashboard)/dashboard/agent/page.tsx+++ b/web/src/app/[locale]/(dashboard)/dashboard/agent/page.tsx@@ -778,7 +778,7 @@ function KeyMissingState() {<h2 className="text-lg font-semibold">{t('keyMissingTitle')}</h2><p className="text-sm text-muted-foreground mt-2">{t('keyMissingBody')}</p><Link- href="/dashboard/settings?tab=agent"+ href="/dashboard/settings/ai-providers"className={cn(buttonVariants({ variant: 'default' }), 'mt-5 gap-2')}><KeyRound className="h-4 w-4" />diff --git a/web/src/app/[locale]/(dashboard)/dashboard/settings/[section]/page.tsx b/web/src/app/[locale]/(dashboard)/dashboard/settings/[section]/page.tsxnew file mode 100644index 000000000..a9e61c09b--- /dev/null+++ b/web/src/app/[locale]/(dashboard)/dashboard/settings/[section]/page.tsx@@ -0,0 +1,15 @@+'use client';++import { useParams } from 'next/navigation';+import { usePlanContext } from '@/components/providers/plan-provider';+import { SettingsView } from '../_settings-view';+import { resolveSettingsSection } from '../_sections';++/** A settings section at its own address: /dashboard/settings/ai-providers. */+export default function SettingsSectionPage() {+ const { isCloud } = usePlanContext();+ const { section } = useParams<{ section: string }>();+ const resolved = resolveSettingsSection(section, { isCloud });+ // Keyed: a link from one section's address to another's opens the new one.+ return <SettingsView key={resolved} section={resolved} />;+}diff --git a/web/src/app/[locale]/(dashboard)/dashboard/settings/_sections.test.ts b/web/src/app/[locale]/(dashboard)/dashboard/settings/_sections.test.tsnew file mode 100644index 000000000..7bf6b7d80--- /dev/null+++ b/web/src/app/[locale]/(dashboard)/dashboard/settings/_sections.test.ts@@ -0,0 +1,33 @@+import { describe, expect, it } from 'vitest';+import { resolveSettingsSection, settingsSectionPath } from './_sections';++const cloud = { isCloud: true };+const selfHost = { isCloud: false };++describe('resolveSettingsSection', () => {+ it('opens the section the address names', () => {+ expect(resolveSettingsSection('ai-providers', cloud)).toBe('ai-providers');+ expect(resolveSettingsSection('notifications', selfHost)).toBe('notifications');+ });++ it('reads the older names an address may carry', () => {+ expect(resolveSettingsSection('agent', cloud)).toBe('ai-providers');+ expect(resolveSettingsSection('project', selfHost)).toBe('organization');+ });++ it("opens Account for none, an unknown section, or one self-host doesn't have", () => {+ expect(resolveSettingsSection(null, cloud)).toBe('account');+ expect(resolveSettingsSection('nope', cloud)).toBe('account');+ expect(resolveSettingsSection('ai-providers', selfHost)).toBe('account');+ expect(resolveSettingsSection('billing', selfHost)).toBe('account');+ });+});++describe('settingsSectionPath', () => {+ it('keeps the locale prefix and replaces the section', () => {+ expect(settingsSectionPath('/dashboard/settings', 'team')).toBe('/dashboard/settings/team');+ expect(settingsSectionPath('/tr/dashboard/settings/team', 'ai-providers')).toBe(+ '/tr/dashboard/settings/ai-providers',+ );+ });+});diff --git a/web/src/app/[locale]/(dashboard)/dashboard/settings/_sections.ts b/web/src/app/[locale]/(dashboard)/dashboard/settings/_sections.tsnew file mode 100644index 000000000..4041b3e2e--- /dev/null+++ b/web/src/app/[locale]/(dashboard)/dashboard/settings/_sections.ts@@ -0,0 +1,54 @@+/**+ * Settings' sections, each with its own address (/dashboard/settings/<id>),+ * so a page or an e-mail can link straight to one: the Chat page links to AI+ * Providers when no key is set.+ */+export const SETTINGS_SECTIONS = [+ 'account',+ 'organization',+ 'team',+ 'notifications',+ 'integrations',+ 'api-keys',+ 'ai-providers',+ 'billing',+] as const;++export type SettingsSection = (typeof SETTINGS_SECTIONS)[number];++/** Sections only Ansvisor Cloud has: self-host sets its AI key in env, and has no billing. */+const CLOUD_ONLY: readonly SettingsSection[] = ['ai-providers', 'billing'];++/** Older names an address may still carry: ?tab=project, ?tab=agent. */+const RENAMED: Record<string, SettingsSection> = {+ project: 'organization',+ agent: 'ai-providers',+};++/**+ * The section an address names (the path's last part, or the older ?tab=),+ * or Account for none, an unknown one, or one this install doesn't have.+ */+export function resolveSettingsSection(+ value: string | null | undefined,+ { isCloud }: { isCloud: boolean },+): SettingsSection {+ const name = value ? (RENAMED[value] ?? value) : null;+ const section = SETTINGS_SECTIONS.find((s) => s === name);+ if (!section || (!isCloud && CLOUD_ONLY.includes(section))) return 'account';+ return section;+}++/** Whether this install shows the section. */+export function hasSettingsSection(section: SettingsSection, { isCloud }: { isCloud: boolean }) {+ return isCloud || !CLOUD_ONLY.includes(section);+}++/**+ * The address of a section, from the current path: the locale prefix it may+ * carry is kept.+ */+export function settingsSectionPath(pathname: string, section: SettingsSection): string {+ const base = pathname.replace(/\/dashboard\/settings(\/.*)?$/, '/dashboard/settings');+ return `${base}/${section}`;+}diff --git a/web/src/app/[locale]/(dashboard)/dashboard/settings/_settings-view.tsx b/web/src/app/[locale]/(dashboard)/dashboard/settings/_settings-view.tsxnew file mode 100644index 000000000..94f4c9a8f--- /dev/null+++ b/web/src/app/[locale]/(dashboard)/dashboard/settings/_settings-view.tsx@@ -0,0 +1,190 @@+'use client';++import { useEffect, useState } from 'react';+import { useTranslations } from 'next-intl';+import { useRouter } from '@/i18n/navigation';+import { createClient } from '@/lib/supabase/client';+import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';+import { Input } from '@/components/ui/input';+import { Label } from '@/components/ui/label';+import { Button } from '@/components/ui/button';+import { Separator } from '@/components/ui/separator';+import { cn } from '@/lib/utils';+import { usePlanContext } from '@/components/providers/plan-provider';+import { BillingSection } from '@/components/settings/billing-section';+import { TeamSection } from '@/components/settings/team-section';+import { ApiKeysSection } from '@/components/settings/api-keys-section';+import { AgentSection } from '@/components/settings/agent-section';+import { NotificationsSection } from '@/components/settings/notifications-section';+import { IntegrationsSection } from '@/components/settings/integrations-section';+import { OrganizationSection } from '@/components/settings/organization-section';+import { updateAccountName } from '@/lib/actions/organization';+import { Loader2 } from 'lucide-react';+import { toast } from 'sonner';+import {+ SETTINGS_SECTIONS,+ hasSettingsSection,+ settingsSectionPath,+ type SettingsSection,+} from './_sections';++/**+ * Settings, opened on `section`: from its own address (/dashboard/settings/+ * ai-providers) or the older ?tab= one, which e-mails and the integrations'+ * OAuth return still use. Picking a section moves the address to it.+ */+export function SettingsView({ section }: { section: SettingsSection }) {+ const t = useTranslations('settings');+ const tAuth = useTranslations('auth');+ const router = useRouter();+ const { isCloud } = usePlanContext();+ const [active, setActive] = useState<SettingsSection>(section);++ const show = (next: SettingsSection) => {+ setActive(next);+ window.history.replaceState(null, '', settingsSectionPath(window.location.pathname, next));+ };+ const [displayName, setDisplayName] = useState('');+ const [email, setEmail] = useState('');+ const [savingName, setSavingName] = useState(false);++ useEffect(() => {+ const supabase = createClient();+ supabase.auth.getUser().then(({ data: { user: u } }) => {+ setDisplayName(u?.user_metadata?.full_name ?? '');+ setEmail(u?.email ?? '');+ });+ }, []);++ async function handleSignOut() {+ const supabase = createClient();+ await supabase.auth.signOut();+ router.push('/sign-in');+ router.refresh();+ }++ async function handleSaveAccount() {+ setSavingName(true);+ try {+ await updateAccountName(displayName);+ toast.success(t('saved'));+ } catch (err) {+ toast.error(err instanceof Error ? err.message : t('accountSaveFailed'));+ } finally {+ setSavingName(false);+ }+ }++ const labels: Record<SettingsSection, string> = {+ account: t('account'),+ organization: t('organization'),+ team: t('team'),+ notifications: t('notifications'),+ integrations: t('integrations'),+ 'api-keys': t('apiKeys'),+ 'ai-providers': t('aiProviders'),+ billing: t('billing'),+ };+ // AI Providers (bring your own key) and Billing are cloud-only: self-host+ // operators set ANTHROPIC_API_KEY in their own env.+ const navItems = SETTINGS_SECTIONS.filter((id) => hasSettingsSection(id, { isCloud })).map(+ (id) => ({ id, label: labels[id] }),+ );++ return (+ <div className="space-y-6">+ <div>+ <h1 className="text-2xl font-bold tracking-tight">{t('title')}</h1>+ <p className="text-muted-foreground">{t('description')}</p>+ </div>++ <Separator />++ <div className="grid grid-cols-1 gap-6 lg:grid-cols-3">+ {/* Sidebar nav */}+ <nav className="space-y-1">+ {navItems.map((item) => (+ <button+ key={item.id}+ onClick={() => show(item.id)}+ className={cn(+ 'w-full text-left rounded-md px-3 py-2 text-sm font-medium transition-colors',+ active === item.id+ ? 'bg-accent text-accent-foreground'+ : 'text-muted-foreground hover:bg-accent hover:text-accent-foreground',+ )}+ >+ {item.label}+ </button>+ ))}+ </nav>++ {/* Main content — only active section shown */}+ <div className="lg:col-span-2">+ {/* Account */}+ {active === 'account' && (+ <Card>+ <CardHeader>+ <CardTitle>{t('account')}</CardTitle>+ <CardDescription>{t('accountDescription')}</CardDescription>+ </CardHeader>+ <CardContent className="space-y-4">+ <div className="space-y-2">+ <Label htmlFor="name">{t('displayName')}</Label>+ <Input+ id="name"+ placeholder="Your name"+ value={displayName}+ onChange={(e) => setDisplayName(e.target.value)}+ />+ </div>+ <div className="space-y-2">+ <Label htmlFor="email">{t('email')}</Label>+ <Input+ id="email"+ type="email"+ placeholder="[email protected]"+ value={email}+ onChange={() => {}}+ disabled+ />+ </div>+ <Button onClick={handleSaveAccount} disabled={savingName || !displayName.trim()}>+ {savingName && <Loader2 className="mr-2 h-4 w-4 animate-spin" />}+ {t('save')}+ </Button>+ <Separator className="my-2" />+ <Button+ variant="outline"+ onClick={handleSignOut}+ className="text-destructive hover:text-destructive"+ >+ {tAuth('signOut')}+ </Button>+ </CardContent>+ </Card>+ )}++ {/* Organization */}+ {active === 'organization' && <OrganizationSection />}++ {/* Team */}+ {active === 'team' && <TeamSection />}++ {active === 'notifications' && <NotificationsSection />}++ {active === 'integrations' && <IntegrationsSection />}++ {/* API Keys */}+ {active === 'api-keys' && <ApiKeysSection />}++ {/* AI Providers (cloud BYOK) */}+ {active === 'ai-providers' && isCloud && <AgentSection />}++ {/* Billing */}+ {active === 'billing' && isCloud && <BillingSection />}+ </div>+ </div>+ </div>+ );+}diff --git a/web/src/app/[locale]/(dashboard)/dashboard/settings/page.tsx b/web/src/app/[locale]/(dashboard)/dashboard/settings/page.tsxindex 8253d00b8..4f81212a4 100644--- a/web/src/app/[locale]/(dashboard)/dashboard/settings/page.tsx+++ b/web/src/app/[locale]/(dashboard)/dashboard/settings/page.tsx@@ -1,194 +1,17 @@'use client';-import { useEffect, useState } from 'react';-import { useTranslations } from 'next-intl';-import { useRouter } from '@/i18n/navigation';import { useSearchParams } from 'next/navigation';-import { createClient } from '@/lib/supabase/client';-import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';-import { Input } from '@/components/ui/input';-import { Label } from '@/components/ui/label';-import { Button } from '@/components/ui/button';-import { Separator } from '@/components/ui/separator';-import { cn } from '@/lib/utils';import { usePlanContext } from '@/components/providers/plan-provider';-import { BillingSection } from '@/components/settings/billing-section';-import { TeamSection } from '@/components/settings/team-section';-import { ApiKeysSection } from '@/components/settings/api-keys-section';-import { AgentSection } from '@/components/settings/agent-section';-import { NotificationsSection } from '@/components/settings/notifications-section';-import { IntegrationsSection } from '@/components/settings/integrations-section';-import { OrganizationSection } from '@/components/settings/organization-section';-import { updateAccountName } from '@/lib/actions/organization';-import { Loader2 } from 'lucide-react';-import { toast } from 'sonner';--type Section =- | 'account'- | 'organization'- | 'team'- | 'notifications'- | 'integrations'- | 'api-keys'- | 'agent'- | 'billing';-+import { SettingsView } from './_settings-view';+import { resolveSettingsSection } from './_sections';++/**+ * /dashboard/settings, on Account or on the section an older ?tab= names: the+ * Daily Pulse e-mail links ?tab=notifications, the integrations' OAuth popups+ * return to ?tab=integrations, and ?tab=agent is AI Providers now.+ */export default function SettingsPage() {- const t = useTranslations('settings');- const tAuth = useTranslations('auth');- const router = useRouter();const { isCloud } = usePlanContext();- const searchParams = useSearchParams();- const tabParam = searchParams.get('tab');- const [active, setActive] = useState<Section>(() => {- if (tabParam === 'billing' && isCloud) return 'billing';- if (tabParam === 'agent' && isCloud) return 'agent';- // Deep-linked from the Daily Pulse email's "manage notifications" footer.- if (tabParam === 'notifications') return 'notifications';- // OAuth popups land back here after the Composio consent flow (#577).- if (tabParam === 'integrations') return 'integrations';- // Legacy deep-link: ?tab=project now maps to the new organization tab.- if (tabParam === 'organization' || tabParam === 'project') return 'organization';- return 'account';- });- const [displayName, setDisplayName] = useState('');- const [email, setEmail] = useState('');- const [savingName, setSavingName] = useState(false);-- useEffect(() => {- const supabase = createClient();- supabase.auth.getUser().then(({ data: { user: u } }) => {- setDisplayName(u?.user_metadata?.full_name ?? '');- setEmail(u?.email ?? '');- });- }, []);-- async function handleSignOut() {- const supabase = createClient();- await supabase.auth.signOut();- router.push('/sign-in');- router.refresh();- }-- async function handleSaveAccount() {- setSavingName(true);- try {- await updateAccountName(displayName);- toast.success(t('saved'));- } catch (err) {- toast.error(err instanceof Error ? err.message : t('accountSaveFailed'));- } finally {- setSavingName(false);- }- }-- const navItems: { id: Section; label: string }[] = [- { id: 'account', label: t('account') },- { id: 'organization', label: t('organization') },- { id: 'team', label: t('team') },- { id: 'notifications', label: t('notifications') },- { id: 'integrations', label: t('integrations') },- { id: 'api-keys', label: t('apiKeys') },- // Agent BYOK is a cloud-only concern — self-host operators configure- // ANTHROPIC_API_KEY in their own env, no UI needed.- ...(isCloud ? [{ id: 'agent' as Section, label: t('agent') }] : []),- ...(isCloud ? [{ id: 'billing' as Section, label: t('billing') }] : []),- ];-- return (- <div className="space-y-6">- <div>- <h1 className="text-2xl font-bold tracking-tight">{t('title')}</h1>- <p className="text-muted-foreground">{t('description')}</p>- </div>-- <Separator />-- <div className="grid grid-cols-1 gap-6 lg:grid-cols-3">- {/* Sidebar nav */}- <nav className="space-y-1">- {navItems.map((item) => (- <button- key={item.id}- onClick={() => setActive(item.id)}- className={cn(- 'w-full text-left rounded-md px-3 py-2 text-sm font-medium transition-colors',- active === item.id- ? 'bg-accent text-accent-foreground'- : 'text-muted-foreground hover:bg-accent hover:text-accent-foreground',- )}- >- {item.label}- </button>- ))}- </nav>-- {/* Main content — only active section shown */}- <div className="lg:col-span-2">- {/* Account */}- {active === 'account' && (- <Card>- <CardHeader>- <CardTitle>{t('account')}</CardTitle>- <CardDescription>{t('accountDescription')}</CardDescription>- </CardHeader>- <CardContent className="space-y-4">- <div className="space-y-2">- <Label htmlFor="name">{t('displayName')}</Label>- <Input- id="name"- placeholder="Your name"- value={displayName}- onChange={(e) => setDisplayName(e.target.value)}- />- </div>- <div className="space-y-2">- <Label htmlFor="email">{t('email')}</Label>- <Input- id="email"- type="email"- placeholder="[email protected]"- value={email}- onChange={() => {}}- disabled- />- </div>- <Button onClick={handleSaveAccount} disabled={savingName || !displayName.trim()}>- {savingName && <Loader2 className="mr-2 h-4 w-4 animate-spin" />}- {t('save')}- </Button>- <Separator className="my-2" />- <Button- variant="outline"- onClick={handleSignOut}- className="text-destructive hover:text-destructive"- >- {tAuth('signOut')}- </Button>- </CardContent>- </Card>- )}-- {/* Organization */}- {active === 'organization' && <OrganizationSection />}-- {/* Team */}- {active === 'team' && <TeamSection />}-- {active === 'notifications' && <NotificationsSection />}-- {active === 'integrations' && <IntegrationsSection />}-- {/* API Keys */}- {active === 'api-keys' && <ApiKeysSection />}-- {/* Agent (cloud BYOK) */}- {active === 'agent' && isCloud && <AgentSection />}-- {/* Billing */}- {active === 'billing' && isCloud && <BillingSection />}- </div>- </div>- </div>- );+ const tab = useSearchParams().get('tab');+ return <SettingsView section={resolveSettingsSection(tab, { isCloud })} />;}diff --git a/web/src/components/settings/agent-section.tsx b/web/src/components/settings/agent-section.tsxindex a100068b5..4c48ae5d4 100644--- a/web/src/components/settings/agent-section.tsx+++ b/web/src/components/settings/agent-section.tsx@@ -120,7 +120,7 @@ export function AgentSection() {<CardHeader><CardTitle className="flex items-center gap-2"><Sparkles className="h-4 w-4" />- {t('agent')}+ {t('aiProviders')}</CardTitle><CardDescription>{t('agent_description')}</CardDescription></CardHeader>