Repository navigation
Fix 5 Lens UI bugs (#132–#136) - #137
Conversation
#132 — First-load lands on Overview: - getRoute() defaults to 'overview' (single source of the default), and the render-time `location.hash = '#/overview'` redirect (which raced the initial render → blank content + Status highlighted) is replaced by a cosmetic history.replaceState in an effect. Empty hash now renders Overview with the sidebar highlighting it. #133 + #136 — Spend chart spans the full window with consistent labels: - /api/v1/cost returns a window-bucketed series (hourly for ≤2d windows, daily otherwise) as epoch buckets, plus series_bucket + window_start/end. - The chart builds a continuous, zero-filled grid across the FULL window and pins the x scale to it, so 7d/30d/90d render distinctly and idle periods show as $0. Tick increments are constrained to the bucket unit (no duplicate day labels), and labels use one consistent format — "6 PM" (hourly) / "Jun 15" (daily), never "6/15/26" mixed with "6/16". #134 — Run-rate is cycle-relative: - Replace the fixed ×30 (circular at a 30d window, undershooting at 90d) with daily_rate × days-remaining-in-calendar-cycle, captioned "~$X by end of {month}", per lens-architecture §10. Keeps "linear run-rate, not a forecast". #135 — Cache "at ceiling" detected: - classifyFinding no longer gates at_ceiling on input volume (a fully-cached model has tiny uncached input). 100% efficacy now renders the positive "✓ Already optimized" state, not "No candidates". The efficacy ceiling is exposed on the cache finding so the UI reads it instead of hardcoding. Tests: window-series shape (bucket/window bounds) + hourly bucketing for short windows; regression guards for each fix in index.html. Verified live across all four windows + first-load + at-ceiling. Full suite green (695); ruff (tokenjam/) + mypy clean. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
anilmurty
left a comment
There was a problem hiding this comment.
Review: ✅ Approve
All five bugs addressed cleanly. Tight diff (+200/-71). CI green on 3.10/3.11/3.12 + TS.
Per-bug verification:
-
#132 ✓
getRoute()defaults to'overview'(index.html:783, 786); render-time hash redirect replaced with cosmetichistory.replaceStateinsideuseEffect(:2207-2210). No hashchange re-fire, no race. -
#133 ✓
cost.py:_window_seriesreturns hourly buckets (≤2d windows) or daily buckets (longer), plusseries_bucket+window_start/endmetadata. SQL uses parameterizeddate_trunc($1, ...)(Rule 7 honored — comment even calls this out). UIbuildCostSerieszero-fills the full grid (:1289-1308);SpendChartpinsscales.x.rangeto the window bounds (:961); tickincrsconstrain spacing to bucket units (:967-970). -
#134 ✓ New
cycleRemaining()(:855-861) computes days to end-of-calendar-month. Projection:runRate × cyc.days. Caption:"~$X by end of ${cyc.label}". Both* 30and"over 30 days"removed (regression-test grep enforces). -
#135 ✓
classifyFindingCache branch (index.html:1843-1850) removes theCACHE_MIN_INPUTvolume gate. Ceiling read fromfd.efficacy_ceilingwith 0.80 constant as safe fallback. Backend exposesefficacy_ceilingonCacheEfficacyFinding(cache_efficacy.py:74);report_to_dictserializes viaasdict. Round-trip inrunner.pyreads with default. -
#136 ✓
fmtAxisTime(epoch, bucket)(:879-883) returns"6 PM"(hourly) or"Jun 15"(daily) usingtoLocaleTimeString/toLocaleDateStringwithtimeZone: 'UTC'matching the UTC-aligned buckets. Single format per axis.
Quality checks clean: no f-string SQL (bucket bound as $1); utcnow() used in cost.py (Rule 9); no external HTTP loads (Rule 18); the +3 lines in cache_efficacy.py and +1 in runner.py are purely additive. Tests look good — test_lens_ui_regression.py has static-grep guards for each fix, test_api.py asserts the new response shape (series_bucket, window_start/end).
On your flagged judgment call (90d projects smaller than 7d): Concur. Window-average is what the spec says; the new "~$X by end of June" framing is interpretable at every window selection without the circular 30d artifact. Stable-across-window projections would be a deliberate spec change — worth a separate issue, not a blocker here.
Two non-blocking follow-ups worth filing:
-
cycleRemaining()uses the calendar month, not the user's configured[budget.<provider>] cycle_start_day. Withcycle_start_day = 15, the "by end of June" caption would be off by half a month. The existingbudget-projectionanalyzer honors per-provider cycle days — symmetric treatment would be nicer for honesty parity. -
xs.length > 5000guard inbuildCostSeriesis good defense but at hourly bucketing a 200d window would silently hit it (returnsnull→ empty state). Fine today since the window picker tops out at 90d; worth noting if/when longer windows or finer bucketing ship.
Ship it.
|
Thanks! Both follow-ups filed (keeping this PR as the approved bug-fix scope):
And agreed on the 90d-vs-7d projection: window-average per the spec; a recency-weighted variant would be a deliberate §10 change, separate issue. |
Closes #132, #133, #134, #135, #136. Verified live across all four windows + first-load.
#132 — First-load lands on Overview (was blank + Status highlighted)
getRoute()now defaults tooverview(the single source of the default), andthe render-time
location.hash = '#/overview'redirect — which raced theinitial render and left the content blank while the sidebar highlighted Status —
is replaced by a cosmetic
history.replaceStatein an effect. Bare URL nowrenders Overview with the sidebar highlighting it, no hard-refresh needed.
#133 + #136 — Spend chart spans the full window, with consistent labels
/api/v1/costreturns a window-bucketed series — hourly for ≤2-daywindows, daily otherwise — as epoch buckets, plus
series_bucketandwindow_start/window_end.pins the x scale to it, so 7d/30d/90d render distinctly and idle periods
show as
$0."Jun 11 / Jun 11" labels), and labels use one consistent format —
"6 PM" (hourly) / "Jun 15" (daily) — never
6/15/26mixed with6/16.#134 — Run-rate is cycle-relative
Replaced the fixed
×30(circular at a 30d window, undershooting at 90d) withdaily_rate × days-remaining-in-calendar-cycle, captioned "~$X by end of{month}" per
lens-architecture§10. Keeps "linear run-rate, not a forecast".#135 — Cache "at ceiling" now detected
classifyFindingno longer gatesat_ceilingon input volume — a fully-cachedmodel has tiny uncached input, so 100% efficacy was misclassified as
"No candidates". It now renders the positive "✓ Already optimized — 100% (or
86%…) cache efficacy" state. The efficacy ceiling is exposed on the cache
finding so the UI reads it instead of hardcoding
0.80.Verified live (
tj serve, seeded data)weekly over the quarter — all distinct, full-window, zero-filled.
Tests
bucket+series_bucket+ window bounds);hourly bucketing for short windows.
tests/unit/test_lens_ui_regression.pyguards for each fix (overview default,full-window range, time-axis formatter, cycle-relative caption, cache ceiling
not volume-gated).
ruff check tokenjam/+mypyclean.