Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions console-ui/src/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -340,23 +340,6 @@ h1, h2, h3 {
animation: fade-in 0.3s ease-out;
}

@keyframes network-flow-ping {
from { stroke-dashoffset: 0; }
to { stroke-dashoffset: -180; }
}

.network-flow-ping {
animation-name: network-flow-ping;
animation-timing-function: linear;
animation-iteration-count: infinite;
}

@media (prefers-reduced-motion: reduce) {
.network-flow-ping {
animation: none;
}
}

/* ─── Syntax highlighting ─── */
.hljs {
background: transparent !important;
Expand Down
1,356 changes: 594 additions & 762 deletions console-ui/src/app/stats/page.tsx

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions console-ui/src/components/stats/StatsFlowMetric.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"use client";

import { statsFlowTickerCell } from "./styles";

interface StatsFlowMetricProps {
label: string;
value: string;
sub: string;
}

export function StatsFlowMetric({ label, value, sub }: StatsFlowMetricProps) {
return (
<div className={statsFlowTickerCell}>
<p className="font-mono text-[0.56rem] tracking-[0.16em] uppercase text-text-tertiary">{label}</p>
<p className="mt-1.5 font-mono text-lg font-bold tracking-tight text-text-primary leading-none">
{value}
</p>
<p className="mt-1 truncate font-mono text-[0.62rem] text-text-tertiary">{sub}</p>
</div>
);
}
181 changes: 181 additions & 0 deletions console-ui/src/components/stats/StatsGeographyPanels.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
"use client";

import { useMemo, useState } from "react";
import type {
ProviderLocationBucketView,
RequestLocationBucketView,
} from "@/lib/stats-geography-types";
import { statsCapacityGrid } from "./styles";

export type { ProviderLocationBucketView, RequestLocationBucketView };

interface StatsRequestGeographyLeaderboardProps {
cityBuckets: RequestLocationBucketView[];
regionBuckets: RequestLocationBucketView[];
maxCityRequests: number;
maxRegionRequests: number;
formatPlace: (bucket: RequestLocationBucketView) => string;
formatNumber: (n: number) => string;
}

export function StatsRequestGeographyLeaderboard({
cityBuckets,
regionBuckets,
maxCityRequests,
maxRegionRequests,
formatPlace,
formatNumber,
}: StatsRequestGeographyLeaderboardProps) {
const [scope, setScope] = useState<"city" | "region">("city");
const buckets = scope === "city" ? cityBuckets : regionBuckets;
const maxRequests = scope === "city" ? maxCityRequests : maxRegionRequests;
const barPcts = useMemo(
() => buckets.map((bucket) => (
maxRequests > 0 ? Math.max(6, (bucket.requests / maxRequests) * 100) : 0
)),
[buckets, maxRequests],
);
const emptyMessage =
scope === "city"
? "No city-level demand buckets yet."
: "No demand regions resolved yet.";

return (
<div className="flex min-h-full flex-col overflow-hidden rounded-[0.35rem] border border-border-dim bg-bg-secondary shadow-sm">
<div className="flex items-center justify-between gap-3 border-b border-border-dim bg-bg-primary px-3.5 py-2.5">
<p className="font-mono text-[0.58rem] tracking-[0.16em] uppercase text-text-tertiary">
Top demand
</p>
<div
className="inline-flex gap-0.5 rounded border border-border-dim bg-bg-secondary p-0.5"
role="tablist"
aria-label="Demand scope"
>
{(["city", "region"] as const).map((value) => {
const active = scope === value;
return (
<button
key={value}
type="button"
role="tab"
aria-selected={active}
className={`min-h-6.5 rounded px-2.5 font-mono text-[0.62rem] tracking-wide uppercase transition-colors ${
active
? "bg-accent-brand-dim text-accent-brand"
: "text-text-tertiary hover:text-text-primary"
}`}
onClick={() => setScope(value)}
>
{value === "city" ? "Cities" : "Regions"}
</button>
);
})}
</div>
</div>

{buckets.length === 0 ? (
<p className="px-3.5 py-5 text-[0.82rem] text-text-tertiary">{emptyMessage}</p>
) : (
<ol className="m-0 list-none flex-1 p-0.5">
{buckets.map((bucket, index) => {
const tokens = bucket.prompt_tokens + bucket.completion_tokens;
const barPct = barPcts[index];
const rankLabel = (index + 1).toString().padStart(2, "0");

return (
<li
key={bucket.key}
className="grid grid-cols-[1.6rem_minmax(0,1fr)] items-start gap-2 border-b border-border-dim px-3.5 py-2 last:border-b-0"
>
<span className="pt-0.5 font-mono text-[0.64rem] font-bold tracking-wide text-accent-brand" aria-hidden="true">
{rankLabel}
</span>
<div className="min-w-0">
<div className="flex items-baseline justify-between gap-2.5">
<p className="min-w-0 truncate text-[0.8rem] font-semibold text-text-primary" title={formatPlace(bucket)}>
{formatPlace(bucket)}
</p>
<p className="shrink-0 font-mono text-[0.82rem] font-bold tracking-tight text-text-primary whitespace-nowrap">
{formatNumber(bucket.requests)}
<span className="ml-1 text-[0.56rem] font-medium tracking-widest uppercase text-text-tertiary">
req
</span>
</p>
</div>
<div className="mt-1.5 h-0.5 overflow-hidden rounded-full bg-bg-elevated" aria-hidden="true">
<span
className="block h-full rounded-full bg-linear-to-r from-accent-brand to-accent-green transition-[width] duration-500"
style={{ width: `${barPct}%` }}
/>
</div>
<p className="mt-1 truncate font-mono text-[0.62rem] text-text-secondary">
{formatNumber(tokens)} tokens
<span className="mx-1 text-text-tertiary">·</span>
{formatNumber(bucket.prompt_tokens)} in
<span className="mx-1 text-text-tertiary">/</span>
{formatNumber(bucket.completion_tokens)} out
{bucket.providers > 0 && (
<>
<span className="mx-1 text-text-tertiary">·</span>
{bucket.providers} nodes
</>
)}
</p>
</div>
</li>
);
})}
</ol>
)}
</div>
Comment on lines +77 to +130

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 [INFO] ⚡ Math.max calculation repeated for every bucket in render loop

💡 Suggestion: Pre-calculate maxRequests outside the map function or memoize the calculation

📊 Score: 2×3 = 6 · Category: repeated_work

);
}

export function StatsProviderCapacityTable({
buckets,
formatPlace,
formatNumber,
emptyMessage,
}: {
buckets: ProviderLocationBucketView[];
formatPlace: (bucket: ProviderLocationBucketView) => string;
formatNumber: (n: number) => string;
emptyMessage: string;
}) {
if (buckets.length === 0) {
return <p className="text-sm text-text-tertiary">{emptyMessage}</p>;
}

return (
<div className="overflow-hidden rounded-[0.35rem] border border-border-dim bg-bg-primary shadow-sm">
<div className={`${statsCapacityGrid} border-b border-border-dim bg-bg-secondary font-mono text-[0.56rem] tracking-[0.14em] uppercase text-text-tertiary`} aria-hidden="true">
<span>Location</span>
<span className="text-right">Nodes</span>
<span className="text-right">Attested</span>
<span className="text-right">GPU</span>
<span className="text-right">RAM</span>
</div>
{buckets.map((bucket) => {
const attestedPct = bucket.providers > 0
? Math.round((bucket.hardware_attested / bucket.providers) * 100)
: 0;
return (
<div
key={bucket.key}
className={`${statsCapacityGrid} border-b border-border-dim font-mono text-[0.72rem] last:border-b-0 hover:bg-accent-brand-dim/35`}
>
<span className="min-w-0 truncate font-sans text-[0.8rem] font-semibold text-text-primary" title={formatPlace(bucket)}>
{formatPlace(bucket)}
</span>
<span className="text-right font-semibold text-text-primary">{bucket.providers}</span>
<span className="text-right font-semibold text-text-primary">{attestedPct}%</span>
<span className="text-right font-semibold text-text-primary">{bucket.gpu_cores}</span>
<span className="text-right text-[0.68rem] font-semibold whitespace-nowrap text-text-primary">
{formatNumber(bucket.memory_gb)} GB
</span>
</div>
);
})}
</div>
);
}
45 changes: 45 additions & 0 deletions console-ui/src/components/stats/StatsHardwareStrip.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
"use client";

import { statsMetricLabel, statsMetricSub, statsMetricValue, statsReveal3, statsSectionIndex } from "./styles";

interface HardwareMetric {
label: string;
value: string;
unit?: string;
sub?: string;
power?: boolean;
}

export function StatsHardwareStrip({ metrics }: { metrics: HardwareMetric[] }) {
return (
<div className={`flex flex-col gap-2.5 ${statsReveal3}`}>
<div className="flex items-center font-mono text-[0.62rem] tracking-[0.18em] uppercase text-text-tertiary">
<span className={`${statsSectionIndex} mr-1.5 pt-0`}>05</span>
<span>Fleet telemetry</span>
</div>
<div className="grid grid-cols-2 overflow-hidden rounded-[0.35rem] border border-border-dim bg-bg-primary shadow-sm sm:grid-cols-3 lg:grid-cols-6 divide-x divide-y divide-border-dim lg:divide-y-0">
{metrics.map((metric) => (
<div
key={metric.label}
className="bg-bg-primary p-4 transition-colors hover:bg-accent-brand-dim/55"
>
<p className={statsMetricLabel}>{metric.label}</p>
<p
className={`${statsMetricValue} flex flex-nowrap items-baseline gap-1 whitespace-nowrap text-[clamp(1.1rem,2.1vw,1.65rem)] ${
metric.power ? "text-accent-amber" : ""
}`}
>
<span>{metric.value}</span>
{metric.unit && (
<span className="text-[0.58em] font-semibold tracking-wide text-text-secondary">
{metric.unit}
</span>
)}
</p>
{metric.sub && <p className={statsMetricSub}>{metric.sub}</p>}
</div>
))}
</div>
</div>
);
}
74 changes: 74 additions & 0 deletions console-ui/src/components/stats/StatsHeroBento.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
"use client";

import { statsMetricLabel, statsMetricSub, statsMetricValue, statsReveal2 } from "./styles";

interface StatsHeroBentoProps {
totalTokens: string;
tokenSub: string;
totalRequests: string;
nodesOnline: string;
nodesSub: string;
bandwidth: string;
}

const bentoCard =
"group relative overflow-hidden rounded-[0.35rem] border border-border-dim bg-bg-primary p-5 shadow-sm transition-[border-color,transform,box-shadow] hover:-translate-y-0.5 hover:border-accent-brand/30 hover:shadow-md";

export function StatsHeroBento({
totalTokens,
tokenSub,
totalRequests,
nodesOnline,
nodesSub,
bandwidth,
}: StatsHeroBentoProps) {
return (
<div className={`grid grid-cols-1 gap-2.5 md:grid-cols-[1.45fr_1fr_1fr] md:grid-rows-[auto_auto] ${statsReveal2}`}>
<div
className={`${bentoCard} md:col-start-1 md:row-span-2 flex min-h-48 flex-col justify-end bg-linear-to-br from-accent-brand-dim via-transparent to-bg-secondary`}
>
<span
className="pointer-events-none absolute -top-6 -right-6 size-36 rounded-full border border-accent-brand/20"
aria-hidden="true"
/>
<span className="absolute top-3.5 right-4 font-mono text-[0.58rem] tracking-widest text-text-tertiary opacity-70" aria-hidden="true">
01
</span>
<span className="pointer-events-none absolute top-2.5 left-2.5 size-3.5 border-t-2 border-l-2 border-accent-brand/45" aria-hidden="true" />
<span className="pointer-events-none absolute right-2.5 bottom-2.5 size-3.5 border-r-2 border-b-2 border-accent-brand/45" aria-hidden="true" />
<p className={statsMetricLabel}>Tokens served</p>
<p className={`${statsMetricValue} text-[clamp(2.75rem,8vw,5rem)] bg-linear-to-b from-text-primary to-accent-brand bg-clip-text text-transparent`}>
{totalTokens}
</p>
<p className={`${statsMetricSub} text-accent-green`}>{tokenSub}</p>
</div>

<div className={`${bentoCard} md:col-span-2 md:col-start-2 md:row-start-1`}>
<span className="absolute top-3.5 right-4 font-mono text-[0.58rem] tracking-widest text-text-tertiary opacity-70" aria-hidden="true">
02
</span>
<p className={statsMetricLabel}>Requests</p>
<p className={`${statsMetricValue} text-[clamp(1.85rem,4.5vw,3rem)]`}>{totalRequests}</p>
<p className={statsMetricSub}>lifetime completions</p>
</div>

<div className={bentoCard}>
<span className="absolute top-3.5 right-4 font-mono text-[0.58rem] tracking-widest text-text-tertiary opacity-70" aria-hidden="true">
03
</span>
<p className={statsMetricLabel}>Nodes online</p>
<p className={`${statsMetricValue} text-[clamp(1.4rem,3vw,2.1rem)]`}>{nodesOnline}</p>
<p className={statsMetricSub}>{nodesSub}</p>
</div>

<div className={bentoCard}>
<span className="absolute top-3.5 right-4 font-mono text-[0.58rem] tracking-widest text-text-tertiary opacity-70" aria-hidden="true">
04
</span>
<p className={statsMetricLabel}>GB/s bandwidth</p>
<p className={`${statsMetricValue} text-[clamp(1.4rem,3vw,2.1rem)]`}>{bandwidth}</p>
<p className={statsMetricSub}>unified memory throughput</p>
</div>
</div>
);
}
Loading