@oh-my-pi/omp-stats 18.3.4 → 18.4.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/CHANGELOG.md +16 -0
- package/README.md +13 -11
- package/build.ts +5 -49
- package/dist/client/index.css +1 -1
- package/dist/client/index.html +2 -2
- package/dist/client/index.js +105 -126
- package/dist/types/aggregator.d.ts +25 -22
- package/dist/types/client/api.d.ts +11 -7
- package/dist/types/client/app/LiveChip.d.ts +2 -0
- package/dist/types/client/app/Shell.d.ts +16 -0
- package/dist/types/client/app/ThemeToggle.d.ts +1 -0
- package/dist/types/client/app/nav.d.ts +18 -0
- package/dist/types/client/charts/BarList.d.ts +17 -0
- package/dist/types/client/charts/Chart.d.ts +49 -0
- package/dist/types/client/charts/Legend.d.ts +16 -0
- package/dist/types/client/charts/ShareBar.d.ts +11 -0
- package/dist/types/client/charts/Sparkline.d.ts +11 -0
- package/dist/types/client/charts/TimeChart.d.ts +9 -0
- package/dist/types/client/charts/index.d.ts +7 -0
- package/dist/types/client/charts/types.d.ts +25 -0
- package/dist/types/client/charts/useWidth.d.ts +3 -0
- package/dist/types/client/data/colors.d.ts +25 -0
- package/dist/types/client/data/formatters.d.ts +9 -1
- package/dist/types/client/data/live.d.ts +29 -0
- package/dist/types/client/data/query.d.ts +35 -0
- package/dist/types/client/data/range.d.ts +31 -0
- package/dist/types/client/data/series.d.ts +28 -0
- package/dist/types/client/data/useHashRoute.d.ts +18 -4
- package/dist/types/client/data/view-models.d.ts +111 -28
- package/dist/types/client/index.d.ts +0 -1
- package/dist/types/client/routes/CostsRoute.d.ts +2 -2
- package/dist/types/client/routes/ErrorsRoute.d.ts +2 -2
- package/dist/types/client/routes/FrustrationRoute.d.ts +7 -0
- package/dist/types/client/routes/GainRoute.d.ts +1 -2
- package/dist/types/client/routes/ModelsRoute.d.ts +2 -2
- package/dist/types/client/routes/OverviewRoute.d.ts +1 -2
- package/dist/types/client/routes/ProjectsRoute.d.ts +2 -2
- package/dist/types/client/routes/ProvidersRoute.d.ts +2 -2
- package/dist/types/client/routes/RequestsRoute.d.ts +1 -2
- package/dist/types/client/routes/ToolsRoute.d.ts +2 -2
- package/dist/types/client/routes/TracesRoute.d.ts +2 -2
- package/dist/types/client/routes/index.d.ts +1 -1
- package/dist/types/client/traces/AggregatesPanel.d.ts +4 -3
- package/dist/types/client/traces/SummaryStrip.d.ts +2 -2
- package/dist/types/client/traces/trace-colors.d.ts +18 -12
- package/dist/types/client/ui/Badge.d.ts +19 -0
- package/dist/types/client/ui/Card.d.ts +25 -0
- package/dist/types/client/ui/Drawer.d.ts +25 -0
- package/dist/types/client/ui/JsonBlock.d.ts +2 -2
- package/dist/types/client/ui/Modal.d.ts +23 -0
- package/dist/types/client/ui/RequestDrawer.d.ts +10 -1
- package/dist/types/client/ui/SearchInput.d.ts +8 -0
- package/dist/types/client/ui/Segmented.d.ts +15 -0
- package/dist/types/client/ui/Stat.d.ts +36 -0
- package/dist/types/client/ui/States.d.ts +41 -0
- package/dist/types/client/ui/Table.d.ts +48 -0
- package/dist/types/client/ui/index.d.ts +9 -10
- package/dist/types/db.d.ts +90 -106
- package/dist/types/frustration.d.ts +70 -0
- package/dist/types/index.d.ts +3 -1
- package/dist/types/live.d.ts +30 -0
- package/dist/types/rollup.d.ts +115 -0
- package/dist/types/server.d.ts +6 -1
- package/dist/types/shared-types.d.ts +116 -56
- package/dist/types/types.d.ts +4 -0
- package/dist/types/user-metrics.d.ts +8 -0
- package/package.json +7 -13
- package/src/aggregator.ts +276 -211
- package/src/client/App.tsx +38 -80
- package/src/client/api.ts +65 -7
- package/src/client/app/LiveChip.tsx +97 -0
- package/src/client/app/Shell.tsx +181 -0
- package/src/client/app/ThemeToggle.tsx +5 -2
- package/src/client/app/nav.ts +78 -0
- package/src/client/charts/BarList.tsx +48 -0
- package/src/client/charts/Chart.tsx +388 -0
- package/src/client/charts/Legend.tsx +61 -0
- package/src/client/charts/ShareBar.tsx +26 -0
- package/src/client/charts/Sparkline.tsx +38 -0
- package/src/client/charts/TimeChart.tsx +22 -0
- package/src/client/charts/index.ts +7 -0
- package/src/client/charts/types.ts +27 -0
- package/src/client/charts/useWidth.ts +19 -0
- package/src/client/data/colors.ts +45 -0
- package/src/client/data/formatters.ts +30 -9
- package/src/client/data/live.tsx +85 -0
- package/src/client/data/query.ts +166 -0
- package/src/client/data/range.ts +82 -0
- package/src/client/data/series.ts +85 -0
- package/src/client/data/useHashRoute.ts +41 -83
- package/src/client/data/view-models.ts +347 -140
- package/src/client/index.tsx +3 -6
- package/src/client/routes/CostsRoute.tsx +394 -222
- package/src/client/routes/ErrorsRoute.tsx +401 -98
- package/src/client/routes/FrustrationRoute.tsx +924 -0
- package/src/client/routes/GainRoute.tsx +209 -206
- package/src/client/routes/ModelsRoute.tsx +540 -431
- package/src/client/routes/OverviewRoute.tsx +283 -311
- package/src/client/routes/ProjectsRoute.tsx +298 -156
- package/src/client/routes/ProvidersRoute.tsx +948 -416
- package/src/client/routes/RequestsRoute.tsx +295 -107
- package/src/client/routes/ToolsRoute.tsx +495 -398
- package/src/client/routes/TracesRoute.tsx +136 -117
- package/src/client/routes/costs.css +24 -0
- package/src/client/routes/errors.css +60 -0
- package/src/client/routes/frustration.css +123 -0
- package/src/client/routes/index.ts +1 -1
- package/src/client/routes/models.css +43 -0
- package/src/client/routes/projects.css +6 -0
- package/src/client/routes/providers.css +28 -0
- package/src/client/routes/tools.css +14 -0
- package/src/client/styles.css +1396 -1299
- package/src/client/traces/AggregatesPanel.tsx +55 -74
- package/src/client/traces/Minimap.tsx +6 -15
- package/src/client/traces/SpanDrawer.tsx +128 -194
- package/src/client/traces/SummaryStrip.tsx +21 -24
- package/src/client/traces/TimelineCanvas.tsx +27 -44
- package/src/client/traces/TraceView.tsx +175 -130
- package/src/client/traces/TranscriptList.tsx +13 -41
- package/src/client/traces/trace-colors.ts +60 -53
- package/src/client/traces/traces.css +279 -0
- package/src/client/ui/Badge.tsx +29 -0
- package/src/client/ui/Card.tsx +61 -0
- package/src/client/ui/Drawer.tsx +93 -0
- package/src/client/ui/JsonBlock.tsx +26 -44
- package/src/client/ui/Modal.tsx +106 -0
- package/src/client/ui/RequestDrawer.tsx +163 -188
- package/src/client/ui/SearchInput.tsx +25 -0
- package/src/client/ui/Segmented.tsx +61 -0
- package/src/client/ui/Stat.tsx +104 -0
- package/src/client/ui/States.tsx +81 -0
- package/src/client/ui/Table.tsx +229 -0
- package/src/client/ui/index.ts +9 -10
- package/src/client/ui/modal.css +54 -0
- package/src/client/ui/request-drawer.css +40 -0
- package/src/db.ts +379 -983
- package/src/frustration.ts +473 -0
- package/src/index.ts +22 -22
- package/src/live.ts +259 -0
- package/src/parser.ts +55 -66
- package/src/rollup.ts +951 -0
- package/src/server.ts +123 -40
- package/src/shared-types.ts +120 -56
- package/src/trace.ts +14 -7
- package/src/types.ts +4 -0
- package/src/user-metrics.ts +13 -0
- package/dist/client/styles.css +0 -1976
- package/dist/types/client/app/AppLayout.d.ts +0 -16
- package/dist/types/client/app/NavRail.d.ts +0 -7
- package/dist/types/client/app/RangeControl.d.ts +0 -7
- package/dist/types/client/app/SyncButton.d.ts +0 -14
- package/dist/types/client/app/TopBar.d.ts +0 -15
- package/dist/types/client/app/routes.d.ts +0 -12
- package/dist/types/client/components/AgentTokenShare.d.ts +0 -5
- package/dist/types/client/components/chart-shared.d.ts +0 -178
- package/dist/types/client/components/models-table-shared.d.ts +0 -175
- package/dist/types/client/components/range-meta.d.ts +0 -21
- package/dist/types/client/data/charts.d.ts +0 -1
- package/dist/types/client/data/useResource.d.ts +0 -13
- package/dist/types/client/routes/BehaviorRoute.d.ts +0 -7
- package/dist/types/client/ui/AsyncBoundary.d.ts +0 -12
- package/dist/types/client/ui/DataTable.d.ts +0 -17
- package/dist/types/client/ui/EmptyState.d.ts +0 -7
- package/dist/types/client/ui/ErrorState.d.ts +0 -6
- package/dist/types/client/ui/MetricCluster.d.ts +0 -5
- package/dist/types/client/ui/Panel.d.ts +0 -7
- package/dist/types/client/ui/SegmentedControl.d.ts +0 -12
- package/dist/types/client/ui/Skeleton.d.ts +0 -8
- package/dist/types/client/ui/StatusPill.d.ts +0 -7
- package/src/client/app/AppLayout.tsx +0 -93
- package/src/client/app/NavRail.tsx +0 -44
- package/src/client/app/RangeControl.tsx +0 -39
- package/src/client/app/SyncButton.tsx +0 -75
- package/src/client/app/TopBar.tsx +0 -73
- package/src/client/app/routes.ts +0 -93
- package/src/client/components/AgentTokenShare.tsx +0 -68
- package/src/client/components/chart-shared.tsx +0 -273
- package/src/client/components/models-table-shared.tsx +0 -255
- package/src/client/components/range-meta.ts +0 -73
- package/src/client/data/charts.ts +0 -14
- package/src/client/data/useResource.ts +0 -154
- package/src/client/routes/BehaviorRoute.tsx +0 -623
- package/src/client/ui/AsyncBoundary.tsx +0 -54
- package/src/client/ui/DataTable.tsx +0 -122
- package/src/client/ui/EmptyState.tsx +0 -16
- package/src/client/ui/ErrorState.tsx +0 -25
- package/src/client/ui/MetricCluster.tsx +0 -92
- package/src/client/ui/Panel.tsx +0 -24
- package/src/client/ui/SegmentedControl.tsx +0 -36
- package/src/client/ui/Skeleton.tsx +0 -17
- package/src/client/ui/StatusPill.tsx +0 -15
- package/tailwind.config.js +0 -40
|
@@ -1,177 +1,319 @@
|
|
|
1
|
-
import { useMemo } from "react";
|
|
1
|
+
import { useDeferredValue, useMemo, useState } from "react";
|
|
2
2
|
import { getFolderStats } from "../api";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { BarList } from "../charts";
|
|
4
|
+
import {
|
|
5
|
+
formatCompact,
|
|
6
|
+
formatDurationMs,
|
|
7
|
+
formatEstimatedCost,
|
|
8
|
+
formatFolder,
|
|
9
|
+
formatInteger,
|
|
10
|
+
formatPercent,
|
|
11
|
+
formatRelativeTime,
|
|
12
|
+
} from "../data/formatters";
|
|
13
|
+
import { useQuery } from "../data/query";
|
|
14
|
+
import { rangeMeta } from "../data/range";
|
|
5
15
|
import { buildFolderRows, type FolderRowView } from "../data/view-models";
|
|
6
16
|
import type { TimeRange } from "../types";
|
|
7
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
Badge,
|
|
19
|
+
Card,
|
|
20
|
+
ChartSkeleton,
|
|
21
|
+
type Column,
|
|
22
|
+
EmptyState,
|
|
23
|
+
errorRateTone,
|
|
24
|
+
MeterCell,
|
|
25
|
+
PageHeader,
|
|
26
|
+
QueryView,
|
|
27
|
+
SearchInput,
|
|
28
|
+
Stat,
|
|
29
|
+
StatGrid,
|
|
30
|
+
Table,
|
|
31
|
+
TableSkeleton,
|
|
32
|
+
} from "../ui";
|
|
33
|
+
import "./projects.css";
|
|
8
34
|
|
|
9
35
|
export interface ProjectsRouteProps {
|
|
10
36
|
active: boolean;
|
|
11
37
|
range: TimeRange;
|
|
12
|
-
refreshTrigger: number;
|
|
13
38
|
}
|
|
14
39
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
error,
|
|
19
|
-
loading,
|
|
20
|
-
} = useResource(["projects", range, refreshTrigger], signal => getFolderStats(range, signal), {
|
|
21
|
-
pollMs: 30000,
|
|
22
|
-
enabled: active,
|
|
23
|
-
});
|
|
40
|
+
/** Rows rendered before "Show all": keeps the first paint cheap with tens of thousands of folders. */
|
|
41
|
+
const TABLE_LIMIT = 100;
|
|
42
|
+
const TOP_LIMIT = 8;
|
|
24
43
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
44
|
+
export function ProjectsRoute({ active, range }: ProjectsRouteProps) {
|
|
45
|
+
const folders = useQuery(["projects", range], () => getFolderStats(range), { enabled: active });
|
|
46
|
+
const [search, setSearch] = useState("");
|
|
47
|
+
// Benchmarks and scratch sessions can leave tens of thousands of one-off temp folders; hide them by default.
|
|
48
|
+
const [hideTemporary, setHideTemporary] = useState(true);
|
|
49
|
+
const query = useDeferredValue(search.trim().toLowerCase());
|
|
50
|
+
const meta = rangeMeta(range);
|
|
29
51
|
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
const view = useMemo(() => buildFolderRows(folders.data ?? []), [folders.data]);
|
|
53
|
+
const scoped = useMemo(
|
|
54
|
+
() => (hideTemporary ? view.rows.filter(row => !row.temporary) : view.rows),
|
|
55
|
+
[view, hideTemporary],
|
|
56
|
+
);
|
|
57
|
+
const matching = useMemo(
|
|
58
|
+
() => (query ? scoped.filter(row => row.folder.toLowerCase().includes(query)) : scoped),
|
|
59
|
+
[scoped, query],
|
|
60
|
+
);
|
|
61
|
+
const top = useMemo(
|
|
62
|
+
() => ({
|
|
63
|
+
cost: [...scoped].sort((a, b) => b.totalCost - a.totalCost).slice(0, TOP_LIMIT),
|
|
64
|
+
requests: [...scoped].sort((a, b) => b.totalRequests - a.totalRequests).slice(0, TOP_LIMIT),
|
|
65
|
+
}),
|
|
66
|
+
[scoped],
|
|
67
|
+
);
|
|
68
|
+
const topEmpty = (
|
|
69
|
+
<EmptyState
|
|
70
|
+
title={view.rows.length === 0 ? "No project folders in this range" : "Only temporary folders in this range"}
|
|
71
|
+
/>
|
|
72
|
+
);
|
|
73
|
+
// Meter scales follow the whole range so a bar's length does not change while filtering.
|
|
74
|
+
const columns = useMemo(() => folderColumns(view.maxRequests, view.maxCost), [view]);
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<div className="page">
|
|
78
|
+
<PageHeader title="Projects" description={`Usage by session folder in ${meta.windowLabel}.`} />
|
|
79
|
+
|
|
80
|
+
<QueryView query={folders} skeleton={<ChartSkeleton height={96} />}>
|
|
81
|
+
{() => (
|
|
82
|
+
<div data-stale={folders.stale}>
|
|
83
|
+
<StatGrid min={180}>
|
|
84
|
+
<Stat
|
|
85
|
+
label="Folders"
|
|
86
|
+
value={formatInteger(view.rows.length)}
|
|
87
|
+
hint={view.temporaryCount > 0 ? `${formatInteger(view.temporaryCount)} temporary` : undefined}
|
|
56
88
|
/>
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
89
|
+
<Stat
|
|
90
|
+
label="Requests"
|
|
91
|
+
value={formatInteger(view.totalRequests)}
|
|
92
|
+
hint={`${formatInteger(view.failedRequests)} failed`}
|
|
93
|
+
/>
|
|
94
|
+
<Stat
|
|
95
|
+
label="API-equivalent cost"
|
|
96
|
+
title="What this usage would cost at public API rates"
|
|
97
|
+
value={formatEstimatedCost(view.totalCost, view.unpricedRequests)}
|
|
98
|
+
hint={
|
|
99
|
+
view.unpricedRequests > 0 ? `${formatInteger(view.unpricedRequests)} unpriced` : undefined
|
|
100
|
+
}
|
|
101
|
+
/>
|
|
102
|
+
<Stat
|
|
103
|
+
label="Conversation tokens"
|
|
104
|
+
title="Uncached input + cache reads + cache writes + output"
|
|
105
|
+
value={formatCompact(view.conversationTokens)}
|
|
106
|
+
/>
|
|
107
|
+
<Stat
|
|
108
|
+
label="Cache rate"
|
|
109
|
+
title="Cache reads ÷ (uncached input + cache reads), across every folder"
|
|
110
|
+
value={formatPercent(view.cacheRate)}
|
|
73
111
|
/>
|
|
74
|
-
</
|
|
112
|
+
</StatGrid>
|
|
75
113
|
</div>
|
|
76
|
-
)
|
|
77
|
-
|
|
78
|
-
{
|
|
79
|
-
key: "totalTokens",
|
|
80
|
-
header: "Tokens",
|
|
81
|
-
numeric: true,
|
|
82
|
-
render: (item: FolderRowView) => (
|
|
83
|
-
<div className="font-mono">{formatInteger(item.totalInputTokens + item.totalOutputTokens)}</div>
|
|
84
|
-
),
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
key: "cacheRate",
|
|
88
|
-
header: "Cache Rate",
|
|
89
|
-
numeric: true,
|
|
90
|
-
render: (item: FolderRowView) => <span className="font-mono">{formatPercent(item.cacheRate)}</span>,
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
key: "cacheSavings",
|
|
94
|
-
header: "Cache Savings",
|
|
95
|
-
numeric: true,
|
|
96
|
-
render: (item: FolderRowView) => (
|
|
97
|
-
<span className={`${item.cacheSavings < 0 ? "stats-text-danger" : "stats-text-success"} font-medium`}>
|
|
98
|
-
{formatPercent(item.cacheSavings)}
|
|
99
|
-
</span>
|
|
100
|
-
),
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
key: "errorRate",
|
|
104
|
-
header: "Error Rate",
|
|
105
|
-
numeric: true,
|
|
106
|
-
render: (item: FolderRowView) => (
|
|
107
|
-
<StatusPill variant={item.errorRate > 0.1 ? "danger" : item.errorRate > 0 ? "warning" : "success"}>
|
|
108
|
-
{formatPercent(item.errorRate)}
|
|
109
|
-
</StatusPill>
|
|
110
|
-
),
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
key: "avgDuration",
|
|
114
|
-
header: "Avg Duration",
|
|
115
|
-
numeric: true,
|
|
116
|
-
render: (item: FolderRowView) => formatDurationMs(item.avgDuration),
|
|
117
|
-
},
|
|
118
|
-
],
|
|
119
|
-
[],
|
|
120
|
-
);
|
|
114
|
+
)}
|
|
115
|
+
</QueryView>
|
|
121
116
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
117
|
+
<div className="grid grid-2">
|
|
118
|
+
<Card index={1} title="Top by cost" description="Share of API-equivalent cost" stale={folders.stale}>
|
|
119
|
+
<QueryView
|
|
120
|
+
query={folders}
|
|
121
|
+
skeleton={<ChartSkeleton height={236} />}
|
|
122
|
+
isEmpty={() => top.cost.length === 0}
|
|
123
|
+
empty={topEmpty}
|
|
124
|
+
>
|
|
125
|
+
{() => (
|
|
126
|
+
<BarList
|
|
127
|
+
items={top.cost.map(row => ({
|
|
128
|
+
key: row.folder,
|
|
129
|
+
label: <span className="mono">{formatFolder(row.folder)}</span>,
|
|
130
|
+
value: row.totalCost,
|
|
131
|
+
display: `${formatEstimatedCost(row.totalCost, row.unpricedRequests)} · ${formatPercent(row.costShare)}`,
|
|
132
|
+
color: "var(--chart-secondary)",
|
|
133
|
+
}))}
|
|
134
|
+
onSelect={setSearch}
|
|
135
|
+
/>
|
|
136
|
+
)}
|
|
137
|
+
</QueryView>
|
|
138
|
+
</Card>
|
|
139
|
+
<Card index={2} title="Top by requests" description="Share of all requests" stale={folders.stale}>
|
|
140
|
+
<QueryView
|
|
141
|
+
query={folders}
|
|
142
|
+
skeleton={<ChartSkeleton height={236} />}
|
|
143
|
+
isEmpty={() => top.requests.length === 0}
|
|
144
|
+
empty={topEmpty}
|
|
145
|
+
>
|
|
146
|
+
{() => (
|
|
147
|
+
<BarList
|
|
148
|
+
items={top.requests.map(row => ({
|
|
149
|
+
key: row.folder,
|
|
150
|
+
label: <span className="mono">{formatFolder(row.folder)}</span>,
|
|
151
|
+
value: row.totalRequests,
|
|
152
|
+
display: `${formatInteger(row.totalRequests)} · ${formatPercent(row.requestShare)}`,
|
|
153
|
+
}))}
|
|
154
|
+
onSelect={setSearch}
|
|
155
|
+
/>
|
|
156
|
+
)}
|
|
157
|
+
</QueryView>
|
|
158
|
+
</Card>
|
|
153
159
|
</div>
|
|
160
|
+
|
|
161
|
+
<Card
|
|
162
|
+
index={3}
|
|
163
|
+
title="Folders"
|
|
164
|
+
description={
|
|
165
|
+
folders.data
|
|
166
|
+
? matching.length === view.rows.length
|
|
167
|
+
? `${formatInteger(view.rows.length)} folders`
|
|
168
|
+
: `${formatInteger(matching.length)} of ${formatInteger(view.rows.length)} folders`
|
|
169
|
+
: undefined
|
|
170
|
+
}
|
|
171
|
+
actions={
|
|
172
|
+
<>
|
|
173
|
+
{view.temporaryCount > 0 && (
|
|
174
|
+
<label className="check" title="Session folders under /tmp or /var/folders">
|
|
175
|
+
<input
|
|
176
|
+
type="checkbox"
|
|
177
|
+
checked={hideTemporary}
|
|
178
|
+
onChange={e => setHideTemporary(e.target.checked)}
|
|
179
|
+
/>
|
|
180
|
+
Hide temporary ({formatInteger(view.temporaryCount)})
|
|
181
|
+
</label>
|
|
182
|
+
)}
|
|
183
|
+
<SearchInput value={search} onChange={setSearch} placeholder="Filter folders…" width={240} />
|
|
184
|
+
</>
|
|
185
|
+
}
|
|
186
|
+
flush
|
|
187
|
+
stale={folders.stale}
|
|
188
|
+
>
|
|
189
|
+
<QueryView query={folders} skeleton={<TableSkeleton rows={10} />}>
|
|
190
|
+
{() => (
|
|
191
|
+
<Table
|
|
192
|
+
rows={matching}
|
|
193
|
+
rowKey={row => row.folder}
|
|
194
|
+
columns={columns}
|
|
195
|
+
initialSort={{ key: "cost", dir: "desc" }}
|
|
196
|
+
limit={TABLE_LIMIT}
|
|
197
|
+
dense
|
|
198
|
+
empty={
|
|
199
|
+
<EmptyState
|
|
200
|
+
title={view.rows.length === 0 ? "No project folders in this range" : "No folders match"}
|
|
201
|
+
hint={
|
|
202
|
+
view.rows.length === 0
|
|
203
|
+
? "Try a longer range."
|
|
204
|
+
: hideTemporary && view.temporaryCount > 0
|
|
205
|
+
? "Temporary folders are hidden."
|
|
206
|
+
: undefined
|
|
207
|
+
}
|
|
208
|
+
/>
|
|
209
|
+
}
|
|
210
|
+
/>
|
|
211
|
+
)}
|
|
212
|
+
</QueryView>
|
|
213
|
+
</Card>
|
|
154
214
|
</div>
|
|
155
215
|
);
|
|
216
|
+
}
|
|
156
217
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
<
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
218
|
+
function folderColumns(maxRequests: number, maxCost: number): Column<FolderRowView>[] {
|
|
219
|
+
return [
|
|
220
|
+
{
|
|
221
|
+
key: "folder",
|
|
222
|
+
header: "Folder",
|
|
223
|
+
sort: row => row.folder,
|
|
224
|
+
render: row => (
|
|
225
|
+
<span className="row projects-folder" title={row.folder || "(root)"}>
|
|
226
|
+
<span className="mono truncate">{formatFolder(row.folder)}</span>
|
|
227
|
+
{row.temporary && <Badge>temp</Badge>}
|
|
228
|
+
</span>
|
|
229
|
+
),
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
key: "requests",
|
|
233
|
+
header: "Requests",
|
|
234
|
+
align: "right",
|
|
235
|
+
sort: row => row.totalRequests,
|
|
236
|
+
render: row => (
|
|
237
|
+
<span title={`${formatPercent(row.requestShare)} of all requests`}>
|
|
238
|
+
<MeterCell value={row.totalRequests} max={maxRequests} display={formatInteger(row.totalRequests)} />
|
|
239
|
+
</span>
|
|
240
|
+
),
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
key: "cost",
|
|
244
|
+
header: "Cost",
|
|
245
|
+
title: "API-equivalent cost at public API rates",
|
|
246
|
+
align: "right",
|
|
247
|
+
sort: row => row.totalCost,
|
|
248
|
+
render: row => (
|
|
249
|
+
<span title={`${formatPercent(row.costShare)} of all cost`}>
|
|
250
|
+
<MeterCell
|
|
251
|
+
value={row.totalCost}
|
|
252
|
+
max={maxCost}
|
|
253
|
+
display={formatEstimatedCost(row.totalCost, row.unpricedRequests)}
|
|
254
|
+
color="var(--chart-secondary)"
|
|
172
255
|
/>
|
|
173
|
-
</
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
256
|
+
</span>
|
|
257
|
+
),
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
key: "tokens",
|
|
261
|
+
header: "Tokens",
|
|
262
|
+
title: "Uncached input + cache reads + cache writes + output",
|
|
263
|
+
align: "right",
|
|
264
|
+
sort: row => row.conversationTokens,
|
|
265
|
+
render: row => (
|
|
266
|
+
<span className="num" title={formatInteger(row.conversationTokens)}>
|
|
267
|
+
{formatCompact(row.conversationTokens)}
|
|
268
|
+
</span>
|
|
269
|
+
),
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
key: "cacheRate",
|
|
273
|
+
header: "Cache rate",
|
|
274
|
+
title: "Cache reads ÷ (uncached input + cache reads)",
|
|
275
|
+
align: "right",
|
|
276
|
+
sort: row => row.cacheRate,
|
|
277
|
+
render: row => <span className="num">{formatPercent(row.cacheRate)}</span>,
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
key: "cacheSavings",
|
|
281
|
+
header: "Cache savings",
|
|
282
|
+
title: "Prompt-input cost saved versus billing the same tokens uncached",
|
|
283
|
+
align: "right",
|
|
284
|
+
sort: row => row.cacheSavings,
|
|
285
|
+
render: row => (
|
|
286
|
+
<span className={`num ${row.cacheSavings < 0 ? "tone-bad" : "muted"}`}>
|
|
287
|
+
{formatPercent(row.cacheSavings)}
|
|
288
|
+
</span>
|
|
289
|
+
),
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
key: "errorRate",
|
|
293
|
+
header: "Errors",
|
|
294
|
+
align: "right",
|
|
295
|
+
sort: row => row.errorRate,
|
|
296
|
+
render: row => (
|
|
297
|
+
<span title={`${formatInteger(row.failedRequests)} failed`}>
|
|
298
|
+
<Badge tone={row.failedRequests > 0 ? errorRateTone(row.errorRate) : "neutral"} mono>
|
|
299
|
+
{formatPercent(row.errorRate)}
|
|
300
|
+
</Badge>
|
|
301
|
+
</span>
|
|
302
|
+
),
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
key: "duration",
|
|
306
|
+
header: "Avg duration",
|
|
307
|
+
align: "right",
|
|
308
|
+
sort: row => row.avgDuration ?? -1,
|
|
309
|
+
render: row => <span className="num">{formatDurationMs(row.avgDuration)}</span>,
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
key: "last",
|
|
313
|
+
header: "Last active",
|
|
314
|
+
align: "right",
|
|
315
|
+
sort: row => row.lastTimestamp,
|
|
316
|
+
render: row => <span className="dim">{formatRelativeTime(row.lastTimestamp)}</span>,
|
|
317
|
+
},
|
|
318
|
+
];
|
|
177
319
|
}
|