Fix: Lens Overview false empty on historical-only telemetry#392
Merged
Conversation
The Overview (default landing route) showed "No data yet — TokenJam is listening" even when the DB held a full historical spend history. Root cause: the Overview `load()` gated its `empty` state purely on the count of active agents from `/api/v1/status` and returned early *before* `/api/v1/cost` was ever fetched. On any DB where all sessions are >24h old (0 active agents) — e.g. a user upgrading and opening Lens to review historical spend — the front door read empty while `/api/v1/cost` returned thousands of dollars and the Cost/Analytics/Optimize screens all rendered fine. Fix: fold `/status` into the same parallel fan-out as `/cost` and derive `empty` from the presence of real telemetry — no cost history AND no tokens AND no active agents AND no traces. Historical cost is now sufficient to render the spend/waste/health tiles. `/cost` stays load-bearing (no `.catch`); the existing error-handling asymmetry is preserved. `/status` moves into the degradable set with a `.catch`. Overview-component-only, offline-safe (no new external loads). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Lens Overview/Dashboard (default landing route) showed "No data yet — TokenJam is listening" even when the DB held a full historical spend history. This is a release blocker: it's the front door a user lands on when they open Lens to review past spend.
Summary
load()now folds/api/v1/statusinto the same parallel fan-out as/api/v1/costand derivesemptyfrom the presence of real telemetry, not just active agents./costload-bearing, no.catch; the rest degrade individually);/statusmoves into the degradable set.Root cause
The Overview
load()gated itsemptystate on the count of active agents from/statusand returned early before fetching/cost. On any DB where all sessions are >24h old (0 active agents) — e.g. a user upgrading and opening Lens to review historical spend — the front door read empty even though/costreturned thousands of dollars and Cost/Analytics/Optimize all rendered fine.Fix
emptyis now!hasCost && !hasAgents && !hasTraces, wherehasCostistotal_cost_usd > 0 || total_tokens > 0from/cost. "No data yet" only shows when there is genuinely NO telemetry.Tests / Verification
node --checkon the extracted<script type="module">block: parses.tests/unit/test_lens_ui_regression.pywithtest_overview_empty_gate_considers_historical_cost— asserts the buggy pattern (early return gated purely on active agents) is gone and the fix pattern (empty considers cost/history) is present, scoped to the Overview component.python3 -m pytest tests/unit/test_lens_ui_regression.py tests/unit/test_ui_offline.py -q→ 191 passed. Offline regression test still passes (no new external loads).What's NOT in this PR
/cost-load-bearing vs others-.catchasymmetry — kept intact per CLAUDE.md.🤖 Generated with Claude Code