claude-usage-dashboard 1.5.5 → 1.5.7
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/js/app.js +15 -36
- package/server/quota-cycles.js +5 -0
package/package.json
CHANGED
package/public/js/app.js
CHANGED
|
@@ -74,16 +74,12 @@ async function loadQuota() {
|
|
|
74
74
|
if (window && sevenDay.utilization > 0) {
|
|
75
75
|
quotaWindowFrom = window.from;
|
|
76
76
|
quotaWindowTo = window.to;
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
plan: state.plan.plan,
|
|
84
|
-
});
|
|
85
|
-
cost7dValue = cost7d.api_equivalent_cost_usd;
|
|
86
|
-
}
|
|
77
|
+
const cost7d = await fetchCost({
|
|
78
|
+
from: window.from.toISOString(),
|
|
79
|
+
to: window.to.toISOString(),
|
|
80
|
+
plan: state.plan.plan,
|
|
81
|
+
});
|
|
82
|
+
cost7dValue = cost7d.api_equivalent_cost_usd;
|
|
87
83
|
}
|
|
88
84
|
|
|
89
85
|
renderQuotaGauges(document.getElementById('chart-quota'), data, {
|
|
@@ -144,35 +140,18 @@ async function loadAll() {
|
|
|
144
140
|
fetchCache(params),
|
|
145
141
|
]);
|
|
146
142
|
|
|
147
|
-
// Summary cards
|
|
143
|
+
// Summary cards
|
|
148
144
|
const t = usage.total;
|
|
149
|
-
|
|
150
|
-
let tokCR = t.cache_read_tokens, tokCW = t.cache_creation_tokens;
|
|
151
|
-
let apiCost = cost.api_equivalent_cost_usd;
|
|
152
|
-
const cc = _cachedCycleData?.currentCycle?.overall;
|
|
153
|
-
if (cc?.tokens) {
|
|
154
|
-
const cct = cc.tokens;
|
|
155
|
-
const mergedAll = cct.input + cct.output + cct.cacheRead + cct.cacheCreation;
|
|
156
|
-
const localAll = tokIn + tokOut + tokCR + tokCW;
|
|
157
|
-
if (mergedAll > localAll) {
|
|
158
|
-
tokIn = cct.input; tokOut = cct.output;
|
|
159
|
-
tokCR = cct.cacheRead; tokCW = cct.cacheCreation;
|
|
160
|
-
apiCost = cc.actualCost;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
const totalAll = tokIn + tokOut + tokCR + tokCW;
|
|
145
|
+
const totalAll = t.input_tokens + t.output_tokens + t.cache_read_tokens + t.cache_creation_tokens;
|
|
164
146
|
document.getElementById('val-total-tokens').textContent = formatNumber(totalAll);
|
|
165
147
|
document.getElementById('sub-total-tokens').innerHTML =
|
|
166
|
-
`<span style="color:#4ade80">cache read:${formatNumber(
|
|
167
|
-
`<span style="color:#f59e0b">cache write:${formatNumber(
|
|
168
|
-
`<span style="color:#60a5fa">in:${formatNumber(
|
|
169
|
-
`<span style="color:#f97316">out:${formatNumber(
|
|
170
|
-
document.getElementById('val-api-cost').textContent = `$${
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
document.getElementById('val-cache-rate').textContent = totalInput > 0
|
|
174
|
-
? `${((tokCR / totalInput) * 100).toFixed(1)}%`
|
|
175
|
-
: `${(cache.cache_read_rate * 100).toFixed(1)}%`;
|
|
148
|
+
`<span style="color:#4ade80">cache read:${formatNumber(t.cache_read_tokens)}</span> · ` +
|
|
149
|
+
`<span style="color:#f59e0b">cache write:${formatNumber(t.cache_creation_tokens)}</span> · ` +
|
|
150
|
+
`<span style="color:#60a5fa">in:${formatNumber(t.input_tokens)}</span> · ` +
|
|
151
|
+
`<span style="color:#f97316">out:${formatNumber(t.output_tokens)}</span>`;
|
|
152
|
+
document.getElementById('val-api-cost').textContent = `$${cost.api_equivalent_cost_usd.toFixed(2)}`;
|
|
153
|
+
|
|
154
|
+
document.getElementById('val-cache-rate').textContent = `${(cache.cache_read_rate * 100).toFixed(1)}%`;
|
|
176
155
|
|
|
177
156
|
// Set active granularity button
|
|
178
157
|
const activeGran = usage.granularity;
|
package/server/quota-cycles.js
CHANGED
|
@@ -174,6 +174,11 @@ export function updateQuotaCycleSnapshot(quotaData, logBaseDir, machineName, sna
|
|
|
174
174
|
...cycleData,
|
|
175
175
|
};
|
|
176
176
|
|
|
177
|
+
// Remove stale history entries for the current cycle's period — these are
|
|
178
|
+
// artifacts from past false cycle-switch detections on this same machine.
|
|
179
|
+
const currentKey = cyclePeriodKey(snapshot.currentCycle);
|
|
180
|
+
snapshot.history = snapshot.history.filter(h => cyclePeriodKey(h) !== currentKey);
|
|
181
|
+
|
|
177
182
|
fs.writeFileSync(filePath, JSON.stringify(snapshot, null, 2));
|
|
178
183
|
}
|
|
179
184
|
|