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(#456): show Set up badge on Agent nav item when Anthropic key is missing (#472)
Maqbool Ahmedc94adbe1dbe4
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex d84cc7eef..3be0f5e98 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0## [Unreleased]+### Added++- Sidebar / Mobile nav: Agent nav item now shows a **"Set up"** badge on cloud when the org has no Anthropic API key saved — clicking still lands on the existing Settings CTA; badge disappears automatically after the key is saved and the page is reloaded; self-host instances are unaffected and make no extra network calls (#456)+### Fixed- Prompts / Query Fan-out: the High frequency pager no longer renders one button per page — replaced with a windowed pager (`‹ 1 … n-1 n n+1 … last ›`) that caps at ~9 elements, preventing overflow on brands with hundreds of pages; Previous/Next chevron buttons added, disabled at boundaries; ellipsis shown as a non-interactive span; all page numbers shown without ellipsis when total pages ≤ 7 (#446)@@ -278,4 +282,4 @@ Huge thanks to everyone who contributed to this release: @Pallavikumarimdb, @Mai- Real-time brand visibility monitoring across AI search engines- Competitor tracking and content optimization suggestions- Prompt volume analysis-- Stripe integration for cloud billing+- Stripe integration for cloud billing\ No newline at end of filediff --git a/web/src/components/layout/mobile-nav.tsx b/web/src/components/layout/mobile-nav.tsxindex 7ff3e7ca9..71ee438d9 100644--- a/web/src/components/layout/mobile-nav.tsx+++ b/web/src/components/layout/mobile-nav.tsx@@ -5,6 +5,7 @@ import { useTranslations } from 'next-intl';import { usePathname, Link } from '@/i18n/navigation';import { dashboardNav } from '@/config/dashboard';import { useFeatureGate } from '@/hooks/use-feature-gate';+import { useAgentKeyStatus } from '@/hooks/use-agent-key-status';import { siteConfig } from '@/config/site';import { cn } from '@/lib/utils';import { Button } from '@/components/ui/button';@@ -22,6 +23,10 @@ export function MobileNav() {const t = useTranslations('nav');const tBrands = useTranslations('brands');const { canUse, requiredPlanFor, isCloud } = useFeatureGate();+ // Probe once per session — shares the module-level cache with sidebar.tsx+ // so at most one network request is made even when both components mount.+ const agentKeyStatus = useAgentKeyStatus(isCloud);+ const agentKeyMissing = isCloud && agentKeyStatus === 'missing';const { activeBrandId } = useBrandStore();const { resolvedTheme } = useTheme();const [mounted, setMounted] = useState(false);@@ -97,6 +102,11 @@ export function MobileNav() {: pathname.startsWith(item.href);const label = getLabel(item.title);+ // Dynamic badge override: show "Set up" on the Agent item+ // when the org has no Anthropic key saved (cloud only).+ const effectiveBadge =+ item.href === '/dashboard/agent' && agentKeyMissing ? 'Set up' : item.badge;+const isLocked =isCloud && item.requiredFeature != null && !canUse(item.requiredFeature);@@ -130,7 +140,15 @@ export function MobileNav() {)}><item.icon className="h-4 w-4 shrink-0" />- {label}+ <span className="flex-1">{label}</span>+ {effectiveBadge && (+ <Badge+ variant="secondary"+ className="h-5 shrink-0 px-1.5 text-[10px] font-normal"+ >+ {effectiveBadge}+ </Badge>+ )}</span></Link>);diff --git a/web/src/components/layout/sidebar.tsx b/web/src/components/layout/sidebar.tsxindex 6500ad4a6..3c4c3cbe4 100644--- a/web/src/components/layout/sidebar.tsx+++ b/web/src/components/layout/sidebar.tsx@@ -9,6 +9,7 @@ import { dashboardNav } from '@/config/dashboard';import { useSidebarStore } from '@/stores/use-sidebar-store';import { useBrandStore } from '@/stores/use-brand-store';import { useFeatureGate } from '@/hooks/use-feature-gate';+import { useAgentKeyStatus } from '@/hooks/use-agent-key-status';import { siteConfig } from '@/config/site';import { cn } from '@/lib/utils';import { Button } from '@/components/ui/button';@@ -25,6 +26,10 @@ export function Sidebar() {const t = useTranslations('nav');const tBrands = useTranslations('brands');const { canUse, requiredPlanFor, isCloud } = useFeatureGate();+ // Probe once per session whether the org has saved an Anthropic key.+ // Returns 'configured' immediately on self-host (no network call).+ const agentKeyStatus = useAgentKeyStatus(isCloud);+ const agentKeyMissing = isCloud && agentKeyStatus === 'missing';// Brand-scoped gates follow the active brand, not the org. Selecting the// derived brand keeps this reactive: switching brands via BrandSwitcher or// toggling the flag in Brand Settings flips the gate without a route change.@@ -118,6 +123,11 @@ export function Sidebar() {const labelFn = navKeyMap[item.title];const label = labelFn ? labelFn() : item.title;+ // Dynamic badge override: show "Set up" on the Agent item+ // when the org has no Anthropic key saved (cloud only).+ const effectiveBadge =+ item.href === '/dashboard/agent' && agentKeyMissing ? 'Set up' : item.badge;+const isLocked =isCloud && item.requiredFeature != null && !canUse(item.requiredFeature);@@ -165,10 +175,28 @@ export function Sidebar() {: 'text-muted-foreground hover:bg-accent hover:text-accent-foreground',isCollapsed && 'justify-center',)}- title={isCollapsed ? label : undefined}+ title={+ isCollapsed+ ? effectiveBadge+ ? `${label} (${effectiveBadge})`+ : label+ : undefined+ }><item.icon className="h-4 w-4 shrink-0" />- {!isCollapsed && <span className="truncate">{label}</span>}+ {!isCollapsed && (+ <>+ <span className="flex-1 truncate">{label}</span>+ {effectiveBadge && (+ <Badge+ variant="secondary"+ className="ml-auto h-5 shrink-0 px-1.5 text-[10px] font-normal"+ >+ {effectiveBadge}+ </Badge>+ )}+ </>+ )}</span></Link>);diff --git a/web/src/hooks/use-agent-key-status.ts b/web/src/hooks/use-agent-key-status.tsnew file mode 100644index 000000000..f228f1f57--- /dev/null+++ b/web/src/hooks/use-agent-key-status.ts@@ -0,0 +1,76 @@+'use client';++import { useEffect, useState } from 'react';++/**+ * Module-level cache so we only hit /api/settings/anthropic-key once per+ * page-load session — not on every navigation. The sidebar and mobile nav+ * both consume this hook; sharing the cache means a single inflight request+ * even when both components mount simultaneously (e.g. on a resize boundary).+ *+ * The cache intentionally resets on a full page reload (module re-evaluation),+ * which satisfies the acceptance criterion: "after the key is saved, the badge+ * disappears on next load fine — no realtime requirement."+ */+let cachedStatus: 'loading' | 'configured' | 'missing' = 'loading';+let fetchPromise: Promise<void> | null = null;++export function fetchKeyStatus(): Promise<void> {+ if (fetchPromise) return fetchPromise;+ fetchPromise = (async () => {+ try {+ const res = await fetch('/api/settings/anthropic-key');+ if (!res.ok) {+ cachedStatus = 'missing';+ return;+ }+ const body = (await res.json()) as { configured?: boolean };+ cachedStatus = body.configured ? 'configured' : 'missing';+ } catch {+ cachedStatus = 'missing';+ }+ })();+ return fetchPromise;+}++/** Exposed for tests only — reads the current module-level cache value. */+export function getCachedStatus() {+ return cachedStatus;+}++/**+ * Returns whether the org has saved an Anthropic API key.+ *+ * On self-host (`isCloud === false`) this is a no-op — the key lives in the+ * server env and no network call is made. Only cloud instances probe the+ * endpoint, gated by the same `NEXT_PUBLIC_IS_CLOUD` flag the rest of the+ * dashboard uses.+ *+ * @param isCloud - pass the value from `useFeatureGate()` so this hook stays+ * pure and testable without a real PlanContext.+ */+export function useAgentKeyStatus(isCloud: boolean): 'loading' | 'configured' | 'missing' {+ // Self-host never needs a key check — return a stable value immediately.+ if (!isCloud) return 'configured';++ // eslint-disable-next-line react-hooks/rules-of-hooks+ const [status, setStatus] = useState<'loading' | 'configured' | 'missing'>(cachedStatus);++ // eslint-disable-next-line react-hooks/rules-of-hooks+ useEffect(() => {+ // Already resolved from a prior render or sibling mount — nothing to do.+ if (cachedStatus !== 'loading') {+ setStatus(cachedStatus);+ return;+ }+ let cancelled = false;+ fetchKeyStatus().then(() => {+ if (!cancelled) setStatus(cachedStatus);+ });+ return () => {+ cancelled = true;+ };+ }, []);++ return status;+}