claude-code-cost 0.23.0 → 0.24.0-rc.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/README.md +67 -25
- package/lib/net-guard.js +20 -3
- package/package.json +1 -1
- package/public/app.js +103 -22
- package/public/index.html +34 -3
- package/public/style.css +192 -2
- package/public/themes.css +52 -82
- package/server.js +78 -23
package/README.md
CHANGED
|
@@ -4,51 +4,93 @@
|
|
|
4
4
|
[](LICENSE)
|
|
5
5
|
[](https://www.npmjs.com/package/claude-code-cost)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
See what [Claude Code](https://docs.anthropic.com/en/docs/claude-code) costs you per day, project, session, and message.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
**[Documentation](https://nikiforovall.blog/claude-code-cost/)**
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
<picture>
|
|
12
|
+
<source media="(prefers-color-scheme: dark)" srcset="website/public/shots/themes/ember-h2-hub-cost-dark.webp">
|
|
13
|
+
<img alt="The Overview tab: cost cards, a daily cost chart stacked by model, a Cost by Model chart, and the Projects table" src="website/public/shots/themes/ember-h2-hub-cost-light.webp">
|
|
14
|
+
</picture>
|
|
12
15
|
|
|
13
|
-
## Getting
|
|
16
|
+
## Getting started
|
|
17
|
+
|
|
18
|
+
You need Node.js 20 or later and a Claude config dir with at least one session.
|
|
14
19
|
|
|
15
20
|
```bash
|
|
16
21
|
npx claude-code-cost --open
|
|
17
22
|
```
|
|
18
23
|
|
|
19
|
-
|
|
24
|
+
The server starts on `http://localhost:3543` and `--open` opens it in your browser. If the port is in use, the server picks a random free port and prints the real URL.
|
|
25
|
+
|
|
26
|
+
You do not need hooks, plugins, or a config file. The dashboard reads the session logs that Claude Code already writes to `~/.claude/projects/` and never writes to them. Your transcripts and cost data stay on your machine. The server downloads the LiteLLM price list, and the Plan usage dialog runs your local `claude` CLI. See [What it reads and what it sends](https://nikiforovall.blog/claude-code-cost/getting-started/#what-it-reads-and-what-it-sends).
|
|
20
27
|
|
|
21
28
|
### Install as a desktop app
|
|
22
29
|
|
|
23
|
-
The dashboard is a PWA. With the server running, open it in Chrome or Edge and click **Install** in the top bar
|
|
30
|
+
The dashboard is a PWA. With the server running, open it in Chrome or Edge and click **Install** in the top bar, or the install icon in the address bar. The app opens in its own window. Right-click its icon for the **Overview** and **Insights** shortcuts. The server must still run, because the app is a window onto the local URL.
|
|
24
31
|
|
|
25
32
|
## Features
|
|
26
33
|
|
|
27
|
-
- **
|
|
28
|
-
- **
|
|
29
|
-
- **
|
|
30
|
-
- **
|
|
31
|
-
- **
|
|
32
|
-
- **
|
|
33
|
-
- **
|
|
34
|
-
- **17 color themes
|
|
35
|
-
- **
|
|
34
|
+
- **Drill down from the total to one message.** Open a project to see its sessions, then a session to see each message. <kbd>Backspace</kbd> goes back one level.
|
|
35
|
+
- **Session detail.** A cumulative cost curve, the tokens of each message, and a table with the model, the tools it called, and the running total. Subagents and Workflow runs are in the totals, with a row per agent. Compactions show with an estimated summarizer cost. A range brush picks which messages to show in long sessions.
|
|
36
|
+
- **Date ranges.** Presets from Today and Last 24h up to 1 Year, or two dates on a calendar. The range and the project scope apply to every view.
|
|
37
|
+
- **Insights.** The active 5-hour block with its time left, burn rate, monthly run-rate, cache savings, and subagent share. Charts for token composition, top tools, an hourly heatmap, and weekly cost, plus a table of past 5-hour blocks.
|
|
38
|
+
- **Plan usage.** Press <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>S</kbd> to see your plan windows, the percent used, and what drives the cost.
|
|
39
|
+
- **Pricing.** Live prices from the [LiteLLM](https://github.com/BerriAI/litellm) price list, with the 200K-token tier, cache reads and writes, and fast mode. A built-in table fills in when the list cannot load. Streamed lines are counted once per `message.id` plus `requestId`.
|
|
40
|
+
- **Keyboard.** <kbd>1</kbd> and <kbd>2</kbd> switch between Overview and Insights. <kbd>↓</kbd>/<kbd>↑</kbd> or <kbd>J</kbd>/<kbd>K</kbd> move through rows, and <kbd>Enter</kbd> opens one. Press <kbd>?</kbd> for the full list.
|
|
41
|
+
- **17 color themes**, each in light and dark.
|
|
42
|
+
- **Claude Code Hub.** Runs standalone or as a tab in [Claude Code Hub](https://github.com/NikiforovAll/claude-code-hub), with a shared project scope and theme.
|
|
43
|
+
|
|
44
|
+
All numbers are estimates from token counts and public list prices, not a bill. See [How costs are computed](https://nikiforovall.blog/claude-code-cost/how-costs-are-computed/).
|
|
45
|
+
|
|
46
|
+
<picture>
|
|
47
|
+
<source media="(prefers-color-scheme: dark)" srcset="website/public/shots/themes/ember-h2d-hub-cost-sessions-dark.webp">
|
|
48
|
+
<img alt="A project's sessions view: daily cost by model, Cost by Model, Total Cost, and the sessions table" src="website/public/shots/themes/ember-h2d-hub-cost-sessions-light.webp">
|
|
49
|
+
</picture>
|
|
50
|
+
|
|
51
|
+
<picture>
|
|
52
|
+
<source media="(prefers-color-scheme: dark)" srcset="website/public/shots/themes/ember-cost-detail-dark.webp">
|
|
53
|
+
<img alt="Session detail: stat header, Cumulative Cost and Token Breakdown per Message charts, the range brush, and the messages table" src="website/public/shots/themes/ember-cost-detail-light.webp">
|
|
54
|
+
</picture>
|
|
55
|
+
|
|
56
|
+
<picture>
|
|
57
|
+
<source media="(prefers-color-scheme: dark)" srcset="website/public/shots/themes/ember-cost-insights-dark.webp">
|
|
58
|
+
<img alt="Insights: active 5-hour block, burn rate, run-rate, cache savings and subagent share cards, charts, and the 5-hour billing blocks table" src="website/public/shots/themes/ember-cost-insights-light.webp">
|
|
59
|
+
</picture>
|
|
60
|
+
|
|
61
|
+
<picture>
|
|
62
|
+
<source media="(prefers-color-scheme: dark)" srcset="website/public/shots/themes/ember-h2g-hub-cost-range-dark.webp">
|
|
63
|
+
<img alt="The date range picker with presets from Today to 1 Year and a two-month calendar" src="website/public/shots/themes/ember-h2g-hub-cost-range-light.webp">
|
|
64
|
+
</picture>
|
|
36
65
|
|
|
37
|
-
|
|
66
|
+
## Configuration
|
|
38
67
|
|
|
39
|
-
|
|
68
|
+
A flag wins over its environment variable. Flags take a value as `--port 3000` or `--port=3000`.
|
|
40
69
|
|
|
41
|
-
|
|
70
|
+
| Flag | Environment variable | Default | What it does |
|
|
71
|
+
| --- | --- | --- | --- |
|
|
72
|
+
| `--port <n>` | `PORT` | `3543` | Port to listen on. Falls back to a random port if busy. |
|
|
73
|
+
| `--dir <path>` | `CLAUDE_CONFIG_DIR`, then `CLAUDE_DIR` | `~/.claude` | Claude config dir to read. |
|
|
74
|
+
| `--open` | | off | Open the dashboard in your browser. |
|
|
75
|
+
| `--host <addr>` | `HOST` | `127.0.0.1` | Address to bind. |
|
|
76
|
+
| `--allowed-hosts=<list>` | `ALLOWED_HOSTS` | empty | Extra host names to accept, on top of loopback names. |
|
|
77
|
+
| | `CLAUDE_BIN` | `claude` (`claude.exe` on Windows) | Claude Code executable for Plan usage. |
|
|
42
78
|
|
|
43
|
-
|
|
79
|
+
With a custom config dir, the server reads only `<dir>/projects`. With the default dir, it also reads `~/.config/claude/projects`.
|
|
44
80
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
--open Open browser on start
|
|
49
|
-
```
|
|
81
|
+
The server has no authentication. Bind a non-loopback address only on a network you trust. See [Configuration and CLI](https://nikiforovall.blog/claude-code-cost/reference/configuration/) for the network rules and the HTTP API.
|
|
82
|
+
|
|
83
|
+
## Documentation
|
|
50
84
|
|
|
51
|
-
|
|
85
|
+
- [Getting started](https://nikiforovall.blog/claude-code-cost/getting-started/)
|
|
86
|
+
- [Read the overview](https://nikiforovall.blog/claude-code-cost/guides/overview/)
|
|
87
|
+
- [Trace a project to a message](https://nikiforovall.blog/claude-code-cost/guides/sessions/)
|
|
88
|
+
- [Watch 5-hour blocks and burn rate](https://nikiforovall.blog/claude-code-cost/guides/insights/)
|
|
89
|
+
- [Choose a date range and project scope](https://nikiforovall.blog/claude-code-cost/guides/ranges-and-scope/)
|
|
90
|
+
- [How costs are computed](https://nikiforovall.blog/claude-code-cost/how-costs-are-computed/)
|
|
91
|
+
- [Keyboard shortcuts](https://nikiforovall.blog/claude-code-cost/reference/keyboard-shortcuts/)
|
|
92
|
+
- [Run inside Claude Code Hub](https://nikiforovall.blog/claude-code-cost/reference/claude-code-hub/)
|
|
93
|
+
- [Troubleshooting](https://nikiforovall.blog/claude-code-cost/reference/troubleshooting/)
|
|
52
94
|
|
|
53
95
|
## License
|
|
54
96
|
|
package/lib/net-guard.js
CHANGED
|
@@ -181,6 +181,16 @@ function createNetGuard(config = {}) {
|
|
|
181
181
|
return next();
|
|
182
182
|
}
|
|
183
183
|
|
|
184
|
+
// For a WebSocket upgrade, which originGuard must not judge: the handshake is a
|
|
185
|
+
// GET, and WebSocket has no CORS, so any page can open one. Browsers always send
|
|
186
|
+
// Origin on the handshake, so a missing or `null` one is refused, not trusted.
|
|
187
|
+
// Returns null when allowed, or the reason it was refused.
|
|
188
|
+
function upgradeVerdict(req) {
|
|
189
|
+
if (!hostAllowed(parseHostHeader(req.headers.host))) return 'unrecognized Host header';
|
|
190
|
+
if (originVerdict(req.headers.origin) !== true) return 'cross-origin or missing Origin';
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
|
|
184
194
|
// Constant for the life of the process, and frameGuard runs ahead of
|
|
185
195
|
// express.static — so this is built once rather than per asset fetch.
|
|
186
196
|
//
|
|
@@ -229,12 +239,19 @@ function createNetGuard(config = {}) {
|
|
|
229
239
|
* @param {any} app express app (or any http request handler)
|
|
230
240
|
* @param {number} port 0 selects a free port
|
|
231
241
|
* @param {(port: number) => void} [onReady]
|
|
232
|
-
*
|
|
242
|
+
* `onUpgrade` is attached to both servers; a caller that attached it to the
|
|
243
|
+
* returned one alone would drop every WebSocket that arrives over the other family.
|
|
244
|
+
*
|
|
245
|
+
* @param {{maxHeaderSize?: number, onUpgrade?: (req: any, socket: any, head: Buffer) => void}} [opts]
|
|
233
246
|
*/
|
|
234
247
|
function listenLoopback(app, port, onReady, opts = {}) {
|
|
235
248
|
const http = require('http');
|
|
236
249
|
const serverOpts = opts.maxHeaderSize ? { maxHeaderSize: opts.maxHeaderSize } : {};
|
|
237
|
-
const makeServer = (handler) =>
|
|
250
|
+
const makeServer = (handler) => {
|
|
251
|
+
const s = http.createServer(serverOpts, handler);
|
|
252
|
+
if (opts.onUpgrade) s.on('upgrade', opts.onUpgrade);
|
|
253
|
+
return s;
|
|
254
|
+
};
|
|
238
255
|
const server = makeServer(app);
|
|
239
256
|
let secondary = null;
|
|
240
257
|
|
|
@@ -261,7 +278,7 @@ function createNetGuard(config = {}) {
|
|
|
261
278
|
return `WARNING: listening on ${BIND_HOST} - reachable from your network, with no authentication.`;
|
|
262
279
|
}
|
|
263
280
|
|
|
264
|
-
return { BIND_HOST, ALLOWED_HOSTS, hostGuard, originGuard, frameGuard, listenLoopback, exposureWarning };
|
|
281
|
+
return { BIND_HOST, ALLOWED_HOSTS, EXPOSED, hostGuard, originGuard, upgradeVerdict, frameGuard, listenLoopback, exposureWarning };
|
|
265
282
|
}
|
|
266
283
|
|
|
267
284
|
module.exports = { createNetGuard, parseHostHeader, isLoopbackAddress };
|
package/package.json
CHANGED
package/public/app.js
CHANGED
|
@@ -494,7 +494,11 @@ async function fetchJSON(url, skipCache) {
|
|
|
494
494
|
if (cached) return cached;
|
|
495
495
|
}
|
|
496
496
|
const res = await fetch(url);
|
|
497
|
-
if (!res.ok)
|
|
497
|
+
if (!res.ok) {
|
|
498
|
+
const err = new Error(`HTTP ${res.status}`);
|
|
499
|
+
err.status = res.status;
|
|
500
|
+
throw err;
|
|
501
|
+
}
|
|
498
502
|
const data = await res.json();
|
|
499
503
|
dataFetchedAt = Date.now();
|
|
500
504
|
if (!skipCache) cacheData(url, data);
|
|
@@ -559,13 +563,51 @@ async function fetchSessionDetail(sessionId) {
|
|
|
559
563
|
|
|
560
564
|
// #endregion
|
|
561
565
|
|
|
566
|
+
// #region LOADING
|
|
567
|
+
|
|
568
|
+
const BOOT_VERBS = ['Clawding…', 'Counting tokens…', 'Tallying costs…', 'Pricing models…', 'Crunching sessions…'];
|
|
569
|
+
let booted = false;
|
|
570
|
+
|
|
571
|
+
const CLAWD_SVG = `<svg class="clawd" viewBox="1 0 16 10" shape-rendering="crispEdges">
|
|
572
|
+
<rect x="3" y="0" width="12" height="2"/><rect x="3" y="2" width="2" height="2"/>
|
|
573
|
+
<rect x="6" y="2" width="6" height="2"/><rect x="13" y="2" width="2" height="2"/>
|
|
574
|
+
<rect x="1" y="4" width="16" height="2"/><rect x="3" y="6" width="12" height="2"/>
|
|
575
|
+
<rect x="4" y="8" width="1" height="2"/><rect x="6" y="8" width="1" height="2"/>
|
|
576
|
+
<rect x="11" y="8" width="1" height="2"/><rect x="13" y="8" width="1" height="2"/>
|
|
577
|
+
</svg>`;
|
|
578
|
+
|
|
579
|
+
const SKEL_BARS = [35, 60, 45, 80, 55, 70, 40, 90, 65, 50, 75, 30];
|
|
580
|
+
|
|
581
|
+
function skeletonHtml(view) {
|
|
582
|
+
const line = '<span class="skel"></span>';
|
|
583
|
+
const cards = `<div class="cards-row">${'<div class="stat-card"><span class="skel card-label"></span><span class="skel card-value"></span><span class="skel card-sub"></span></div>'.repeat(4)}</div>`;
|
|
584
|
+
const plot = booted
|
|
585
|
+
? SKEL_BARS.map((h) => `<span class="skel" style="--h:${h}%"></span>`).join('')
|
|
586
|
+
: `<div class="clawd-boot">${CLAWD_SVG}<span>${BOOT_VERBS[Math.floor(Math.random() * BOOT_VERBS.length)]}</span></div>`;
|
|
587
|
+
const charts = `<div class="charts-row">
|
|
588
|
+
<div class="chart-box"><span class="skel chart-title"></span><div class="skel-plot">${plot}</div></div>
|
|
589
|
+
<div class="chart-box"><span class="skel chart-title"></span><div class="skel-donut"></div></div>
|
|
590
|
+
</div>`;
|
|
591
|
+
const table = `<div class="skel-table">${`<div>${line.repeat(4)}</div>`.repeat(6)}</div>`;
|
|
592
|
+
const head =
|
|
593
|
+
view === 'overview' || view === 'insights'
|
|
594
|
+
? `<div class="skel-tabs">${line.repeat(2)}</div>`
|
|
595
|
+
: `<div class="breadcrumb">${line}</div>`;
|
|
596
|
+
const body = view === 'sessions' ? charts + table : cards + charts + table;
|
|
597
|
+
// The first JS skeleton replaces the static one from index.html; fading it in again would blink.
|
|
598
|
+
const fade = booted ? ' skeleton-fade' : '';
|
|
599
|
+
return `<div class="dashboard-content skeleton${esc(fade)}" aria-busy="true" aria-label="Loading">${head}${body}</div>`;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
// #endregion
|
|
603
|
+
|
|
562
604
|
// #region RENDER_OVERVIEW
|
|
563
605
|
|
|
564
606
|
function renderOverview() {
|
|
565
607
|
const el = document.getElementById('overview-view');
|
|
566
608
|
if (!el) return;
|
|
567
609
|
if (!overviewData) {
|
|
568
|
-
el.innerHTML = '
|
|
610
|
+
el.innerHTML = skeletonHtml('overview');
|
|
569
611
|
return;
|
|
570
612
|
}
|
|
571
613
|
|
|
@@ -808,7 +850,7 @@ function renderInsights() {
|
|
|
808
850
|
const el = document.getElementById('insights-view');
|
|
809
851
|
if (!el) return;
|
|
810
852
|
if (!insightsData) {
|
|
811
|
-
el.innerHTML = '
|
|
853
|
+
el.innerHTML = skeletonHtml('insights');
|
|
812
854
|
return;
|
|
813
855
|
}
|
|
814
856
|
|
|
@@ -934,7 +976,7 @@ function renderSessions() {
|
|
|
934
976
|
const el = document.getElementById('sessions-view');
|
|
935
977
|
if (!el) return;
|
|
936
978
|
if (!sessionsData) {
|
|
937
|
-
el.innerHTML = '
|
|
979
|
+
el.innerHTML = skeletonHtml('sessions');
|
|
938
980
|
return;
|
|
939
981
|
}
|
|
940
982
|
|
|
@@ -1021,7 +1063,7 @@ function renderDetail() {
|
|
|
1021
1063
|
const el = document.getElementById('detail-view');
|
|
1022
1064
|
if (!el) return;
|
|
1023
1065
|
if (!sessionDetailData) {
|
|
1024
|
-
el.innerHTML = '
|
|
1066
|
+
el.innerHTML = skeletonHtml('detail');
|
|
1025
1067
|
return;
|
|
1026
1068
|
}
|
|
1027
1069
|
|
|
@@ -1112,7 +1154,7 @@ function renderDetail() {
|
|
|
1112
1154
|
destroyChart('cumulative');
|
|
1113
1155
|
destroyChart('tokenBreakdown');
|
|
1114
1156
|
applyDetailRange(d.messages, detailRangeFor(d));
|
|
1115
|
-
initRangeBrush(d.messages);
|
|
1157
|
+
initRangeBrush(d.messages, d.workflows);
|
|
1116
1158
|
});
|
|
1117
1159
|
}
|
|
1118
1160
|
|
|
@@ -1726,6 +1768,7 @@ function rangeBrushHtml(total) {
|
|
|
1726
1768
|
<div class="rb-track" tabindex="0" role="slider" aria-label="Visible message range"
|
|
1727
1769
|
aria-valuemin="1" aria-valuemax="${esc(total)}">
|
|
1728
1770
|
${rangeOverviewSvg}
|
|
1771
|
+
<div class="rb-spans"></div>
|
|
1729
1772
|
<div class="rb-bursts"></div>
|
|
1730
1773
|
<div class="rb-window">
|
|
1731
1774
|
<div class="rb-handle rb-handle-left" data-edge="start"></div>
|
|
@@ -1740,7 +1783,7 @@ function rangeBrushHtml(total) {
|
|
|
1740
1783
|
const rangeOverviewSvg =
|
|
1741
1784
|
'<svg class="rb-overview" viewBox="0 0 1000 100" preserveAspectRatio="none" aria-hidden="true"><polygon /><polyline /></svg>';
|
|
1742
1785
|
|
|
1743
|
-
function initRangeBrush(messages) {
|
|
1786
|
+
function initRangeBrush(messages, workflows) {
|
|
1744
1787
|
const root = document.getElementById('rangeBrush');
|
|
1745
1788
|
if (!root) return;
|
|
1746
1789
|
const total = messages.length;
|
|
@@ -1757,6 +1800,16 @@ function initRangeBrush(messages) {
|
|
|
1757
1800
|
|
|
1758
1801
|
drawRangeOverview(q('.rb-overview'), messages);
|
|
1759
1802
|
|
|
1803
|
+
const runs = workflows || [];
|
|
1804
|
+
q('.rb-spans').innerHTML = runs
|
|
1805
|
+
.map((w) => {
|
|
1806
|
+
const left = ((w.startIndex - 1) / total) * 100;
|
|
1807
|
+
const width = Math.max(((w.endIndex - w.startIndex + 1) / total) * 100, 0.6);
|
|
1808
|
+
const tip = `${w.name} · ${w.agents} agent${w.agents === 1 ? '' : 's'} · ${formatCost(w.totalCost)}`;
|
|
1809
|
+
return `<span class="rb-span" style="left:${left}%;width:${width}%" title="${esc(tip)}"><i>${esc(w.name)}</i></span>`;
|
|
1810
|
+
})
|
|
1811
|
+
.join('');
|
|
1812
|
+
|
|
1760
1813
|
const markers = notableEvents(messages);
|
|
1761
1814
|
const burstsEl = q('.rb-bursts');
|
|
1762
1815
|
burstsEl.innerHTML = markers
|
|
@@ -1767,12 +1820,12 @@ function initRangeBrush(messages) {
|
|
|
1767
1820
|
.join('');
|
|
1768
1821
|
const burstEls = [...burstsEl.children].map((el, k) => ({ el, i: markers[k].i }));
|
|
1769
1822
|
const counts = [
|
|
1770
|
-
['burst', 'cache burst', ''],
|
|
1771
|
-
['compaction', 'compaction', ' class="compact"'],
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1823
|
+
[markers.filter((k) => k.kind === 'burst').length, 'cache burst', ''],
|
|
1824
|
+
[markers.filter((k) => k.kind === 'compaction').length, 'compaction', ' class="compact"'],
|
|
1825
|
+
[runs.length, 'workflow', ' class="workflow"'],
|
|
1826
|
+
]
|
|
1827
|
+
.filter(([n]) => n)
|
|
1828
|
+
.map(([n, label, attr]) => `<span${attr}><i></i>${n} ${label}${n === 1 ? '' : 's'}</span>`);
|
|
1776
1829
|
if (counts.length) {
|
|
1777
1830
|
burstCount.hidden = false;
|
|
1778
1831
|
burstCount.innerHTML = counts.join('<span class="rb-sep">·</span>');
|
|
@@ -2574,7 +2627,7 @@ async function loadAndRender(view) {
|
|
|
2574
2627
|
if (viewEl) {
|
|
2575
2628
|
const hasContent = viewEl.querySelector('.dashboard-content');
|
|
2576
2629
|
if (!hasContent) {
|
|
2577
|
-
viewEl.innerHTML =
|
|
2630
|
+
viewEl.innerHTML = skeletonHtml(view);
|
|
2578
2631
|
}
|
|
2579
2632
|
}
|
|
2580
2633
|
|
|
@@ -2617,9 +2670,20 @@ async function loadAndRender(view) {
|
|
|
2617
2670
|
} catch (err) {
|
|
2618
2671
|
if (myNav !== navCounter) return;
|
|
2619
2672
|
console.error(`Failed to load ${view}:`, err);
|
|
2673
|
+
// The cursor is restored from sessionStorage when the iframe reloads with no query, so a
|
|
2674
|
+
// config-dir switch leaves it pointing at a session the new dir never had. A 404 there is a
|
|
2675
|
+
// stale cursor, not a broken app: drop it and land on the overview.
|
|
2676
|
+
if (err.status === 404 && view === 'detail') {
|
|
2677
|
+
sessionDetailData = null;
|
|
2678
|
+
showToast('Not in this config dir — showing overview');
|
|
2679
|
+
await navigate('overview');
|
|
2680
|
+
return;
|
|
2681
|
+
}
|
|
2620
2682
|
showToast(`Error: ${err.message}`);
|
|
2621
2683
|
const viewEl = document.getElementById(`${view}-view`);
|
|
2622
2684
|
if (viewEl) viewEl.innerHTML = `<div class="loading-state"><span>Failed to load data: ${err.message}</span></div>`;
|
|
2685
|
+
} finally {
|
|
2686
|
+
if (myNav === navCounter) booted = true;
|
|
2623
2687
|
}
|
|
2624
2688
|
}
|
|
2625
2689
|
|
|
@@ -2734,6 +2798,20 @@ function initProjectPicker() {
|
|
|
2734
2798
|
pickProject(pickerIdx);
|
|
2735
2799
|
}
|
|
2736
2800
|
});
|
|
2801
|
+
// Vimium eats Escape inside a text input and only blurs it, so the page never sees the key.
|
|
2802
|
+
// A blur that no click in the picker caused, while the window keeps focus and the input is
|
|
2803
|
+
// still shown, is that Escape.
|
|
2804
|
+
const modal = document.getElementById('projectPickerModal');
|
|
2805
|
+
let pointerDown = false;
|
|
2806
|
+
modal.addEventListener('mousedown', () => {
|
|
2807
|
+
pointerDown = true;
|
|
2808
|
+
});
|
|
2809
|
+
document.addEventListener('mouseup', () => {
|
|
2810
|
+
pointerDown = false;
|
|
2811
|
+
});
|
|
2812
|
+
input.addEventListener('blur', () => {
|
|
2813
|
+
if (!pointerDown && document.hasFocus() && input.checkVisibility()) closeProjectPicker();
|
|
2814
|
+
});
|
|
2737
2815
|
}
|
|
2738
2816
|
|
|
2739
2817
|
// Each entry pairs a left and a right group onto the same grid rows, so their
|
|
@@ -3043,7 +3121,7 @@ function renderLimits() {
|
|
|
3043
3121
|
binding: false,
|
|
3044
3122
|
})
|
|
3045
3123
|
: `<p class="modal-note">Disabled${spend.disabledReason ? ` · ${esc(spend.disabledReason)}` : ''}. Nothing covers you past the plan limits.</p>`
|
|
3046
|
-
}
|
|
3124
|
+
}
|
|
3047
3125
|
</div>`
|
|
3048
3126
|
: ''
|
|
3049
3127
|
}
|
|
@@ -3283,21 +3361,24 @@ async function refreshIfStale() {
|
|
|
3283
3361
|
|
|
3284
3362
|
window.__HUB__ = cfg;
|
|
3285
3363
|
|
|
3364
|
+
// e.code travels with e.key because macOS composes Option+<key> into a character (Option+P is
|
|
3365
|
+
// 'π'), so the key alone cannot identify the binding. The hub owns the keymap and normalizes;
|
|
3366
|
+
// these tests only decide whether a press is the hub's to handle.
|
|
3286
3367
|
document.addEventListener('keydown', (e) => {
|
|
3287
|
-
const fwd = (
|
|
3368
|
+
const fwd = () => {
|
|
3288
3369
|
e.preventDefault();
|
|
3289
|
-
hubPost({ type: 'hub:keydown', key, ctrl: e.ctrlKey, alt: e.altKey, shift: e.shiftKey });
|
|
3370
|
+
hubPost({ type: 'hub:keydown', key: e.key, code: e.code, ctrl: e.ctrlKey, alt: e.altKey, shift: e.shiftKey });
|
|
3290
3371
|
};
|
|
3291
3372
|
if (e.ctrlKey && e.altKey && (e.key === 'ArrowLeft' || e.key === 'ArrowRight')) {
|
|
3292
|
-
fwd(
|
|
3373
|
+
fwd();
|
|
3293
3374
|
}
|
|
3294
3375
|
// Own branch: the Alt+digit case below requires !ctrlKey. The hub owns the Ctrl+Alt+letter
|
|
3295
3376
|
// keymap and ignores unbound letters.
|
|
3296
|
-
if (e.ctrlKey && e.altKey && !e.shiftKey && !e.metaKey && /^[a-z]$/i.test(e.key)) {
|
|
3297
|
-
fwd(
|
|
3377
|
+
if (e.ctrlKey && e.altKey && !e.shiftKey && !e.metaKey && (/^[a-z]$/i.test(e.key) || /^Key[A-Z]$/.test(e.code))) {
|
|
3378
|
+
fwd();
|
|
3298
3379
|
}
|
|
3299
|
-
if (e.altKey && !e.ctrlKey && !e.shiftKey && !e.metaKey && /^[1-9]$/.test(e.key)) {
|
|
3300
|
-
fwd(
|
|
3380
|
+
if (e.altKey && !e.ctrlKey && !e.shiftKey && !e.metaKey && (/^[1-9]$/.test(e.key) || /^Digit[1-9]$/.test(e.code))) {
|
|
3381
|
+
fwd();
|
|
3301
3382
|
}
|
|
3302
3383
|
});
|
|
3303
3384
|
})();
|
package/public/index.html
CHANGED
|
@@ -145,9 +145,40 @@
|
|
|
145
145
|
</div>
|
|
146
146
|
|
|
147
147
|
<div class="dashboard" id="app">
|
|
148
|
-
<div class="
|
|
149
|
-
<div class="
|
|
150
|
-
<
|
|
148
|
+
<div class="dashboard-content skeleton skeleton-fade" id="loadingState" aria-busy="true" aria-label="Loading">
|
|
149
|
+
<div class="skel-tabs"><span class="skel"></span><span class="skel"></span></div>
|
|
150
|
+
<div class="cards-row">
|
|
151
|
+
<div class="stat-card"><span class="skel card-label"></span><span class="skel card-value"></span><span class="skel card-sub"></span></div>
|
|
152
|
+
<div class="stat-card"><span class="skel card-label"></span><span class="skel card-value"></span><span class="skel card-sub"></span></div>
|
|
153
|
+
<div class="stat-card"><span class="skel card-label"></span><span class="skel card-value"></span><span class="skel card-sub"></span></div>
|
|
154
|
+
<div class="stat-card"><span class="skel card-label"></span><span class="skel card-value"></span><span class="skel card-sub"></span></div>
|
|
155
|
+
</div>
|
|
156
|
+
<div class="charts-row">
|
|
157
|
+
<div class="chart-box">
|
|
158
|
+
<span class="skel chart-title"></span>
|
|
159
|
+
<div class="skel-plot">
|
|
160
|
+
<div class="clawd-boot">
|
|
161
|
+
<svg class="clawd" viewBox="1 0 16 10" shape-rendering="crispEdges">
|
|
162
|
+
<rect x="3" y="0" width="12" height="2"/><rect x="3" y="2" width="2" height="2"/>
|
|
163
|
+
<rect x="6" y="2" width="6" height="2"/><rect x="13" y="2" width="2" height="2"/>
|
|
164
|
+
<rect x="1" y="4" width="16" height="2"/><rect x="3" y="6" width="12" height="2"/>
|
|
165
|
+
<rect x="4" y="8" width="1" height="2"/><rect x="6" y="8" width="1" height="2"/>
|
|
166
|
+
<rect x="11" y="8" width="1" height="2"/><rect x="13" y="8" width="1" height="2"/>
|
|
167
|
+
</svg>
|
|
168
|
+
<span>Clawding…</span>
|
|
169
|
+
</div>
|
|
170
|
+
</div>
|
|
171
|
+
</div>
|
|
172
|
+
<div class="chart-box"><span class="skel chart-title"></span><div class="skel-donut"></div></div>
|
|
173
|
+
</div>
|
|
174
|
+
<div class="skel-table">
|
|
175
|
+
<div><span class="skel"></span><span class="skel"></span><span class="skel"></span><span class="skel"></span></div>
|
|
176
|
+
<div><span class="skel"></span><span class="skel"></span><span class="skel"></span><span class="skel"></span></div>
|
|
177
|
+
<div><span class="skel"></span><span class="skel"></span><span class="skel"></span><span class="skel"></span></div>
|
|
178
|
+
<div><span class="skel"></span><span class="skel"></span><span class="skel"></span><span class="skel"></span></div>
|
|
179
|
+
<div><span class="skel"></span><span class="skel"></span><span class="skel"></span><span class="skel"></span></div>
|
|
180
|
+
<div><span class="skel"></span><span class="skel"></span><span class="skel"></span><span class="skel"></span></div>
|
|
181
|
+
</div>
|
|
151
182
|
</div>
|
|
152
183
|
</div>
|
|
153
184
|
|
package/public/style.css
CHANGED
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
--chart-5: #b784f5;
|
|
31
31
|
--chart-6: #fb7185;
|
|
32
32
|
--compact: var(--chart-5);
|
|
33
|
+
--workflow: var(--chart-2);
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
/* #endregion */
|
|
@@ -842,6 +843,15 @@ body {
|
|
|
842
843
|
color: var(--compact);
|
|
843
844
|
}
|
|
844
845
|
|
|
846
|
+
.rb-burst-count .workflow {
|
|
847
|
+
color: var(--workflow);
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
.rb-burst-count .workflow i {
|
|
851
|
+
border-radius: 1px;
|
|
852
|
+
background: var(--workflow);
|
|
853
|
+
}
|
|
854
|
+
|
|
845
855
|
.rb-burst-count .compact i,
|
|
846
856
|
.rb-burst.compact::after {
|
|
847
857
|
border-radius: 1px;
|
|
@@ -919,12 +929,38 @@ body {
|
|
|
919
929
|
vector-effect: non-scaling-stroke;
|
|
920
930
|
}
|
|
921
931
|
|
|
922
|
-
.rb-bursts
|
|
932
|
+
.rb-bursts,
|
|
933
|
+
.rb-spans {
|
|
923
934
|
position: absolute;
|
|
924
935
|
inset: 0;
|
|
925
936
|
pointer-events: none;
|
|
926
937
|
}
|
|
927
938
|
|
|
939
|
+
.rb-span {
|
|
940
|
+
position: absolute;
|
|
941
|
+
top: 0;
|
|
942
|
+
bottom: 0;
|
|
943
|
+
background: color-mix(in srgb, var(--workflow) 16%, transparent);
|
|
944
|
+
border-left: 1px solid var(--workflow);
|
|
945
|
+
border-right: 1px solid var(--workflow);
|
|
946
|
+
pointer-events: auto;
|
|
947
|
+
overflow: hidden;
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
.rb-span i {
|
|
951
|
+
position: absolute;
|
|
952
|
+
bottom: 2px;
|
|
953
|
+
left: 3px;
|
|
954
|
+
right: 2px;
|
|
955
|
+
font-size: 9px;
|
|
956
|
+
font-style: normal;
|
|
957
|
+
letter-spacing: 0.03em;
|
|
958
|
+
color: var(--workflow);
|
|
959
|
+
white-space: nowrap;
|
|
960
|
+
overflow: hidden;
|
|
961
|
+
text-overflow: ellipsis;
|
|
962
|
+
}
|
|
963
|
+
|
|
928
964
|
.rb-burst {
|
|
929
965
|
position: absolute;
|
|
930
966
|
top: 0;
|
|
@@ -1310,6 +1346,160 @@ body.light .rb-window {
|
|
|
1310
1346
|
animation: spin 0.8s linear infinite;
|
|
1311
1347
|
}
|
|
1312
1348
|
|
|
1349
|
+
.skeleton-fade {
|
|
1350
|
+
animation: boot-fade 0.3s ease-out 0.15s both;
|
|
1351
|
+
}
|
|
1352
|
+
|
|
1353
|
+
.skeleton .breadcrumb .skel {
|
|
1354
|
+
width: 220px;
|
|
1355
|
+
}
|
|
1356
|
+
|
|
1357
|
+
.skel {
|
|
1358
|
+
display: block;
|
|
1359
|
+
height: 9px;
|
|
1360
|
+
width: 60%;
|
|
1361
|
+
border-radius: 4px;
|
|
1362
|
+
background: var(--border);
|
|
1363
|
+
animation: skel-breathe 1.4s ease-in-out infinite;
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1366
|
+
.skeleton .card-label.skel {
|
|
1367
|
+
width: 40%;
|
|
1368
|
+
}
|
|
1369
|
+
|
|
1370
|
+
.skeleton .card-value.skel {
|
|
1371
|
+
height: 22px;
|
|
1372
|
+
width: 55%;
|
|
1373
|
+
}
|
|
1374
|
+
|
|
1375
|
+
.skeleton .card-sub.skel {
|
|
1376
|
+
width: 70%;
|
|
1377
|
+
margin-top: 14px;
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1380
|
+
.skeleton .chart-title.skel {
|
|
1381
|
+
width: 30%;
|
|
1382
|
+
}
|
|
1383
|
+
|
|
1384
|
+
.skel-tabs {
|
|
1385
|
+
display: flex;
|
|
1386
|
+
gap: 16px;
|
|
1387
|
+
padding: 10px 4px 14px;
|
|
1388
|
+
margin-bottom: 16px;
|
|
1389
|
+
border-bottom: 1px solid var(--border);
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1392
|
+
.skel-tabs .skel {
|
|
1393
|
+
width: 70px;
|
|
1394
|
+
}
|
|
1395
|
+
|
|
1396
|
+
.skel-plot {
|
|
1397
|
+
position: relative;
|
|
1398
|
+
display: flex;
|
|
1399
|
+
align-items: flex-end;
|
|
1400
|
+
gap: 6px;
|
|
1401
|
+
height: 150px;
|
|
1402
|
+
}
|
|
1403
|
+
|
|
1404
|
+
.skel-plot > .skel {
|
|
1405
|
+
flex: 1;
|
|
1406
|
+
height: var(--h);
|
|
1407
|
+
width: auto;
|
|
1408
|
+
border-radius: 3px 3px 0 0;
|
|
1409
|
+
}
|
|
1410
|
+
|
|
1411
|
+
.skel-plot .clawd-boot {
|
|
1412
|
+
position: absolute;
|
|
1413
|
+
inset: 0;
|
|
1414
|
+
}
|
|
1415
|
+
|
|
1416
|
+
.skel-donut {
|
|
1417
|
+
width: 130px;
|
|
1418
|
+
height: 130px;
|
|
1419
|
+
margin: 10px auto;
|
|
1420
|
+
border-radius: 50%;
|
|
1421
|
+
border: 18px solid var(--border);
|
|
1422
|
+
animation: skel-breathe 1.4s ease-in-out infinite;
|
|
1423
|
+
}
|
|
1424
|
+
|
|
1425
|
+
.skel-table {
|
|
1426
|
+
display: flex;
|
|
1427
|
+
flex-direction: column;
|
|
1428
|
+
}
|
|
1429
|
+
|
|
1430
|
+
.skel-table > div {
|
|
1431
|
+
display: flex;
|
|
1432
|
+
gap: 24px;
|
|
1433
|
+
padding: 16px 12px;
|
|
1434
|
+
border-bottom: 1px solid var(--border);
|
|
1435
|
+
}
|
|
1436
|
+
|
|
1437
|
+
.skel-table .skel:first-child {
|
|
1438
|
+
width: 40%;
|
|
1439
|
+
}
|
|
1440
|
+
|
|
1441
|
+
.skel-table .skel {
|
|
1442
|
+
width: 12%;
|
|
1443
|
+
}
|
|
1444
|
+
|
|
1445
|
+
.clawd-boot {
|
|
1446
|
+
display: flex;
|
|
1447
|
+
flex-direction: column;
|
|
1448
|
+
align-items: center;
|
|
1449
|
+
justify-content: center;
|
|
1450
|
+
gap: 12px;
|
|
1451
|
+
color: var(--text-muted);
|
|
1452
|
+
font-size: 12px;
|
|
1453
|
+
}
|
|
1454
|
+
|
|
1455
|
+
.clawd {
|
|
1456
|
+
width: 64px;
|
|
1457
|
+
height: 40px;
|
|
1458
|
+
fill: #d97757;
|
|
1459
|
+
overflow: visible;
|
|
1460
|
+
transform-origin: 50% 100%;
|
|
1461
|
+
animation: clawd-jump 0.9s ease-in-out infinite;
|
|
1462
|
+
}
|
|
1463
|
+
|
|
1464
|
+
@keyframes skel-breathe {
|
|
1465
|
+
50% {
|
|
1466
|
+
opacity: 0.55;
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
|
|
1470
|
+
@keyframes boot-fade {
|
|
1471
|
+
from {
|
|
1472
|
+
opacity: 0;
|
|
1473
|
+
}
|
|
1474
|
+
}
|
|
1475
|
+
|
|
1476
|
+
@keyframes clawd-jump {
|
|
1477
|
+
0%,
|
|
1478
|
+
100% {
|
|
1479
|
+
transform: translateY(0) scale(1, 1);
|
|
1480
|
+
}
|
|
1481
|
+
15% {
|
|
1482
|
+
transform: translateY(0) scale(1.1, 0.85);
|
|
1483
|
+
}
|
|
1484
|
+
45% {
|
|
1485
|
+
transform: translateY(-14px) scale(0.95, 1.05);
|
|
1486
|
+
}
|
|
1487
|
+
70% {
|
|
1488
|
+
transform: translateY(0) scale(1.08, 0.9);
|
|
1489
|
+
}
|
|
1490
|
+
85% {
|
|
1491
|
+
transform: translateY(0) scale(1, 1);
|
|
1492
|
+
}
|
|
1493
|
+
}
|
|
1494
|
+
|
|
1495
|
+
@media (prefers-reduced-motion: reduce) {
|
|
1496
|
+
.skel,
|
|
1497
|
+
.skel-donut,
|
|
1498
|
+
.clawd {
|
|
1499
|
+
animation: none;
|
|
1500
|
+
}
|
|
1501
|
+
}
|
|
1502
|
+
|
|
1313
1503
|
.empty-state {
|
|
1314
1504
|
display: flex;
|
|
1315
1505
|
flex-direction: column;
|
|
@@ -2002,7 +2192,7 @@ body.light {
|
|
|
2002
2192
|
--text-secondary: #444444;
|
|
2003
2193
|
--text-tertiary: #666666;
|
|
2004
2194
|
--text-muted: #888888;
|
|
2005
|
-
--accent-text: #
|
|
2195
|
+
--accent-text: #a0501c;
|
|
2006
2196
|
--accent-dim: rgba(232, 111, 51, 0.18);
|
|
2007
2197
|
--accent-glow: rgba(232, 111, 51, 0.5);
|
|
2008
2198
|
--chart-fill: rgba(232, 111, 51, 0.28);
|
package/public/themes.css
CHANGED
|
@@ -11,18 +11,18 @@ body.light .theme-swatch-gruvbox { --sw-bg: #f3eee0; --sw-accent: #d65d0e; --sw-
|
|
|
11
11
|
body.light .theme-swatch-catppuccin { --sw-bg: #eff1f5; --sw-accent: #8839ef; --sw-ink: #4c4f69; --sw-border: #bcc0cc; }
|
|
12
12
|
.theme-swatch-tokyo-night { --sw-bg: #1a1b26; --sw-accent: #7aa2f7; --sw-ink: #c0caf5; --sw-border: #3b4261; }
|
|
13
13
|
body.light .theme-swatch-tokyo-night { --sw-bg: #e9eaf0; --sw-accent: #2e7de9; --sw-ink: #343b58; --sw-border: #a8aecb; }
|
|
14
|
-
.theme-swatch-solarized { --sw-bg: #073642; --sw-accent: #
|
|
15
|
-
body.light .theme-swatch-solarized { --sw-bg: #
|
|
14
|
+
.theme-swatch-solarized { --sw-bg: #073642; --sw-accent: #c96f47; --sw-ink: #e2dfd0; --sw-border: #586e75; }
|
|
15
|
+
body.light .theme-swatch-solarized { --sw-bg: #fdf6e3; --sw-accent: #2280c2; --sw-ink: #073642; --sw-border: #cdc4ab; }
|
|
16
16
|
.theme-swatch-dracula { --sw-bg: #282a36; --sw-accent: #bd93f9; --sw-ink: #f8f8f2; --sw-border: #565a75; }
|
|
17
17
|
body.light .theme-swatch-dracula { --sw-bg: #f0f0f5; --sw-accent: #7c3aed; --sw-ink: #16161e; --sw-border: #c9c9d6; }
|
|
18
18
|
.theme-swatch-nord { --sw-bg: #2e3440; --sw-accent: #88c0d0; --sw-ink: #eceff4; --sw-border: #4c566a; }
|
|
19
19
|
body.light .theme-swatch-nord { --sw-bg: #eceff4; --sw-accent: #5e81ac; --sw-ink: #2e3440; --sw-border: #c2c9d6; }
|
|
20
20
|
.theme-swatch-rose-pine { --sw-bg: #1f1d2e; --sw-accent: #c4a7e7; --sw-ink: #e0def4; --sw-border: #403d52; }
|
|
21
|
-
body.light .theme-swatch-rose-pine { --sw-bg: #faf4ed; --sw-accent: #907aa9; --sw-ink: #575279; --sw-border: #
|
|
21
|
+
body.light .theme-swatch-rose-pine { --sw-bg: #faf4ed; --sw-accent: #907aa9; --sw-ink: #575279; --sw-border: #cecacd; }
|
|
22
22
|
.theme-swatch-everforest { --sw-bg: #2d353b; --sw-accent: #a7c080; --sw-ink: #d3c6aa; --sw-border: #475258; }
|
|
23
|
-
body.light .theme-swatch-everforest { --sw-bg: #
|
|
23
|
+
body.light .theme-swatch-everforest { --sw-bg: #f5f4e8; --sw-accent: #6f8352; --sw-ink: #3d484e; --sw-border: #d3d2bf; }
|
|
24
24
|
.theme-swatch-kanagawa { --sw-bg: #1f1f28; --sw-accent: #7e9cd8; --sw-ink: #dcd7ba; --sw-border: #54546d; }
|
|
25
|
-
body.light .theme-swatch-kanagawa { --sw-bg: #
|
|
25
|
+
body.light .theme-swatch-kanagawa { --sw-bg: #f3f0e4; --sw-accent: #4d699b; --sw-ink: #545464; --sw-border: #d2ccb6; }
|
|
26
26
|
.theme-swatch-one-dark { --sw-bg: #282c34; --sw-accent: #61afef; --sw-ink: #d7dae0; --sw-border: #4b5263; }
|
|
27
27
|
body.light .theme-swatch-one-dark { --sw-bg: #fafafa; --sw-accent: #4078f2; --sw-ink: #383a42; --sw-border: #d4d4d6; }
|
|
28
28
|
.theme-swatch-night-owl { --sw-bg: #0b2942; --sw-accent: #82aaff; --sw-ink: #d6deeb; --sw-border: #5f7e97; }
|
|
@@ -32,7 +32,7 @@ body.light .theme-swatch-monokai { --sw-bg: #f1efed; --sw-accent: #c08a00; --sw-
|
|
|
32
32
|
.theme-swatch-github { --sw-bg: #24292e; --sw-accent: #58a6ff; --sw-ink: #e1e4e8; --sw-border: #444d56; }
|
|
33
33
|
body.light .theme-swatch-github { --sw-bg: #f6f8fa; --sw-accent: #0366d6; --sw-ink: #24292e; --sw-border: #d1d5da; }
|
|
34
34
|
.theme-swatch-ayu { --sw-bg: #10141c; --sw-accent: #e6b450; --sw-ink: #bfbdb6; --sw-border: #2d3343; }
|
|
35
|
-
body.light .theme-swatch-ayu { --sw-bg: #f8f9fa; --sw-accent: #
|
|
35
|
+
body.light .theme-swatch-ayu { --sw-bg: #f8f9fa; --sw-accent: #c97612; --sw-ink: #3d4149; --sw-border: #d8dde2; }
|
|
36
36
|
.theme-swatch-vitesse { --sw-bg: #181818; --sw-accent: #4d9375; --sw-ink: #dbd7ca; --sw-border: #333333; }
|
|
37
37
|
body.light .theme-swatch-vitesse { --sw-bg: #f7f7f7; --sw-accent: #1c6b48; --sw-ink: #393a34; --sw-border: #d6d6d6; }
|
|
38
38
|
.theme-swatch-synthwave { --sw-bg: #262335; --sw-accent: #ff7edb; --sw-ink: #ffffff; --sw-border: #495495; }
|
|
@@ -54,7 +54,6 @@ body[data-color-theme="gruvbox"]:not(.light) {
|
|
|
54
54
|
--text-tertiary: #bdae93;
|
|
55
55
|
--text-muted: #928374;
|
|
56
56
|
--chart-fill: rgba(254, 128, 25, 0.32);
|
|
57
|
-
--chart-1: #fe8019;
|
|
58
57
|
}
|
|
59
58
|
body.light[data-color-theme="gruvbox"] {
|
|
60
59
|
--accent: #d65d0e;
|
|
@@ -71,7 +70,6 @@ body.light[data-color-theme="gruvbox"] {
|
|
|
71
70
|
--text-tertiary: #665c54;
|
|
72
71
|
--text-muted: #7c6f64;
|
|
73
72
|
--chart-fill: rgba(214, 93, 14, 0.32);
|
|
74
|
-
--chart-1: #d65d0e;
|
|
75
73
|
}
|
|
76
74
|
|
|
77
75
|
/* Catppuccin */
|
|
@@ -90,7 +88,6 @@ body[data-color-theme="catppuccin"]:not(.light) {
|
|
|
90
88
|
--text-tertiary: #a6adc8;
|
|
91
89
|
--text-muted: #7f849c;
|
|
92
90
|
--chart-fill: rgba(203, 166, 247, 0.32);
|
|
93
|
-
--chart-1: #cba6f7;
|
|
94
91
|
}
|
|
95
92
|
body.light[data-color-theme="catppuccin"] {
|
|
96
93
|
--accent: #8839ef;
|
|
@@ -107,7 +104,6 @@ body.light[data-color-theme="catppuccin"] {
|
|
|
107
104
|
--text-tertiary: #6c6f85;
|
|
108
105
|
--text-muted: #8c8fa1;
|
|
109
106
|
--chart-fill: rgba(136, 57, 239, 0.32);
|
|
110
|
-
--chart-1: #8839ef;
|
|
111
107
|
}
|
|
112
108
|
|
|
113
109
|
/* Tokyo Night */
|
|
@@ -126,7 +122,6 @@ body[data-color-theme="tokyo-night"]:not(.light) {
|
|
|
126
122
|
--text-tertiary: #787c99;
|
|
127
123
|
--text-muted: #565f89;
|
|
128
124
|
--chart-fill: rgba(122, 162, 247, 0.32);
|
|
129
|
-
--chart-1: #7aa2f7;
|
|
130
125
|
}
|
|
131
126
|
body.light[data-color-theme="tokyo-night"] {
|
|
132
127
|
--accent: #2e7de9;
|
|
@@ -143,43 +138,42 @@ body.light[data-color-theme="tokyo-night"] {
|
|
|
143
138
|
--text-tertiary: #6c6e75;
|
|
144
139
|
--text-muted: #848cb5;
|
|
145
140
|
--chart-fill: rgba(46, 125, 233, 0.32);
|
|
146
|
-
--chart-1: #2e7de9;
|
|
147
141
|
}
|
|
148
142
|
|
|
149
143
|
/* Solarized */
|
|
150
144
|
body[data-color-theme="solarized"]:not(.light) {
|
|
151
|
-
--accent: #
|
|
152
|
-
--accent-text: #
|
|
153
|
-
--accent-dim: rgba(
|
|
154
|
-
--accent-glow: rgba(
|
|
145
|
+
--accent: #c96f47;
|
|
146
|
+
--accent-text: #d48a6a;
|
|
147
|
+
--accent-dim: rgba(201,111,71,0.25);
|
|
148
|
+
--accent-glow: rgba(201, 111, 71, 0.55);
|
|
155
149
|
--bg-deep: #002b36;
|
|
156
150
|
--bg-surface: #073642;
|
|
157
151
|
--bg-elevated: #0a4250;
|
|
158
152
|
--bg-hover: #11505f;
|
|
159
153
|
--border: #586e75;
|
|
160
|
-
--text-primary: #
|
|
161
|
-
--text-secondary: #
|
|
162
|
-
--text-tertiary: #
|
|
163
|
-
--text-muted: #
|
|
164
|
-
--chart-fill: rgba(
|
|
165
|
-
--chart-1: #cb4b16;
|
|
154
|
+
--text-primary: #e2dfd0;
|
|
155
|
+
--text-secondary: #b7c0bf;
|
|
156
|
+
--text-tertiary: #93a1a1;
|
|
157
|
+
--text-muted: #839496;
|
|
158
|
+
--chart-fill: rgba(201, 111, 71, 0.32);
|
|
166
159
|
}
|
|
167
160
|
body.light[data-color-theme="solarized"] {
|
|
168
|
-
--accent: #
|
|
169
|
-
--accent-text: #
|
|
170
|
-
--accent-dim: rgba(
|
|
171
|
-
--accent-glow: rgba(
|
|
161
|
+
--accent: #2280c2;
|
|
162
|
+
--accent-text: #1b6aa3;
|
|
163
|
+
--accent-dim: rgba(34,128,194,0.18);
|
|
164
|
+
--accent-glow: rgba(34, 128, 194, 0.5);
|
|
172
165
|
--bg-deep: #eee8d5;
|
|
173
|
-
--bg-surface: #
|
|
174
|
-
--bg-elevated: #
|
|
175
|
-
--bg-hover: #
|
|
176
|
-
--border: #
|
|
166
|
+
--bg-surface: #fdf6e3;
|
|
167
|
+
--bg-elevated: #fffbef;
|
|
168
|
+
--bg-hover: #efe8d3;
|
|
169
|
+
--border: #cdc4ab;
|
|
177
170
|
--text-primary: #073642;
|
|
178
|
-
--text-secondary: #
|
|
179
|
-
--text-tertiary: #
|
|
180
|
-
--text-muted: #
|
|
181
|
-
--
|
|
182
|
-
--
|
|
171
|
+
--text-secondary: #4f6369;
|
|
172
|
+
--text-tertiary: #586e75;
|
|
173
|
+
--text-muted: #728589;
|
|
174
|
+
--sidebar-bg: #e6dfc7;
|
|
175
|
+
--sidebar-item-bg: #f3ecd6;
|
|
176
|
+
--chart-fill: rgba(34, 128, 194, 0.32);
|
|
183
177
|
}
|
|
184
178
|
|
|
185
179
|
/* Dracula */
|
|
@@ -198,7 +192,6 @@ body[data-color-theme="dracula"]:not(.light) {
|
|
|
198
192
|
--text-tertiary: #b0b3c5;
|
|
199
193
|
--text-muted: #6272a4;
|
|
200
194
|
--chart-fill: rgba(189, 147, 249, 0.32);
|
|
201
|
-
--chart-1: #bd93f9;
|
|
202
195
|
}
|
|
203
196
|
body.light[data-color-theme="dracula"] {
|
|
204
197
|
--accent: #7c3aed;
|
|
@@ -215,7 +208,6 @@ body.light[data-color-theme="dracula"] {
|
|
|
215
208
|
--text-tertiary: #5a5a68;
|
|
216
209
|
--text-muted: #787885;
|
|
217
210
|
--chart-fill: rgba(124, 58, 237, 0.32);
|
|
218
|
-
--chart-1: #7c3aed;
|
|
219
211
|
}
|
|
220
212
|
|
|
221
213
|
/* Nord */
|
|
@@ -234,7 +226,6 @@ body[data-color-theme="nord"]:not(.light) {
|
|
|
234
226
|
--text-tertiary: #aeb6c5;
|
|
235
227
|
--text-muted: #7b88a1;
|
|
236
228
|
--chart-fill: rgba(136, 192, 208, 0.32);
|
|
237
|
-
--chart-1: #88c0d0;
|
|
238
229
|
}
|
|
239
230
|
body.light[data-color-theme="nord"] {
|
|
240
231
|
--accent: #5e81ac;
|
|
@@ -251,7 +242,6 @@ body.light[data-color-theme="nord"] {
|
|
|
251
242
|
--text-tertiary: #4c566a;
|
|
252
243
|
--text-muted: #6b7589;
|
|
253
244
|
--chart-fill: rgba(94, 129, 172, 0.32);
|
|
254
|
-
--chart-1: #5e81ac;
|
|
255
245
|
}
|
|
256
246
|
|
|
257
247
|
/* Rosé Pine */
|
|
@@ -270,7 +260,6 @@ body[data-color-theme="rose-pine"]:not(.light) {
|
|
|
270
260
|
--text-tertiary: #908caa;
|
|
271
261
|
--text-muted: #6e6a86;
|
|
272
262
|
--chart-fill: rgba(196, 167, 231, 0.32);
|
|
273
|
-
--chart-1: #c4a7e7;
|
|
274
263
|
}
|
|
275
264
|
body.light[data-color-theme="rose-pine"] {
|
|
276
265
|
--accent: #907aa9;
|
|
@@ -281,13 +270,12 @@ body.light[data-color-theme="rose-pine"] {
|
|
|
281
270
|
--bg-surface: #faf4ed;
|
|
282
271
|
--bg-elevated: #fffaf3;
|
|
283
272
|
--bg-hover: #ebdfd4;
|
|
284
|
-
--border: #
|
|
273
|
+
--border: #cecacd;
|
|
285
274
|
--text-primary: #575279;
|
|
286
275
|
--text-secondary: #635e87;
|
|
287
|
-
--text-tertiary: #
|
|
288
|
-
--text-muted: #
|
|
276
|
+
--text-tertiary: #6e6a88;
|
|
277
|
+
--text-muted: #857f96;
|
|
289
278
|
--chart-fill: rgba(144, 122, 169, 0.32);
|
|
290
|
-
--chart-1: #907aa9;
|
|
291
279
|
}
|
|
292
280
|
|
|
293
281
|
/* Everforest */
|
|
@@ -306,24 +294,22 @@ body[data-color-theme="everforest"]:not(.light) {
|
|
|
306
294
|
--text-tertiary: #9da9a0;
|
|
307
295
|
--text-muted: #859289;
|
|
308
296
|
--chart-fill: rgba(167, 192, 128, 0.32);
|
|
309
|
-
--chart-1: #a7c080;
|
|
310
297
|
}
|
|
311
298
|
body.light[data-color-theme="everforest"] {
|
|
312
299
|
--accent: #6f8352;
|
|
313
300
|
--accent-text: #56683f;
|
|
314
301
|
--accent-dim: rgba(111,131,82,0.18);
|
|
315
302
|
--accent-glow: rgba(111, 131, 82, 0.5);
|
|
316
|
-
--bg-deep: #
|
|
317
|
-
--bg-surface: #
|
|
318
|
-
--bg-elevated: #
|
|
319
|
-
--bg-hover: #
|
|
320
|
-
--border: #
|
|
321
|
-
--text-primary: #
|
|
322
|
-
--text-secondary: #
|
|
323
|
-
--text-tertiary: #
|
|
324
|
-
--text-muted: #
|
|
303
|
+
--bg-deep: #ebeadb;
|
|
304
|
+
--bg-surface: #f5f4e8;
|
|
305
|
+
--bg-elevated: #fbfbf4;
|
|
306
|
+
--bg-hover: #e5e4d3;
|
|
307
|
+
--border: #d3d2bf;
|
|
308
|
+
--text-primary: #3d484e;
|
|
309
|
+
--text-secondary: #55636b;
|
|
310
|
+
--text-tertiary: #66705f;
|
|
311
|
+
--text-muted: #7a8577;
|
|
325
312
|
--chart-fill: rgba(111, 131, 82, 0.32);
|
|
326
|
-
--chart-1: #6f8352;
|
|
327
313
|
}
|
|
328
314
|
|
|
329
315
|
/* Kanagawa */
|
|
@@ -342,24 +328,22 @@ body[data-color-theme="kanagawa"]:not(.light) {
|
|
|
342
328
|
--text-tertiary: #a6a69c;
|
|
343
329
|
--text-muted: #727169;
|
|
344
330
|
--chart-fill: rgba(126, 156, 216, 0.32);
|
|
345
|
-
--chart-1: #7e9cd8;
|
|
346
331
|
}
|
|
347
332
|
body.light[data-color-theme="kanagawa"] {
|
|
348
333
|
--accent: #4d699b;
|
|
349
334
|
--accent-text: #38537f;
|
|
350
335
|
--accent-dim: rgba(77,105,155,0.18);
|
|
351
336
|
--accent-glow: rgba(77, 105, 155, 0.5);
|
|
352
|
-
--bg-deep: #
|
|
353
|
-
--bg-surface: #
|
|
354
|
-
--bg-elevated: #
|
|
355
|
-
--bg-hover: #
|
|
356
|
-
--border: #
|
|
337
|
+
--bg-deep: #e9e5d6;
|
|
338
|
+
--bg-surface: #f3f0e4;
|
|
339
|
+
--bg-elevated: #faf8f1;
|
|
340
|
+
--bg-hover: #e2ddcb;
|
|
341
|
+
--border: #d2ccb6;
|
|
357
342
|
--text-primary: #545464;
|
|
358
343
|
--text-secondary: #66667a;
|
|
359
344
|
--text-tertiary: #716e61;
|
|
360
345
|
--text-muted: #8a8775;
|
|
361
346
|
--chart-fill: rgba(77, 105, 155, 0.32);
|
|
362
|
-
--chart-1: #4d699b;
|
|
363
347
|
}
|
|
364
348
|
|
|
365
349
|
/* One Dark */
|
|
@@ -378,7 +362,6 @@ body[data-color-theme="one-dark"]:not(.light) {
|
|
|
378
362
|
--text-tertiary: #8b919e;
|
|
379
363
|
--text-muted: #5c6370;
|
|
380
364
|
--chart-fill: rgba(97, 175, 239, 0.32);
|
|
381
|
-
--chart-1: #61afef;
|
|
382
365
|
}
|
|
383
366
|
body.light[data-color-theme="one-dark"] {
|
|
384
367
|
--accent: #4078f2;
|
|
@@ -395,7 +378,6 @@ body.light[data-color-theme="one-dark"] {
|
|
|
395
378
|
--text-tertiary: #696c77;
|
|
396
379
|
--text-muted: #a0a1a7;
|
|
397
380
|
--chart-fill: rgba(64, 120, 242, 0.32);
|
|
398
|
-
--chart-1: #4078f2;
|
|
399
381
|
}
|
|
400
382
|
|
|
401
383
|
/* Night Owl */
|
|
@@ -414,7 +396,6 @@ body[data-color-theme="night-owl"]:not(.light) {
|
|
|
414
396
|
--text-tertiary: #8ba3b8;
|
|
415
397
|
--text-muted: #637777;
|
|
416
398
|
--chart-fill: rgba(130, 170, 255, 0.32);
|
|
417
|
-
--chart-1: #82aaff;
|
|
418
399
|
}
|
|
419
400
|
body.light[data-color-theme="night-owl"] {
|
|
420
401
|
--accent: #0c969b;
|
|
@@ -431,7 +412,6 @@ body.light[data-color-theme="night-owl"] {
|
|
|
431
412
|
--text-tertiary: #6f6e85;
|
|
432
413
|
--text-muted: #989fb1;
|
|
433
414
|
--chart-fill: rgba(12, 150, 155, 0.32);
|
|
434
|
-
--chart-1: #0c969b;
|
|
435
415
|
}
|
|
436
416
|
|
|
437
417
|
/* Monokai Pro */
|
|
@@ -450,11 +430,10 @@ body[data-color-theme="monokai"]:not(.light) {
|
|
|
450
430
|
--text-tertiary: #939293;
|
|
451
431
|
--text-muted: #727072;
|
|
452
432
|
--chart-fill: rgba(255, 216, 102, 0.32);
|
|
453
|
-
--chart-1: #ffd866;
|
|
454
433
|
}
|
|
455
434
|
body.light[data-color-theme="monokai"] {
|
|
456
435
|
--accent: #c08a00;
|
|
457
|
-
--accent-text: #
|
|
436
|
+
--accent-text: #856000;
|
|
458
437
|
--accent-dim: rgba(192,138,0,0.18);
|
|
459
438
|
--accent-glow: rgba(192, 138, 0, 0.5);
|
|
460
439
|
--bg-deep: #e9e6e4;
|
|
@@ -467,7 +446,6 @@ body.light[data-color-theme="monokai"] {
|
|
|
467
446
|
--text-tertiary: #6b686d;
|
|
468
447
|
--text-muted: #8d8a8d;
|
|
469
448
|
--chart-fill: rgba(192, 138, 0, 0.32);
|
|
470
|
-
--chart-1: #c08a00;
|
|
471
449
|
}
|
|
472
450
|
|
|
473
451
|
/* GitHub */
|
|
@@ -486,7 +464,6 @@ body[data-color-theme="github"]:not(.light) {
|
|
|
486
464
|
--text-tertiary: #959da5;
|
|
487
465
|
--text-muted: #6a737d;
|
|
488
466
|
--chart-fill: rgba(88, 166, 255, 0.32);
|
|
489
|
-
--chart-1: #58a6ff;
|
|
490
467
|
}
|
|
491
468
|
body.light[data-color-theme="github"] {
|
|
492
469
|
--accent: #0366d6;
|
|
@@ -503,7 +480,6 @@ body.light[data-color-theme="github"] {
|
|
|
503
480
|
--text-tertiary: #586069;
|
|
504
481
|
--text-muted: #6a737d;
|
|
505
482
|
--chart-fill: rgba(3, 102, 214, 0.32);
|
|
506
|
-
--chart-1: #0366d6;
|
|
507
483
|
}
|
|
508
484
|
|
|
509
485
|
/* Ayu */
|
|
@@ -522,13 +498,12 @@ body[data-color-theme="ayu"]:not(.light) {
|
|
|
522
498
|
--text-tertiary: #8a9199;
|
|
523
499
|
--text-muted: #6c7380;
|
|
524
500
|
--chart-fill: rgba(230, 180, 80, 0.32);
|
|
525
|
-
--chart-1: #e6b450;
|
|
526
501
|
}
|
|
527
502
|
body.light[data-color-theme="ayu"] {
|
|
528
|
-
--accent: #
|
|
529
|
-
--accent-text: #
|
|
530
|
-
--accent-dim: rgba(
|
|
531
|
-
--accent-glow: rgba(
|
|
503
|
+
--accent: #c97612;
|
|
504
|
+
--accent-text: #a65e0c;
|
|
505
|
+
--accent-dim: rgba(201,118,18,0.18);
|
|
506
|
+
--accent-glow: rgba(201, 118, 18, 0.5);
|
|
532
507
|
--bg-deep: #eff1f3;
|
|
533
508
|
--bg-surface: #f8f9fa;
|
|
534
509
|
--bg-elevated: #fcfcfc;
|
|
@@ -538,8 +513,7 @@ body.light[data-color-theme="ayu"] {
|
|
|
538
513
|
--text-secondary: #5c6166;
|
|
539
514
|
--text-tertiary: #787b80;
|
|
540
515
|
--text-muted: #8a9199;
|
|
541
|
-
--chart-fill: rgba(
|
|
542
|
-
--chart-1: #f2ae49;
|
|
516
|
+
--chart-fill: rgba(201, 118, 18, 0.32);
|
|
543
517
|
}
|
|
544
518
|
|
|
545
519
|
/* Vitesse */
|
|
@@ -558,7 +532,6 @@ body[data-color-theme="vitesse"]:not(.light) {
|
|
|
558
532
|
--text-tertiary: #8f8f85;
|
|
559
533
|
--text-muted: #758575;
|
|
560
534
|
--chart-fill: rgba(77, 147, 117, 0.32);
|
|
561
|
-
--chart-1: #4d9375;
|
|
562
535
|
}
|
|
563
536
|
body.light[data-color-theme="vitesse"] {
|
|
564
537
|
--accent: #1c6b48;
|
|
@@ -575,7 +548,6 @@ body.light[data-color-theme="vitesse"] {
|
|
|
575
548
|
--text-tertiary: #6b6d63;
|
|
576
549
|
--text-muted: #a0ada0;
|
|
577
550
|
--chart-fill: rgba(28, 107, 72, 0.32);
|
|
578
|
-
--chart-1: #1c6b48;
|
|
579
551
|
}
|
|
580
552
|
|
|
581
553
|
/* Synthwave '84 */
|
|
@@ -594,7 +566,6 @@ body[data-color-theme="synthwave"]:not(.light) {
|
|
|
594
566
|
--text-tertiary: #b6b1d8;
|
|
595
567
|
--text-muted: #848bbd;
|
|
596
568
|
--chart-fill: rgba(255, 126, 219, 0.32);
|
|
597
|
-
--chart-1: #ff7edb;
|
|
598
569
|
}
|
|
599
570
|
body.light[data-color-theme="synthwave"] {
|
|
600
571
|
--accent: #c936a6;
|
|
@@ -611,5 +582,4 @@ body.light[data-color-theme="synthwave"] {
|
|
|
611
582
|
--text-tertiary: #5c5380;
|
|
612
583
|
--text-muted: #7d76a3;
|
|
613
584
|
--chart-fill: rgba(201, 54, 166, 0.32);
|
|
614
|
-
--chart-1: #c936a6;
|
|
615
585
|
}
|
package/server.js
CHANGED
|
@@ -411,6 +411,33 @@ function decodeProjectPath(encoded) {
|
|
|
411
411
|
} catch { return encoded; }
|
|
412
412
|
}
|
|
413
413
|
|
|
414
|
+
// The folder name is lossy (separators and hyphens both become "-"), so the cwd a transcript
|
|
415
|
+
// records names the project; the decode is the fallback for folders with no cwd line.
|
|
416
|
+
const CWD_RE = /"cwd":"((?:[^"\\]|\\.)*)"/;
|
|
417
|
+
const projectNames = new Map();
|
|
418
|
+
|
|
419
|
+
function readCwd(filePath) {
|
|
420
|
+
let fd;
|
|
421
|
+
try {
|
|
422
|
+
fd = fs.openSync(filePath, 'r');
|
|
423
|
+
const buf = Buffer.alloc(64 * 1024);
|
|
424
|
+
const n = fs.readSync(fd, buf, 0, buf.length, 0);
|
|
425
|
+
const m = buf.toString('utf-8', 0, n).match(CWD_RE);
|
|
426
|
+
return m ? JSON.parse(`"${m[1]}"`) : null;
|
|
427
|
+
} catch { return null; } finally {
|
|
428
|
+
if (fd !== undefined) fs.closeSync(fd);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
function projectName(encodedPath, files) {
|
|
433
|
+
if (projectNames.has(encodedPath)) return projectNames.get(encodedPath);
|
|
434
|
+
const cwd = files.slice(0, 3).map(readCwd).find(Boolean);
|
|
435
|
+
if (!cwd) return decodeProjectPath(encodedPath);
|
|
436
|
+
const name = cwd.split(/[\\/]/).filter(Boolean).pop() || decodeProjectPath(encodedPath);
|
|
437
|
+
projectNames.set(encodedPath, name);
|
|
438
|
+
return name;
|
|
439
|
+
}
|
|
440
|
+
|
|
414
441
|
function getSessionIdFromFile(filePath) {
|
|
415
442
|
return path.basename(filePath, '.jsonl');
|
|
416
443
|
}
|
|
@@ -433,7 +460,10 @@ function collectAgents(dir, workflowId, out) {
|
|
|
433
460
|
}
|
|
434
461
|
continue;
|
|
435
462
|
}
|
|
436
|
-
|
|
463
|
+
// A workflow run also drops its journal.jsonl next to the agents; only `agent-*.jsonl` is a
|
|
464
|
+
// transcript, and counting the journal inflated the run's agent count by one and stretched its
|
|
465
|
+
// span, since a file with no priced turns falls back to the session's own start time.
|
|
466
|
+
if (!e.name.startsWith('agent-') || !e.name.endsWith('.jsonl')) continue;
|
|
437
467
|
const agentId = e.name.replace('.jsonl', '');
|
|
438
468
|
let meta = {};
|
|
439
469
|
try { meta = JSON.parse(fs.readFileSync(path.join(dir, `${agentId}.meta.json`), 'utf-8')); } catch { /* no meta */ }
|
|
@@ -499,31 +529,43 @@ async function loadSubagentData(subagentInfos, pricing) {
|
|
|
499
529
|
messageCount: 0,
|
|
500
530
|
models: new Set(),
|
|
501
531
|
firstTimestamp: null,
|
|
532
|
+
lastTimestamp: null,
|
|
502
533
|
};
|
|
503
|
-
|
|
534
|
+
// An agent log writes one line per streamed content block, each carrying the usage as it stood
|
|
535
|
+
// then, so a turn's first line can report one output token and its last the whole reply: the
|
|
536
|
+
// turn is the largest usage logged for its (message.id, requestId). The session log repeats the
|
|
537
|
+
// final usage on every line, which is why first-wins reads the same there.
|
|
538
|
+
const kept = new Map();
|
|
539
|
+
const unhashed = [];
|
|
504
540
|
await processJSONLFile(info.filePath, async (line) => {
|
|
505
541
|
let parsed;
|
|
506
542
|
try { parsed = JSON.parse(line); } catch { return; }
|
|
507
|
-
|
|
543
|
+
const usage = parsed.message?.usage;
|
|
544
|
+
if (!usage?.input_tokens && usage?.input_tokens !== 0) return;
|
|
508
545
|
if (!parsed.timestamp) return;
|
|
509
546
|
|
|
547
|
+
// Only what the totals need: `parsed` also holds the turn's content blocks.
|
|
548
|
+
const entry = { costUSD: parsed.costUSD, timestamp: parsed.timestamp, message: { model: parsed.message.model, usage } };
|
|
510
549
|
const hash = createDedupeHash(parsed);
|
|
511
|
-
if (hash
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
const cost = calculateEntryCost(parsed, pricing);
|
|
515
|
-
const usage = parsed.message.usage;
|
|
516
|
-
agent.totalCost += cost;
|
|
517
|
-
agent.inputTokens += usage.input_tokens || 0;
|
|
518
|
-
agent.outputTokens += usage.output_tokens || 0;
|
|
519
|
-
agent.cacheCreationTokens += (usage.cache_creation_input_tokens || 0);
|
|
520
|
-
agent.cacheReadTokens += (usage.cache_read_input_tokens || 0);
|
|
521
|
-
agent.messageCount++;
|
|
522
|
-
agent.models.add(parsed.message?.model || 'unknown');
|
|
523
|
-
if (!agent.firstTimestamp || parsed.timestamp < agent.firstTimestamp) {
|
|
524
|
-
agent.firstTimestamp = parsed.timestamp;
|
|
525
|
-
}
|
|
550
|
+
if (!hash) { unhashed.push(entry); return; }
|
|
551
|
+
const prev = kept.get(hash);
|
|
552
|
+
if (!prev || (usage.output_tokens || 0) > (prev.message.usage.output_tokens || 0)) kept.set(hash, entry);
|
|
526
553
|
});
|
|
554
|
+
const turns = [...kept.values(), ...unhashed].map(e => ({
|
|
555
|
+
cost: calculateEntryCost(e, pricing),
|
|
556
|
+
inputTokens: e.message.usage.input_tokens || 0,
|
|
557
|
+
outputTokens: e.message.usage.output_tokens || 0,
|
|
558
|
+
cacheCreationTokens: e.message.usage.cache_creation_input_tokens || 0,
|
|
559
|
+
cacheReadTokens: e.message.usage.cache_read_input_tokens || 0,
|
|
560
|
+
model: e.message.model || 'unknown',
|
|
561
|
+
timestamp: e.timestamp,
|
|
562
|
+
}));
|
|
563
|
+
Object.assign(agent, summarizeMessages(turns));
|
|
564
|
+
for (const t of turns) {
|
|
565
|
+
agent.models.add(t.model);
|
|
566
|
+
if (!agent.firstTimestamp || t.timestamp < agent.firstTimestamp) agent.firstTimestamp = t.timestamp;
|
|
567
|
+
if (!agent.lastTimestamp || t.timestamp > agent.lastTimestamp) agent.lastTimestamp = t.timestamp;
|
|
568
|
+
}
|
|
527
569
|
agent.models = [...agent.models];
|
|
528
570
|
return agent;
|
|
529
571
|
}));
|
|
@@ -635,6 +677,10 @@ async function loadProjectData(files, pricing) {
|
|
|
635
677
|
if (subagentInfos.length > 0) {
|
|
636
678
|
const subagents = await loadSubagentData(subagentInfos, pricing);
|
|
637
679
|
for (const sa of subagents) {
|
|
680
|
+
// An agent log with no priced turns — empty, truncated, or a crash before the first
|
|
681
|
+
// response — would fold in as a zero-cost message dated at the session's own start,
|
|
682
|
+
// which stretches every span it lands in.
|
|
683
|
+
if (sa.messageCount === 0) continue;
|
|
638
684
|
session.totalCost += sa.totalCost;
|
|
639
685
|
session.inputTokens += sa.inputTokens;
|
|
640
686
|
session.outputTokens += sa.outputTokens;
|
|
@@ -650,7 +696,7 @@ async function loadProjectData(files, pricing) {
|
|
|
650
696
|
cacheCreationTokens: sa.cacheCreationTokens,
|
|
651
697
|
cacheReadTokens: sa.cacheReadTokens,
|
|
652
698
|
speed: 'standard',
|
|
653
|
-
_subagent: { agentId: sa.agentId, agentType: sa.agentType, description: sa.description, messageCount: sa.messageCount, workflowId: sa.workflowId },
|
|
699
|
+
_subagent: { agentId: sa.agentId, agentType: sa.agentType, description: sa.description, messageCount: sa.messageCount, workflowId: sa.workflowId, lastTimestamp: sa.lastTimestamp },
|
|
654
700
|
});
|
|
655
701
|
}
|
|
656
702
|
}
|
|
@@ -840,7 +886,7 @@ async function getOverviewData(range, projectFilter) {
|
|
|
840
886
|
if (projSessions > 0) {
|
|
841
887
|
projectSummaries.push({
|
|
842
888
|
encodedPath,
|
|
843
|
-
name:
|
|
889
|
+
name: projectName(encodedPath, proj.files),
|
|
844
890
|
totalCost: projCost,
|
|
845
891
|
sessionCount: projSessions,
|
|
846
892
|
lastActive: projLastActive,
|
|
@@ -916,7 +962,7 @@ async function getProjectsData(range, projectFilter) {
|
|
|
916
962
|
if (sessionCount > 0) {
|
|
917
963
|
result.push({
|
|
918
964
|
encodedPath,
|
|
919
|
-
name:
|
|
965
|
+
name: projectName(encodedPath, proj.files),
|
|
920
966
|
totalCost,
|
|
921
967
|
sessionCount,
|
|
922
968
|
lastActive,
|
|
@@ -1062,12 +1108,21 @@ async function getSessionDetailData(sessionId) {
|
|
|
1062
1108
|
: new Map();
|
|
1063
1109
|
const workflows = [...byWorkflow].map(([id, msgs]) => {
|
|
1064
1110
|
const { messageCount, ...totals } = summarizeMessages(msgs);
|
|
1111
|
+
// A folded message carries its agent's start time, so the run ends at the latest agent's
|
|
1112
|
+
// own last turn — the last folded message only says when that agent started.
|
|
1113
|
+
const end = msgs.reduce((max, m) => {
|
|
1114
|
+
const t = m._subagent.lastTimestamp || m.timestamp;
|
|
1115
|
+
return t > max ? t : max;
|
|
1116
|
+
}, msgs[0].timestamp);
|
|
1065
1117
|
return {
|
|
1066
1118
|
id,
|
|
1067
1119
|
name: names.get(id) || id,
|
|
1068
1120
|
agents: messageCount,
|
|
1069
1121
|
firstTimestamp: msgs[0].timestamp,
|
|
1070
|
-
lastTimestamp:
|
|
1122
|
+
lastTimestamp: end,
|
|
1123
|
+
// Where the run sits in `messages`, for the timeline band.
|
|
1124
|
+
startIndex: msgs[0].index,
|
|
1125
|
+
endIndex: msgs.at(-1).index,
|
|
1071
1126
|
...totals,
|
|
1072
1127
|
};
|
|
1073
1128
|
}).sort((a, b) => b.totalCost - a.totalCost);
|
|
@@ -1075,7 +1130,7 @@ async function getSessionDetailData(sessionId) {
|
|
|
1075
1130
|
const result = {
|
|
1076
1131
|
sessionId,
|
|
1077
1132
|
customTitle: session.customTitle,
|
|
1078
|
-
projectPath:
|
|
1133
|
+
projectPath: projectName(encodedPath, [matchingFile]),
|
|
1079
1134
|
encodedProjectPath: encodedPath,
|
|
1080
1135
|
totalCost: session.totalCost,
|
|
1081
1136
|
inputTokens: session.inputTokens,
|