diff --git a/app/page.tsx b/app/page.tsx index 717f75f..e2f2720 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -3,6 +3,7 @@ import Link from "next/link"; import { Puzzle, Timer, Sparkles } from "lucide-react"; import { StatusCard } from "@/components/StatusCard"; +import { StatsCard } from "@/components/StatsCard"; import { SessionCard } from "@/components/SessionCard"; import { MemorySnapshotCard } from "@/components/MemorySnapshotCard"; import { useSessions } from "@/lib/hooks"; @@ -23,9 +24,9 @@ export default function PulsePage() { + - {/* Quick links */}
{QUICK_LINKS.map(({ href, label, icon: Icon, color }) => ( diff --git a/components/StatsCard.tsx b/components/StatsCard.tsx new file mode 100644 index 0000000..18eaad4 --- /dev/null +++ b/components/StatsCard.tsx @@ -0,0 +1,39 @@ +"use client"; + +import { BarChart3 } from "lucide-react"; +import { useSessions } from "@/lib/hooks"; +import { formatTokens } from "@/lib/utils"; + +export function StatsCard() { + const { data } = useSessions(50); + + const items = data?.items || []; + const total = data?.total || 0; + const totalTokens = items.reduce((s, i) => s + i.input_tokens + i.output_tokens, 0); + const totalCost = items.reduce((s, i) => s + (i.estimated_cost_usd || 0), 0); + const platforms = new Set(items.map((i) => i.source)); + + const stats = [ + { label: "Sessions", value: String(total) }, + { label: "Tokens (recent)", value: formatTokens(totalTokens) }, + { label: "Platforms", value: String(platforms.size) }, + ...(totalCost > 0 ? [{ label: "Est. Cost", value: "$" + totalCost.toFixed(2) }] : []), + ]; + + return ( +
+
+ + Stats +
+
+ {stats.map((s) => ( +
+
{s.value}
+
{s.label}
+
+ ))} +
+
+ ); +}