import { useMemo } from "react"; import { formatCompact, formatInteger, formatPercent } from "../data/formatters"; import { buildAgentTokenShare } from "../data/view-models"; import type { AgentType, AgentTypeStats } from "../types"; /** * Per-agent-type display chrome. Colors follow the OMP brand palette * (pink -> violet -> cyan) used by the dashboard charts so the bar reads on * both themes without per-theme overrides. */ const AGENT_META: Record = { main: { label: "Main agent", color: "#ed4abf" }, subagent: { label: "Subagents", color: "#9b4dff" }, advisor: { label: "Advisor", color: "#5ad8e6" }, }; export interface AgentTokenShareProps { stats: AgentTypeStats[]; } export function AgentTokenShare({ stats }: AgentTokenShareProps) { const view = useMemo(() => buildAgentTokenShare(stats), [stats]); if (view.totalTokens === 0) { return
No token usage in this range
; } return (
{view.segments.map( seg => seg.share > 0 && (
), )}
{view.segments.map(seg => (
{AGENT_META[seg.agentType].label} {formatInteger(seg.requests)} req
{formatCompact(seg.tokens)} tok {formatPercent(seg.share)}
))}
); }