Skip to content

Fix: Lens Overview false empty on historical-only telemetry#392

Merged
anilmurty merged 2 commits into
mainfrom
fix/lens-overview-empty-gate
Jul 3, 2026
Merged

Fix: Lens Overview false empty on historical-only telemetry#392
anilmurty merged 2 commits into
mainfrom
fix/lens-overview-empty-gate

Conversation

@anilmurty

Copy link
Copy Markdown
Contributor

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

  • Overview load() now folds /api/v1/status into the same parallel fan-out as /api/v1/cost and derives empty from the presence of real telemetry, not just active agents.
  • Historical cost/tokens now render the spend/waste/health tiles even when 0 agents are active.
  • Existing error-handling asymmetry preserved (/cost load-bearing, no .catch; the rest degrade individually); /status moves into the degradable set.
  • Overview-component-only, offline-safe (no new external loads).

Root cause

The Overview load() gated its empty state on the count of active agents from /status and 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 /cost returned thousands of dollars and Cost/Analytics/Optimize all rendered fine.

Fix

empty is now !hasCost && !hasAgents && !hasTraces, where hasCost is total_cost_usd > 0 || total_tokens > 0 from /cost. "No data yet" only shows when there is genuinely NO telemetry.

Tests / Verification

  • node --check on the extracted <script type="module"> block: parses.
  • Extended tests/unit/test_lens_ui_regression.py with test_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

  • No change to the /cost-load-bearing vs others-.catch asymmetry — kept intact per CLAUDE.md.
  • No backend/route changes — the empty-gate bug is entirely client-side.

🤖 Generated with Claude Code

anilmurty and others added 2 commits July 2, 2026 21:17
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>
@anilmurty anilmurty merged commit 43357c0 into main Jul 3, 2026
4 checks passed
@anilmurty anilmurty deleted the fix/lens-overview-empty-gate branch July 3, 2026 04:59
@anilmurty anilmurty mentioned this pull request Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant