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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-usage-dashboard",
3
- "version": "1.5.5",
3
+ "version": "1.5.7",
4
4
  "description": "Claude Code usage dashboard — token costs, quota cycle tracking, cache efficiency, multi-machine sync across all your devices",
5
5
  "main": "server/index.js",
6
6
  "bin": {
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
- // Prefer cycle data (multi-machine merged) over cost API (local only)
78
- cost7dValue = cycleData?.currentCycle?.overall?.actualCost || 0;
79
- if (cost7dValue === 0) {
80
- const cost7d = await fetchCost({
81
- from: window.from.toISOString(),
82
- to: window.to.toISOString(),
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 — use multi-machine cycle data when viewing current cycle
143
+ // Summary cards
148
144
  const t = usage.total;
149
- let tokIn = t.input_tokens, tokOut = t.output_tokens;
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(tokCR)}</span> · ` +
167
- `<span style="color:#f59e0b">cache write:${formatNumber(tokCW)}</span> · ` +
168
- `<span style="color:#60a5fa">in:${formatNumber(tokIn)}</span> · ` +
169
- `<span style="color:#f97316">out:${formatNumber(tokOut)}</span>`;
170
- document.getElementById('val-api-cost').textContent = `$${apiCost.toFixed(2)}`;
171
-
172
- const totalInput = tokIn + tokCR + tokCW;
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;
@@ -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