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
fix(citations): group raw model slugs under display names in the Platforms filter (#48)
Sourabh Haldarfb29037fb5b6
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/citations/page.tsx b/web/src/app/[locale]/(dashboard)/dashboard/citations/page.tsxindex da7211148..8e5183151 100644--- a/web/src/app/[locale]/(dashboard)/dashboard/citations/page.tsx+++ b/web/src/app/[locale]/(dashboard)/dashboard/citations/page.tsx@@ -72,6 +72,7 @@ import { Skeleton } from '@/components/ui/skeleton';import { cn } from '@/lib/utils';import {AIProviderAvatar,+ getAIProviderDisplayName,resolveAIProvider,type AIProviderKey,} from '@/components/ai-provider-avatar';@@ -117,6 +118,25 @@ const CATEGORY_BADGE_CLASSES: Record<SourceCategory, string> = {};// AI platform / model friendly names — kept in sync with the insights page.+const PLATFORM_LABELS: Record<string, string> = {+ chatgpt: 'ChatGPT',+ gemini: 'Gemini',+ perplexity: 'Perplexity',+ claude: 'Claude',+ grok: 'Grok',+ copilot: 'Copilot',+ 'meta-ai': 'Meta AI',+ 'google-ai-overviews': 'Google AI',+ 'google-ai-mode': 'Google AI Mode',+ 'chatgpt-web': 'ChatGPT',+ 'google-aio': 'Google AI Overview',+ 'google-aimode': 'Google AI Mode',+ 'copilot-web': 'Microsoft Copilot',+ 'grok-web': 'Grok',+ 'perplexity-web': 'Perplexity',+ 'gemini-web': 'Google Gemini',+};+const MODEL_DISPLAY_NAME: Record<string, string> = {'gpt-4o': 'GPT-4o','gpt-4o-mini': 'GPT-4o Mini',@@ -140,8 +160,20 @@ const MODEL_DISPLAY_NAME: Record<string, string> = {'gemini-web': 'Gemini',};-function getModelLabel(model: string): string {- return MODEL_DISPLAY_NAME[model] ?? model;+function getPlatformDisplayLabel(slug: string): string {+ return (+ MODEL_DISPLAY_NAME[slug] ??+ PLATFORM_LABELS[slug] ??+ getAIProviderDisplayName(resolveAIProvider(slug))+ );+}++function getGroupedPlatformLabel(value: string): string {+ const firstSlug = value+ .split(',')+ .map((slug) => slug.trim())+ .find(Boolean);+ return firstSlug ? getPlatformDisplayLabel(firstSlug) : value;}// ─── Filter types ─────────────────────────────────────────────────────────────@@ -157,6 +189,11 @@ interface UIFilters {competitorOnly: boolean;}+interface PlatformOption {+ value: string;+ label: string;+}+const DEFAULT_FILTERS: UIFilters = {datePreset: 'all',dateFrom: '',@@ -168,6 +205,35 @@ const DEFAULT_FILTERS: UIFilters = {competitorOnly: false,};+function buildPlatformOptions(+ rows: CitationsOverview['rows'],+): PlatformOption[] {+ const slugToLabel = new Map<string, string>();+ for (const row of rows) {+ for (const slug of row.models) {+ if (!slug || slugToLabel.has(slug)) continue;+ slugToLabel.set(slug, getPlatformDisplayLabel(slug));+ }+ }++ const familyToSlugs = new Map<string, string[]>();+ for (const [slug, label] of slugToLabel) {+ const slugs = familyToSlugs.get(label) ?? [];+ slugs.push(slug);+ familyToSlugs.set(label, slugs);+ }++ return Array.from(familyToSlugs.entries())+ .map(([label, slugs]) => ({+ label,+ value: slugs.sort().join(','),+ }))+ .sort(+ (a, b) =>+ a.label.localeCompare(b.label) || a.value.localeCompare(b.value),+ );+}+// ─── Sub-components ───────────────────────────────────────────────────────────function CategoryBadge({ category }: { category: SourceCategory }) {@@ -373,7 +439,7 @@ function FilterBar({filters: UIFilters;onChange: (patch: Partial<UIFilters>) => void;topics: Topic[];- platforms: string[];+ platforms: PlatformOption[];regions: string[];}) {return (@@ -474,16 +540,17 @@ function FilterBar({<SelectValue placeholder="All Platforms">{(value) =>value && value !== '__all__'- ? getModelLabel(value)+ ? platforms.find((platform) => platform.value === value)+ ?.label ?? getGroupedPlatformLabel(value): 'All Platforms'}</SelectValue></SelectTrigger><SelectContent><SelectItem value="__all__">All Platforms</SelectItem>- {platforms.map((p) => (- <SelectItem key={p} value={p}>- {getModelLabel(p)}+ {platforms.map((platform) => (+ <SelectItem key={platform.value} value={platform.value}>+ {platform.label}</SelectItem>))}</SelectContent>@@ -739,7 +806,9 @@ export default function CitationsPage() {const [data, setData] = useState<CitationsOverview | null>(null);const [isLoading, setIsLoading] = useState(true);const [topics, setTopics] = useState<Topic[]>([]);- const [availablePlatforms, setAvailablePlatforms] = useState<string[]>([]);+ const [availablePlatforms, setAvailablePlatforms] = useState<PlatformOption[]>(+ [],+ );const [availableRegions, setAvailableRegions] = useState<string[]>([]);const activeBrandId = brand?.id ?? null;@@ -774,14 +843,19 @@ export default function CitationsPage() {setData(overview);// Surface filter options from the observed models/regions.- const platforms = new Set<string>();+ const platformOptions = buildPlatformOptions(overview.rows);const regions = new Set<string>();- for (const row of overview.rows) {- for (const m of row.models) platforms.add(m);- }setAvailablePlatforms((prev) =>- Array.from(new Set([...prev, ...platforms])).sort((a, b) =>- a.localeCompare(b),+ Array.from(+ new Map(+ [...prev, ...platformOptions].map((platform) => [+ platform.value,+ platform,+ ]),+ ).values(),+ ).sort(+ (a, b) =>+ a.label.localeCompare(b.label) || a.value.localeCompare(b.value),),);if (regions.size > 0) {diff --git a/web/src/lib/actions/citations.ts b/web/src/lib/actions/citations.tsindex 236dcfcf7..298ad9a3e 100644--- a/web/src/lib/actions/citations.ts+++ b/web/src/lib/actions/citations.ts@@ -111,6 +111,35 @@ function resolveDateRange(// ─── Main action ──────────────────────────────────────────────────────────────+/**+ * Apply the platform/model filter to `prompt_results.model_used`.+ *+ * Supports both a single slug (`gpt-5-5`) and a comma-joined family+ * (`gpt-5-3-mini,gpt-5-5`) so the UI can filter an entire provider family+ * from one dropdown option.+ */+// eslint-disable-next-line @typescript-eslint/no-explicit-any+function applyModelFilter<T extends { eq: any; in: any }>(+ query: T,+ models: string[] | undefined,+): T {+ if (!models || models.length === 0) return query;++ const list = Array.from(+ new Set(+ models.flatMap((model) =>+ model+ .split(',')+ .map((slug) => slug.trim())+ .filter(Boolean),+ ),+ ),+ );++ if (list.length <= 1) return query.eq('model_used', list[0] ?? models[0]);+ return query.in('model_used', list);+}+export async function getCitationsOverview(brandId: string,filters: CitationsFilters,@@ -149,7 +178,7 @@ export async function getCitationsOverview(if (from) query = query.gte('created_at', from);if (to) query = query.lte('created_at', to);if (filters.platforms && filters.platforms.length > 0) {- query = query.in('platform', filters.platforms);+ query = applyModelFilter(query, filters.platforms);}if (filters.regions && filters.regions.length > 0) {query = query.in('region', filters.regions);