@linxiraos/pi-stats 1.4.13 → 1.5.1
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/CHANGELOG.md +14 -5
- package/dist/client/index.js +86 -86
- package/dist/types/client/data/formatters.d.ts +9 -0
- package/dist/types/client/i18n/messages/common.d.ts +2 -2
- package/dist/types/client/i18n/messages/en.d.ts +2 -2
- package/dist/types/client/i18n/messages/models.d.ts +2 -2
- package/dist/types/client/i18n/messages/overview.d.ts +1 -1
- package/dist/types/client/ui/RequestDrawer.d.ts +2 -2
- package/dist/types/server.d.ts +3 -1
- package/dist/types/shared-types.d.ts +4 -3
- package/dist/types/trace.d.ts +8 -5
- package/package.json +4 -4
- package/src/client/data/formatters.ts +47 -6
- package/src/client/i18n/messages/common.ts +2 -2
- package/src/client/i18n/messages/models.ts +2 -2
- package/src/client/i18n/messages/overview.ts +1 -1
- package/src/client/routes/CostsRoute.tsx +24 -28
- package/src/client/routes/ErrorsRoute.tsx +57 -55
- package/src/client/routes/GainRoute.tsx +54 -54
- package/src/client/routes/ModelsRoute.tsx +7 -5
- package/src/client/routes/OverviewRoute.tsx +73 -62
- package/src/client/routes/ProvidersRoute.tsx +188 -176
- package/src/client/routes/RequestsRoute.tsx +98 -96
- package/src/client/routes/ToolsRoute.tsx +11 -10
- package/src/client/routes/TracesRoute.tsx +2 -1
- package/src/client/traces/SpanDrawer.tsx +2 -2
- package/src/client/traces/TimelineCanvas.tsx +16 -12
- package/src/client/traces/TraceView.tsx +18 -14
- package/src/client/ui/RequestDrawer.tsx +16 -6
- package/src/server.ts +7 -3
- package/src/shared-types.ts +4 -3
- package/src/trace.ts +43 -13
|
@@ -52,21 +52,27 @@ export interface ProvidersRouteProps {
|
|
|
52
52
|
|
|
53
53
|
type BurnMetric = "tokens" | "cost" | "requests";
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
// Built per render, like every translated option list: a module-level `t()`
|
|
56
|
+
// call freezes the boot locale and survives a topbar language switch.
|
|
57
|
+
function burnOptions() {
|
|
58
|
+
return [
|
|
59
|
+
{ value: "tokens" as const, label: t("common.tokens") },
|
|
60
|
+
{ value: "cost" as const, label: t("common.cost"), title: t("providers.cost-title") },
|
|
61
|
+
{ value: "requests" as const, label: t("common.requests") },
|
|
62
|
+
];
|
|
63
|
+
}
|
|
60
64
|
|
|
61
65
|
/** Providers stacked individually in the burn chart; the rest fold into "Other". */
|
|
62
66
|
const TOP_PROVIDERS = 6;
|
|
63
67
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
function tokenMix() {
|
|
69
|
+
return [
|
|
70
|
+
{ key: "input", label: t("ui.uncached-input"), color: "#5b8cff" },
|
|
71
|
+
{ key: "cacheRead", label: t("common.cache-read"), color: "var(--chart-primary)" },
|
|
72
|
+
{ key: "cacheWrite", label: t("common.cache-write"), color: "#f5b54a" },
|
|
73
|
+
{ key: "output", label: t("common.output"), color: "var(--chart-secondary)" },
|
|
74
|
+
] as const;
|
|
75
|
+
}
|
|
70
76
|
|
|
71
77
|
interface WindowRef {
|
|
72
78
|
provider: string;
|
|
@@ -236,7 +242,7 @@ export function ProvidersRoute({ active, range }: ProvidersRouteProps) {
|
|
|
236
242
|
count: TOP_PROVIDERS,
|
|
237
243
|
})
|
|
238
244
|
}
|
|
239
|
-
actions={<Segmented size="sm" options={
|
|
245
|
+
actions={<Segmented size="sm" options={burnOptions()} value={metric} onChange={setMetric} />}
|
|
240
246
|
stale={stats.stale}
|
|
241
247
|
>
|
|
242
248
|
<QueryView query={stats} skeleton={<ChartSkeleton height={260} />}>
|
|
@@ -468,9 +474,11 @@ function TokenMix({ provider }: { provider: ProviderAggregate }) {
|
|
|
468
474
|
};
|
|
469
475
|
return (
|
|
470
476
|
<div className="providers-mix">
|
|
471
|
-
<ShareBar
|
|
477
|
+
<ShareBar
|
|
478
|
+
segments={tokenMix().map(m => ({ key: m.key, label: m.label, value: mix[m.key], color: m.color }))}
|
|
479
|
+
/>
|
|
472
480
|
<Legend
|
|
473
|
-
items={
|
|
481
|
+
items={tokenMix().map(m => ({
|
|
474
482
|
key: m.key,
|
|
475
483
|
label: m.label,
|
|
476
484
|
color: m.color,
|
|
@@ -601,7 +609,7 @@ function WindowInsightsTable({
|
|
|
601
609
|
<Table
|
|
602
610
|
rows={insights}
|
|
603
611
|
rowKey={i => `${i.provider}::${i.windowKey}`}
|
|
604
|
-
columns={
|
|
612
|
+
columns={insightColumns()}
|
|
605
613
|
initialSort={{ key: "consumed", dir: "desc" }}
|
|
606
614
|
limit={12}
|
|
607
615
|
selectedKey={selected ? `${selected.provider}::${selected.windowKey}` : null}
|
|
@@ -611,104 +619,106 @@ function WindowInsightsTable({
|
|
|
611
619
|
);
|
|
612
620
|
}
|
|
613
621
|
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
{
|
|
622
|
-
key: "accounts",
|
|
623
|
-
header: t("providers.accounts"),
|
|
624
|
-
title: t("providers.accounts-title"),
|
|
625
|
-
align: "right",
|
|
626
|
-
sort: i => i.accounts,
|
|
627
|
-
render: i => <span className="num">{formatInteger(i.accounts)}</span>,
|
|
628
|
-
},
|
|
629
|
-
{
|
|
630
|
-
key: "cycles",
|
|
631
|
-
header: t("providers.resets"),
|
|
632
|
-
title: t("providers.resets-title"),
|
|
633
|
-
align: "right",
|
|
634
|
-
sort: i => i.cycles,
|
|
635
|
-
render: i => <span className="num muted">{formatInteger(i.cycles)}</span>,
|
|
636
|
-
},
|
|
637
|
-
{
|
|
638
|
-
key: "consumed",
|
|
639
|
-
header: t("providers.windows-burned"),
|
|
640
|
-
title: t("providers.windows-burned-title"),
|
|
641
|
-
align: "right",
|
|
642
|
-
sort: i => i.fractionConsumed,
|
|
643
|
-
render: i => <span className="num">{i.fractionConsumed.toFixed(2)}</span>,
|
|
644
|
-
},
|
|
645
|
-
{
|
|
646
|
-
key: "capacity",
|
|
647
|
-
header: t("providers.tokens-per-window"),
|
|
648
|
-
title: t("providers.tokens-per-window-title"),
|
|
649
|
-
align: "right",
|
|
650
|
-
sort: i => i.estTokensPerWindow ?? -1,
|
|
651
|
-
render: i =>
|
|
652
|
-
i.estTokensPerWindow !== null ? (
|
|
653
|
-
<span className="num">{formatCompact(i.estTokensPerWindow)}</span>
|
|
654
|
-
) : (
|
|
655
|
-
<span className="dim" title={t("providers.too-little-consumed")}>
|
|
656
|
-
–
|
|
657
|
-
</span>
|
|
658
|
-
),
|
|
659
|
-
},
|
|
660
|
-
{
|
|
661
|
-
key: "peak",
|
|
662
|
-
header: t("providers.peak-utilization"),
|
|
663
|
-
title: t("providers.peak-utilization-title"),
|
|
664
|
-
align: "right",
|
|
665
|
-
sort: i => i.peakConcurrentFraction,
|
|
666
|
-
render: i => {
|
|
667
|
-
const load = i.accounts > 0 ? i.peakConcurrentFraction / i.accounts : 0;
|
|
668
|
-
return (
|
|
669
|
-
<MeterCell
|
|
670
|
-
value={i.peakConcurrentFraction}
|
|
671
|
-
max={i.accounts}
|
|
672
|
-
display={formatPercent(i.peakConcurrentFraction, 0)}
|
|
673
|
-
color={load >= 0.9 ? "var(--warn)" : undefined}
|
|
674
|
-
/>
|
|
675
|
-
);
|
|
622
|
+
function insightColumns(): Column<ProviderWindowInsight>[] {
|
|
623
|
+
return [
|
|
624
|
+
{
|
|
625
|
+
key: "window",
|
|
626
|
+
header: t("providers.window"),
|
|
627
|
+
sort: i => `${i.provider} ${i.windowKey}`,
|
|
628
|
+
render: i => <LabelCell primary={i.windowKey} secondary={<span className="mono">{i.provider}</span>} />,
|
|
676
629
|
},
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
630
|
+
{
|
|
631
|
+
key: "accounts",
|
|
632
|
+
header: t("providers.accounts"),
|
|
633
|
+
title: t("providers.accounts-title"),
|
|
634
|
+
align: "right",
|
|
635
|
+
sort: i => i.accounts,
|
|
636
|
+
render: i => <span className="num">{formatInteger(i.accounts)}</span>,
|
|
637
|
+
},
|
|
638
|
+
{
|
|
639
|
+
key: "cycles",
|
|
640
|
+
header: t("providers.resets"),
|
|
641
|
+
title: t("providers.resets-title"),
|
|
642
|
+
align: "right",
|
|
643
|
+
sort: i => i.cycles,
|
|
644
|
+
render: i => <span className="num muted">{formatInteger(i.cycles)}</span>,
|
|
645
|
+
},
|
|
646
|
+
{
|
|
647
|
+
key: "consumed",
|
|
648
|
+
header: t("providers.windows-burned"),
|
|
649
|
+
title: t("providers.windows-burned-title"),
|
|
650
|
+
align: "right",
|
|
651
|
+
sort: i => i.fractionConsumed,
|
|
652
|
+
render: i => <span className="num">{i.fractionConsumed.toFixed(2)}</span>,
|
|
653
|
+
},
|
|
654
|
+
{
|
|
655
|
+
key: "capacity",
|
|
656
|
+
header: t("providers.tokens-per-window"),
|
|
657
|
+
title: t("providers.tokens-per-window-title"),
|
|
658
|
+
align: "right",
|
|
659
|
+
sort: i => i.estTokensPerWindow ?? -1,
|
|
660
|
+
render: i =>
|
|
661
|
+
i.estTokensPerWindow !== null ? (
|
|
662
|
+
<span className="num">{formatCompact(i.estTokensPerWindow)}</span>
|
|
663
|
+
) : (
|
|
664
|
+
<span className="dim" title={t("providers.too-little-consumed")}>
|
|
665
|
+
–
|
|
666
|
+
</span>
|
|
667
|
+
),
|
|
668
|
+
},
|
|
669
|
+
{
|
|
670
|
+
key: "peak",
|
|
671
|
+
header: t("providers.peak-utilization"),
|
|
672
|
+
title: t("providers.peak-utilization-title"),
|
|
673
|
+
align: "right",
|
|
674
|
+
sort: i => i.peakConcurrentFraction,
|
|
675
|
+
render: i => {
|
|
676
|
+
const load = i.accounts > 0 ? i.peakConcurrentFraction / i.accounts : 0;
|
|
677
|
+
return (
|
|
678
|
+
<MeterCell
|
|
679
|
+
value={i.peakConcurrentFraction}
|
|
680
|
+
max={i.accounts}
|
|
681
|
+
display={formatPercent(i.peakConcurrentFraction, 0)}
|
|
682
|
+
color={load >= 0.9 ? "var(--warn)" : undefined}
|
|
683
|
+
/>
|
|
684
|
+
);
|
|
685
|
+
},
|
|
686
|
+
},
|
|
687
|
+
{
|
|
688
|
+
key: "ideal",
|
|
689
|
+
header: t("providers.accounts-needed"),
|
|
690
|
+
title: t("providers.accounts-needed-title"),
|
|
691
|
+
align: "right",
|
|
692
|
+
sort: i => i.idealAccounts - i.accounts,
|
|
693
|
+
render: i =>
|
|
694
|
+
i.idealAccounts > i.accounts ? (
|
|
695
|
+
<Badge tone="warn" mono>
|
|
696
|
+
{t("providers.ideal-accounts", {
|
|
697
|
+
ideal: formatInteger(i.idealAccounts),
|
|
698
|
+
have: formatInteger(i.accounts),
|
|
699
|
+
})}
|
|
700
|
+
</Badge>
|
|
701
|
+
) : (
|
|
702
|
+
<span className="num">{formatInteger(i.idealAccounts)}</span>
|
|
703
|
+
),
|
|
704
|
+
},
|
|
705
|
+
{
|
|
706
|
+
key: "exhausted",
|
|
707
|
+
header: t("providers.exhaustions"),
|
|
708
|
+
title: t("providers.exhaustions-title"),
|
|
709
|
+
align: "right",
|
|
710
|
+
sort: i => i.exhaustedEvents,
|
|
711
|
+
render: i =>
|
|
712
|
+
i.exhaustedEvents > 0 ? (
|
|
713
|
+
<Badge tone="warn" mono>
|
|
714
|
+
{t("providers.exhausted-n", { count: formatInteger(i.exhaustedEvents) })}
|
|
715
|
+
</Badge>
|
|
716
|
+
) : (
|
|
717
|
+
<span className="num dim">0</span>
|
|
718
|
+
),
|
|
719
|
+
},
|
|
720
|
+
];
|
|
721
|
+
}
|
|
712
722
|
|
|
713
723
|
// ---------------------------------------------------------------------------
|
|
714
724
|
// Window utilization
|
|
@@ -930,7 +940,7 @@ function WindowUtilizationCard({
|
|
|
930
940
|
<Table
|
|
931
941
|
rows={rows}
|
|
932
942
|
rowKey={r => `${r.series.windowKey}::${r.series.accountKey}`}
|
|
933
|
-
columns={
|
|
943
|
+
columns={accountColumns()}
|
|
934
944
|
limit={16}
|
|
935
945
|
onRowClick={r => onSelect({ provider: r.series.provider, windowKey: r.series.windowKey })}
|
|
936
946
|
dense
|
|
@@ -1019,68 +1029,70 @@ function statusBadge(latest: AccountRow["latest"]): ReactNode {
|
|
|
1019
1029
|
return <Badge tone="ok">{t("ui.status-ok")}</Badge>;
|
|
1020
1030
|
}
|
|
1021
1031
|
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
<span className="
|
|
1030
|
-
|
|
1031
|
-
{r.
|
|
1032
|
+
function accountColumns(): Column<AccountRow>[] {
|
|
1033
|
+
return [
|
|
1034
|
+
{
|
|
1035
|
+
key: "account",
|
|
1036
|
+
header: t("providers.account"),
|
|
1037
|
+
sort: r => r.name,
|
|
1038
|
+
render: r => (
|
|
1039
|
+
<span className="row" style={{ gap: 8 }}>
|
|
1040
|
+
<span className="providers-swatch-slot">{r.color && <Swatch color={r.color} />}</span>
|
|
1041
|
+
<span className="truncate providers-account" title={r.series.accountKey}>
|
|
1042
|
+
{r.name}
|
|
1043
|
+
</span>
|
|
1032
1044
|
</span>
|
|
1033
|
-
</span>
|
|
1034
|
-
),
|
|
1035
|
-
},
|
|
1036
|
-
{
|
|
1037
|
-
key: "window",
|
|
1038
|
-
header: t("providers.window"),
|
|
1039
|
-
sort: r => r.series.windowKey,
|
|
1040
|
-
render: r => <span className={r.color ? undefined : "muted"}>{r.series.windowKey}</span>,
|
|
1041
|
-
},
|
|
1042
|
-
{
|
|
1043
|
-
key: "latest",
|
|
1044
|
-
header: t("providers.latest-used"),
|
|
1045
|
-
align: "right",
|
|
1046
|
-
sort: r => r.latest?.fraction ?? -1,
|
|
1047
|
-
render: r =>
|
|
1048
|
-
r.latest ? (
|
|
1049
|
-
<MeterCell
|
|
1050
|
-
value={r.latest.fraction}
|
|
1051
|
-
max={1}
|
|
1052
|
-
display={formatPercent(r.latest.fraction, 0)}
|
|
1053
|
-
color={r.latest.exhausted ? "var(--bad)" : r.latest.fraction >= 0.8 ? "var(--warn)" : "var(--ok)"}
|
|
1054
|
-
/>
|
|
1055
|
-
) : (
|
|
1056
|
-
<span className="dim">–</span>
|
|
1057
1045
|
),
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1046
|
+
},
|
|
1047
|
+
{
|
|
1048
|
+
key: "window",
|
|
1049
|
+
header: t("providers.window"),
|
|
1050
|
+
sort: r => r.series.windowKey,
|
|
1051
|
+
render: r => <span className={r.color ? undefined : "muted"}>{r.series.windowKey}</span>,
|
|
1052
|
+
},
|
|
1053
|
+
{
|
|
1054
|
+
key: "latest",
|
|
1055
|
+
header: t("providers.latest-used"),
|
|
1056
|
+
align: "right",
|
|
1057
|
+
sort: r => r.latest?.fraction ?? -1,
|
|
1058
|
+
render: r =>
|
|
1059
|
+
r.latest ? (
|
|
1060
|
+
<MeterCell
|
|
1061
|
+
value={r.latest.fraction}
|
|
1062
|
+
max={1}
|
|
1063
|
+
display={formatPercent(r.latest.fraction, 0)}
|
|
1064
|
+
color={r.latest.exhausted ? "var(--bad)" : r.latest.fraction >= 0.8 ? "var(--warn)" : "var(--ok)"}
|
|
1065
|
+
/>
|
|
1066
|
+
) : (
|
|
1067
|
+
<span className="dim">–</span>
|
|
1068
|
+
),
|
|
1069
|
+
},
|
|
1070
|
+
{
|
|
1071
|
+
key: "status",
|
|
1072
|
+
header: t("providers.status"),
|
|
1073
|
+
sort: r => (r.latest?.exhausted ? 2 : (r.latest?.fraction ?? 0) >= 0.8 ? 1 : 0),
|
|
1074
|
+
render: r => statusBadge(r.latest),
|
|
1075
|
+
},
|
|
1076
|
+
{
|
|
1077
|
+
key: "peak",
|
|
1078
|
+
header: t("providers.peak-in-range"),
|
|
1079
|
+
align: "right",
|
|
1080
|
+
sort: r => r.peak ?? -1,
|
|
1081
|
+
render: r => <span className="num">{r.peak === null ? "–" : formatPercent(r.peak, 0)}</span>,
|
|
1082
|
+
},
|
|
1083
|
+
{
|
|
1084
|
+
key: "samples",
|
|
1085
|
+
header: t("providers.snapshots"),
|
|
1086
|
+
align: "right",
|
|
1087
|
+
sort: r => r.samples,
|
|
1088
|
+
render: r => <span className="num muted">{formatInteger(r.samples)}</span>,
|
|
1089
|
+
},
|
|
1090
|
+
{
|
|
1091
|
+
key: "recorded",
|
|
1092
|
+
header: t("providers.recorded"),
|
|
1093
|
+
align: "right",
|
|
1094
|
+
sort: r => r.latest?.timestamp ?? 0,
|
|
1095
|
+
render: r => <span className="muted">{r.latest ? formatRelativeTime(r.latest.timestamp) : "–"}</span>,
|
|
1096
|
+
},
|
|
1097
|
+
];
|
|
1098
|
+
}
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
import { useQuery } from "../data/query";
|
|
16
16
|
import { rangeMeta } from "../data/range";
|
|
17
17
|
import { type RequestStatus, requestStatus, summarizeRequests } from "../data/view-models";
|
|
18
|
-
import {
|
|
18
|
+
import { requestStatusMeta } from "../ui/RequestDrawer";
|
|
19
19
|
import type { MessageStats, TimeRange } from "../types";
|
|
20
20
|
import {
|
|
21
21
|
Card,
|
|
@@ -99,7 +99,7 @@ export function RequestsRoute({ active, range, onRequestClick }: RequestsRoutePr
|
|
|
99
99
|
value,
|
|
100
100
|
label: (
|
|
101
101
|
<>
|
|
102
|
-
{value === "all" ? t("requests.status-all") :
|
|
102
|
+
{value === "all" ? t("requests.status-all") : requestStatusMeta(value).label}{" "}
|
|
103
103
|
<span className="dim num">{formatCompact(counts[value])}</span>
|
|
104
104
|
</>
|
|
105
105
|
),
|
|
@@ -215,7 +215,7 @@ export function RequestsRoute({ active, range, onRequestClick }: RequestsRoutePr
|
|
|
215
215
|
rows={filtered}
|
|
216
216
|
rowKey={row => row.id ?? `${row.sessionFile}:${row.entryId}`}
|
|
217
217
|
onRowClick={row => row.id !== undefined && onRequestClick(row.id)}
|
|
218
|
-
columns={
|
|
218
|
+
columns={requestColumns()}
|
|
219
219
|
initialSort={{ key: "time", dir: "desc" }}
|
|
220
220
|
limit={100}
|
|
221
221
|
dense
|
|
@@ -237,98 +237,100 @@ export function RequestsRoute({ active, range, onRequestClick }: RequestsRoutePr
|
|
|
237
237
|
);
|
|
238
238
|
}
|
|
239
239
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
{
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
{
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
{
|
|
284
|
-
|
|
285
|
-
),
|
|
286
|
-
},
|
|
287
|
-
{
|
|
288
|
-
key: "output",
|
|
289
|
-
header: t("common.output"),
|
|
290
|
-
align: "right",
|
|
291
|
-
sort: row => row.usage.output,
|
|
292
|
-
render: row => <span className="num">{formatCompact(row.usage.output)}</span>,
|
|
293
|
-
},
|
|
294
|
-
{
|
|
295
|
-
key: "cost",
|
|
296
|
-
header: t("common.cost"),
|
|
297
|
-
title: t("requests.cost-estimate"),
|
|
298
|
-
align: "right",
|
|
299
|
-
sort: row => row.usage.cost.total,
|
|
300
|
-
render: row => <span className="num">{formatMessageCost(row, 4)}</span>,
|
|
301
|
-
},
|
|
302
|
-
{
|
|
303
|
-
key: "duration",
|
|
304
|
-
header: t("common.duration"),
|
|
305
|
-
align: "right",
|
|
306
|
-
sort: row => row.duration ?? -1,
|
|
307
|
-
render: row => <span className="num">{formatDurationMs(row.duration)}</span>,
|
|
308
|
-
},
|
|
309
|
-
{
|
|
310
|
-
key: "ttft",
|
|
311
|
-
header: t("requests.ttft"),
|
|
312
|
-
title: t("requests.ttft-hint"),
|
|
313
|
-
align: "right",
|
|
314
|
-
sort: row => row.ttft ?? -1,
|
|
315
|
-
render: row => <span className="num muted">{formatDurationMs(row.ttft)}</span>,
|
|
316
|
-
},
|
|
317
|
-
{
|
|
318
|
-
key: "status",
|
|
319
|
-
header: t("requests.status"),
|
|
320
|
-
sort: row => requestStatus(row),
|
|
321
|
-
render: row => {
|
|
322
|
-
const status = REQUEST_STATUS[requestStatus(row)];
|
|
323
|
-
return (
|
|
324
|
-
<span title={row.errorMessage ?? undefined}>
|
|
325
|
-
<LabelCell
|
|
326
|
-
lead={<Dot tone={status.tone} />}
|
|
327
|
-
primary={status.label}
|
|
328
|
-
secondary={<span className="mono">{row.stopReason}</span>}
|
|
329
|
-
/>
|
|
240
|
+
function requestColumns(): readonly Column<MessageStats>[] {
|
|
241
|
+
return [
|
|
242
|
+
{
|
|
243
|
+
key: "model",
|
|
244
|
+
header: t("common.model"),
|
|
245
|
+
sort: row => row.model,
|
|
246
|
+
render: row => <LabelCell primary={<span className="mono">{row.model}</span>} secondary={row.provider} />,
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
key: "time",
|
|
250
|
+
header: t("requests.when"),
|
|
251
|
+
sort: row => row.timestamp,
|
|
252
|
+
render: row => (
|
|
253
|
+
<span className="muted" title={formatTimestamp(row.timestamp)}>
|
|
254
|
+
{formatRelativeTime(row.timestamp)}
|
|
255
|
+
</span>
|
|
256
|
+
),
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
key: "project",
|
|
260
|
+
header: t("common.project"),
|
|
261
|
+
sort: row => row.folder,
|
|
262
|
+
render: row => (
|
|
263
|
+
<span className="mono muted truncate" title={row.folder} style={{ display: "block", maxWidth: 180 }}>
|
|
264
|
+
{formatFolder(row.folder)}
|
|
265
|
+
</span>
|
|
266
|
+
),
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
key: "input",
|
|
270
|
+
header: t("common.input"),
|
|
271
|
+
title: t("requests.uncached-input"),
|
|
272
|
+
align: "right",
|
|
273
|
+
sort: row => row.usage.input,
|
|
274
|
+
render: row => <span className="num">{formatCompact(row.usage.input)}</span>,
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
key: "cache",
|
|
278
|
+
header: t("common.cache-read"),
|
|
279
|
+
title: t("requests.cache-read-title"),
|
|
280
|
+
align: "right",
|
|
281
|
+
sort: row => row.usage.cacheRead,
|
|
282
|
+
render: row => (
|
|
283
|
+
<span className="num" title={t("requests.cache-write", { count: formatInteger(row.usage.cacheWrite) })}>
|
|
284
|
+
{formatCompact(row.usage.cacheRead)}
|
|
330
285
|
</span>
|
|
331
|
-
)
|
|
286
|
+
),
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
key: "output",
|
|
290
|
+
header: t("common.output"),
|
|
291
|
+
align: "right",
|
|
292
|
+
sort: row => row.usage.output,
|
|
293
|
+
render: row => <span className="num">{formatCompact(row.usage.output)}</span>,
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
key: "cost",
|
|
297
|
+
header: t("common.cost"),
|
|
298
|
+
title: t("requests.cost-estimate"),
|
|
299
|
+
align: "right",
|
|
300
|
+
sort: row => row.usage.cost.total,
|
|
301
|
+
render: row => <span className="num">{formatMessageCost(row, 4)}</span>,
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
key: "duration",
|
|
305
|
+
header: t("common.duration"),
|
|
306
|
+
align: "right",
|
|
307
|
+
sort: row => row.duration ?? -1,
|
|
308
|
+
render: row => <span className="num">{formatDurationMs(row.duration)}</span>,
|
|
332
309
|
},
|
|
333
|
-
|
|
334
|
-
|
|
310
|
+
{
|
|
311
|
+
key: "ttft",
|
|
312
|
+
header: t("requests.ttft"),
|
|
313
|
+
title: t("requests.ttft-hint"),
|
|
314
|
+
align: "right",
|
|
315
|
+
sort: row => row.ttft ?? -1,
|
|
316
|
+
render: row => <span className="num muted">{formatDurationMs(row.ttft)}</span>,
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
key: "status",
|
|
320
|
+
header: t("requests.status"),
|
|
321
|
+
sort: row => requestStatus(row),
|
|
322
|
+
render: row => {
|
|
323
|
+
const status = requestStatusMeta(requestStatus(row));
|
|
324
|
+
return (
|
|
325
|
+
<span title={row.errorMessage ?? undefined}>
|
|
326
|
+
<LabelCell
|
|
327
|
+
lead={<Dot tone={status.tone} />}
|
|
328
|
+
primary={status.label}
|
|
329
|
+
secondary={<span className="mono">{row.stopReason}</span>}
|
|
330
|
+
/>
|
|
331
|
+
</span>
|
|
332
|
+
);
|
|
333
|
+
},
|
|
334
|
+
},
|
|
335
|
+
];
|
|
336
|
+
}
|