From 4ab41d0e3867949cefb9c83b07b5f3c739905739 Mon Sep 17 00:00:00 2001 From: Hermes Date: Thu, 9 Apr 2026 21:23:03 -0500 Subject: [PATCH] Platform breakdown on Pulse, cost display on sessions --- app/page.tsx | 2 ++ components/PlatformBreakdown.tsx | 46 ++++++++++++++++++++++++++++++++ components/SessionCard.tsx | 8 +++++- 3 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 components/PlatformBreakdown.tsx diff --git a/app/page.tsx b/app/page.tsx index 6e4fe66..730e0af 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -7,6 +7,7 @@ import { StatusCard } from "@/components/StatusCard"; import { StatsCard } from "@/components/StatsCard"; import { SessionCard } from "@/components/SessionCard"; import { MemorySnapshotCard } from "@/components/MemorySnapshotCard"; +import { PlatformBreakdown } from "@/components/PlatformBreakdown"; import { useSessions } from "@/lib/hooks"; import { usePullToRefresh } from "@/lib/usePullToRefresh"; @@ -28,6 +29,7 @@ export default function PulsePage() { +
{QUICK_LINKS.map(({ href, label, icon: Icon }) => ( diff --git a/components/PlatformBreakdown.tsx b/components/PlatformBreakdown.tsx new file mode 100644 index 0000000..185639a --- /dev/null +++ b/components/PlatformBreakdown.tsx @@ -0,0 +1,46 @@ +"use client"; + +import { useSessions } from "@/lib/hooks"; +import { platformBadgeClass } from "@/lib/utils"; + +export function PlatformBreakdown() { + const { data } = useSessions(50); + const items = data?.items || []; + + if (items.length === 0) return null; + + const counts: Record = {}; + for (const s of items) { + counts[s.source] = (counts[s.source] || 0) + 1; + } + + const sorted = Object.entries(counts).sort((a, b) => b[1] - a[1]); + const total = items.length; + + return ( +
+
Platforms
+
+ {sorted.map(([platform, count]) => { + const pct = Math.round((count / total) * 100); + return ( +
+ + {platform} + +
+
+
+ + {count} + +
+ ); + })} +
+
+ ); +} diff --git a/components/SessionCard.tsx b/components/SessionCard.tsx index 7c6ef3e..635a6b6 100644 --- a/components/SessionCard.tsx +++ b/components/SessionCard.tsx @@ -8,13 +8,14 @@ import type { Session } from "@/lib/types"; export function SessionCard({ session }: { session: Session }) { const tokens = session.input_tokens + session.output_tokens; const title = session.title || "Untitled session"; + const cost = session.estimated_cost_usd; return (
{title}
-
+
{session.source} @@ -26,6 +27,11 @@ export function SessionCard({ session }: { session: Session }) { {formatTokens(tokens)} )} + {cost != null && cost > 0 && ( + + ${cost.toFixed(2)} + + )} {timeAgo(session.started_at)}