llmtop 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +259 -2
- package/bin/llmtop.mjs +101 -0
- package/dashboard/dist/apple-touch-icon.png +0 -0
- package/dashboard/dist/assets/index-BVbAwMVB.js +9 -0
- package/dashboard/dist/assets/index-Cp7Swcz5.css +1 -0
- package/dashboard/dist/assets/llmtop-lockup-DtFPJmhv.svg +1 -0
- package/dashboard/dist/assets/llmtop-lockup-reversed-D9OmQIVU.svg +1 -0
- package/dashboard/dist/favicon.ico +0 -0
- package/dashboard/dist/favicon.svg +1 -0
- package/dashboard/dist/index.html +19 -0
- package/dashboard/dist/llmtop-mark-192.png +0 -0
- package/dashboard/dist/llmtop-mark-512.png +0 -0
- package/dashboard/dist/site.webmanifest +11 -0
- package/dashboard/src/App.tsx +213 -0
- package/dashboard/src/controls/DateRange.tsx +108 -0
- package/dashboard/src/controls/Disclosure.tsx +15 -0
- package/dashboard/src/controls/Search.tsx +18 -0
- package/dashboard/src/controls/Select.tsx +48 -0
- package/dashboard/src/controls/popover.tsx +31 -0
- package/dashboard/src/dash.ts +23 -0
- package/dashboard/src/extra.test.ts +9 -0
- package/dashboard/src/extra.ts +16 -0
- package/dashboard/src/format.ts +29 -0
- package/dashboard/src/i18n.tsx +52 -0
- package/dashboard/src/index.ts +7 -0
- package/dashboard/src/main.tsx +7 -0
- package/dashboard/src/model.test.ts +110 -0
- package/dashboard/src/model.ts +255 -0
- package/dashboard/src/state.test.ts +48 -0
- package/dashboard/src/state.ts +61 -0
- package/dashboard/src/styles.css +401 -0
- package/dashboard/src/tip.ts +51 -0
- package/dashboard/src/treemap.test.ts +23 -0
- package/dashboard/src/treemap.ts +30 -0
- package/dashboard/src/ui.tsx +327 -0
- package/dashboard/src/views/Activity.tsx +177 -0
- package/dashboard/src/views/Context.tsx +183 -0
- package/dashboard/src/views/Models.tsx +155 -0
- package/dashboard/src/views/Overview.tsx +83 -0
- package/dashboard/src/views/Projects.tsx +116 -0
- package/dashboard/src/views/Sessions.tsx +54 -0
- package/dashboard/src/views/Subagents.tsx +102 -0
- package/docs/brand/README.md +91 -0
- package/docs/brand/brand.json +67 -0
- package/docs/brand/favicon.ico +0 -0
- package/docs/brand/png/apple-touch-icon.png +0 -0
- package/docs/brand/png/favicon-16.png +0 -0
- package/docs/brand/png/favicon-32.png +0 -0
- package/docs/brand/png/favicon-48.png +0 -0
- package/docs/brand/png/llmtop-lockup-reversed@2x.png +0 -0
- package/docs/brand/png/llmtop-lockup@2x.png +0 -0
- package/docs/brand/png/llmtop-mark-1024.png +0 -0
- package/docs/brand/png/llmtop-mark-192.png +0 -0
- package/docs/brand/png/llmtop-mark-512.png +0 -0
- package/docs/brand/png/llmtop-wordmark@2x.png +0 -0
- package/docs/brand/source/build_brand.py +173 -0
- package/docs/brand/svg/favicon.svg +1 -0
- package/docs/brand/svg/llmtop-glyph.svg +1 -0
- package/docs/brand/svg/llmtop-lockup-reversed.svg +1 -0
- package/docs/brand/svg/llmtop-lockup.svg +1 -0
- package/docs/brand/svg/llmtop-mark-light.svg +1 -0
- package/docs/brand/svg/llmtop-mark.svg +1 -0
- package/docs/brand/svg/llmtop-wordmark-reversed.svg +1 -0
- package/docs/brand/svg/llmtop-wordmark.svg +1 -0
- package/llmtop.config.example.json +10 -0
- package/package.json +71 -4
- package/prices.md +27 -0
- package/src/api.mjs +53 -0
- package/src/archive.mjs +142 -0
- package/src/config.mjs +55 -0
- package/src/context.mjs +151 -0
- package/src/dashboard.mjs +61 -0
- package/src/db.mjs +102 -0
- package/src/derive.mjs +346 -0
- package/src/effort.mjs +18 -0
- package/src/format.mjs +19 -0
- package/src/paths.mjs +82 -0
- package/src/prices-command.mjs +25 -0
- package/src/prices.mjs +146 -0
- package/src/providers/agy.mjs +438 -0
- package/src/providers/claude.mjs +274 -0
- package/src/providers/codex.mjs +589 -0
- package/src/providers/index.mjs +25 -0
- package/src/rebuilds.mjs +85 -0
- package/src/scan.mjs +214 -0
- package/src/serve.mjs +44 -0
- package/src/show.mjs +20 -0
- package/src/usage-command.mjs +110 -0
- package/src/usage.mjs +388 -0
- package/src/zone.mjs +15 -0
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
// Pieces the views share: charts, ranked bars, the hour heatmap, mixes, cost cells and the notes on cost.
|
|
2
|
+
import { useId, type CSSProperties, type ReactNode } from "react";
|
|
3
|
+
import { usePopover } from "./controls/popover.tsx";
|
|
4
|
+
import { useDash } from "./dash.ts";
|
|
5
|
+
import type { Fact, Metric, Run, SessionRow } from "./model.ts";
|
|
6
|
+
import type { UrlState } from "./state.ts";
|
|
7
|
+
|
|
8
|
+
type Group = { n: string; c: string };
|
|
9
|
+
export type TipRow = [cls: string, name: string, value: string];
|
|
10
|
+
|
|
11
|
+
// A tooltip's content, read by tip.ts from the data-tip attribute of the hovered or focused element.
|
|
12
|
+
export const tip = (head: string, rows: TipRow[]) => JSON.stringify({ h: head, r: rows });
|
|
13
|
+
const m = (v: string): CSSProperties => ({ "--m": v }) as CSSProperties;
|
|
14
|
+
|
|
15
|
+
// "up": a rise is better (cache share, speed); "none": a volume, money included, colored neutrally either way.
|
|
16
|
+
// "up" and "down" say which way is better; a total that follows how much work was done takes no color.
|
|
17
|
+
export type Side = "up" | "down" | "none";
|
|
18
|
+
export const tone = (d: number, side: Side) => (!d ? "" : side === "none" ? "vol" : (d > 0) === (side === "up") ? "better" : "worse");
|
|
19
|
+
|
|
20
|
+
// The change against the window before, in percent, or in points for a share.
|
|
21
|
+
export function Delta({ a, b, side, points = false, bare = false }: { a: number; b: number | undefined; side: Side; points?: boolean; bare?: boolean }) {
|
|
22
|
+
const { t } = useDash();
|
|
23
|
+
if (!b) return bare ? null : <span>{t("noPrev")}</span>;
|
|
24
|
+
const d = points ? (a - b) * 100 : ((a - b) / b) * 100, shown = Math.abs(d).toFixed(points ? 1 : 0);
|
|
25
|
+
return <span><b className={tone(Number(shown) && d, side)}>{d >= 0 ? "▲" : "▼"} {shown}{points ? " pt" : "%"}</b>{bare ? null : <> {t("vsPrev")}</>}</span>;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const Kpi = ({ label, value, d, series }: { label: string; value: ReactNode; d: ReactNode; series: number[] }) => (
|
|
29
|
+
<div className="card kpi"><div className="l">{label}</div><div className="vr"><div className="v">{value}</div><Spark values={series} /></div><div className="d">{d}</div></div>
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
export const Empty = () => { const { t } = useDash(); return <div className="empty">{t("nodata")}</div>; };
|
|
33
|
+
export const Swatch = ({ c }: { c: string }) => <i className={c} style={{ display: "inline-block", width: 9, height: 9, borderRadius: 3, marginRight: 8 }} />;
|
|
34
|
+
|
|
35
|
+
export function Spark({ values }: { values: number[] }) {
|
|
36
|
+
const id = useId();
|
|
37
|
+
if (values.length < 2) return null;
|
|
38
|
+
const max = Math.max(...values, 1), n = values.length, pts = values.map((v, i) => `${(i / (n - 1 || 1)) * 72},${22 - (v / max) * 20}`);
|
|
39
|
+
return (
|
|
40
|
+
<svg className="spark" viewBox="0 0 72 24" preserveAspectRatio="none" aria-hidden="true">
|
|
41
|
+
<defs><linearGradient id={id} x1="0" y1="0" x2="0" y2="1"><stop offset="0" className="g0" /><stop offset="1" className="g1" /></linearGradient></defs>
|
|
42
|
+
<polygon points={`0,24 ${pts.join(" ")} 72,24`} fill={`url(#${id})`} />
|
|
43
|
+
<polyline points={pts.join(" ")} />
|
|
44
|
+
<circle cx="72" cy={22 - (values[n - 1] / max) * 20} r="3" />
|
|
45
|
+
</svg>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function niceTop(max: number) {
|
|
50
|
+
const step = [1, 2, 5].flatMap((b) => [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8].map((p) => b * p)).sort((a, b) => a - b).find((s) => max / s <= 4) || max;
|
|
51
|
+
return { step, top: Math.max(step, Math.ceil(max / step) * step) };
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Stacked columns per day, or per hour when list holds hours; with share, each column is the groups' split of 100%.
|
|
55
|
+
// Totals draw as stacked areas when the chart toggle says so, each slot still a column to hover; a share keeps its
|
|
56
|
+
// columns, since a day without use has no split to draw. fmt replaces the metric's format; extra adds tooltip rows for a column.
|
|
57
|
+
export function Columns({ list, rows, groups, metric, fmt, extra }: { list: (string | number)[]; rows: number[][]; groups: Group[]; metric: Metric; fmt?: (v: number) => string; extra?: (i: number) => TipRow[] }) {
|
|
58
|
+
const { f, S } = useDash();
|
|
59
|
+
const share = S.chart === "share";
|
|
60
|
+
const show = fmt ?? ((v: number) => f.fmt(metric, v));
|
|
61
|
+
const max = Math.max(...rows.map((r) => r.reduce((a, b) => a + b, 0)), 0);
|
|
62
|
+
if (!max) return <Empty />;
|
|
63
|
+
const { step, top } = share ? { step: 0.25, top: 1 } : niceTop(max), ticks: number[] = [];
|
|
64
|
+
const h = (i: number, k: number) => (share ? rows[i][k] / (rows[i].reduce((a, b) => a + b, 0) || 1) : rows[i][k]);
|
|
65
|
+
for (let v = 0; v <= top + 1e-9; v += step) ticks.push(v);
|
|
66
|
+
const hourly = typeof list[0] === "number", every = hourly ? 3 : Math.ceil(list.length / 15);
|
|
67
|
+
const area = S.chart === "area" && list.length > 1, n = list.length;
|
|
68
|
+
// Each group's band, from the groups below it to its own top, in percent of the plot; the first group is the lowest.
|
|
69
|
+
const cum = list.map((_, i) => { let s = 0; return [0, ...groups.map((_, k) => (s += h(i, k)))]; });
|
|
70
|
+
const px = (i: number) => ((i + 0.5) / n) * 100, py = (v: number) => 100 - (v / top) * 100;
|
|
71
|
+
const band = (k: number) => [...list.map((_, i) => `${px(i)}% ${py(cum[i][k + 1])}%`), ...list.map((_, i) => `${px(n - 1 - i)}% ${py(cum[n - 1 - i][k])}%`)].join(",");
|
|
72
|
+
return (
|
|
73
|
+
<>
|
|
74
|
+
<div className="chart">
|
|
75
|
+
<div className="axis">{ticks.map((v) => <span key={v} style={{ bottom: `${(v / top) * 100}%` }}>{v ? (share ? f.pct(v) : show(v)) : "0"}</span>)}</div>
|
|
76
|
+
<div className={area ? "plot area" : "plot"}>
|
|
77
|
+
{ticks.slice(1).map((v) => <div key={v} className="gl" style={{ bottom: `${(v / top) * 100}%` }} />)}
|
|
78
|
+
{area ? (
|
|
79
|
+
<div className="bands" aria-hidden="true">
|
|
80
|
+
{groups.map((g, k) => <i key={k} className={g.c} style={{ clipPath: `polygon(${band(k)})` }} />)}
|
|
81
|
+
<svg viewBox="0 0 100 100" preserveAspectRatio="none">{/* Top group first, so where a group is empty the line of the group below it shows. */}
|
|
82
|
+
{groups.map((g, k) => <polyline key={k} className={g.c} points={list.map((_, i) => `${px(i)},${py(cum[i][k + 1])}`).join(" ")} />).reverse()}</svg>
|
|
83
|
+
</div>
|
|
84
|
+
) : null}
|
|
85
|
+
{list.map((d, i) => {
|
|
86
|
+
const sum = rows[i].reduce((a, b) => a + b, 0), dn = hourly ? (d as number) : Number((d as string).slice(8));
|
|
87
|
+
const month = !hourly && (i === 0 || dn === 1) ? <em>{f.month(d as string)}</em> : null;
|
|
88
|
+
const head = (hourly ? d + ":00" : f.dshort(d as string)) + " · " + show(sum);
|
|
89
|
+
return (
|
|
90
|
+
<div key={d} className="col" tabIndex={0} data-tip={tip(head, [...groups.map((g, k): TipRow => [g.c, g.n, (share ? f.pct(h(i, k)) + " · " : "") + show(rows[i][k])]).filter((_, k) => rows[i][k]), ...(extra?.(i) ?? [])])}>
|
|
91
|
+
{area ? groups.map((g, k) => (rows[i][k] ? <b key={k} className={`dot ${g.c}`} style={{ bottom: `${(cum[i][k + 1] / top) * 100}%` }} /> : null)) : <div className="bars">{groups.map((g, k) => (rows[i][k] ? <i key={k} className={g.c} style={{ height: `${(h(i, k) / top) * 100}%` }} /> : null)).reverse()}</div>}
|
|
92
|
+
{i % every === 0 || month ? <span className="x">{dn}{month}</span> : null}
|
|
93
|
+
</div>
|
|
94
|
+
);
|
|
95
|
+
})}
|
|
96
|
+
</div>
|
|
97
|
+
</div>
|
|
98
|
+
<div className="xpad" />
|
|
99
|
+
</>
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export function Legend({ groups, sums, metric, style }: { groups: Group[]; sums?: number[]; metric: Metric; style?: CSSProperties }) {
|
|
104
|
+
const { f } = useDash();
|
|
105
|
+
return (
|
|
106
|
+
<ul className="legend" style={style}>
|
|
107
|
+
{groups.map((g, k) => (!sums || sums[k] ? <li key={k}><i className={g.c} />{g.n}{sums ? <b>{f.fmt(metric, sums[k])}</b> : null}</li> : null))}
|
|
108
|
+
</ul>
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// The parts of a cost, in costParts order, with their neutral colors; web search is striped, the rest only outlined.
|
|
113
|
+
export function useCostKinds(): Group[] {
|
|
114
|
+
const { t } = useDash();
|
|
115
|
+
return [{ n: t("kRead"), c: "k0" }, { n: t("kWrite"), c: "k1" }, { n: t("kOut"), c: "k2" }, { n: t("kWeb"), c: "kw" }, { n: t("kRest"), c: "kx" }];
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// How a cost chart splits its columns: by model or by what the money paid for.
|
|
119
|
+
// How the overview's chart splits its columns; cost can also split by what it paid for.
|
|
120
|
+
export function SplitSeg({ split }: { split: UrlState["split"] }) {
|
|
121
|
+
const { M, S, t, set } = useDash();
|
|
122
|
+
const label = { model: "splitModel", provider: "splitProvider", project: "splitProject", effort: "splitEffort", kind: "splitKind" } as const;
|
|
123
|
+
return (
|
|
124
|
+
<div className="seg" role="group">
|
|
125
|
+
{(["model", ...(M.providers.length > 1 ? ["provider"] as const : []), "project", "effort", ...(S.metric === "cost" ? ["kind"] as const : [])] as const).map((k) => <button key={k} aria-pressed={split === k} onClick={() => set({ split: k })}>{t(label[k])}</button>)}
|
|
126
|
+
</div>
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// How per-day and per-hour charts draw their totals: stacked columns, stacked areas or each slot as 100%, for every chart at once.
|
|
131
|
+
export function ChartSeg() {
|
|
132
|
+
const { S, t, set } = useDash();
|
|
133
|
+
const icon = { bar: <path d="M3 13V8M8 13V3M13 13V6" />, area: <path d="M2 13L5.5 7l3 3L14 4v9z" />, share: <path d="M2.5 3h11v10h-11zM6.2 3v10M9.8 3v10M2.5 8.5h3.7M6.2 6.5h3.6M9.8 9.5h3.7" /> };
|
|
134
|
+
const label = { bar: "bars", area: "areas", share: "shares" } as const;
|
|
135
|
+
return (
|
|
136
|
+
<div className="seg chartseg" role="group">
|
|
137
|
+
{(["bar", "area", "share"] as const).map((k) => (
|
|
138
|
+
<button key={k} aria-pressed={S.chart === k} aria-label={t(label[k])} data-tip={tip(t(label[k]), [])} onClick={() => set({ chart: k })}>
|
|
139
|
+
<svg viewBox="0 0 16 16" aria-hidden="true">{icon[k]}</svg>
|
|
140
|
+
</button>
|
|
141
|
+
))}
|
|
142
|
+
</div>
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export function MetricSeg() {
|
|
147
|
+
const { S, t, set } = useDash();
|
|
148
|
+
return (
|
|
149
|
+
<div className="seg" role="group">
|
|
150
|
+
{(["out", "cost", "sess"] as const).map((k) => <button key={k} aria-pressed={S.metric === k} onClick={() => set({ metric: k })}>{t(k)}</button>)}
|
|
151
|
+
</div>
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// x replaces the share shown after the value; tip goes on the bar. fmt replaces the metric's format.
|
|
156
|
+
// A row with none has no figure: it shows a dash, and none says why in the tooltip.
|
|
157
|
+
export type RankRow = { n: string; v: number; c?: string; x?: string; tip?: string; none?: string; onClick?: () => void };
|
|
158
|
+
export function Rank({ rows, metric, color, fmt }: { rows: RankRow[]; metric: Metric; color?: boolean; fmt?: (v: number) => string }) {
|
|
159
|
+
const { f } = useDash();
|
|
160
|
+
const show = fmt ?? ((v: number) => f.fmt(metric, v));
|
|
161
|
+
const max = Math.max(...rows.map((r) => r.v), 1), sum = rows.reduce((n, r) => n + r.v, 0) || 1;
|
|
162
|
+
return (
|
|
163
|
+
<div className="rank">
|
|
164
|
+
{rows.map((r, k) => {
|
|
165
|
+
const name = <>{r.c ? <i className={r.c} /> : null}{r.n}</>;
|
|
166
|
+
return [
|
|
167
|
+
r.onClick ? <button key={`n${k}`} className="n" onClick={r.onClick}>{name}</button> : <span key={`n${k}`} className="n">{name}</span>,
|
|
168
|
+
<span key={`t${k}`} className="t" data-tip={r.none ? tip(r.n, [["c0", r.none, ""]]) : r.tip} tabIndex={r.none ? 0 : undefined}>{r.none ? null : <span className={`b ${color && r.c ? r.c : ""}`} style={{ display: "block", width: `${(r.v / max) * 100}%` }} />}</span>,
|
|
169
|
+
<span key={`v${k}`} className="val">{r.none ? "—" : show(r.v)}{r.x === "" || r.none ? null : <small>{r.x ?? f.pct(r.v / sum)}</small>}</span>,
|
|
170
|
+
];
|
|
171
|
+
})}
|
|
172
|
+
</div>
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// Activity per weekday and hour, by requests (each step the agent took, whatever its context or output) or by output.
|
|
177
|
+
export function Heat({ F, by }: { F: Fact[]; by: "req" | "out" }) {
|
|
178
|
+
const { t, f, L } = useDash();
|
|
179
|
+
const label = by === "req" ? t("requests") : t("out"), show = by === "req" ? f.int : f.cmp;
|
|
180
|
+
const g = Array.from({ length: 7 }, () => new Array<number>(24).fill(0));
|
|
181
|
+
let max = 0, peak = [0, 0];
|
|
182
|
+
// Beside the grid: the weekend's and the night's share, and how many sessions had requests in the same hour.
|
|
183
|
+
let all = 0, weekend = 0, night = 0;
|
|
184
|
+
const slots = new Map<string, Set<number>>();
|
|
185
|
+
for (const x of F) {
|
|
186
|
+
const wd = (new Date(x.d + "T00:00:00Z").getUTCDay() + 6) % 7, v = by === "req" ? x.q : x.o;
|
|
187
|
+
g[wd][x.h] += v; all += v;
|
|
188
|
+
if (wd >= 5) weekend += v;
|
|
189
|
+
if (x.h >= 22 || x.h < 6) night += v;
|
|
190
|
+
if (g[wd][x.h] > max) { max = g[wd][x.h]; peak = [wd, x.h]; }
|
|
191
|
+
const k = x.d + " " + x.h;
|
|
192
|
+
if (!slots.has(k)) slots.set(k, new Set());
|
|
193
|
+
slots.get(k)!.add(x.s);
|
|
194
|
+
}
|
|
195
|
+
if (!max) return <Empty />;
|
|
196
|
+
const same = [...slots.values()].map((s) => s.size).sort((a, b) => a - b), mid = same[Math.floor(same.length / 2)], most = same[same.length - 1];
|
|
197
|
+
return (
|
|
198
|
+
<>
|
|
199
|
+
<div className="heat">
|
|
200
|
+
{g.map((row, wd) => [
|
|
201
|
+
<span key={`r${wd}`} className="rl">{L.wd[wd]}</span>,
|
|
202
|
+
...row.map((v, h) => <span key={`${wd}-${h}`} className="cell" tabIndex={-1} style={m(`${v ? Math.round(10 + 80 * Math.sqrt(v / max)) : 0}%`)} data-tip={tip(L.wd[wd] + " · " + h + ":00", [["c1", label, show(v)]])} />),
|
|
203
|
+
])}
|
|
204
|
+
<span />
|
|
205
|
+
{Array.from({ length: 24 }, (_, h) => <span key={`l${h}`} className="cl">{h % 3 === 0 ? h : ""}</span>)}
|
|
206
|
+
</div>
|
|
207
|
+
<Stats items={[
|
|
208
|
+
{ label: t("peak"), value: <><i className="hsw" style={m("90%")} />{L.wd[peak[0]]}, {peak[1]}:00</>, sub: `${show(max)} ${label.toLowerCase()}` },
|
|
209
|
+
{ label: t("weekend"), value: f.pct(weekend / all), meter: [weekend / all, "cseq"], sub: label.toLowerCase() },
|
|
210
|
+
{ label: "22:00–6:00", value: f.pct(night / all), meter: [night / all, "cseq"], sub: label.toLowerCase() },
|
|
211
|
+
{ label: t("sameHour"), value: f.int(mid), dots: [mid, most], sub: L.atMost(f.int(most)) },
|
|
212
|
+
]} />
|
|
213
|
+
</>
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// A row of figures under a chart: a label, the figure, and under it a meter (a share, in a series color), dots (a typical
|
|
218
|
+
// count out of the most) or a line of context. tone colors the figure itself, for errors only; money stays neutral.
|
|
219
|
+
export type Stat = { label: ReactNode; value: ReactNode; sub?: ReactNode; meter?: [number, string]; dots?: [number, number]; tone?: string };
|
|
220
|
+
export function Stats({ items }: { items: Stat[] }) {
|
|
221
|
+
return (
|
|
222
|
+
<dl className="hstats">
|
|
223
|
+
{items.map((x, k) => (
|
|
224
|
+
<div key={k}>
|
|
225
|
+
<dt>{x.label}</dt>
|
|
226
|
+
<dd className={x.tone}>{x.value}</dd>
|
|
227
|
+
{x.meter ? <span className="meter"><i className={x.meter[1]} style={{ width: `${Math.min(1, Math.max(0, x.meter[0])) * 100}%` }} /></span> : null}
|
|
228
|
+
{x.dots && x.dots[1] <= 20 ? <span className="dots">{Array.from({ length: x.dots[1] }, (_, i) => <i key={i} className={i < x.dots![0] ? "on" : ""} />)}</span> : null}
|
|
229
|
+
{/* Keeps the line under the figure level with the tiles that draw a meter or dots. */}
|
|
230
|
+
{!x.meter && !(x.dots && x.dots[1] <= 20) && items.some((y) => y.meter || y.dots) ? <span className="gap" /> : null}
|
|
231
|
+
{x.sub ? <span className="sub">{x.sub}</span> : null}
|
|
232
|
+
</div>
|
|
233
|
+
))}
|
|
234
|
+
</dl>
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// What the hour heatmap counts.
|
|
239
|
+
export function HeatSeg() {
|
|
240
|
+
const { S, t, set } = useDash();
|
|
241
|
+
return (
|
|
242
|
+
<div className="seg" role="group">
|
|
243
|
+
{(["req", "out"] as const).map((k) => <button key={k} aria-pressed={S.heat === k} onClick={() => set({ heat: k })}>{t(k === "req" ? "requests" : "out")}</button>)}
|
|
244
|
+
</div>
|
|
245
|
+
);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// Shares of a total as one thin bar, colored by model.
|
|
249
|
+
export function Mix({ arr, className = "mix", style, tip: about }: { arr: number[]; className?: string; style?: CSSProperties; tip?: string }) {
|
|
250
|
+
const { M } = useDash();
|
|
251
|
+
const sum = arr.reduce((a, b) => a + b, 0) || 1;
|
|
252
|
+
return <span className={className} style={style} data-tip={about}>{arr.map((v, k) => (v ? <i key={k} className={M.mColor(k)} style={{ width: `${(v / sum) * 100}%` }} /> : null))}</span>;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// A session's output tokens per model, the main thread and subagents apart, largest first.
|
|
256
|
+
export function SessionMix({ r }: { r: SessionRow }) {
|
|
257
|
+
const { M, t, f } = useDash();
|
|
258
|
+
if (r.mix.filter((v) => v > 0).length < 2) return null; // one model needs no bar
|
|
259
|
+
const sum = r.mix.reduce((a, b) => a + b, 0) || 1;
|
|
260
|
+
const parts = r.mix.flatMap((v, k) => [{ k, n: v - r.subMix[k], who: t("mainThread") }, { k, n: r.subMix[k], who: t("subs") }]).filter((p) => p.n > 0);
|
|
261
|
+
parts.sort((a, b) => b.n - a.n);
|
|
262
|
+
return <Mix arr={r.mix} tip={tip(t("out"), parts.map(({ k, n, who }): TipRow => [M.mColor(k), `${M.models[k]} · ${who}`, `${f.cmp(n)} · ${f.pct(n / sum)}`]))} />;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// A session's effort runs in time order, each as wide as its requests.
|
|
266
|
+
export function RunsStrip({ runs, wide }: { runs: Run[]; wide?: boolean }) {
|
|
267
|
+
const { M, t, f } = useDash();
|
|
268
|
+
const sum = runs.reduce((n, r) => n + r[1], 0) || 1;
|
|
269
|
+
return (
|
|
270
|
+
<span className={`mix${wide ? " wide" : ""}`} style={wide ? { width: 160 } : undefined} data-tip={tip(t("effort"), runs.map(([e, q]): TipRow => ["v" + e, M.efforts[e], f.int(q) + " " + t("requests").toLowerCase()]))}>
|
|
271
|
+
{runs.map(([e, q], k) => <i key={k} className={`v${e}`} style={{ width: `${(q / sum) * 100}%` }} />)}
|
|
272
|
+
</span>
|
|
273
|
+
);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
// A session without a host cost record shows no figure; one the host marked incomplete, or estimated, is flagged.
|
|
277
|
+
export function CostCell({ r }: { r: SessionRow }) {
|
|
278
|
+
const { t, f } = useDash();
|
|
279
|
+
const s = r.x.costState;
|
|
280
|
+
if (s === "unknown") return <span data-tip={tip(t("costUnknown"), [])}>—</span>;
|
|
281
|
+
if (s === "incomplete") return <span data-tip={tip(t("costPartial"), [])}>{f.usd(r.c)}*</span>;
|
|
282
|
+
if (s === "estimated") return <span data-tip={tip(t("costEstimated"), [])}>{f.usd(r.c)}*</span>;
|
|
283
|
+
return <>{f.usd(r.c)}</>;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
export function Title({ title }: { title: string }) {
|
|
287
|
+
const { t } = useDash();
|
|
288
|
+
return <div className="title">{title || <span className="sub" style={{ display: "inline" }}>{t("untitled")}</span>}</div>;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// What makes a cost figure uncertain, as tooltip rows: sessions whose cost is missing, partial or estimated,
|
|
292
|
+
// and models the price table misses or lacks.
|
|
293
|
+
export function useCostFlags(F: Fact[]): TipRow[] {
|
|
294
|
+
const { M, t, L, f } = useDash();
|
|
295
|
+
const ss = [...new Set(F.map((x) => x.s))].map((s) => M.sessions[s]).sort((a, b) => (a.day < b.day ? -1 : 1));
|
|
296
|
+
const list = ss.filter((x) => x.costState !== "ok");
|
|
297
|
+
const state = { unknown: t("stUnknown"), incomplete: t("stPartial"), estimated: t("stEst"), ok: "" };
|
|
298
|
+
const rows: TipRow[] = list.slice(0, 5).map((x) => ["c0", `${x.title || M.projects[x.p]} · ${f.startText(x)}`, state[x.costState]]);
|
|
299
|
+
if (list.length > 5) rows.push(["c0", L.moreSess(list.length - 5), ""]);
|
|
300
|
+
// A model off the price table in these sessions, with how many and the first day, and models without a price row.
|
|
301
|
+
const off = new Map<string, { n: number; since: string }>();
|
|
302
|
+
for (const s of ss) for (const m of s.priceOff) { const x = off.get(m); if (x) x.n++; else off.set(m, { n: 1, since: s.day }); }
|
|
303
|
+
for (const [model, { n, since }] of off) rows.push(["c2", model, L.priceOff(f.int(n), f.dshort(since))]);
|
|
304
|
+
const unpriced = [...new Set(ss.flatMap((s) => s.unpriced))].sort();
|
|
305
|
+
if (unpriced.length) rows.push(["c4", unpriced.join(", "), t("noPrice")]);
|
|
306
|
+
return rows;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
export const heatStyle = m;
|
|
310
|
+
|
|
311
|
+
// A table figure with a thin bar under it, as long as the figure against the largest in its column.
|
|
312
|
+
export const Mag = ({ v, max, children }: { v: number; max: number; children: ReactNode }) => (
|
|
313
|
+
<span className="magbar" style={{ "--w": max > 0 ? Math.max(0, v) / max : 0 } as CSSProperties}>{children}</span>
|
|
314
|
+
);
|
|
315
|
+
|
|
316
|
+
// A small (i) beside a card title that opens a short note on how to read the card; closes like the filter popovers.
|
|
317
|
+
export function Info({ label, children }: { label: string; children: ReactNode }) {
|
|
318
|
+
const p = usePopover();
|
|
319
|
+
return (
|
|
320
|
+
<div className="ctl info" ref={p.root}>
|
|
321
|
+
<button ref={p.trigger} type="button" className="ib" aria-expanded={p.open} aria-label={label} onClick={() => p.setOpen(!p.open)}>
|
|
322
|
+
<svg viewBox="0 0 16 16" aria-hidden="true"><circle cx="8" cy="8" r="6.5" /><path d="M8 7.2v3.8M8 4.9v.1" /></svg>
|
|
323
|
+
</button>
|
|
324
|
+
{p.open ? <div ref={p.pop} className="pop note" style={p.place} role="dialog" aria-label={label}>{children}</div> : null}
|
|
325
|
+
</div>
|
|
326
|
+
);
|
|
327
|
+
}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { Fragment, useState, type ReactNode } from "react";
|
|
2
|
+
import { useDash } from "../dash.ts";
|
|
3
|
+
import { dayAdd, rebuilds, skillUses, slice, slotsOf, toolCalls, type Fact, type Model, type Session } from "../model.ts";
|
|
4
|
+
import { ChartSeg, Columns, Delta, Empty, Heat, HeatSeg, Info, Kpi, Stats, tip } from "../ui.tsx";
|
|
5
|
+
|
|
6
|
+
// What the agent did: time on the model and on tools, owner turns, lines, compactions and agent time per owner turn
|
|
7
|
+
// against the window before; working time per day beside the hours of the week it fell in; lines per day; where the cache was rebuilt;
|
|
8
|
+
// tool calls with their failed part beside the skills used.
|
|
9
|
+
const work = (M: Model, F: Fact[]) => {
|
|
10
|
+
const ids = [...new Set(F.map((x) => x.s))], ss = ids.map((s) => M.sessions[s]), add = (k: (s: Session) => number) => ss.reduce((n, s) => n + k(s), 0);
|
|
11
|
+
return { ids, ss, api: add((s) => s.api), tool: add((s) => s.tool), idle: add((s) => Math.max(0, s.dur * 60 - s.api - s.tool)), owner: add((s) => s.owner), compact: add((s) => s.compact), la: add((s) => s.la), lr: add((s) => s.lr) };
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
// How long the agent worked, waiting for the model or running tools, for each owner turn.
|
|
15
|
+
const perTurn = (w: { api: number; tool: number; owner: number }) => (w.owner ? (w.api + w.tool) / w.owner : 0);
|
|
16
|
+
|
|
17
|
+
export function Activity({ F, list }: { F: Fact[]; list: string[] }) {
|
|
18
|
+
const { M, S, filter, t, f } = useDash();
|
|
19
|
+
const w = work(M, F), pf = dayAdd(filter.from, -list.length);
|
|
20
|
+
const p = pf >= M.first ? work(M, slice(M, filter, pf, dayAdd(filter.from, -1))) : null;
|
|
21
|
+
if (!w.ss.length) return <section className="card"><Empty /></section>;
|
|
22
|
+
|
|
23
|
+
// Per day by session start, or per hour in a one-day window.
|
|
24
|
+
const slots = slotsOf(list), hourly = slots !== list;
|
|
25
|
+
const at = (s: Session) => slots.indexOf(hourly ? s.hour : s.day);
|
|
26
|
+
const per = (k: (s: Session) => number) => { const out = slots.map(() => 0); w.ss.forEach((s) => { const i = at(s); if (i >= 0) out[i] += k(s); }); return out; };
|
|
27
|
+
const api = per((s) => s.api / 3600), tool = per((s) => s.tool / 3600), idle = per((s) => Math.max(0, s.dur * 60 - s.api - s.tool) / 3600);
|
|
28
|
+
const la = per((s) => s.la), lr = per((s) => s.lr);
|
|
29
|
+
const daily = (k: (s: Session) => number) => list.map((d) => w.ss.reduce((n, s) => n + (s.day === d ? k(s) : 0), 0));
|
|
30
|
+
const hours = (h: number) => (h >= 1 ? `${f.dec(h)}h` : `${Math.round(h * 60)}m`);
|
|
31
|
+
const kpi = (label: string, value: ReactNode, a: number, b: number | undefined, series: number[]) => (
|
|
32
|
+
<Kpi label={label} value={value} d={<Delta a={a} b={p ? b : undefined} side="none" />} series={series} />
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<div className="stack">
|
|
37
|
+
<div className="grid kpis">
|
|
38
|
+
{kpi(t("api"), f.dur(w.api / 60), w.api, p?.api, daily((s) => s.api))}
|
|
39
|
+
{kpi(t("tool"), f.dur(w.tool / 60), w.tool, p?.tool, daily((s) => s.tool))}
|
|
40
|
+
{kpi(t("ownerTurns"), f.int(w.owner), w.owner, p?.owner, daily((s) => s.owner))}
|
|
41
|
+
{kpi(t("linesAR"), <>{f.cmp(w.la)} <small>/ {f.cmp(w.lr)}</small></>, w.la + w.lr, p ? p.la + p.lr : undefined, daily((s) => s.la + s.lr))}
|
|
42
|
+
{kpi(t("compactions"), f.int(w.compact), w.compact, p?.compact, daily((s) => s.compact))}
|
|
43
|
+
{kpi(t("perTurn"), f.dur(perTurn(w) / 60), perTurn(w), p ? perTurn(p) : undefined, list.map((d) => { const ss = w.ss.filter((s) => s.day === d), o = ss.reduce((n, s) => n + s.owner, 0); return o ? ss.reduce((n, s) => n + s.api + s.tool, 0) / o : 0; }))}
|
|
44
|
+
</div>
|
|
45
|
+
<div className="grid half">
|
|
46
|
+
<section className="card">
|
|
47
|
+
<header><h2>{t("time")}</h2><div className="segs"><span className="hint">{t("idle")}: {f.dur(w.idle / 60)}</span><ChartSeg /></div></header>
|
|
48
|
+
<ul className="legend"><li><i className="c1" />{t("api")}<b>{f.dur(w.api / 60)}</b></li><li><i className="c3" />{t("tool")}<b>{f.dur(w.tool / 60)}</b></li></ul>
|
|
49
|
+
<Columns list={slots} rows={slots.map((_, i) => [api[i], tool[i]])} groups={[{ n: t("api"), c: "c1" }, { n: t("tool"), c: "c3" }]} metric="out" fmt={hours}
|
|
50
|
+
extra={(i) => (idle[i] ? [["c0", t("idle"), hours(idle[i])]] : [])} />
|
|
51
|
+
</section>
|
|
52
|
+
<section className="card"><header><h2>{t("hours")}</h2><HeatSeg /></header><Heat F={F} by={S.heat} /></section>
|
|
53
|
+
</div>
|
|
54
|
+
<section className="card">
|
|
55
|
+
<header><h2>{t("lines")}</h2><ChartSeg /></header>
|
|
56
|
+
<ul className="legend"><li><i className="c1" />{t("added")}<b>{f.cmp(w.la)}</b></li><li><i className="c4" />{t("removed")}<b>{f.cmp(w.lr)}</b></li></ul>
|
|
57
|
+
<Columns list={slots} rows={slots.map((_, i) => [la[i], lr[i]])} groups={[{ n: t("added"), c: "c1" }, { n: t("removed"), c: "c4" }]} metric="out" fmt={(v) => f.cmp(v)} />
|
|
58
|
+
</section>
|
|
59
|
+
<Rebuilds F={F} />
|
|
60
|
+
<div className="grid half">
|
|
61
|
+
<Tools ids={w.ids} />
|
|
62
|
+
<Skills ids={w.ids} />
|
|
63
|
+
</div>
|
|
64
|
+
</div>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const SHOWN = 12;
|
|
69
|
+
|
|
70
|
+
// Tool calls, most used first, each with its failed part; the lead says how many failed and which tool most of them came
|
|
71
|
+
// from. Past SHOWN rows the rest opens below.
|
|
72
|
+
function Tools({ ids }: { ids: number[] }) {
|
|
73
|
+
const { M, t, L, f } = useDash();
|
|
74
|
+
const [all, setAll] = useState(false);
|
|
75
|
+
const rows = toolCalls(M, ids), shown = all ? rows : rows.slice(0, SHOWN);
|
|
76
|
+
const calls = rows.reduce((n, [, [c]]) => n + c, 0), errs = rows.reduce((n, [, [, e]]) => n + e, 0), tmax = Math.max(1, ...rows.map(([, [c]]) => c));
|
|
77
|
+
const worst = [...rows].sort((a, b) => b[1][1] - a[1][1])[0];
|
|
78
|
+
return (
|
|
79
|
+
<section className="card">
|
|
80
|
+
<header><h2>{t("tools")}</h2><span className="hint">{f.int(calls)} {t("calls")} · {f.int(rows.length)} {t("toolCount")}</span></header>
|
|
81
|
+
{errs ? <Stats items={[
|
|
82
|
+
{ label: t("failed"), value: f.int(errs), tone: "err", sub: L.ofCalls(f.pct(errs / calls)) },
|
|
83
|
+
{ label: L.fromTool(worst[0]), value: f.pct(worst[1][1] / errs), meter: [worst[1][1] / errs, "cneg"], sub: t("ofFailures") },
|
|
84
|
+
]} /> : null}
|
|
85
|
+
{rows.length ? <div className="rank tools">{shown.map(([n, [c, e]]) => [
|
|
86
|
+
<span key={`n${n}`} className="n" title={n}>{n}</span>,
|
|
87
|
+
<span key={`t${n}`} className="t"><span className="b" style={{ width: `${(c / tmax) * 100}%` }} data-tip={tip(n, [["c1", t("calls"), f.int(c)], ["neg", t("errors"), f.int(e)]])}>{e ? <i style={{ width: `max(2px, ${(e / c) * 100}%)` }} /> : null}</span></span>,
|
|
88
|
+
<span key={`v${n}`} className="val">{f.int(c)}<small className={e ? "err" : ""}>{f.pct(e / c)} {t("errors")}</small></span>,
|
|
89
|
+
])}</div> : <Empty />}
|
|
90
|
+
{rows.length > SHOWN ? <button type="button" className="disc more" aria-expanded={all} onClick={() => setAll(!all)}>
|
|
91
|
+
<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M6 4l4 4-4 4" /></svg>{all ? t("showFewer") : `${t("seeAll")} (${rows.length})`}
|
|
92
|
+
</button> : null}
|
|
93
|
+
</section>
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
const SOURCE = { project: "srcProject", personal: "srcPersonal", plugin: "srcPlugin", builtin: "srcBuiltin", other: "srcOther" } as const;
|
|
97
|
+
|
|
98
|
+
// Skills by where they were loaded from, most used first: each bar splits what the owner typed as a command from what the
|
|
99
|
+
// agent called on its own, with its failed calls at the end. Past SHOWN rows the rest opens below.
|
|
100
|
+
function Skills({ ids }: { ids: number[] }) {
|
|
101
|
+
const { M, t, f } = useDash();
|
|
102
|
+
const [all, setAll] = useState(false);
|
|
103
|
+
const rows = skillUses(M, ids), uses = rows.reduce((n, r) => n + r.command + r.agent, 0);
|
|
104
|
+
const top = new Set([...rows].sort((a, b) => b.command + b.agent - (a.command + a.agent)).slice(0, SHOWN).map((r) => r.name));
|
|
105
|
+
const shown = all ? rows : rows.filter((r) => top.has(r.name));
|
|
106
|
+
const max = Math.max(1, ...rows.map((r) => r.command + r.agent));
|
|
107
|
+
return (
|
|
108
|
+
<section className="card">
|
|
109
|
+
<header><h2>{t("skills")}</h2><span className="hint">{f.int(uses)} {t("uses")} · {f.int(rows.length)} {t("skillCount")}</span></header>
|
|
110
|
+
{rows.length ? <>
|
|
111
|
+
<ul className="legend"><li><i className="c1" />{t("skillTyped")}</li><li><i className="c3" />{t("skillAgent")}</li></ul>
|
|
112
|
+
<div className="rank tools">{shown.map((r, k) => {
|
|
113
|
+
const n = r.command + r.agent;
|
|
114
|
+
return <Fragment key={r.name}>
|
|
115
|
+
{k === 0 || shown[k - 1].source !== r.source ? <span className="grp">{t(SOURCE[r.source])}</span> : null}
|
|
116
|
+
<span className="n" title={r.name}>{r.name}</span>
|
|
117
|
+
<span className="t"><span className="b parts" style={{ width: `${(n / max) * 100}%` }} data-tip={tip(r.name, [["c1", t("skillTyped"), f.int(r.command)], ["c3", t("skillAgent"), f.int(r.agent)], ["neg", t("errors"), f.int(r.errors)], ["c0", t("lastUsed"), r.last ? f.dshort(r.last) : "—"]])}>
|
|
118
|
+
{r.command ? <b className="c1" style={{ width: `${(r.command / n) * 100}%` }} /> : null}
|
|
119
|
+
{r.agent ? <b className="c3" style={{ width: `${(r.agent / n) * 100}%` }} /> : null}
|
|
120
|
+
{r.errors ? <i style={{ width: `max(2px, ${(r.errors / n) * 100}%)` }} /> : null}
|
|
121
|
+
</span></span>
|
|
122
|
+
<span className="val">{f.int(n)}<small>{f.int(r.sessions)} {t("sess").toLowerCase()}</small></span>
|
|
123
|
+
</Fragment>;
|
|
124
|
+
})}</div>
|
|
125
|
+
{rows.length > SHOWN ? <button type="button" className="disc more" aria-expanded={all} onClick={() => setAll(!all)}>
|
|
126
|
+
<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M6 4l4 4-4 4" /></svg>{all ? t("showFewer") : `${t("seeAll")} (${rows.length})`}
|
|
127
|
+
</button> : null}
|
|
128
|
+
</> : <Empty />}
|
|
129
|
+
</section>
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Where the prompt cache had to be written again: the four causes with their count, rewritten tokens and extra cost
|
|
134
|
+
// over reading it; beside it, the idle ones by the time since the previous request.
|
|
135
|
+
function Rebuilds({ F }: { F: Fact[] }) {
|
|
136
|
+
const { t, L, f } = useDash();
|
|
137
|
+
const r = rebuilds(F);
|
|
138
|
+
const rows = [["idle", t("rbIdle"), t("rbIdleTip")], ["compaction", t("rbCompaction"), t("rbCompactionTip")], ["other", t("rbOther"), t("rbOtherTip")], ["start", t("rbStart"), t("rbStartTip")]] as const;
|
|
139
|
+
const count = r.start.n + r.compaction.n + r.idle.n + r.other.n;
|
|
140
|
+
const gaps = [t("gapShort"), t("gapMid"), t("gapLong")], gmax = Math.max(1, ...r.gaps);
|
|
141
|
+
return (
|
|
142
|
+
<div className="grid half">
|
|
143
|
+
<section className="card">
|
|
144
|
+
<header>
|
|
145
|
+
<div className="ttl"><h2>{t("rebuilt")}</h2><Info label={t("howToRead")}>
|
|
146
|
+
<p>{t("rbInfo")}</p>
|
|
147
|
+
<ul>{rows.map(([c, label, def]) => <li key={c}><b>{label}</b>: {def}</li>)}</ul>
|
|
148
|
+
</Info></div>
|
|
149
|
+
<span className="hint">{f.int(count)}</span>
|
|
150
|
+
</header>
|
|
151
|
+
{count ? <div className="scroll"><table>
|
|
152
|
+
<thead><tr><th /><th className="num">{t("count")}</th><th className="num">{t("rbTokens")}</th><th className="num">{t("rbExtra")}</th></tr></thead>
|
|
153
|
+
<tbody>{rows.map(([c, label]) => (
|
|
154
|
+
<tr key={c}>
|
|
155
|
+
<th className="name">{label}</th>
|
|
156
|
+
<td className="num">{f.int(r[c].n)}</td>
|
|
157
|
+
<td className="num">{r[c].n ? f.cmp(r[c].tokens) : "—"}</td>
|
|
158
|
+
<td className="num">{c === "start" || !r[c].n ? "—" : f.usd(r[c].extra)}</td>
|
|
159
|
+
</tr>
|
|
160
|
+
))}</tbody>
|
|
161
|
+
</table></div> : <Empty />}
|
|
162
|
+
</section>
|
|
163
|
+
<section className="card">
|
|
164
|
+
<header><h2>{t("idleGap")}</h2><span className="hint">{t("rbIdle")}: {f.int(r.idle.n)}</span></header>
|
|
165
|
+
{r.idle.n ? <Stats items={[
|
|
166
|
+
{ label: t("perBreak"), value: f.usd(r.idle.extra / r.idle.n), sub: t("onAverage") },
|
|
167
|
+
{ label: t("overHour"), value: f.pct(r.gaps[2] / r.idle.n), meter: [r.gaps[2] / r.idle.n, "c1"], sub: t("ofRebuilds") },
|
|
168
|
+
]} /> : null}
|
|
169
|
+
{r.idle.n ? <div className="rank">{gaps.map((label, k) => [
|
|
170
|
+
<span key={`n${k}`} className="n">{label}</span>,
|
|
171
|
+
<span key={`t${k}`} className="t">{r.gaps[k] ? <span className="b" style={{ width: `${(r.gaps[k] / gmax) * 100}%` }} /> : null}</span>,
|
|
172
|
+
<span key={`v${k}`} className="val">{f.int(r.gaps[k])}</span>,
|
|
173
|
+
])}</div> : <Empty />}
|
|
174
|
+
</section>
|
|
175
|
+
</div>
|
|
176
|
+
);
|
|
177
|
+
}
|