/** * Savings Summary Card (Feature 17 — Story 17.15) * * Displays total potential savings and per-category breakdown. */ import React from 'react'; import type { OptimizationCategory } from '@agentkitai/agentlens-core'; interface CategoryBreakdown { count: number; totalSavings: number; } interface SavingsSummaryProps { totalPotentialSavings: number; analyzedCalls: number; period: number; byCategory: Partial>; } const CATEGORY_META: Record = { model_downgrade: { label: 'Model Downgrade', icon: '⬇️', color: 'bg-blue-100 text-blue-800' }, prompt_optimization: { label: 'Prompt Optimization', icon: '✂️', color: 'bg-purple-100 text-purple-800' }, caching: { label: 'Caching', icon: '💾', color: 'bg-green-100 text-green-800' }, tool_reduction: { label: 'Tool Reduction', icon: '🔧', color: 'bg-amber-100 text-amber-800' }, }; function formatCost(usd: number): string { if (usd < 0.01) return `$${usd.toFixed(4)}`; if (usd < 1) return `$${usd.toFixed(3)}`; return `$${usd.toFixed(2)}`; } export function SavingsSummary({ totalPotentialSavings, analyzedCalls, period, byCategory, }: SavingsSummaryProps): React.ReactElement { const categories = Object.entries(byCategory).filter( ([, v]) => v && v.count > 0, ) as [OptimizationCategory, CategoryBreakdown][]; return (

Potential Savings

Based on {analyzedCalls.toLocaleString()} calls over {period} days

{formatCost(totalPotentialSavings)}
per month
{categories.length > 0 && (
{categories.map(([cat, data]) => { const meta = CATEGORY_META[cat]; return (
{meta.icon}
{meta.label}
{formatCost(data.totalSavings)}
{data.count}
); })}
)}
); }