/** * dashboard-client/src/components/ActiveReposTable.tsx — Active repos table. * * Columns: Repo, Model, Tier, Context %, State, Compactions s/t, * Cache Hits s/t, Cache Hit %, Cache Read, Cache Write, Est. Saved, * Compact s/t (s), CacheHit s/t (s). * Data from fetchServers() via useApi with 10s polling. */ import type React from "react"; import type { ServerEntry } from "@contracts"; import { fmtTokens } from "@/utils/format.ts"; import { Card, CardContent } from "../components/ui/card"; export interface ActiveReposTableProps { servers: ServerEntry[]; } /** Format seconds → human-readable duration (matches html.ts fmtSec). */ function fmtSec(s: number | undefined): string { const v = s ?? 0; if (v >= 3600) return `${(v / 3600).toFixed(1)}h`; if (v >= 60) return `${Math.round(v / 60)}m`; if (v >= 1) return `${v.toFixed(1)}s`; return `${Math.round(v * 1000)}ms`; } const HEADERS = [ "Repo", "Model", "Tier", "Context %", "State", "Compactions (s/t)", "Cache Hits (s/t)", "Cache Hit %", "Est. Saved", "Cache Read", "Cache Write", "Compact s/t (s)", "CacheHit s/t (s)", ] as const; export function ActiveReposTable({ servers, }: ActiveReposTableProps): React.ReactElement { return (

Repos seen within the last 30 minutes, with their per-repo cache-hit, compaction, and time-saved (est.) totals pulled live from each repo's dashboard.json.

{HEADERS.map((h, i) => ( ))} {servers.length === 0 && ( )} {servers.map((r) => { const ch = r.cacheHits ?? { session: 0, total: 0, sessionTokensSaved: 0, totalTokensSaved: 0, }; const cp = r.compacts ?? { session: 0, total: 0 }; const ts = r.timeSaved ?? { compact: { sessionSec: 0, totalSec: 0 }, cacheHit: { sessionSec: 0, totalSec: 0 }, }; return ( ); })}
= 3 && i !== 4 ? " text-right" : "" }`} > {h}
No active repositories.
{r.displayName || r.repoRoot} {r.model ?? "\u2014"} {r.tier ?? "\u2014"} {r.contextPct != null ? `${Math.round(r.contextPct * 100)}%` : "\u2014"} {r.state ?? "\u2014"} {cp.session} / {cp.total} {ch.session} / {ch.total} {r.providerCache != null ? `${r.providerCache.avgHitPct.toFixed(1)}%` : "—"} {r.providerCache?.estimatedSaved != null ? `$${r.providerCache.estimatedSaved.toFixed(2)}` : "—"} {r.providerCache?.cacheRead != null ? fmtTokens(r.providerCache.cacheRead) : "—"} {r.providerCache?.cacheWrite != null ? fmtTokens(r.providerCache.cacheWrite) : "—"} {fmtSec(ts.compact.sessionSec)} /{" "} {fmtSec(ts.compact.totalSec)} {fmtSec(ts.cacheHit.sessionSec)} /{" "} {fmtSec(ts.cacheHit.totalSec)}
); }