@linxiraos/pi-stats 1.4.12 → 1.5.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.
Files changed (32) hide show
  1. package/CHANGELOG.md +14 -5
  2. package/dist/client/index.js +86 -86
  3. package/dist/types/client/data/formatters.d.ts +9 -0
  4. package/dist/types/client/i18n/messages/common.d.ts +2 -2
  5. package/dist/types/client/i18n/messages/en.d.ts +2 -2
  6. package/dist/types/client/i18n/messages/models.d.ts +2 -2
  7. package/dist/types/client/i18n/messages/overview.d.ts +1 -1
  8. package/dist/types/client/ui/RequestDrawer.d.ts +2 -2
  9. package/dist/types/server.d.ts +3 -1
  10. package/dist/types/shared-types.d.ts +4 -3
  11. package/dist/types/trace.d.ts +8 -5
  12. package/package.json +4 -4
  13. package/src/client/data/formatters.ts +47 -6
  14. package/src/client/i18n/messages/common.ts +2 -2
  15. package/src/client/i18n/messages/models.ts +2 -2
  16. package/src/client/i18n/messages/overview.ts +1 -1
  17. package/src/client/routes/CostsRoute.tsx +24 -28
  18. package/src/client/routes/ErrorsRoute.tsx +57 -55
  19. package/src/client/routes/GainRoute.tsx +54 -54
  20. package/src/client/routes/ModelsRoute.tsx +7 -5
  21. package/src/client/routes/OverviewRoute.tsx +73 -62
  22. package/src/client/routes/ProvidersRoute.tsx +188 -176
  23. package/src/client/routes/RequestsRoute.tsx +98 -96
  24. package/src/client/routes/ToolsRoute.tsx +11 -10
  25. package/src/client/routes/TracesRoute.tsx +2 -1
  26. package/src/client/traces/SpanDrawer.tsx +2 -2
  27. package/src/client/traces/TimelineCanvas.tsx +16 -12
  28. package/src/client/traces/TraceView.tsx +18 -14
  29. package/src/client/ui/RequestDrawer.tsx +16 -6
  30. package/src/server.ts +7 -3
  31. package/src/shared-types.ts +4 -3
  32. package/src/trace.ts +43 -13
@@ -1,5 +1,10 @@
1
1
  import type { MessageStats } from "../types.js";
2
2
  export declare function formatInteger(value: number): string;
3
+ /**
4
+ * Compact units stay English in every locale (`1.2B`, `23M`, `546K`):
5
+ * `zh-CN` would otherwise print `12亿` / `2300万`, which the dashboard's
6
+ * charts and table cells never use.
7
+ */
3
8
  export declare function formatCompact(value: number): string;
4
9
  export declare function formatCost(value: number, digits?: number): string;
5
10
  /** Format an API-equivalent estimate, using N/A when all usage is unpriced. */
@@ -26,6 +31,10 @@ export declare function formatRelativeTime(timestamp: number, now?: number): str
26
31
  export declare function formatDateTimeShort(timestamp: number): string;
27
32
  /** Absolute local date and time to the second ("Sep 28, 14:03:22" / "9月28日 14:03:22"). */
28
33
  export declare function formatTimestamp(timestamp: number): string;
34
+ /** UTC day label for the cost/gain charts; `long` adds the weekday and year. */
35
+ export declare function formatUtcDay(timestamp: number, long?: boolean): string;
36
+ /** Wall-clock time of day to the second, using the dashboard locale. */
37
+ export declare function formatTimeOfDay(timestamp: number): string;
29
38
  /** Project folder as stored by ingest (`/work-pi/`), without the slashes. */
30
39
  export declare function formatFolder(folder: string): string;
31
40
  export declare function formatBytes(value: number): string;
@@ -91,8 +91,8 @@ export declare const common: {
91
91
  readonly "common.share": "占比";
92
92
  readonly "common.cost": "费用";
93
93
  readonly "common.error-rate": "错误率";
94
- readonly "common.tokens-per-second": "Token/秒";
95
- readonly "common.output-tokens-per-second": "输出 Token/秒";
94
+ readonly "common.tokens-per-second": "Token/s";
95
+ readonly "common.output-tokens-per-second": "输出 Token/s";
96
96
  readonly "common.premium": "溢价";
97
97
  readonly "common.premium-requests": "溢价请求";
98
98
  readonly "common.duration": "耗时";
@@ -118,7 +118,7 @@ export declare const enMessages: {
118
118
  readonly "overview.by-agent": "By agent";
119
119
  readonly "overview.requests-short": "{count} req";
120
120
  readonly "overview.main-agent": "Main agent";
121
- readonly "overview.subagents": "Subagents";
121
+ readonly "overview.subagents": "Subagent";
122
122
  readonly "overview.advisor": "Advisor";
123
123
  readonly "overview.latest-requests": "Latest requests";
124
124
  readonly "overview.latest-requests-description": "Most recent model calls across every session";
@@ -786,7 +786,7 @@ export declare const enLocale: {
786
786
  readonly "overview.by-agent": "By agent";
787
787
  readonly "overview.requests-short": "{count} req";
788
788
  readonly "overview.main-agent": "Main agent";
789
- readonly "overview.subagents": "Subagents";
789
+ readonly "overview.subagents": "Subagent";
790
790
  readonly "overview.advisor": "Advisor";
791
791
  readonly "overview.latest-requests": "Latest requests";
792
792
  readonly "overview.latest-requests-description": "Most recent model calls across every session";
@@ -71,7 +71,7 @@ export declare const models: {
71
71
  readonly "models.cache-rate": "缓存命中率";
72
72
  readonly "models.cache-title": "缓存读取 ÷(未缓存输入 + 缓存读取)";
73
73
  readonly "models.errors": "错误";
74
- readonly "models.tps-title": "平均每秒输出 Token 数";
74
+ readonly "models.tps-title": "平均输出 Token/s";
75
75
  readonly "models.ttft": "首 Token 延迟";
76
76
  readonly "models.ttft-title": "平均首 Token 延迟";
77
77
  readonly "models.trend": "趋势";
@@ -86,7 +86,7 @@ export declare const models: {
86
86
  readonly "models.performance-per-bucket": "每个活跃{bucket}的性能";
87
87
  readonly "models.no-samples-title": "没有性能样本";
88
88
  readonly "models.no-samples-hint": "只有流式响应会记录耗时。";
89
- readonly "models.tok-per-second": "{value} Token/秒";
89
+ readonly "models.tok-per-second": "{value} Token/s";
90
90
  readonly "models.bucket-5m": "5 分钟";
91
91
  readonly "models.bucket-hour": "小时";
92
92
  readonly "models.bucket-day": "天";
@@ -31,7 +31,7 @@ export declare const overview: {
31
31
  readonly "overview.by-agent": "By agent";
32
32
  readonly "overview.requests-short": "{count} req";
33
33
  readonly "overview.main-agent": "Main agent";
34
- readonly "overview.subagents": "Subagents";
34
+ readonly "overview.subagents": "Subagent";
35
35
  readonly "overview.advisor": "Advisor";
36
36
  readonly "overview.latest-requests": "Latest requests";
37
37
  readonly "overview.latest-requests-description": "Most recent model calls across every session";
@@ -2,10 +2,10 @@ import { type RequestStatus } from "../data/view-models.js";
2
2
  import { type Tone } from "./Badge.js";
3
3
  import "./request-drawer.css";
4
4
  /** Label and tone for each request outcome; shared by the request tables. */
5
- export declare const REQUEST_STATUS: Record<RequestStatus, {
5
+ export declare function requestStatusMeta(status: RequestStatus): {
6
6
  label: string;
7
7
  tone: Tone;
8
- }>;
8
+ };
9
9
  export interface RequestDrawerProps {
10
10
  id: number | null;
11
11
  onClose: () => void;
@@ -12,10 +12,12 @@ export declare function setStatsCloseHandler(close: (() => void) | undefined): v
12
12
  export declare function handleApi(req: Request): Promise<Response>;
13
13
  /** Format a dashboard origin, including brackets required by IPv6 literals. */
14
14
  export declare function formatStatsDashboardUrl(hostname: string, port: number): string;
15
- /** A dashboard this process started or found; `port` is where it listens, which may differ from the one requested. */
15
+ /** A dashboard this process started or found; `reused` distinguishes another process's server from one we own. */
16
16
  export interface StatsServerHandle {
17
17
  hostname: string;
18
18
  port: number;
19
+ /** True when the dashboard belongs to another process and this process has no server to keep alive. */
20
+ reused: boolean;
19
21
  stop: () => void;
20
22
  }
21
23
  export interface StartServerOptions {
@@ -1148,9 +1148,10 @@ export interface SessionTrace {
1148
1148
  /** Root transcript mtime, or recorded root activity/header time for offline snapshots. */
1149
1149
  mtimeMs: number;
1150
1150
  /**
1151
- * Conditional-request fingerprint `"<rootMs>:<childHighMs>"` (see
1152
- * traceFingerprintForEtag): the server ETag is built from this, so a
1153
- * subagent-only append changes the ETag even when the root is untouched.
1151
+ * Conditional-request fingerprint `"<rootMs>:<rootSize>:<digest>"` (see
1152
+ * traceFingerprintForEtag): the digest folds the child-transcript set into a
1153
+ * fixed-size key, so a subagent-only append changes the ETag even when the
1154
+ * root is untouched without making `If-None-Match` unbounded.
1154
1155
  * Offline snapshots use "snapshot" and do not support HTTP revalidation.
1155
1156
  */
1156
1157
  etag: string;
@@ -17,17 +17,20 @@ export declare class TracePathError extends Error {
17
17
  * span assembly changes so browsers don't revalidate stale cached bodies
18
18
  * against an unchanged transcript mtime.
19
19
  */
20
- export declare const TRACE_ETAG_VERSION = 4;
21
- /** Freshness of a root trace: root mtime plus the child-transcript set fingerprint. */
20
+ export declare const TRACE_ETAG_VERSION = 5;
21
+ /** Freshness of a root trace: root mtime+size plus the child-transcript set fingerprint. */
22
22
  export interface TraceFingerprint {
23
23
  rootMtimeMs: number;
24
+ rootSize: number;
24
25
  childFingerprint: string;
25
26
  }
27
+ /** Build the wire ETag from a fingerprint already computed by the caller. */
28
+ export declare function traceEtagForFingerprint(fingerprint: TraceFingerprint): string;
26
29
  /**
27
30
  * Freshness fingerprint for the trace ETag pre-check; `SessionTrace.etag` is
28
- * `${rootMtimeMs}:${childFingerprint}` for an unraced build. Returns undefined
29
- * when the path is rejected or missing (the caller falls through to the full
30
- * build, which maps those to 400/404).
31
+ * the compact `${rootMtimeMs}:${rootSize}:${digest}` key for an unraced build.
32
+ * Returns undefined when the path is rejected or missing (the caller falls
33
+ * through to the full build, which maps those to 400/404).
31
34
  */
32
35
  export declare function traceFingerprintForEtag(fileParam: string): Promise<TraceFingerprint | undefined>;
33
36
  export declare function traceMemoForTests(): {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@linxiraos/pi-stats",
4
- "version": "1.4.12",
4
+ "version": "1.5.0",
5
5
  "description": "Local observability dashboard for omp AI usage statistics",
6
6
  "homepage": "https://linxira-os.github.io/zeta/",
7
7
  "author": "Linxira-OS",
@@ -39,9 +39,9 @@
39
39
  "fmt": "oxfmt --no-error-on-unmatched-pattern 'src/**/*.{ts,tsx}' '{test,bench,examples,scripts}/**/*.ts' '*.ts'"
40
40
  },
41
41
  "dependencies": {
42
- "@linxiraos/pi-ai": "1.4.12",
43
- "@linxiraos/pi-catalog": "1.4.12",
44
- "@linxiraos/pi-utils": "1.4.12",
42
+ "@linxiraos/pi-ai": "1.5.0",
43
+ "@linxiraos/pi-catalog": "1.5.0",
44
+ "@linxiraos/pi-utils": "1.5.0",
45
45
  "lucide-react": "^1.24.0",
46
46
  "react": "19.2.7",
47
47
  "react-dom": "19.2.7"
@@ -2,11 +2,11 @@ import { getLocale, t } from "../i18n";
2
2
  import type { MessageStats } from "../types";
3
3
 
4
4
  /**
5
- * One locale drives every number and date, and it is the *product's* — the
6
- * host CLI's language injected into the page, not the browser's. Mixing
7
- * conventions (e.g. `1,4 Mr` beside `97.0%` on a tr-TR browser) stays
8
- * impossible; the difference from the pre-i18n build is only that a `zh-CN`
9
- * dashboard now formats in `zh-CN` throughout.
5
+ * One locale drives number grouping, costs and dates, and it is the
6
+ * *product's* — the host CLI's language injected into the page, not the
7
+ * browser's. Mixing conventions (e.g. `1,4 Mr` beside `97.0%` on a tr-TR
8
+ * browser) stays impossible. Compact units are the exception in both locales:
9
+ * they stay `K`/`M`/`B` (see `formatCompact`).
10
10
  */
11
11
  function numberLocale(): string {
12
12
  return getLocale();
@@ -16,8 +16,13 @@ export function formatInteger(value: number): string {
16
16
  return value.toLocaleString(numberLocale());
17
17
  }
18
18
 
19
+ /**
20
+ * Compact units stay English in every locale (`1.2B`, `23M`, `546K`):
21
+ * `zh-CN` would otherwise print `12亿` / `2300万`, which the dashboard's
22
+ * charts and table cells never use.
23
+ */
19
24
  export function formatCompact(value: number): string {
20
- return value.toLocaleString(numberLocale(), { notation: "compact" });
25
+ return value.toLocaleString("en", { notation: "compact" });
21
26
  }
22
27
 
23
28
  export function formatCost(value: number, digits?: number): string {
@@ -152,6 +157,42 @@ export function formatTimestamp(timestamp: number): string {
152
157
  return formatter.format(timestamp);
153
158
  }
154
159
 
160
+ const utcDayFormatters = new Map<string, Intl.DateTimeFormat>();
161
+
162
+ /** UTC day label for the cost/gain charts; `long` adds the weekday and year. */
163
+ export function formatUtcDay(timestamp: number, long = false): string {
164
+ const locale = getLocale();
165
+ const key = `${locale}:${long ? "long" : "short"}`;
166
+ let formatter = utcDayFormatters.get(key);
167
+ if (!formatter) {
168
+ formatter = new Intl.DateTimeFormat(
169
+ locale,
170
+ long
171
+ ? { weekday: "short", month: "short", day: "numeric", year: "numeric", timeZone: "UTC" }
172
+ : { month: "short", day: "numeric", timeZone: "UTC" },
173
+ );
174
+ utcDayFormatters.set(key, formatter);
175
+ }
176
+ return formatter.format(timestamp);
177
+ }
178
+
179
+ /** Wall-clock time of day to the second, using the dashboard locale. */
180
+ export function formatTimeOfDay(timestamp: number): string {
181
+ const locale = getLocale();
182
+ const key = `${locale}:time`;
183
+ let formatter = dateFormatters.get(key);
184
+ if (!formatter) {
185
+ formatter = new Intl.DateTimeFormat(locale, {
186
+ hour: "2-digit",
187
+ minute: "2-digit",
188
+ second: "2-digit",
189
+ hourCycle: "h23",
190
+ });
191
+ dateFormatters.set(key, formatter);
192
+ }
193
+ return formatter.format(timestamp);
194
+ }
195
+
155
196
  /** Project folder as stored by ingest (`/work-pi/`), without the slashes. */
156
197
  export function formatFolder(folder: string): string {
157
198
  return folder.replace(/^\/+|\/+$/g, "") || t("common.root");
@@ -95,8 +95,8 @@ export const common = {
95
95
  "common.share": "占比",
96
96
  "common.cost": "费用",
97
97
  "common.error-rate": "错误率",
98
- "common.tokens-per-second": "Token/秒",
99
- "common.output-tokens-per-second": "输出 Token/秒",
98
+ "common.tokens-per-second": "Token/s",
99
+ "common.output-tokens-per-second": "输出 Token/s",
100
100
  "common.premium": "溢价",
101
101
  "common.premium-requests": "溢价请求",
102
102
  "common.duration": "耗时",
@@ -71,7 +71,7 @@ export const models = {
71
71
  "models.cache-rate": "缓存命中率",
72
72
  "models.cache-title": "缓存读取 ÷(未缓存输入 + 缓存读取)",
73
73
  "models.errors": "错误",
74
- "models.tps-title": "平均每秒输出 Token 数",
74
+ "models.tps-title": "平均输出 Token/s",
75
75
  "models.ttft": "首 Token 延迟",
76
76
  "models.ttft-title": "平均首 Token 延迟",
77
77
  "models.trend": "趋势",
@@ -86,7 +86,7 @@ export const models = {
86
86
  "models.performance-per-bucket": "每个活跃{bucket}的性能",
87
87
  "models.no-samples-title": "没有性能样本",
88
88
  "models.no-samples-hint": "只有流式响应会记录耗时。",
89
- "models.tok-per-second": "{value} Token/秒",
89
+ "models.tok-per-second": "{value} Token/s",
90
90
  "models.bucket-5m": "5 分钟",
91
91
  "models.bucket-hour": "小时",
92
92
  "models.bucket-day": "天",
@@ -35,7 +35,7 @@ export const overview = {
35
35
  "overview.by-agent": "By agent",
36
36
  "overview.requests-short": "{count} req",
37
37
  "overview.main-agent": "Main agent",
38
- "overview.subagents": "Subagents",
38
+ "overview.subagents": "Subagent",
39
39
  "overview.advisor": "Advisor",
40
40
  // ── latest requests card + table ────────────────────────────────────
41
41
  "overview.latest-requests": "Latest requests",
@@ -4,7 +4,7 @@ import { getCostDashboardStats } from "../api";
4
4
  import { t } from "../i18n";
5
5
  import { Chart, type ChartSeries, Legend, ShareBar, useHiddenSeries } from "../charts";
6
6
  import { buildModelColorLookup, modelKey, OTHER_COLOR, SERIES_COLORS } from "../data/colors";
7
- import { formatCost, formatEstimatedCost, formatInteger, formatPercent } from "../data/formatters";
7
+ import { formatCost, formatEstimatedCost, formatInteger, formatPercent, formatUtcDay } from "../data/formatters";
8
8
  import { useQuery } from "../data/query";
9
9
  import { bucketAxis, rangeMeta } from "../data/range";
10
10
  import { densify, pivotSeries } from "../data/series";
@@ -35,10 +35,13 @@ export interface CostsRouteProps {
35
35
 
36
36
  type SplitMode = "model" | "component";
37
37
 
38
- const SPLIT_OPTIONS = [
39
- { value: "model" as const, label: t("costs.by-model") },
40
- { value: "component" as const, label: t("costs.by-component") },
41
- ];
38
+ // Translated labels are built at render time so the topbar switch updates them.
39
+ function splitOptions() {
40
+ return [
41
+ { value: "model" as const, label: t("costs.by-model") },
42
+ { value: "component" as const, label: t("costs.by-component") },
43
+ ];
44
+ }
42
45
 
43
46
  /** Models stacked individually in the daily chart; the rest fold into "Other". */
44
47
  const MODEL_LIMIT = 6;
@@ -46,21 +49,14 @@ const MODEL_LIMIT = 6;
46
49
  /** The cost series is bucketed by UTC day on the server. */
47
50
  const DAY_MS = 86_400_000;
48
51
 
49
- const COMPONENTS = [
50
- { key: "costInput", label: t("common.input"), color: "#5b8cff" },
51
- { key: "costOutput", label: t("common.output"), color: "var(--chart-secondary)" },
52
- { key: "costCacheRead", label: t("common.cache-read"), color: "var(--chart-primary)" },
53
- { key: "costCacheWrite", label: t("common.cache-write"), color: "#f5b54a" },
54
- ] as const satisfies readonly { key: keyof CostComponents; label: string; color: string }[];
55
-
56
- const UTC_DAY = new Intl.DateTimeFormat(undefined, { month: "short", day: "numeric", timeZone: "UTC" });
57
- const UTC_DAY_LONG = new Intl.DateTimeFormat(undefined, {
58
- weekday: "short",
59
- month: "short",
60
- day: "numeric",
61
- year: "numeric",
62
- timeZone: "UTC",
63
- });
52
+ function components(): readonly { key: keyof CostComponents; label: string; color: string }[] {
53
+ return [
54
+ { key: "costInput", label: t("common.input"), color: "#5b8cff" },
55
+ { key: "costOutput", label: t("common.output"), color: "var(--chart-secondary)" },
56
+ { key: "costCacheRead", label: t("common.cache-read"), color: "var(--chart-primary)" },
57
+ { key: "costCacheWrite", label: t("common.cache-write"), color: "#f5b54a" },
58
+ ];
59
+ }
64
60
 
65
61
  export function CostsRoute({ active, range }: CostsRouteProps) {
66
62
  const query = useQuery(["costs", range], ({ signal }) => getCostDashboardStats(range, signal), { enabled: active });
@@ -94,7 +90,7 @@ export function CostsRoute({ active, range }: CostsRouteProps) {
94
90
  actions={
95
91
  <Segmented
96
92
  size="sm"
97
- options={SPLIT_OPTIONS}
93
+ options={splitOptions()}
98
94
  value={split}
99
95
  onChange={setSplit}
100
96
  aria-label={t("costs.split-by")}
@@ -110,8 +106,8 @@ export function CostsRoute({ active, range }: CostsRouteProps) {
110
106
  <div className="stack" style={{ gap: 12 }}>
111
107
  <Chart
112
108
  slots={view.buckets.length}
113
- tickLabel={i => UTC_DAY.format(view.buckets[i])}
114
- tooltipTitle={i => UTC_DAY_LONG.format(view.buckets[i])}
109
+ tickLabel={i => formatUtcDay(view.buckets[i])}
110
+ tooltipTitle={i => formatUtcDay(view.buckets[i], true)}
115
111
  series={series}
116
112
  hidden={hidden}
117
113
  height={280}
@@ -230,7 +226,7 @@ function buildCostsView(data: CostDashboardStats, range: TimeRange): CostsView {
230
226
  dailyTotals: densify(points, buckets, p => p.cost),
231
227
  unpricedPerDay: densify(points, buckets, p => p.unpricedRequests),
232
228
  modelSeries,
233
- componentSeries: COMPONENTS.map(c => ({
229
+ componentSeries: components().map(c => ({
234
230
  key: c.key,
235
231
  label: c.label,
236
232
  color: c.color,
@@ -298,10 +294,10 @@ function ComponentBreakdown({ summary }: { summary: CostSummaryView }) {
298
294
  <div className="stack" style={{ gap: 14 }}>
299
295
  <ShareBar
300
296
  height={10}
301
- segments={COMPONENTS.map(c => ({ key: c.key, label: c.label, value: summary[c.key], color: c.color }))}
297
+ segments={components().map(c => ({ key: c.key, label: c.label, value: summary[c.key], color: c.color }))}
302
298
  />
303
299
  <div className="costs-components">
304
- {COMPONENTS.map(c => (
300
+ {components().map(c => (
305
301
  <div key={c.key} className="costs-component-row">
306
302
  <span className="row">
307
303
  <Swatch color={c.color} />
@@ -331,7 +327,7 @@ function ComponentBreakdown({ summary }: { summary: CostSummaryView }) {
331
327
  }
332
328
 
333
329
  function buildCostColumns(view: CostsView): Column<CostModelRow>[] {
334
- const componentColumns: Column<CostModelRow>[] = COMPONENTS.map(c => ({
330
+ const componentColumns: Column<CostModelRow>[] = components().map(c => ({
335
331
  key: c.key,
336
332
  header: c.label,
337
333
  align: "right",
@@ -388,7 +384,7 @@ function buildCostColumns(view: CostsView): Column<CostModelRow>[] {
388
384
  render: row =>
389
385
  row.cost > 0 ? (
390
386
  <ShareBar
391
- segments={COMPONENTS.map(c => ({ key: c.key, label: c.label, value: row[c.key], color: c.color }))}
387
+ segments={components().map(c => ({ key: c.key, label: c.label, value: row[c.key], color: c.color }))}
392
388
  />
393
389
  ) : (
394
390
  <span className="dim">–</span>
@@ -292,7 +292,7 @@ export function ErrorsRoute({ active, range, onRequestClick }: ErrorsRouteProps)
292
292
  rows={filtered}
293
293
  rowKey={row => row.id ?? `${row.sessionFile}:${row.entryId}`}
294
294
  onRowClick={row => row.id !== undefined && onRequestClick(row.id)}
295
- columns={FAILURE_COLUMNS}
295
+ columns={failureColumns()}
296
296
  initialSort={{ key: "time", dir: "desc" }}
297
297
  limit={50}
298
298
  dense
@@ -389,57 +389,59 @@ function SignatureDetail({ group, onRequestClick }: { group: ErrorGroupView; onR
389
389
  );
390
390
  }
391
391
 
392
- const FAILURE_COLUMNS: readonly Column<MessageStats>[] = [
393
- {
394
- key: "time",
395
- header: t("errors.when"),
396
- width: 120,
397
- sort: row => row.timestamp,
398
- render: row => (
399
- <span className="muted" title={formatTimestamp(row.timestamp)}>
400
- {formatRelativeTime(row.timestamp)}
401
- </span>
402
- ),
403
- },
404
- {
405
- key: "model",
406
- header: t("common.model"),
407
- sort: row => row.model,
408
- render: row => <LabelCell primary={<span className="mono">{row.model}</span>} secondary={row.provider} />,
409
- },
410
- {
411
- key: "error",
412
- header: t("common.error"),
413
- sort: row => row.errorMessage ?? "",
414
- render: row => (
415
- <span className="errors-message" title={row.errorMessage ?? undefined}>
416
- {row.errorMessage ?? t("errors.unknown-error")}
417
- </span>
418
- ),
419
- },
420
- {
421
- key: "project",
422
- header: t("common.project"),
423
- sort: row => row.folder,
424
- render: row => (
425
- <span className="mono muted" title={row.folder}>
426
- {formatFolder(row.folder)}
427
- </span>
428
- ),
429
- },
430
- {
431
- key: "tokens",
432
- header: t("common.tokens"),
433
- align: "right",
434
- sort: row => row.usage.totalTokens,
435
- render: row => <span className="num">{formatInteger(row.usage.totalTokens)}</span>,
436
- },
437
- {
438
- key: "cost",
439
- header: t("common.cost"),
440
- title: t("errors.cost-hint"),
441
- align: "right",
442
- sort: row => row.usage.cost.total,
443
- render: row => <span className="num">{formatMessageCost(row, 4)}</span>,
444
- },
445
- ];
392
+ function failureColumns(): readonly Column<MessageStats>[] {
393
+ return [
394
+ {
395
+ key: "time",
396
+ header: t("errors.when"),
397
+ width: 120,
398
+ sort: row => row.timestamp,
399
+ render: row => (
400
+ <span className="muted" title={formatTimestamp(row.timestamp)}>
401
+ {formatRelativeTime(row.timestamp)}
402
+ </span>
403
+ ),
404
+ },
405
+ {
406
+ key: "model",
407
+ header: t("common.model"),
408
+ sort: row => row.model,
409
+ render: row => <LabelCell primary={<span className="mono">{row.model}</span>} secondary={row.provider} />,
410
+ },
411
+ {
412
+ key: "error",
413
+ header: t("common.error"),
414
+ sort: row => row.errorMessage ?? "",
415
+ render: row => (
416
+ <span className="errors-message" title={row.errorMessage ?? undefined}>
417
+ {row.errorMessage ?? t("errors.unknown-error")}
418
+ </span>
419
+ ),
420
+ },
421
+ {
422
+ key: "project",
423
+ header: t("common.project"),
424
+ sort: row => row.folder,
425
+ render: row => (
426
+ <span className="mono muted" title={row.folder}>
427
+ {formatFolder(row.folder)}
428
+ </span>
429
+ ),
430
+ },
431
+ {
432
+ key: "tokens",
433
+ header: t("common.tokens"),
434
+ align: "right",
435
+ sort: row => row.usage.totalTokens,
436
+ render: row => <span className="num">{formatInteger(row.usage.totalTokens)}</span>,
437
+ },
438
+ {
439
+ key: "cost",
440
+ header: t("common.cost"),
441
+ title: t("errors.cost-hint"),
442
+ align: "right",
443
+ sort: row => row.usage.cost.total,
444
+ render: row => <span className="num">{formatMessageCost(row, 4)}</span>,
445
+ },
446
+ ];
447
+ }