Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

address review (codex): don't cache a zero-limit /usage read

Adam Eivybf01b52cafde
diff --git a/server/services/claudeCodeUsage.js b/server/services/claudeCodeUsage.js
index ecf863c0f4..358febdf3b 100644
--- a/server/services/claudeCodeUsage.js
+++ b/server/services/claudeCodeUsage.js
@@ -228,7 +228,13 @@ export async function getClaudeCodeUsage({ refresh = false } = {}) {
.then((stdout) => {
const parsed = parseUsageOutput(stdout);
const data = { ...parsed, fetchedAt: new Date().toISOString() };
- cache = { data, at: Date.now() };
+ // Only cache a read that actually produced rate-limit lines. A transient
+ // degraded /usage (e.g. the live-limit lines dropped by a hiccup) would
+ // otherwise poison the panel with an empty state for the full 60s TTL; not
+ // caching it lets the next view self-heal. A subscription always has limit
+ // lines — an API-key user legitimately has none, but re-reading on each
+ // view for that minority is cheap (the call is 0-token).
+ if (data.limits.length > 0) cache = { data, at: Date.now() };
return data;
})
.finally(() => { inflight = null; });