llmtop 0.1.4 → 0.1.6
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/README.md +70 -67
- package/dashboard/dist/assets/be-vietnam-pro-latin-400-normal-PpnXBOrz.woff2 +0 -0
- package/dashboard/dist/assets/be-vietnam-pro-latin-500-normal-B6LVzGNe.woff2 +0 -0
- package/dashboard/dist/assets/be-vietnam-pro-latin-600-normal-BZDkUTrt.woff2 +0 -0
- package/dashboard/dist/assets/be-vietnam-pro-latin-700-normal-DlW1Zbsh.woff2 +0 -0
- package/dashboard/dist/assets/be-vietnam-pro-latin-800-normal-BpHZASpI.woff2 +0 -0
- package/dashboard/dist/assets/be-vietnam-pro-latin-ext-400-normal-CiZNW1ec.woff2 +0 -0
- package/dashboard/dist/assets/be-vietnam-pro-latin-ext-500-normal-h0Fp6aX0.woff2 +0 -0
- package/dashboard/dist/assets/be-vietnam-pro-latin-ext-600-normal-BNd8euf0.woff2 +0 -0
- package/dashboard/dist/assets/be-vietnam-pro-latin-ext-700-normal-C8_gqRu2.woff2 +0 -0
- package/dashboard/dist/assets/be-vietnam-pro-latin-ext-800-normal-GEpNgheG.woff2 +0 -0
- package/dashboard/dist/assets/be-vietnam-pro-vietnamese-400-normal-CRcqvyg1.woff2 +0 -0
- package/dashboard/dist/assets/be-vietnam-pro-vietnamese-500-normal-DREgrEoJ.woff2 +0 -0
- package/dashboard/dist/assets/be-vietnam-pro-vietnamese-600-normal-nyU-ZL2p.woff2 +0 -0
- package/dashboard/dist/assets/be-vietnam-pro-vietnamese-700-normal-Csr0PCuG.woff2 +0 -0
- package/dashboard/dist/assets/be-vietnam-pro-vietnamese-800-normal-D4LFh2W4.woff2 +0 -0
- package/dashboard/dist/assets/index-C6JlgSDz.js +9 -0
- package/dashboard/dist/assets/index-CeDllzpB.css +1 -0
- package/dashboard/dist/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
- package/dashboard/dist/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
- package/dashboard/dist/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
- package/dashboard/dist/index.html +2 -2
- package/dashboard/src/App.tsx +224 -88
- package/dashboard/src/controls/DateRange.tsx +3 -3
- package/dashboard/src/controls/Search.tsx +2 -2
- package/dashboard/src/controls/popover.tsx +24 -4
- package/dashboard/src/format.ts +1 -1
- package/dashboard/src/i18n.tsx +32 -4
- package/dashboard/src/main.tsx +11 -2
- package/dashboard/src/model.ts +1 -1
- package/dashboard/src/overview-flow.css +24 -0
- package/dashboard/src/overviewFlow.tsx +76 -0
- package/dashboard/src/sessionDetail.test.ts +19 -0
- package/dashboard/src/sessionScope.tsx +28 -0
- package/dashboard/src/shell/ConsoleFilters.tsx +203 -0
- package/dashboard/src/shell/Header.tsx +29 -0
- package/dashboard/src/shell/MobileSheet.tsx +29 -0
- package/dashboard/src/shell/Palette.tsx +114 -0
- package/dashboard/src/shell/Settings.tsx +37 -0
- package/dashboard/src/shell/SpecialStates.tsx +145 -0
- package/dashboard/src/shell/preferences.ts +71 -0
- package/dashboard/src/shell/styleColors.ts +5 -0
- package/dashboard/src/shell/useShortcuts.ts +67 -0
- package/dashboard/src/state.test.ts +9 -0
- package/dashboard/src/state.ts +13 -2
- package/dashboard/src/styles/commands.css +61 -0
- package/dashboard/src/styles/console.css +149 -0
- package/dashboard/src/styles/donut.css +83 -0
- package/dashboard/src/styles/fonts/be-vietnam-pro-LICENSE +93 -0
- package/dashboard/src/styles/fonts/be-vietnam-pro-latin-400-normal.woff2 +0 -0
- package/dashboard/src/styles/fonts/be-vietnam-pro-latin-500-normal.woff2 +0 -0
- package/dashboard/src/styles/fonts/be-vietnam-pro-latin-600-normal.woff2 +0 -0
- package/dashboard/src/styles/fonts/be-vietnam-pro-latin-700-normal.woff2 +0 -0
- package/dashboard/src/styles/fonts/be-vietnam-pro-latin-800-normal.woff2 +0 -0
- package/dashboard/src/styles/fonts/be-vietnam-pro-latin-ext-400-normal.woff2 +0 -0
- package/dashboard/src/styles/fonts/be-vietnam-pro-latin-ext-500-normal.woff2 +0 -0
- package/dashboard/src/styles/fonts/be-vietnam-pro-latin-ext-600-normal.woff2 +0 -0
- package/dashboard/src/styles/fonts/be-vietnam-pro-latin-ext-700-normal.woff2 +0 -0
- package/dashboard/src/styles/fonts/be-vietnam-pro-latin-ext-800-normal.woff2 +0 -0
- package/dashboard/src/styles/fonts/be-vietnam-pro-vietnamese-400-normal.woff2 +0 -0
- package/dashboard/src/styles/fonts/be-vietnam-pro-vietnamese-500-normal.woff2 +0 -0
- package/dashboard/src/styles/fonts/be-vietnam-pro-vietnamese-600-normal.woff2 +0 -0
- package/dashboard/src/styles/fonts/be-vietnam-pro-vietnamese-700-normal.woff2 +0 -0
- package/dashboard/src/styles/fonts/be-vietnam-pro-vietnamese-800-normal.woff2 +0 -0
- package/dashboard/src/styles/fonts/jetbrains-mono-LICENSE +93 -0
- package/dashboard/src/styles/fonts/jetbrains-mono-latin-ext-wght-normal.woff2 +0 -0
- package/dashboard/src/styles/fonts/jetbrains-mono-latin-wght-normal.woff2 +0 -0
- package/dashboard/src/styles/fonts/jetbrains-mono-vietnamese-wght-normal.woff2 +0 -0
- package/dashboard/src/styles/fonts.css +240 -0
- package/dashboard/src/styles/shell.css +151 -0
- package/dashboard/src/styles/states.css +32 -0
- package/dashboard/src/styles/tokens.css +159 -0
- package/dashboard/src/styles.css +13 -44
- package/dashboard/src/tip.ts +3 -1
- package/dashboard/src/treemap.ts +3 -0
- package/dashboard/src/ui.tsx +21 -32
- package/dashboard/src/views/Breakdown.tsx +46 -0
- package/dashboard/src/views/SessionDetail.tsx +67 -0
- package/dashboard/src/views/breakdown.css +33 -0
- package/dashboard/src/views/{Activity.tsx → classic/Activity.tsx} +31 -50
- package/dashboard/src/views/classic/Context.tsx +140 -0
- package/dashboard/src/views/{Models.tsx → classic/Models.tsx} +18 -35
- package/dashboard/src/views/classic/Overview.tsx +80 -0
- package/dashboard/src/views/classic/Projects.tsx +98 -0
- package/dashboard/src/views/{Sessions.tsx → classic/Sessions.tsx} +14 -17
- package/dashboard/src/views/{Subagents.tsx → classic/Subagents.tsx} +10 -34
- package/dashboard/src/views/console/Activity.tsx +241 -0
- package/dashboard/src/views/console/ConsoleBoot.tsx +73 -0
- package/dashboard/src/views/console/Context.tsx +162 -0
- package/dashboard/src/views/console/Models.tsx +187 -0
- package/dashboard/src/views/console/Overview.tsx +91 -0
- package/dashboard/src/views/console/Projects.tsx +6 -0
- package/dashboard/src/views/console/ProviderMeters.tsx +35 -0
- package/dashboard/src/views/console/Sessions.tsx +6 -0
- package/dashboard/src/views/console/Subagents.tsx +137 -0
- package/dashboard/src/views/console/activity-context.css +92 -0
- package/dashboard/src/views/console/console-boot.css +137 -0
- package/dashboard/src/views/console/modelVisuals.tsx +29 -0
- package/dashboard/src/views/console/models-subagents.css +203 -0
- package/dashboard/src/views/donut/Activity.tsx +247 -0
- package/dashboard/src/views/donut/Context.tsx +169 -0
- package/dashboard/src/views/donut/DonutBoot.tsx +68 -0
- package/dashboard/src/views/donut/Models.tsx +58 -0
- package/dashboard/src/views/donut/Overview.tsx +49 -0
- package/dashboard/src/views/donut/Projects.tsx +6 -0
- package/dashboard/src/views/donut/Ring.tsx +30 -0
- package/dashboard/src/views/donut/Sessions.tsx +6 -0
- package/dashboard/src/views/donut/Subagents.tsx +131 -0
- package/dashboard/src/views/donut/activity-context.css +154 -0
- package/dashboard/src/views/donut/donut-boot.css +165 -0
- package/dashboard/src/views/donut/models-subagents.css +157 -0
- package/dashboard/src/views/records/Projects.tsx +140 -0
- package/dashboard/src/views/records/Sessions.tsx +125 -0
- package/dashboard/src/views/records/records.css +119 -0
- package/dashboard/src/views/session-detail.css +44 -0
- package/dashboard/src/vm/activity.ts +72 -0
- package/dashboard/src/vm/colors.ts +57 -0
- package/dashboard/src/vm/context.ts +81 -0
- package/dashboard/src/vm/filterChoices.ts +27 -0
- package/dashboard/src/vm/models.ts +50 -0
- package/dashboard/src/vm/overview.ts +46 -0
- package/dashboard/src/vm/palette.ts +63 -0
- package/dashboard/src/vm/projects.ts +63 -0
- package/dashboard/src/vm/providerBreakdown.ts +19 -0
- package/dashboard/src/vm/sessionDetail.ts +16 -0
- package/dashboard/src/vm/sessions.ts +36 -0
- package/dashboard/src/vm/specialStates.ts +64 -0
- package/dashboard/src/vm/subagents.ts +36 -0
- package/dashboard/src/vm.test.ts +183 -0
- package/package.json +1 -1
- package/src/api.mjs +6 -1
- package/src/dashboard.mjs +4 -1
- package/src/db.mjs +5 -2
- package/src/providers/codex.mjs +121 -19
- package/src/serve.mjs +20 -10
- package/dashboard/dist/assets/index-Ba0kF2tG.js +0 -9
- package/dashboard/dist/assets/index-NQzaBVIY.css +0 -1
- package/dashboard/dist/assets/montserrat-cyrillic-ext-wght-normal-CO5hGrJv.woff2 +0 -0
- package/dashboard/dist/assets/montserrat-cyrillic-wght-normal-EAA9jha_.woff2 +0 -0
- package/dashboard/dist/assets/roboto-mono-cyrillic-ext-wght-normal-BUDPrIko.woff2 +0 -0
- package/dashboard/dist/assets/roboto-mono-cyrillic-wght-normal-HUlVHixE.woff2 +0 -0
- package/dashboard/dist/assets/roboto-mono-greek-wght-normal-BJJTbwTT.woff2 +0 -0
- package/dashboard/src/views/Context.tsx +0 -183
- package/dashboard/src/views/Overview.tsx +0 -83
- package/dashboard/src/views/Projects.tsx +0 -116
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
.console-boot {
|
|
2
|
+
display: grid;
|
|
3
|
+
place-items: center;
|
|
4
|
+
min-height: 100vh;
|
|
5
|
+
min-height: 100dvh;
|
|
6
|
+
padding: var(--space-8);
|
|
7
|
+
background: var(--bg);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.console-boot-inner {
|
|
11
|
+
display: grid;
|
|
12
|
+
gap: 18px;
|
|
13
|
+
width: min(620px, 100%);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.console-boot .brand { padding: 0; }
|
|
17
|
+
.console-boot .brand .brand-lockup { width: 160px; }
|
|
18
|
+
|
|
19
|
+
.console-boot-panel {
|
|
20
|
+
padding: var(--space-6) 28px;
|
|
21
|
+
border: 1px solid var(--line);
|
|
22
|
+
border-radius: var(--radius-lg);
|
|
23
|
+
background: var(--panel);
|
|
24
|
+
font: var(--fs-md)/1.5 var(--font-mono);
|
|
25
|
+
color: var(--ink);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.console-boot-panel h1 {
|
|
29
|
+
margin: 0 0 6px;
|
|
30
|
+
font: inherit;
|
|
31
|
+
font-weight: var(--fw-bold);
|
|
32
|
+
overflow-wrap: anywhere;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.console-boot-command { margin: 0 0 var(--space-3); }
|
|
36
|
+
.console-boot-command strong,
|
|
37
|
+
.console-boot-row[data-state="done"] strong { color: var(--good); }
|
|
38
|
+
|
|
39
|
+
.console-boot-cursor {
|
|
40
|
+
display: inline-block;
|
|
41
|
+
width: .6em;
|
|
42
|
+
height: 1.1em;
|
|
43
|
+
margin-inline-start: 1ch;
|
|
44
|
+
vertical-align: text-bottom;
|
|
45
|
+
background: var(--ink);
|
|
46
|
+
animation: console-boot-blink 1s steps(1) infinite;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.console-boot-steps { margin: 0; padding: 0; list-style: none; }
|
|
50
|
+
|
|
51
|
+
.console-boot-row {
|
|
52
|
+
display: grid;
|
|
53
|
+
grid-template-columns: 34px minmax(0, 1fr) auto;
|
|
54
|
+
gap: var(--space-2);
|
|
55
|
+
align-items: baseline;
|
|
56
|
+
padding: 3px 0;
|
|
57
|
+
color: var(--ink-2);
|
|
58
|
+
overflow-wrap: anywhere;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.console-boot-row [aria-hidden="true"] { white-space: pre; }
|
|
62
|
+
.console-boot-row[data-state="pending"] { color: var(--muted); }
|
|
63
|
+
.console-boot-row[data-state="active"] { color: var(--ink); font-weight: var(--fw-bold); }
|
|
64
|
+
.console-boot-row > :nth-child(3) { color: var(--muted); text-align: right; font-weight: var(--fw-regular); }
|
|
65
|
+
|
|
66
|
+
.console-boot-meter {
|
|
67
|
+
display: flex;
|
|
68
|
+
gap: var(--space-2);
|
|
69
|
+
align-items: center;
|
|
70
|
+
margin-top: 14px;
|
|
71
|
+
color: var(--muted);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.console-boot-meter strong { width: 44px; color: var(--ink); text-align: right; }
|
|
75
|
+
|
|
76
|
+
.console-boot-track {
|
|
77
|
+
flex: 1;
|
|
78
|
+
min-width: 0;
|
|
79
|
+
height: 14px;
|
|
80
|
+
overflow: hidden;
|
|
81
|
+
background: var(--track);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.console-boot-fill {
|
|
85
|
+
display: block;
|
|
86
|
+
height: 100%;
|
|
87
|
+
background: repeating-linear-gradient(90deg, var(--work) 0 3px, transparent 3px 5px);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.console-boot-track:not([aria-valuenow]) .console-boot-fill {
|
|
91
|
+
width: 30%;
|
|
92
|
+
animation: console-boot-slide 1.4s linear infinite;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.console-boot-bytes {
|
|
96
|
+
margin: 6px 0 0;
|
|
97
|
+
text-align: right;
|
|
98
|
+
color: var(--muted);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.console-boot-panel[role="alert"] h1,
|
|
102
|
+
.console-boot-error-row,
|
|
103
|
+
.console-boot-error-row > :nth-child(3) { color: var(--bad); }
|
|
104
|
+
|
|
105
|
+
.console-boot-help { margin: var(--space-3) 0; color: var(--ink-2); }
|
|
106
|
+
.console-boot-actions { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-3); color: var(--muted); }
|
|
107
|
+
|
|
108
|
+
.console-boot-retry {
|
|
109
|
+
min-height: var(--tap-min);
|
|
110
|
+
padding: 0 var(--space-4);
|
|
111
|
+
border: 0;
|
|
112
|
+
border-radius: var(--radius-md);
|
|
113
|
+
background: var(--ink);
|
|
114
|
+
color: var(--bg);
|
|
115
|
+
font-weight: var(--fw-bold);
|
|
116
|
+
cursor: pointer;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.console-boot-retry:focus-visible { outline: none; box-shadow: var(--focus-ring); }
|
|
120
|
+
.console-boot-actions kbd { padding: 2px var(--space-1); border: 1px solid var(--line); border-radius: var(--radius-sm); font: inherit; }
|
|
121
|
+
|
|
122
|
+
@keyframes console-boot-blink { 50% { opacity: 0; } }
|
|
123
|
+
@keyframes console-boot-slide {
|
|
124
|
+
from { transform: translateX(-100%); }
|
|
125
|
+
to { transform: translateX(333.333%); }
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
@media (max-width: 639px) {
|
|
129
|
+
.console-boot { padding: var(--space-4); }
|
|
130
|
+
.console-boot .brand .brand-lockup { width: 132px; }
|
|
131
|
+
.console-boot-panel { padding: 18px; font-size: var(--fs-sm); }
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
@media (prefers-reduced-motion: reduce) {
|
|
135
|
+
.console-boot-cursor { animation: none; }
|
|
136
|
+
.console-boot-track:not([aria-valuenow]) .console-boot-fill { width: 100%; opacity: .35; animation: none; }
|
|
137
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { CSSProperties } from "react";
|
|
2
|
+
import { tip, type TipRow } from "../../ui.tsx";
|
|
3
|
+
import { BreakdownSessions } from "../Breakdown.tsx";
|
|
4
|
+
import "./models-subagents.css";
|
|
5
|
+
|
|
6
|
+
type Band = { share: number; color: string; label: string; value: string };
|
|
7
|
+
|
|
8
|
+
export function ModelDot({ color }: { color: string }) {
|
|
9
|
+
return <i className="console-model-dot" aria-hidden="true" style={{ background: `var(${color})` }} />;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function ModelBands({ label, bands, model, provider }: { label: string; bands: Band[]; model?: string; provider?: string }) {
|
|
13
|
+
const visible = bands.filter((band) => band.share > 0);
|
|
14
|
+
const rows = visible.map((band): TipRow => [band.color, band.label, band.value]);
|
|
15
|
+
const detail = visible.length ? tip(label, rows) : undefined;
|
|
16
|
+
const bar = (
|
|
17
|
+
<span className="console-model-bands" role={visible.length ? "img" : undefined} tabIndex={!model && visible.length ? 0 : undefined}
|
|
18
|
+
data-tip={!model ? detail : undefined}
|
|
19
|
+
aria-label={visible.length ? `${label}: ${visible.map(({ label, value }) => `${label} ${value}`).join(", ")}` : undefined}>
|
|
20
|
+
{visible.map((band, i) => (
|
|
21
|
+
<i key={i} className="bar-fill" aria-hidden="true"
|
|
22
|
+
style={{ flexBasis: `${band.share * 100}%`, "--c": `var(${band.color})` } as CSSProperties} />
|
|
23
|
+
))}
|
|
24
|
+
</span>
|
|
25
|
+
);
|
|
26
|
+
return model ? <BreakdownSessions model={model} {...(provider === undefined ? {} : { provider })} detail={detail}>{bar}</BreakdownSessions> : bar;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { effortColor } from "../../vm/colors.ts";
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
.console-model-columns {
|
|
2
|
+
display: grid;
|
|
3
|
+
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
4
|
+
gap: var(--space-4);
|
|
5
|
+
}
|
|
6
|
+
.console-sub-columns { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
|
|
7
|
+
|
|
8
|
+
.console-model-view h3 {
|
|
9
|
+
margin: 0 0 var(--space-2);
|
|
10
|
+
font: var(--fw-semibold) var(--fs-md) / var(--lh-body) var(--font-heading);
|
|
11
|
+
overflow-wrap: anywhere;
|
|
12
|
+
}
|
|
13
|
+
.console-model-providers { display: grid; row-gap: var(--space-4); }
|
|
14
|
+
.console-model-providers :is(.console-model-provider, .console-model-meter-list, .console-model-meter-row) {
|
|
15
|
+
display: grid;
|
|
16
|
+
grid-column: 1 / -1;
|
|
17
|
+
grid-template-columns: subgrid;
|
|
18
|
+
column-gap: inherit;
|
|
19
|
+
}
|
|
20
|
+
.console-model-provider > h3 { grid-column: 1 / -1; }
|
|
21
|
+
.console-model-provider + .console-model-provider {
|
|
22
|
+
padding-top: var(--space-3);
|
|
23
|
+
border-top: 1px solid var(--line);
|
|
24
|
+
}
|
|
25
|
+
.console-model-meter-list { display: grid; gap: var(--space-2); }
|
|
26
|
+
.console-model-meter-row {
|
|
27
|
+
display: grid;
|
|
28
|
+
grid-template-columns: minmax(0, 1fr) minmax(0, 3fr) minmax(0, max-content);
|
|
29
|
+
align-items: center;
|
|
30
|
+
gap: var(--space-3);
|
|
31
|
+
font-size: var(--fs-sm);
|
|
32
|
+
}
|
|
33
|
+
.console-model-meter-row > :first-child {
|
|
34
|
+
min-width: 0;
|
|
35
|
+
overflow: hidden;
|
|
36
|
+
text-overflow: ellipsis;
|
|
37
|
+
white-space: nowrap;
|
|
38
|
+
}
|
|
39
|
+
.console-model-meter-row > .num { white-space: nowrap; }
|
|
40
|
+
.console-model-bands {
|
|
41
|
+
display: flex;
|
|
42
|
+
min-width: 0;
|
|
43
|
+
width: 100%;
|
|
44
|
+
min-height: var(--bar-height);
|
|
45
|
+
overflow: hidden;
|
|
46
|
+
border-radius: var(--bar-radius);
|
|
47
|
+
background: var(--track);
|
|
48
|
+
}
|
|
49
|
+
.console-model-bands > i {
|
|
50
|
+
flex-grow: 0;
|
|
51
|
+
flex-shrink: 1;
|
|
52
|
+
min-width: 0;
|
|
53
|
+
}
|
|
54
|
+
.console-model-dot {
|
|
55
|
+
display: inline-block;
|
|
56
|
+
width: var(--space-2);
|
|
57
|
+
height: var(--space-2);
|
|
58
|
+
margin-inline-end: var(--space-2);
|
|
59
|
+
border-radius: var(--radius-sm);
|
|
60
|
+
}
|
|
61
|
+
.console-model-link {
|
|
62
|
+
border: 0;
|
|
63
|
+
background: transparent;
|
|
64
|
+
color: var(--ink);
|
|
65
|
+
padding: var(--space-1) 0;
|
|
66
|
+
cursor: pointer;
|
|
67
|
+
text-align: start;
|
|
68
|
+
max-width: 100%;
|
|
69
|
+
}
|
|
70
|
+
.console-model-link:hover { color: var(--focus); }
|
|
71
|
+
.console-model-view :is(button, [tabindex]):focus-visible { box-shadow: var(--focus-ring); }
|
|
72
|
+
.console-model-legend {
|
|
73
|
+
display: flex;
|
|
74
|
+
flex-wrap: wrap;
|
|
75
|
+
gap: var(--space-1) var(--space-3);
|
|
76
|
+
padding: 0;
|
|
77
|
+
margin: var(--space-3) 0;
|
|
78
|
+
list-style: none;
|
|
79
|
+
}
|
|
80
|
+
.console-model-legend li { color: var(--ink-2); font-size: var(--fs-sm); overflow-wrap: anywhere; }
|
|
81
|
+
.console-model-table {
|
|
82
|
+
width: 100%;
|
|
83
|
+
table-layout: fixed;
|
|
84
|
+
font-size: var(--fs-sm);
|
|
85
|
+
}
|
|
86
|
+
.console-model-table + .console-model-table { margin-top: var(--space-4); }
|
|
87
|
+
.console-model-table thead th {
|
|
88
|
+
padding-inline: var(--space-2);
|
|
89
|
+
white-space: normal;
|
|
90
|
+
overflow-wrap: anywhere;
|
|
91
|
+
text-transform: none;
|
|
92
|
+
font: var(--fw-medium) var(--fs-sm) / var(--lh-body) var(--font-heading);
|
|
93
|
+
color: var(--muted);
|
|
94
|
+
}
|
|
95
|
+
.console-model-table tbody :is(th, td) {
|
|
96
|
+
min-width: 0;
|
|
97
|
+
padding: var(--space-2);
|
|
98
|
+
overflow: hidden;
|
|
99
|
+
text-overflow: ellipsis;
|
|
100
|
+
border-color: var(--line);
|
|
101
|
+
}
|
|
102
|
+
.console-model-table tbody th { white-space: normal; overflow-wrap: anywhere; color: var(--ink); }
|
|
103
|
+
.effort-output-table thead th:first-child { width: 22%; }
|
|
104
|
+
.console-model-table tbody td:focus-within { overflow: visible; }
|
|
105
|
+
.console-model-table :is(th, td) small { display: block; color: var(--muted); }
|
|
106
|
+
.console-sub-model-row { margin-top: var(--space-2); }
|
|
107
|
+
.console-sub-kpis {
|
|
108
|
+
display: grid;
|
|
109
|
+
grid-template-columns: repeat(5, minmax(0, 1fr));
|
|
110
|
+
margin: 0;
|
|
111
|
+
border-block: 1px solid var(--line);
|
|
112
|
+
}
|
|
113
|
+
.console-sub-kpis div { padding: var(--space-3); border-inline-end: 1px solid var(--line); }
|
|
114
|
+
.console-sub-kpis div:last-child { border-inline-end: 0; }
|
|
115
|
+
.console-sub-kpis dt, .console-sub-kpis small { color: var(--muted); font-size: var(--fs-sm); }
|
|
116
|
+
.console-sub-kpis dd {
|
|
117
|
+
margin: 0;
|
|
118
|
+
text-align: start;
|
|
119
|
+
font-size: var(--fs-kpi);
|
|
120
|
+
font-weight: var(--fw-semibold);
|
|
121
|
+
overflow: hidden;
|
|
122
|
+
text-overflow: ellipsis;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
@media (max-width: 880px) {
|
|
126
|
+
.console-model-columns { grid-template-columns: minmax(0, 1fr); }
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
@media (max-width: 639px) {
|
|
130
|
+
.console-sub-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
131
|
+
.console-sub-kpis div { border-block-end: 1px solid var(--line); }
|
|
132
|
+
.console-sub-kpis div:first-child { grid-column: 1 / -1; }
|
|
133
|
+
.console-model-table :is(tbody, tr) { display: block; }
|
|
134
|
+
.console-model-table thead {
|
|
135
|
+
position: absolute;
|
|
136
|
+
width: 1px;
|
|
137
|
+
height: 1px;
|
|
138
|
+
overflow: hidden;
|
|
139
|
+
clip-path: inset(50%);
|
|
140
|
+
}
|
|
141
|
+
.console-model-table tbody tr {
|
|
142
|
+
padding: var(--space-2) 0;
|
|
143
|
+
border-block-end: 1px solid var(--line);
|
|
144
|
+
}
|
|
145
|
+
.console-model-table tbody :is(th, td) {
|
|
146
|
+
display: block;
|
|
147
|
+
width: 100%;
|
|
148
|
+
padding: var(--space-1) 0;
|
|
149
|
+
border: 0;
|
|
150
|
+
}
|
|
151
|
+
.console-model-table tbody td {
|
|
152
|
+
display: grid;
|
|
153
|
+
grid-template-columns: minmax(0, 1fr) minmax(0, max-content);
|
|
154
|
+
gap: var(--space-3);
|
|
155
|
+
}
|
|
156
|
+
.console-model-table tbody td::before {
|
|
157
|
+
content: attr(data-label);
|
|
158
|
+
color: var(--muted);
|
|
159
|
+
font-family: var(--font-sans);
|
|
160
|
+
text-align: start;
|
|
161
|
+
}
|
|
162
|
+
.console-model-table tbody td:has(.console-model-bands) {
|
|
163
|
+
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
|
|
164
|
+
align-items: center;
|
|
165
|
+
}
|
|
166
|
+
.compact-metrics tr {
|
|
167
|
+
display: grid;
|
|
168
|
+
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
169
|
+
column-gap: var(--space-4);
|
|
170
|
+
}
|
|
171
|
+
.compact-metrics th { grid-column: 1 / -1; }
|
|
172
|
+
.app .compact-metrics td { display: flex; justify-content: space-between; font-size: var(--fs-xs); gap: var(--space-1); }
|
|
173
|
+
.console-model-meter-row {
|
|
174
|
+
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, max-content);
|
|
175
|
+
gap: var(--space-2);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
.console-model-providers, .thread-share-grid {
|
|
181
|
+
grid-template-columns: minmax(0, 1fr) minmax(0, 3fr) max-content;
|
|
182
|
+
column-gap: var(--space-3);
|
|
183
|
+
}
|
|
184
|
+
.thread-share-grid > :is(.console-model-meter-row, .donut-model-meter-row) {
|
|
185
|
+
grid-column: 1 / -1;
|
|
186
|
+
grid-template-columns: subgrid;
|
|
187
|
+
column-gap: inherit;
|
|
188
|
+
margin-top: 0;
|
|
189
|
+
}
|
|
190
|
+
.thread-share-grid > .console-model-legend { grid-column: 1 / -1; }
|
|
191
|
+
|
|
192
|
+
@media (max-width: 639px) {
|
|
193
|
+
.console-model-providers, .thread-share-grid {
|
|
194
|
+
grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) minmax(0, max-content);
|
|
195
|
+
column-gap: var(--space-2);
|
|
196
|
+
}
|
|
197
|
+
.console-model-providers .console-model-meter-row > .num,
|
|
198
|
+
.thread-share-grid > div > .num {
|
|
199
|
+
max-width: 15ch;
|
|
200
|
+
white-space: normal;
|
|
201
|
+
text-align: end;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { RelatedSessions } from "../../sessionScope.tsx";
|
|
2
|
+
import "./activity-context.css";
|
|
3
|
+
import { useState, type ReactNode, type CSSProperties } from "react";
|
|
4
|
+
import { useDash } from "../../dash.ts";
|
|
5
|
+
import { type Fact } from "../../model.ts";
|
|
6
|
+
import { ACTIVITY_PREVIEW_SIZE as SHOWN, buildActivityVM, type ActivityVM } from "../../vm/activity.ts";
|
|
7
|
+
import { ChartSeg, Columns, Delta, Empty, HeatSeg, Info, Kpi, Stats, tip } from "../../ui.tsx";
|
|
8
|
+
|
|
9
|
+
// What the agent did: time on the model and on tools, owner turns, lines, compactions and agent time per owner turn
|
|
10
|
+
// 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;
|
|
11
|
+
// tool calls with their failed part beside the skills used.
|
|
12
|
+
export function Activity({ F, list }: { F: Fact[]; list: string[] }) {
|
|
13
|
+
const { M, S, filter, t, f, set } = useDash();
|
|
14
|
+
const data = buildActivityVM(M, F, list, filter, S.heat);
|
|
15
|
+
const { w, p, slots, timeRows, lineRows, idle, series, perTurnNow, perTurnPrior } = data;
|
|
16
|
+
if (!w.ss.length) return <section className="card donut-panel"><Empty /></section>;
|
|
17
|
+
|
|
18
|
+
const agent = w.api + w.tool;
|
|
19
|
+
const previousAgent = p ? p.api + p.tool : undefined;
|
|
20
|
+
const workTime = agent + w.idle;
|
|
21
|
+
const workParts = [
|
|
22
|
+
{ key: "api", value: w.api, color: "dac-work" },
|
|
23
|
+
{ key: "tool", value: w.tool, color: "dac-cost" },
|
|
24
|
+
{ key: "idle", value: w.idle, color: "dac-idle" },
|
|
25
|
+
] as const;
|
|
26
|
+
const selectDay = typeof slots[0] === "string" ? (day: string | number) => {
|
|
27
|
+
if (typeof day === "string") set({ range: "", from: day, to: day });
|
|
28
|
+
} : undefined;
|
|
29
|
+
const hours = (h: number) => (h >= 1 ? `${f.dec(h)}h` : `${Math.round(h * 60)}m`);
|
|
30
|
+
const kpi = (label: string, value: ReactNode, a: number, b: number | undefined, series: number[]) => (
|
|
31
|
+
<Kpi label={label} value={value} d={<Delta a={a} b={p ? b : undefined} side="none" />} series={series} />
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<div className="donut-view dac-view">
|
|
36
|
+
<div className="donut-kpis dac-kpis">
|
|
37
|
+
{kpi(t("time"), f.dur(agent / 60), agent, previousAgent, series.api.map((value, index) => value + series.tool[index]))}
|
|
38
|
+
{kpi(`${t("lines")} · ${t("added")}`, `+${f.cmp(w.la)}`, w.la, p?.la, [])}
|
|
39
|
+
{kpi(`${t("lines")} · ${t("removed")}`, `−${f.cmp(w.lr)}`, w.lr, p?.lr, [])}
|
|
40
|
+
<Kpi label={t("failed")} value={f.pct(data.tools.errs / (data.tools.calls || 1))} d={f.int(data.tools.errs)} series={[]} />
|
|
41
|
+
<Kpi label={t("rebuilt")} value={f.int(data.rebuild.count)}
|
|
42
|
+
d={<>{f.usd(data.rebuild.r.idle.extra + data.rebuild.r.compaction.extra + data.rebuild.r.other.extra)} · {t("rbExtra")}</>} series={[]} />
|
|
43
|
+
</div>
|
|
44
|
+
<div className="donut-grid dac-grid dac-time-grid">
|
|
45
|
+
<section className="card donut-panel">
|
|
46
|
+
<header><h2>{t("time")}</h2><div className="segs"><b className="num">{f.dur(workTime / 60)}</b><ChartSeg /></div></header>
|
|
47
|
+
{workTime > 0 ? <>
|
|
48
|
+
<div className="dac-time-ring" aria-hidden="true" style={{
|
|
49
|
+
"--model-stop": `${w.api / workTime * 100}%`,
|
|
50
|
+
"--tool-stop": `${agent / workTime * 100}%`,
|
|
51
|
+
} as CSSProperties}>
|
|
52
|
+
<div><span>{t("time")}</span><strong className="num">{f.dur(workTime / 60)}</strong></div>
|
|
53
|
+
</div>
|
|
54
|
+
<ul className="dac-time-legend">{workParts.map(({ key, value, color }) => <li key={key}>
|
|
55
|
+
<i className={color} /><span>{t(key)}</span><span className="num">{f.dur(value / 60)}</span>
|
|
56
|
+
<b className="num">{f.pct(value / workTime)}</b>
|
|
57
|
+
</li>)}</ul>
|
|
58
|
+
</> : null}
|
|
59
|
+
<Columns list={slots} rows={timeRows} groups={[{ n: t("api"), c: "dac-work" }, { n: t("tool"), c: "dac-cost" }]} metric="out" fmt={hours} onSlot={selectDay}
|
|
60
|
+
extra={(i) => (idle[i] ? [["dac-req", t("idle"), hours(idle[i])]] : [])} />
|
|
61
|
+
<Stats items={[
|
|
62
|
+
{ label: t("ownerTurns"), value: f.int(w.owner), sub: <Delta a={w.owner} b={p?.owner} side="none" /> },
|
|
63
|
+
{ label: t("compactions"), value: f.int(w.compact), sub: <Delta a={w.compact} b={p?.compact} side="none" /> },
|
|
64
|
+
{ label: t("perTurn"), value: f.dur(perTurnNow / 60), sub: <Delta a={perTurnNow} b={perTurnPrior} side="none" /> },
|
|
65
|
+
]} />
|
|
66
|
+
</section>
|
|
67
|
+
<section className="card donut-panel"><header><h2>{t("hours")}</h2><HeatSeg /></header><Heatmap data={data.heat} F={F} /></section>
|
|
68
|
+
</div>
|
|
69
|
+
<div className="donut-grid dac-grid">
|
|
70
|
+
<Tools data={data.tools} />
|
|
71
|
+
<Skills data={data.skills} />
|
|
72
|
+
</div>
|
|
73
|
+
<Rebuilds data={data.rebuild} sessionsLink={<RelatedSessions F={F} scope="rebuild" />} />
|
|
74
|
+
<section className="card donut-panel">
|
|
75
|
+
<header><h2>{t("lines")}</h2><ChartSeg /></header>
|
|
76
|
+
<ul className="legend"><li><i className="dac-work" />{t("added")}<b>{f.cmp(w.la)}</b></li><li><i className="dac-req" />{t("removed")}<b>{f.cmp(w.lr)}</b></li></ul>
|
|
77
|
+
<Columns list={slots} rows={lineRows} groups={[{ n: t("added"), c: "dac-work" }, { n: t("removed"), c: "dac-req" }]} metric="out" fmt={(v) => f.cmp(v)} onSlot={selectDay} />
|
|
78
|
+
</section>
|
|
79
|
+
</div>
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Tool calls, most used first, each with its failed part; the lead says how many failed and which tool most of them came
|
|
84
|
+
// from. Past SHOWN rows the rest opens below.
|
|
85
|
+
function Tools({ data }: { data: ActivityVM["tools"] }) {
|
|
86
|
+
const { t, L, f } = useDash();
|
|
87
|
+
const [all, setAll] = useState(false);
|
|
88
|
+
const { rows, calls, errs, tmax, worst } = data;
|
|
89
|
+
const shown = all ? rows : rows.slice(0, SHOWN);
|
|
90
|
+
return (
|
|
91
|
+
<section className="card donut-panel">
|
|
92
|
+
<header><h2>{t("tools")}</h2><span className="hint">{f.int(calls)} {t("calls")} · {f.int(rows.length)} {t("toolCount")}</span></header>
|
|
93
|
+
{errs ? <Stats items={[
|
|
94
|
+
{ label: t("failed"), value: f.int(errs), tone: "err", sub: L.ofCalls(f.pct(errs / calls)) },
|
|
95
|
+
{ label: L.fromTool(worst[0]), value: f.pct(worst[1][1] / errs), meter: [worst[1][1] / errs, "dac-bad"], sub: t("ofFailures") },
|
|
96
|
+
]} /> : null}
|
|
97
|
+
{rows.length ? <div className="rank tools">{shown.map(([n, [c, e]]) => [
|
|
98
|
+
<span key={`n${n}`} className="n" title={n}>{n}</span>,
|
|
99
|
+
<span key={`t${n}`} className="t"><span className="b" style={{ width: `${(c / tmax) * 100}%` }} data-tip={tip(n, [["dac-work", t("calls"), f.int(c)], ["dac-bad", t("errors"), f.int(e)]])}>{e ? <i style={{ width: `max(2px, ${(e / c) * 100}%)` }} /> : null}</span></span>,
|
|
100
|
+
<span key={`v${n}`} className="val">{f.int(c)}<small className={e ? "err" : ""}>{f.pct(e / c)} {t("errors")}</small></span>,
|
|
101
|
+
])}</div> : <Empty />}
|
|
102
|
+
{rows.length ? <ul className="legend dac-status-legend">
|
|
103
|
+
<li><i className="dac-work" />{t("succeeded")}</li>
|
|
104
|
+
<li><i className="dac-bad" />{t("errors")}</li>
|
|
105
|
+
</ul> : null}
|
|
106
|
+
{rows.length > SHOWN ? <button type="button" className="disc more" aria-expanded={all} onClick={() => setAll(!all)}>
|
|
107
|
+
<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M6 4l4 4-4 4" /></svg>{all ? t("showFewer") : `${t("seeAll")} (${rows.length})`}
|
|
108
|
+
</button> : null}
|
|
109
|
+
</section>
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
const SOURCE = { project: "srcProject", personal: "srcPersonal", plugin: "srcPlugin", builtin: "srcBuiltin", other: "srcOther" } as const;
|
|
113
|
+
|
|
114
|
+
// Skills retain source, command and agent counts, errors, sessions and most recent use.
|
|
115
|
+
function Skills({ data }: { data: ActivityVM["skills"] }) {
|
|
116
|
+
const { t, f } = useDash();
|
|
117
|
+
const [all, setAll] = useState(false);
|
|
118
|
+
const { rows, uses, preview } = data;
|
|
119
|
+
const shown = all ? rows : preview;
|
|
120
|
+
return (
|
|
121
|
+
<section className="card donut-panel">
|
|
122
|
+
<header><h2>{t("skills")}</h2><span className="hint">{f.int(uses)} {t("uses")} · {f.int(rows.length)} {t("skillCount")}</span></header>
|
|
123
|
+
{rows.length ? <>
|
|
124
|
+
<div className="dac-table-wrap"><table className="donut-table dac-table compact-metrics">
|
|
125
|
+
<thead><tr><th scope="col">{t("skills")}</th><th scope="col">{t("source")}</th>
|
|
126
|
+
<th scope="col" className="num">{t("skillTyped")}</th><th scope="col" className="num">{t("skillAgent")}</th>
|
|
127
|
+
<th scope="col" className="num">{t("errors")}</th><th scope="col" className="num">{t("sess")}</th><th scope="col">{t("lastUsed")}</th></tr></thead>
|
|
128
|
+
<tbody>{shown.map((r) => <tr key={r.name} data-tip={tip(r.name, [
|
|
129
|
+
["dac-work", t("skillTyped"), f.int(r.command)], ["dac-cost", t("skillAgent"), f.int(r.agent)],
|
|
130
|
+
["dac-bad", t("errors"), f.int(r.errors)], ["", t("sess"), f.int(r.sessions)],
|
|
131
|
+
])}>
|
|
132
|
+
<th scope="row" title={r.name}>{r.name}</th>
|
|
133
|
+
<td data-label={t("source")}>{t(SOURCE[r.source])}</td>
|
|
134
|
+
<td className="num" data-label={t("skillTyped")}>{f.int(r.command)}</td>
|
|
135
|
+
<td className="num" data-label={t("skillAgent")}>{f.int(r.agent)}</td>
|
|
136
|
+
<td className="num" data-label={t("errors")}>{f.int(r.errors)}</td>
|
|
137
|
+
<td className="num" data-label={t("sess")}>{f.int(r.sessions)}</td>
|
|
138
|
+
<td data-label={t("lastUsed")}>{r.last ? f.dshort(r.last) : "—"}</td>
|
|
139
|
+
</tr>)}</tbody>
|
|
140
|
+
</table></div>
|
|
141
|
+
{rows.length > SHOWN ? <button type="button" className="disc more" aria-expanded={all} onClick={() => setAll(!all)}>
|
|
142
|
+
<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M6 4l4 4-4 4" /></svg>{all ? t("showFewer") : `${t("seeAll")} (${rows.length})`}
|
|
143
|
+
</button> : null}
|
|
144
|
+
</> : <Empty />}
|
|
145
|
+
</section>
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// Where the prompt cache had to be written again: the four causes with their count, rewritten tokens and extra cost
|
|
150
|
+
// over reading it; beside it, the idle ones by the time since the previous request.
|
|
151
|
+
function Rebuilds({ data, sessionsLink }: { data: ActivityVM["rebuild"]; sessionsLink: ReactNode }) {
|
|
152
|
+
const { t, L, f } = useDash();
|
|
153
|
+
const { r, count, gmax } = data;
|
|
154
|
+
const rows = [["idle", t("rbIdle"), t("rbIdleTip")], ["compaction", t("rbCompaction"), t("rbCompactionTip")], ["other", t("rbOther"), t("rbOtherTip")], ["start", t("rbStart"), t("rbStartTip")]] as const;
|
|
155
|
+
const gaps = [t("gapShort"), t("gapMid"), t("gapLong")];
|
|
156
|
+
return (
|
|
157
|
+
<div className="donut-grid dac-grid">
|
|
158
|
+
<section className="card donut-panel">
|
|
159
|
+
<header>
|
|
160
|
+
<div className="ttl"><h2>{t("rebuilt")}</h2>{sessionsLink}<Info label={t("howToRead")}>
|
|
161
|
+
<p>{t("rbInfo")}</p>
|
|
162
|
+
<ul>{rows.map(([c, label, def]) => <li key={c}><b>{label}</b>: {def}</li>)}</ul>
|
|
163
|
+
</Info></div>
|
|
164
|
+
<span className="hint">{f.int(count)}</span>
|
|
165
|
+
</header>
|
|
166
|
+
{count ? <div className="dac-table-wrap"><table className="donut-table dac-table">
|
|
167
|
+
<thead><tr><th /><th className="num">{t("count")}</th><th className="num">{t("rbTokens")}</th><th className="num">{t("rbExtra")}</th></tr></thead>
|
|
168
|
+
<tbody>{rows.map(([c, label]) => (
|
|
169
|
+
<tr key={c}>
|
|
170
|
+
<th scope="row" className="name">{label}</th>
|
|
171
|
+
<td className="num" data-label={t("count")}>{f.int(r[c].n)}</td>
|
|
172
|
+
<td className="num" data-label={t("rbTokens")}>{r[c].n ? f.cmp(r[c].tokens) : "—"}</td>
|
|
173
|
+
<td className="num" data-label={t("rbExtra")}>{c === "start" || !r[c].n ? "—" : f.usd(r[c].extra)}</td>
|
|
174
|
+
</tr>
|
|
175
|
+
))}</tbody>
|
|
176
|
+
</table></div> : <Empty />}
|
|
177
|
+
</section>
|
|
178
|
+
<section className="card donut-panel">
|
|
179
|
+
<header><h2>{t("idleGap")}</h2><span className="hint">{t("rbIdle")}: {f.int(r.idle.n)}</span></header>
|
|
180
|
+
{r.idle.n ? <Stats items={[
|
|
181
|
+
{ label: t("perBreak"), value: f.usd(r.idle.extra / r.idle.n), sub: t("onAverage") },
|
|
182
|
+
{ label: t("overHour"), value: f.pct(r.gaps[2] / r.idle.n), meter: [r.gaps[2] / r.idle.n, "dac-work"], sub: t("ofRebuilds") },
|
|
183
|
+
]} /> : null}
|
|
184
|
+
{r.idle.n ? <div className="rank">{gaps.map((label, k) => [
|
|
185
|
+
<span key={`n${k}`} className="n">{label}</span>,
|
|
186
|
+
<span key={`t${k}`} className="t">{r.gaps[k] ? <span className="b dac-bad" style={{ width: `${(r.gaps[k] / gmax) * 100}%` }} /> : null}</span>,
|
|
187
|
+
<span key={`v${k}`} className="val">{f.int(r.gaps[k])}</span>,
|
|
188
|
+
])}</div> : <Empty />}
|
|
189
|
+
</section>
|
|
190
|
+
</div>
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function Heatmap({ data, F }: { data: ActivityVM["heat"]; F: Fact[] }) {
|
|
195
|
+
const { S, L, f, t } = useDash();
|
|
196
|
+
const { g, max, peak, all, weekend, night, mid, most } = data;
|
|
197
|
+
if (!max) return <Empty />;
|
|
198
|
+
const requestMode = S.heat === "req";
|
|
199
|
+
const metric = requestMode ? t("requests") : t("out");
|
|
200
|
+
const show = requestMode ? f.int : f.cmp;
|
|
201
|
+
const details = g.map((row) => row.map(() => ({ requests: 0, cost: 0, sessions: new Set<number>() })));
|
|
202
|
+
for (const fact of F) {
|
|
203
|
+
const weekday = (new Date(fact.d + "T00:00:00Z").getUTCDay() + 6) % 7;
|
|
204
|
+
const entry = details[weekday][fact.h];
|
|
205
|
+
entry.requests += fact.q;
|
|
206
|
+
entry.cost += fact.c;
|
|
207
|
+
entry.sessions.add(fact.s);
|
|
208
|
+
}
|
|
209
|
+
const step = Math.ceil(max / 4);
|
|
210
|
+
const hour = (h: number) => `${String(h % 24).padStart(2, "0")}:00`;
|
|
211
|
+
return <>
|
|
212
|
+
<div className="heat dac-heat">
|
|
213
|
+
{g.map((row, weekday) => [
|
|
214
|
+
<span key={`r${weekday}`} className="rl">{L.wd[weekday]}</span>,
|
|
215
|
+
...row.map((value, h) => {
|
|
216
|
+
const cell = details[weekday][h];
|
|
217
|
+
const label = `${L.wd[weekday]} · ${hour(h)}–${hour(h + 1)}`;
|
|
218
|
+
const rows: [string, string, string][] = [
|
|
219
|
+
["dac-req", t("requests"), f.int(cell.requests)],
|
|
220
|
+
["", t("sess"), f.int(cell.sessions.size)],
|
|
221
|
+
["dac-cost", t("cost"), f.usd(cell.cost)],
|
|
222
|
+
];
|
|
223
|
+
if (!requestMode) rows.unshift(["dac-work", metric, show(value)]);
|
|
224
|
+
return <span key={`${weekday}-${h}`} className={`dac-heat-cell dac-heat-${Math.ceil(value / step)}`}
|
|
225
|
+
tabIndex={cell.sessions.size ? 0 : undefined} data-tip={tip(label, rows)}
|
|
226
|
+
aria-label={`${label} · ${rows.map(([, key, val]) => `${key} ${val}`).join(" · ")}`} />;
|
|
227
|
+
}),
|
|
228
|
+
])}
|
|
229
|
+
<span />
|
|
230
|
+
{g[0].map((_, h) => <span key={h} className="cl">{h % 3 === 0 ? h : ""}</span>)}
|
|
231
|
+
</div>
|
|
232
|
+
<ul className="legend dac-heat-legend">
|
|
233
|
+
<li>{requestMode ? t("reqPerHour") : metric}</li>
|
|
234
|
+
<li><i className="dac-heat-0" />0</li>
|
|
235
|
+
{Array.from({ length: Math.ceil(max / step) }, (_, i) => {
|
|
236
|
+
const from = i * step + 1, to = Math.min(max, (i + 1) * step);
|
|
237
|
+
return <li key={i}><i className={`dac-heat-${i + 1}`} />{from === to ? show(from) : `${show(from)}–${show(to)}`}</li>;
|
|
238
|
+
})}
|
|
239
|
+
</ul>
|
|
240
|
+
<Stats items={[
|
|
241
|
+
{ label: t("peak"), value: `${L.wd[peak[0]]} · ${hour(peak[1])}`, sub: `${show(max)} ${metric.toLowerCase()}` },
|
|
242
|
+
{ label: t("weekend"), value: f.pct(weekend / all), meter: [weekend / all, "dac-work"], sub: metric.toLowerCase() },
|
|
243
|
+
{ label: "22:00–6:00", value: f.pct(night / all), meter: [night / all, "dac-work"], sub: metric.toLowerCase() },
|
|
244
|
+
{ label: t("sameHour"), value: f.int(mid), dots: [mid, most], sub: L.atMost(f.int(most)) },
|
|
245
|
+
]} />
|
|
246
|
+
</>;
|
|
247
|
+
}
|