claude-code-cost 0.18.1 → 0.19.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/package.json +1 -1
- package/public/app.js +294 -59
- package/public/style.css +216 -0
package/package.json
CHANGED
package/public/app.js
CHANGED
|
@@ -818,9 +818,8 @@ function burnPace(ab, blocks) {
|
|
|
818
818
|
.map((b) => b.cost)
|
|
819
819
|
.sort((a, b) => a - b);
|
|
820
820
|
if (past.length < 3) return null;
|
|
821
|
-
const median = past[Math.floor(past.length / 2)];
|
|
822
821
|
const p90 = past[Math.min(past.length - 1, Math.floor(past.length * 0.9))];
|
|
823
|
-
const cls = ab.burn.projectedCost > p90 ? 'hot' : ab.burn.projectedCost > median ? 'warn' : 'ok';
|
|
822
|
+
const cls = ab.burn.projectedCost > p90 ? 'hot' : ab.burn.projectedCost > median(past) ? 'warn' : 'ok';
|
|
824
823
|
return { cls, note: `vs. ${formatCost(median)} median block` };
|
|
825
824
|
}
|
|
826
825
|
|
|
@@ -1106,6 +1105,8 @@ function renderDetail() {
|
|
|
1106
1105
|
</div>
|
|
1107
1106
|
</div>
|
|
1108
1107
|
|
|
1108
|
+
${rangeBrushHtml(d.messages.length)}
|
|
1109
|
+
|
|
1109
1110
|
<div class="section-title">Messages (${d.messages.length})</div>
|
|
1110
1111
|
<table class="messages-table">
|
|
1111
1112
|
<thead><tr>
|
|
@@ -1126,8 +1127,10 @@ function renderDetail() {
|
|
|
1126
1127
|
</div>`;
|
|
1127
1128
|
|
|
1128
1129
|
requestAnimationFrame(() => {
|
|
1129
|
-
|
|
1130
|
-
|
|
1130
|
+
destroyChart('cumulative');
|
|
1131
|
+
destroyChart('tokenBreakdown');
|
|
1132
|
+
applyDetailRange(d.messages, detailRangeFor(d));
|
|
1133
|
+
initRangeBrush(d.messages);
|
|
1131
1134
|
});
|
|
1132
1135
|
}
|
|
1133
1136
|
|
|
@@ -1421,6 +1424,50 @@ function renderModelChart(models, canvasId = 'modelChart', chartKey = 'model') {
|
|
|
1421
1424
|
});
|
|
1422
1425
|
}
|
|
1423
1426
|
|
|
1427
|
+
function cumulativeChartData(messages, c) {
|
|
1428
|
+
return {
|
|
1429
|
+
labels: messages.map((m) => m.index),
|
|
1430
|
+
datasets: [
|
|
1431
|
+
{
|
|
1432
|
+
label: 'Cumulative Cost',
|
|
1433
|
+
data: messages.map((m) => m.cumulativeCost),
|
|
1434
|
+
borderColor: c.accent,
|
|
1435
|
+
backgroundColor: c.chartFill,
|
|
1436
|
+
fill: true,
|
|
1437
|
+
borderWidth: 2,
|
|
1438
|
+
pointRadius: messages.length > 50 ? 0 : 3,
|
|
1439
|
+
// Subagent points render hollow so they read as folded-in cost, not main-loop turns.
|
|
1440
|
+
pointBackgroundColor: messages.length > 50 ? c.accent : messages.map((m) => (m._subagent ? c.bg : c.accent)),
|
|
1441
|
+
pointBorderColor: c.accent,
|
|
1442
|
+
tension: 0.2,
|
|
1443
|
+
},
|
|
1444
|
+
],
|
|
1445
|
+
};
|
|
1446
|
+
}
|
|
1447
|
+
|
|
1448
|
+
function tokenBreakdownChartData(messages, c) {
|
|
1449
|
+
// Subagent bars render translucent so they read as folded-in usage, not main-loop turns.
|
|
1450
|
+
const barColors = (hex) => {
|
|
1451
|
+
const faded = hexToRgba(hex, 0.45);
|
|
1452
|
+
return messages.map((m) => (m._subagent ? faded : hex));
|
|
1453
|
+
};
|
|
1454
|
+
const series = [
|
|
1455
|
+
['Input', 'inputTokens', c.chart1],
|
|
1456
|
+
['Output', 'outputTokens', c.chart2],
|
|
1457
|
+
['Cache Create', 'cacheCreationTokens', c.chart3],
|
|
1458
|
+
['Cache Read', 'cacheReadTokens', c.chart4],
|
|
1459
|
+
];
|
|
1460
|
+
return {
|
|
1461
|
+
labels: messages.map((m) => m.index),
|
|
1462
|
+
datasets: series.map(([label, key, hex]) => ({
|
|
1463
|
+
label,
|
|
1464
|
+
data: messages.map((m) => m[key]),
|
|
1465
|
+
backgroundColor: barColors(hex),
|
|
1466
|
+
borderRadius: 2,
|
|
1467
|
+
})),
|
|
1468
|
+
};
|
|
1469
|
+
}
|
|
1470
|
+
|
|
1424
1471
|
function renderCumulativeChart(messages) {
|
|
1425
1472
|
const canvas = document.getElementById('cumulativeChart');
|
|
1426
1473
|
if (!canvas || !messages?.length) return;
|
|
@@ -1431,27 +1478,10 @@ function renderCumulativeChart(messages) {
|
|
|
1431
1478
|
|
|
1432
1479
|
charts.cumulative = new Chart(canvas, {
|
|
1433
1480
|
type: 'line',
|
|
1434
|
-
data:
|
|
1435
|
-
labels: messages.map((m) => m.index),
|
|
1436
|
-
datasets: [
|
|
1437
|
-
{
|
|
1438
|
-
label: 'Cumulative Cost',
|
|
1439
|
-
data: messages.map((m) => m.cumulativeCost),
|
|
1440
|
-
borderColor: c.accent,
|
|
1441
|
-
backgroundColor: c.chartFill,
|
|
1442
|
-
fill: true,
|
|
1443
|
-
borderWidth: 2,
|
|
1444
|
-
pointRadius: messages.length > 50 ? 0 : 3,
|
|
1445
|
-
// Subagent points render hollow so they read as folded-in cost, not main-loop turns.
|
|
1446
|
-
pointBackgroundColor: messages.length > 50 ? c.accent : messages.map((m) => (m._subagent ? c.bg : c.accent)),
|
|
1447
|
-
pointBorderColor: c.accent,
|
|
1448
|
-
tension: 0.2,
|
|
1449
|
-
},
|
|
1450
|
-
],
|
|
1451
|
-
},
|
|
1481
|
+
data: cumulativeChartData(messages, c),
|
|
1452
1482
|
options: {
|
|
1453
1483
|
...defaults,
|
|
1454
|
-
plugins: withTooltip(defaults, { title: (items) => messageTooltipTitle(
|
|
1484
|
+
plugins: withTooltip(defaults, { title: (items) => messageTooltipTitle(detailSlice, items) }),
|
|
1455
1485
|
scales: {
|
|
1456
1486
|
...defaults.scales,
|
|
1457
1487
|
x: {
|
|
@@ -1475,47 +1505,13 @@ function renderTokenBreakdownChart(messages) {
|
|
|
1475
1505
|
const c = getChartColors();
|
|
1476
1506
|
const defaults = chartDefaults();
|
|
1477
1507
|
|
|
1478
|
-
// Subagent bars render translucent so they read as folded-in usage, not main-loop turns.
|
|
1479
|
-
const barColors = (hex) => {
|
|
1480
|
-
const faded = hexToRgba(hex, 0.45);
|
|
1481
|
-
return messages.map((m) => (m._subagent ? faded : hex));
|
|
1482
|
-
};
|
|
1483
|
-
|
|
1484
1508
|
charts.tokenBreakdown = new Chart(canvas, {
|
|
1485
1509
|
type: 'bar',
|
|
1486
|
-
data:
|
|
1487
|
-
labels: messages.map((m) => m.index),
|
|
1488
|
-
datasets: [
|
|
1489
|
-
{
|
|
1490
|
-
label: 'Input',
|
|
1491
|
-
data: messages.map((m) => m.inputTokens),
|
|
1492
|
-
backgroundColor: barColors(c.chart1),
|
|
1493
|
-
borderRadius: 2,
|
|
1494
|
-
},
|
|
1495
|
-
{
|
|
1496
|
-
label: 'Output',
|
|
1497
|
-
data: messages.map((m) => m.outputTokens),
|
|
1498
|
-
backgroundColor: barColors(c.chart2),
|
|
1499
|
-
borderRadius: 2,
|
|
1500
|
-
},
|
|
1501
|
-
{
|
|
1502
|
-
label: 'Cache Create',
|
|
1503
|
-
data: messages.map((m) => m.cacheCreationTokens),
|
|
1504
|
-
backgroundColor: barColors(c.chart3),
|
|
1505
|
-
borderRadius: 2,
|
|
1506
|
-
},
|
|
1507
|
-
{
|
|
1508
|
-
label: 'Cache Read',
|
|
1509
|
-
data: messages.map((m) => m.cacheReadTokens),
|
|
1510
|
-
backgroundColor: barColors(c.chart4),
|
|
1511
|
-
borderRadius: 2,
|
|
1512
|
-
},
|
|
1513
|
-
],
|
|
1514
|
-
},
|
|
1510
|
+
data: tokenBreakdownChartData(messages, c),
|
|
1515
1511
|
options: {
|
|
1516
1512
|
...defaults,
|
|
1517
1513
|
plugins: {
|
|
1518
|
-
...withTooltip(defaults, { title: (items) => messageTooltipTitle(
|
|
1514
|
+
...withTooltip(defaults, { title: (items) => messageTooltipTitle(detailSlice, items) }),
|
|
1519
1515
|
legend: {
|
|
1520
1516
|
display: true,
|
|
1521
1517
|
position: 'bottom',
|
|
@@ -1541,6 +1537,245 @@ function renderTokenBreakdownChart(messages) {
|
|
|
1541
1537
|
});
|
|
1542
1538
|
}
|
|
1543
1539
|
|
|
1540
|
+
// #region RANGE BRUSH
|
|
1541
|
+
// Long sessions squash both per-message charts into noise, so the detail view shows a window of
|
|
1542
|
+
// the last DETAIL_WINDOW messages by default and lets the user drag that window across an overview
|
|
1543
|
+
// of the whole session. State lives outside the DOM because renderDetail rebuilds its innerHTML on
|
|
1544
|
+
// every refresh; a window that sits at the tail stays there so new messages scroll into view.
|
|
1545
|
+
const DETAIL_WINDOW_PRESETS = [25, 50, 100, 200];
|
|
1546
|
+
const DETAIL_WINDOW = DETAIL_WINDOW_PRESETS[0];
|
|
1547
|
+
const DETAIL_WINDOW_MIN = 10;
|
|
1548
|
+
let detailRange = null;
|
|
1549
|
+
let detailSlice = [];
|
|
1550
|
+
|
|
1551
|
+
function median(sorted) {
|
|
1552
|
+
return sorted[Math.floor(sorted.length / 2)];
|
|
1553
|
+
}
|
|
1554
|
+
|
|
1555
|
+
// A cache burst is a main-loop turn that wrote far more cache than the session normally does:
|
|
1556
|
+
// the prompt prefix was invalidated (edited system prompt, compaction, new tool set, long gap) and
|
|
1557
|
+
// had to be re-cached. Relative to the session median so a chatty session and a heavy one both
|
|
1558
|
+
// surface their own outliers; the absolute floor drops noise in tiny sessions.
|
|
1559
|
+
const CACHE_BURST_RATIO = 4;
|
|
1560
|
+
const CACHE_BURST_MIN_TOKENS = 20000;
|
|
1561
|
+
|
|
1562
|
+
function cacheBurstIndices(messages) {
|
|
1563
|
+
const writes = messages
|
|
1564
|
+
.filter((m) => !m._subagent && m.cacheCreationTokens > 0)
|
|
1565
|
+
.map((m) => m.cacheCreationTokens)
|
|
1566
|
+
.sort((a, b) => a - b);
|
|
1567
|
+
if (writes.length < 5) return [];
|
|
1568
|
+
const threshold = Math.max(CACHE_BURST_MIN_TOKENS, median(writes) * CACHE_BURST_RATIO);
|
|
1569
|
+
return messages.flatMap((m, i) => (!m._subagent && m.cacheCreationTokens >= threshold ? [i] : []));
|
|
1570
|
+
}
|
|
1571
|
+
|
|
1572
|
+
function clampRange(start, end, total) {
|
|
1573
|
+
const s = Math.max(0, Math.min(start, total - DETAIL_WINDOW_MIN));
|
|
1574
|
+
return { start: s, end: Math.max(s + DETAIL_WINDOW_MIN, Math.min(end, total)) };
|
|
1575
|
+
}
|
|
1576
|
+
|
|
1577
|
+
function detailRangeFor(d) {
|
|
1578
|
+
const total = d.messages.length;
|
|
1579
|
+
const prev = detailRange?.key === d.sessionId ? detailRange : null;
|
|
1580
|
+
const size = prev ? prev.end - prev.start : DETAIL_WINDOW;
|
|
1581
|
+
const atTail = !prev || prev.end === prev.total;
|
|
1582
|
+
const start = atTail ? total - size : prev.start;
|
|
1583
|
+
detailRange = { key: d.sessionId, total, ...clampRange(start, start + size, total) };
|
|
1584
|
+
return detailRange;
|
|
1585
|
+
}
|
|
1586
|
+
|
|
1587
|
+
function applyDetailRange(messages, range) {
|
|
1588
|
+
detailSlice = messages.slice(range.start, range.end);
|
|
1589
|
+
const c = getChartColors();
|
|
1590
|
+
if (charts.cumulative && charts.tokenBreakdown) {
|
|
1591
|
+
charts.cumulative.data = cumulativeChartData(detailSlice, c);
|
|
1592
|
+
charts.cumulative.update('none');
|
|
1593
|
+
charts.tokenBreakdown.data = tokenBreakdownChartData(detailSlice, c);
|
|
1594
|
+
charts.tokenBreakdown.update('none');
|
|
1595
|
+
} else {
|
|
1596
|
+
renderCumulativeChart(detailSlice);
|
|
1597
|
+
renderTokenBreakdownChart(detailSlice);
|
|
1598
|
+
}
|
|
1599
|
+
}
|
|
1600
|
+
|
|
1601
|
+
function rangeBrushHtml(total) {
|
|
1602
|
+
if (total <= DETAIL_WINDOW) return '';
|
|
1603
|
+
const presets = DETAIL_WINDOW_PRESETS.filter((n) => n < total)
|
|
1604
|
+
.map((n) => `<button type="button" class="rb-preset" data-size="${n}">${n}</button>`)
|
|
1605
|
+
.join('');
|
|
1606
|
+
return `
|
|
1607
|
+
<div class="range-brush" id="rangeBrush">
|
|
1608
|
+
<div class="rb-head">
|
|
1609
|
+
<span class="rb-label"><span class="rb-scope"></span><span class="rb-burst-count" hidden><i></i></span></span>
|
|
1610
|
+
<div class="rb-presets" role="group" aria-label="Window size">
|
|
1611
|
+
${presets}
|
|
1612
|
+
<button type="button" class="rb-preset" data-size="all">All</button>
|
|
1613
|
+
</div>
|
|
1614
|
+
</div>
|
|
1615
|
+
<div class="rb-track" tabindex="0" role="slider" aria-label="Visible message range"
|
|
1616
|
+
aria-valuemin="1" aria-valuemax="${esc(total)}">
|
|
1617
|
+
${rangeOverviewSvg}
|
|
1618
|
+
<div class="rb-bursts"></div>
|
|
1619
|
+
<div class="rb-window">
|
|
1620
|
+
<div class="rb-handle rb-handle-left" data-edge="start"></div>
|
|
1621
|
+
<div class="rb-handle rb-handle-right" data-edge="end"></div>
|
|
1622
|
+
</div>
|
|
1623
|
+
</div>
|
|
1624
|
+
</div>`;
|
|
1625
|
+
}
|
|
1626
|
+
|
|
1627
|
+
// The overview shares the brush's percentage coordinate space, so it stretches with the track and
|
|
1628
|
+
// needs no resize handling. Points are filled in by initRangeBrush.
|
|
1629
|
+
const rangeOverviewSvg =
|
|
1630
|
+
'<svg class="rb-overview" viewBox="0 0 1000 100" preserveAspectRatio="none" aria-hidden="true"><polygon /><polyline /></svg>';
|
|
1631
|
+
|
|
1632
|
+
function initRangeBrush(messages) {
|
|
1633
|
+
const root = document.getElementById('rangeBrush');
|
|
1634
|
+
if (!root) return;
|
|
1635
|
+
const total = messages.length;
|
|
1636
|
+
const range = detailRange;
|
|
1637
|
+
const q = (sel) => root.querySelector(sel);
|
|
1638
|
+
const track = q('.rb-track');
|
|
1639
|
+
const win = q('.rb-window');
|
|
1640
|
+
const scope = q('.rb-scope');
|
|
1641
|
+
const burstCount = q('.rb-burst-count');
|
|
1642
|
+
const presets = [...root.querySelectorAll('.rb-preset')].map((el) => ({
|
|
1643
|
+
el,
|
|
1644
|
+
size: el.dataset.size === 'all' ? total : Number(el.dataset.size),
|
|
1645
|
+
}));
|
|
1646
|
+
|
|
1647
|
+
drawRangeOverview(q('.rb-overview'), messages);
|
|
1648
|
+
|
|
1649
|
+
const bursts = cacheBurstIndices(messages);
|
|
1650
|
+
const burstsEl = q('.rb-bursts');
|
|
1651
|
+
burstsEl.innerHTML = bursts
|
|
1652
|
+
.map((i) => {
|
|
1653
|
+
const m = messages[i];
|
|
1654
|
+
const tip = `#${m.index} · cache write ${formatTokens(m.cacheCreationTokens)}`;
|
|
1655
|
+
return `<button type="button" class="rb-burst" data-i="${i}" style="left:${((i + 0.5) / total) * 100}%" title="${esc(tip)}" aria-label="${esc(tip)}"></button>`;
|
|
1656
|
+
})
|
|
1657
|
+
.join('');
|
|
1658
|
+
const burstEls = [...burstsEl.children].map((el, k) => ({ el, i: bursts[k] }));
|
|
1659
|
+
if (bursts.length) {
|
|
1660
|
+
burstCount.hidden = false;
|
|
1661
|
+
burstCount.append(`${bursts.length} cache burst${bursts.length === 1 ? '' : 's'}`);
|
|
1662
|
+
}
|
|
1663
|
+
|
|
1664
|
+
const layout = () => {
|
|
1665
|
+
const size = range.end - range.start;
|
|
1666
|
+
win.style.left = `${(range.start / total) * 100}%`;
|
|
1667
|
+
win.style.width = `${(size / total) * 100}%`;
|
|
1668
|
+
const text =
|
|
1669
|
+
size === total
|
|
1670
|
+
? `All ${total} messages`
|
|
1671
|
+
: `Messages #${messages[range.start].index} – #${messages[range.end - 1].index} · ${size} of ${total}`;
|
|
1672
|
+
scope.textContent = text;
|
|
1673
|
+
track.setAttribute('aria-valuenow', String(range.start + 1));
|
|
1674
|
+
track.setAttribute('aria-valuetext', text);
|
|
1675
|
+
for (const p of presets) p.el.classList.toggle('on', p.size === size);
|
|
1676
|
+
for (const b of burstEls) b.el.classList.toggle('in', b.i >= range.start && b.i < range.end);
|
|
1677
|
+
};
|
|
1678
|
+
|
|
1679
|
+
// Pointer and wheel events outrun the frame rate, so range writes are coalesced into one paint.
|
|
1680
|
+
let frame = 0;
|
|
1681
|
+
const setRange = (from, to) => {
|
|
1682
|
+
const next = clampRange(from, to, total);
|
|
1683
|
+
if (next.start === range.start && next.end === range.end) return;
|
|
1684
|
+
Object.assign(range, next);
|
|
1685
|
+
if (frame) return;
|
|
1686
|
+
frame = requestAnimationFrame(() => {
|
|
1687
|
+
frame = 0;
|
|
1688
|
+
layout();
|
|
1689
|
+
applyDetailRange(messages, range);
|
|
1690
|
+
});
|
|
1691
|
+
};
|
|
1692
|
+
const size = () => range.end - range.start;
|
|
1693
|
+
const step = () => Math.max(1, Math.round(size() / 10));
|
|
1694
|
+
const pan = (delta) => setRange(range.start + delta, range.end + delta);
|
|
1695
|
+
const centerOn = (i) => {
|
|
1696
|
+
const start = Math.max(0, Math.min(i - Math.floor(size() / 2), total - size()));
|
|
1697
|
+
setRange(start, start + size());
|
|
1698
|
+
};
|
|
1699
|
+
const resize = (n) => {
|
|
1700
|
+
const end = Math.min(total, Math.max(range.end, n));
|
|
1701
|
+
setRange(end - n, end);
|
|
1702
|
+
};
|
|
1703
|
+
|
|
1704
|
+
// Pointer capture keeps a fast drag alive after the cursor leaves the thin track. The rect is
|
|
1705
|
+
// read once per drag: reading it per move right after writing the window's style would thrash.
|
|
1706
|
+
track.addEventListener('pointerdown', (e) => {
|
|
1707
|
+
if (e.button !== 0) return;
|
|
1708
|
+
e.preventDefault();
|
|
1709
|
+
track.focus({ preventScroll: true });
|
|
1710
|
+
const rect = track.getBoundingClientRect();
|
|
1711
|
+
const perPx = total / rect.width;
|
|
1712
|
+
const edge = e.target.dataset?.edge;
|
|
1713
|
+
if (!edge && e.target !== win) centerOn(Math.round((e.clientX - rect.left) * perPx));
|
|
1714
|
+
const origin = { x: e.clientX, start: range.start, end: range.end };
|
|
1715
|
+
track.classList.add('dragging');
|
|
1716
|
+
track.setPointerCapture(e.pointerId);
|
|
1717
|
+
const move = (ev) => {
|
|
1718
|
+
const delta = Math.round((ev.clientX - origin.x) * perPx);
|
|
1719
|
+
if (edge === 'start') setRange(origin.start + delta, origin.end);
|
|
1720
|
+
else if (edge === 'end') setRange(origin.start, origin.end + delta);
|
|
1721
|
+
else {
|
|
1722
|
+
const n = origin.end - origin.start;
|
|
1723
|
+
const start = Math.max(0, Math.min(origin.start + delta, total - n));
|
|
1724
|
+
setRange(start, start + n);
|
|
1725
|
+
}
|
|
1726
|
+
};
|
|
1727
|
+
const up = () => {
|
|
1728
|
+
track.classList.remove('dragging');
|
|
1729
|
+
track.removeEventListener('pointermove', move);
|
|
1730
|
+
track.removeEventListener('pointerup', up);
|
|
1731
|
+
track.removeEventListener('pointercancel', up);
|
|
1732
|
+
};
|
|
1733
|
+
track.addEventListener('pointermove', move);
|
|
1734
|
+
track.addEventListener('pointerup', up);
|
|
1735
|
+
track.addEventListener('pointercancel', up);
|
|
1736
|
+
});
|
|
1737
|
+
|
|
1738
|
+
track.addEventListener(
|
|
1739
|
+
'wheel',
|
|
1740
|
+
(e) => {
|
|
1741
|
+
e.preventDefault();
|
|
1742
|
+
pan((e.deltaY || e.deltaX) > 0 ? step() : -step());
|
|
1743
|
+
},
|
|
1744
|
+
{ passive: false },
|
|
1745
|
+
);
|
|
1746
|
+
|
|
1747
|
+
track.addEventListener('keydown', (e) => {
|
|
1748
|
+
const n = e.shiftKey ? size() : step();
|
|
1749
|
+
if (e.key === 'ArrowLeft') pan(-n);
|
|
1750
|
+
else if (e.key === 'ArrowRight') pan(n);
|
|
1751
|
+
else if (e.key === 'Home') setRange(0, size());
|
|
1752
|
+
else if (e.key === 'End') setRange(total - size(), total);
|
|
1753
|
+
else return;
|
|
1754
|
+
e.preventDefault();
|
|
1755
|
+
});
|
|
1756
|
+
|
|
1757
|
+
for (const p of presets) p.el.addEventListener('click', () => resize(p.size));
|
|
1758
|
+
|
|
1759
|
+
burstsEl.addEventListener('pointerdown', (e) => {
|
|
1760
|
+
const b = e.target.closest('.rb-burst');
|
|
1761
|
+
if (!b) return;
|
|
1762
|
+
e.stopPropagation();
|
|
1763
|
+
e.preventDefault();
|
|
1764
|
+
centerOn(Number(b.dataset.i));
|
|
1765
|
+
});
|
|
1766
|
+
|
|
1767
|
+
layout();
|
|
1768
|
+
}
|
|
1769
|
+
|
|
1770
|
+
function drawRangeOverview(svg, messages) {
|
|
1771
|
+
const n = messages.length;
|
|
1772
|
+
const max = messages[n - 1]?.cumulativeCost || 1;
|
|
1773
|
+
const pts = messages.map((m, i) => `${(i / Math.max(1, n - 1)) * 1000},${100 - (m.cumulativeCost / max) * 96 - 2}`);
|
|
1774
|
+
svg.querySelector('polyline').setAttribute('points', pts.join(' '));
|
|
1775
|
+
svg.querySelector('polygon').setAttribute('points', `0,100 ${pts.join(' ')} 1000,100`);
|
|
1776
|
+
}
|
|
1777
|
+
// #endregion
|
|
1778
|
+
|
|
1544
1779
|
function renderTokenSplitChart(t) {
|
|
1545
1780
|
const canvas = document.getElementById('tokenSplitChart');
|
|
1546
1781
|
if (!canvas) return;
|
package/public/style.css
CHANGED
|
@@ -780,6 +780,222 @@ body {
|
|
|
780
780
|
|
|
781
781
|
/* #endregion */
|
|
782
782
|
|
|
783
|
+
/* #region RANGE BRUSH */
|
|
784
|
+
|
|
785
|
+
.range-brush {
|
|
786
|
+
background: var(--bg-surface);
|
|
787
|
+
border: 1px solid var(--border);
|
|
788
|
+
border-radius: 6px;
|
|
789
|
+
padding: 10px 16px 12px;
|
|
790
|
+
margin: -8px 0 20px;
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
.rb-head {
|
|
794
|
+
display: flex;
|
|
795
|
+
align-items: center;
|
|
796
|
+
justify-content: space-between;
|
|
797
|
+
gap: 12px;
|
|
798
|
+
margin-bottom: 8px;
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
.rb-label {
|
|
802
|
+
font-size: 11px;
|
|
803
|
+
color: var(--text-muted);
|
|
804
|
+
text-transform: uppercase;
|
|
805
|
+
letter-spacing: 0.05em;
|
|
806
|
+
white-space: nowrap;
|
|
807
|
+
overflow: hidden;
|
|
808
|
+
text-overflow: ellipsis;
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
.rb-burst-count {
|
|
812
|
+
margin-left: 10px;
|
|
813
|
+
color: var(--warning);
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
.rb-burst-count i {
|
|
817
|
+
display: inline-block;
|
|
818
|
+
width: 6px;
|
|
819
|
+
height: 6px;
|
|
820
|
+
border-radius: 50%;
|
|
821
|
+
background: var(--warning);
|
|
822
|
+
margin-right: 5px;
|
|
823
|
+
vertical-align: middle;
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
.rb-presets {
|
|
827
|
+
display: flex;
|
|
828
|
+
gap: 4px;
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
.rb-preset {
|
|
832
|
+
font: inherit;
|
|
833
|
+
font-size: 10px;
|
|
834
|
+
letter-spacing: 0.03em;
|
|
835
|
+
color: var(--text-tertiary);
|
|
836
|
+
background: transparent;
|
|
837
|
+
border: 1px solid var(--border);
|
|
838
|
+
border-radius: 4px;
|
|
839
|
+
padding: 2px 8px;
|
|
840
|
+
cursor: pointer;
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
.rb-preset:hover {
|
|
844
|
+
color: var(--text-primary);
|
|
845
|
+
border-color: var(--text-muted);
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
.rb-preset.on {
|
|
849
|
+
color: var(--accent-text);
|
|
850
|
+
border-color: var(--accent);
|
|
851
|
+
background: var(--accent-dim);
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
.rb-track {
|
|
855
|
+
position: relative;
|
|
856
|
+
height: 44px;
|
|
857
|
+
border-radius: 4px;
|
|
858
|
+
background: var(--bg-deep);
|
|
859
|
+
border: 1px solid var(--border);
|
|
860
|
+
overflow: hidden;
|
|
861
|
+
cursor: crosshair;
|
|
862
|
+
user-select: none;
|
|
863
|
+
touch-action: none;
|
|
864
|
+
outline: none;
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
.rb-track:focus-visible {
|
|
868
|
+
border-color: var(--accent);
|
|
869
|
+
box-shadow: 0 0 0 2px var(--accent-dim);
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
.rb-overview {
|
|
873
|
+
position: absolute;
|
|
874
|
+
inset: 0;
|
|
875
|
+
width: 100%;
|
|
876
|
+
height: 100%;
|
|
877
|
+
display: block;
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
.rb-overview polygon {
|
|
881
|
+
fill: var(--chart-fill);
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
.rb-overview polyline {
|
|
885
|
+
fill: none;
|
|
886
|
+
stroke: var(--accent);
|
|
887
|
+
stroke-width: 1.5;
|
|
888
|
+
vector-effect: non-scaling-stroke;
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
.rb-bursts {
|
|
892
|
+
position: absolute;
|
|
893
|
+
inset: 0;
|
|
894
|
+
pointer-events: none;
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
.rb-burst {
|
|
898
|
+
position: absolute;
|
|
899
|
+
top: 0;
|
|
900
|
+
bottom: 0;
|
|
901
|
+
width: 7px;
|
|
902
|
+
margin-left: -3.5px;
|
|
903
|
+
padding: 0;
|
|
904
|
+
border: 0;
|
|
905
|
+
background: transparent;
|
|
906
|
+
cursor: pointer;
|
|
907
|
+
pointer-events: auto;
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
.rb-burst::before {
|
|
911
|
+
content: '';
|
|
912
|
+
position: absolute;
|
|
913
|
+
top: 0;
|
|
914
|
+
bottom: 0;
|
|
915
|
+
left: 3px;
|
|
916
|
+
width: 1px;
|
|
917
|
+
background: var(--warning);
|
|
918
|
+
opacity: 0.55;
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
.rb-burst::after {
|
|
922
|
+
content: '';
|
|
923
|
+
position: absolute;
|
|
924
|
+
top: 3px;
|
|
925
|
+
left: 1px;
|
|
926
|
+
width: 5px;
|
|
927
|
+
height: 5px;
|
|
928
|
+
border-radius: 50%;
|
|
929
|
+
background: var(--warning);
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
.rb-burst.in::before,
|
|
933
|
+
.rb-burst:hover::before {
|
|
934
|
+
opacity: 1;
|
|
935
|
+
width: 2px;
|
|
936
|
+
left: 2.5px;
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
/* The shade outside the window is the window's own shadow, clipped by the track. */
|
|
940
|
+
.rb-window {
|
|
941
|
+
position: absolute;
|
|
942
|
+
top: 0;
|
|
943
|
+
bottom: 0;
|
|
944
|
+
border: 1px solid var(--accent);
|
|
945
|
+
border-radius: 3px;
|
|
946
|
+
background: var(--accent-dim);
|
|
947
|
+
box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.45);
|
|
948
|
+
cursor: grab;
|
|
949
|
+
box-sizing: border-box;
|
|
950
|
+
min-width: 8px;
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
body.light .rb-window {
|
|
954
|
+
box-shadow: 0 0 0 9999px rgba(255, 255, 255, 0.55);
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
.rb-track.dragging,
|
|
958
|
+
.rb-track.dragging .rb-window {
|
|
959
|
+
cursor: grabbing;
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
.rb-handle {
|
|
963
|
+
position: absolute;
|
|
964
|
+
top: 0;
|
|
965
|
+
bottom: 0;
|
|
966
|
+
width: 10px;
|
|
967
|
+
cursor: ew-resize;
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
.rb-handle::after {
|
|
971
|
+
content: '';
|
|
972
|
+
position: absolute;
|
|
973
|
+
top: 50%;
|
|
974
|
+
width: 3px;
|
|
975
|
+
height: 14px;
|
|
976
|
+
margin-top: -7px;
|
|
977
|
+
border-radius: 2px;
|
|
978
|
+
background: var(--accent);
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
.rb-handle-left {
|
|
982
|
+
left: -5px;
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
.rb-handle-left::after {
|
|
986
|
+
left: 3px;
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
.rb-handle-right {
|
|
990
|
+
right: -5px;
|
|
991
|
+
}
|
|
992
|
+
|
|
993
|
+
.rb-handle-right::after {
|
|
994
|
+
right: 3px;
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
/* #endregion */
|
|
998
|
+
|
|
783
999
|
/* #region TABLE */
|
|
784
1000
|
|
|
785
1001
|
.section-title {
|