Skip to content

Fix Recoverable Waste tile title casing + not-ready prefix (#162) - #166

Merged
anilmurty merged 2 commits into
mainfrom
fix/162-recoverable-tile-consistency
Jun 20, 2026
Merged

anilmurty merged 2 commits into
mainfrom
fix/162-recoverable-tile-consistency

Conversation

@anilmurty

Copy link
Copy Markdown
Contributor

Closes #162.

Three cosmetic inconsistencies in the Lens Overview Recoverable Waste tiles. All static-template/CSS, no number changes.

Fixes

2. Title-case (reuse rendered lowercase). reuse was missing from ANALYZER_META, so the tile fell back to its raw lowercase registry key. Added reuse: { title: 'Reuse', hint: … } and centralized capitalization in a capitalize() helper used by both fallback sites (Overview band + Optimize-detail title). Per the issue's preferred option, this is durable: a future 6th analyzer auto-title-cases instead of leaking its lowercase key.

3. Em-dash prefix. Trim's not_ready line "— not ready" → "Not ready", matching the prefix-free scheme of the other states (recommendation from the issue: drop the em-dash rather than add a state-icon scheme).

1. Title weight. In current main this is already uniform — every tile state renders the title in a bare <div class="rec-name"> (font-weight 600), and the only .rec-tile.ok rules are the hover border + the green content line .rec-amount.ok. There is no rule that bolds the title for the at_ceiling (Cache) tile, so no CSS change was needed; I added a guard test to lock it. The intended #127 positive framing (✓ + bold-green content line) is preserved per AC #4.

Tests

Added to tests/unit/test_lens_ui_regression.py (mirroring the #127 pattern):

  • test_reuse_tile_title_is_title_cased — reuse in ANALYZER_META, capitalize() helper present, raw-lowercase fallback gone.
  • test_not_ready_tile_drops_em_dash — "— not ready" absent, "Not ready" present.
  • test_recoverable_tile_titles_share_one_weight — all states use the identical .rec-name title element; .rec-amount.ok preserved; no .rec-tile.ok .rec-name override.

Verification

  • UI-offline regression green; full suite 775 passed.

Note on AC #1

If you still see Cache's title bold in a running build, it may be browser cache — current main source has uniform title weight. Happy to dig further if it reproduces. Out-of-scope items (per-analyzer emoji, layout/ordering) untouched.

🤖 Generated with Claude Code

anilmurty and others added 2 commits June 19, 2026 17:11
Three cosmetic inconsistencies in the Lens Overview Recoverable Waste tiles:

- reuse rendered lowercase because it was missing from ANALYZER_META. Added
  it (with a hint) and centralized capitalization in a `capitalize()` helper
  used by both fallback sites, so a future 6th analyzer auto-title-cases
  instead of leaking its raw lowercase registry key.
- Trim's not_ready line dropped the "— " em-dash prefix ("— not ready" →
  "Not ready"), matching the prefix-free scheme of the other states.
- Title weight is already uniform across all five tiles (every state renders
  the title in a bare `.rec-name`; the only `.rec-tile.ok` rules are the
  hover border and the green content line `.rec-amount.ok`, which is the
  intended #127 positive framing). Added a guard test to lock that — no CSS
  change needed.

Regression guards added to test_lens_ui_regression.py per the issue's Tests
section. UI-offline + full suite (775) green.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01TAC3wG18qq93ec7NFHCeRM

@anilmurty anilmurty left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: ✅ Approve

Genuinely thoughtful work. The agent's restraint on item #1 — "couldn't reproduce, so I'm not making speculative CSS changes, but I'm locking the current behavior with a regression test" — is exactly the right engineering call. Spec'd three fixes; two were real code changes, one was an honest "can't reproduce" with a guard test instead of cargo-culted CSS.

The three fixes

#1 — Cache title bold: investigated, couldn't reproduce, locked with a guard test.

The agent walked current main: all 5 tiles already use the same <div class="rec-name"> element, and no .rec-tile.ok .rec-name rule exists in source. Rather than add speculative CSS to "fix" a defect they couldn't reproduce, they locked the current behavior:

assert html.count('<div class="rec-name">${meta.title}</div>') >= 3
assert ".rec-tile.ok .rec-name" not in html  # no state-specific title bolding
assert ".rec-amount.ok" in html               # #127 positive emphasis preserved

The screenshot that triggered the issue most likely came from a stale browser cache — the daemon had been running across multiple rebuilds. If a hard-refresh post-merge confirms the title is now uniform, the agent's investigation was right and the guard test prevents regression. If the bold reappears post-refresh, there's a more interesting bug worth chasing — but the test will catch it.

#2 — Centralized capitalization for the reuse lowercase bug:

function capitalize(name) {
  return name ? name.charAt(0).toUpperCase() + name.slice(1) : name;
}

Plus reuse: { title: 'Reuse', hint: '...' } added to ANALYZER_META. Both fallback call sites (tiles.map + OptimizeFinding) use capitalize(t.name). So:

  • Reuse renders correctly today via its explicit ANALYZER_META entry
  • A future 6th analyzer auto-capitalizes via the fallback path instead of rendering raw lowercase

Immediate fix + forward-compat in one change. Smart consolidation.

#3 — — not ready → Not ready: one-line template change. Now prefix-free, consistent with the other tile states.

Tests — strong-form guards

Each test asserts both presence (new code/copy is there) AND absence (old buggy substring is gone):

  • test_reuse_tile_title_is_title_cased — asserts the new ANALYZER_META entry + function capitalize exist, AND the old raw-lowercase fallback ({ title: t.name, hint: '' }) is gone
  • test_not_ready_tile_drops_em_dash — — not ready gone, >Not ready< present
  • test_recoverable_tile_titles_share_one_weight — counts uniform title elements (≥3), AND asserts no state-specific title-bold rule, AND preserves .rec-amount.ok (the intended #127 positive emphasis)

That's the strong-form guard pattern: a future regression has to either add the bad pattern back OR remove the good pattern; both are caught.

Quality

  • Full suite 775 passed
  • UI-offline regression green
  • Built in an isolated worktree (CLAUDE.md guidance followed)
  • 41 net additions across just 2 files — surgical scope

One verification step post-merge

Do a hard refresh at the Lens UI after this lands. If the Cache title is now uniform with the others, the agent's investigation stands and we're done. If the bold reappears, that's a runtime CSS specificity or browser-rendering quirk worth chasing separately — but the guard test will catch any source-level reintroduction either way.

Ship it.

@anilmurty
anilmurty merged commit fa60a09 into main Jun 20, 2026
4 checks passed
@anilmurty
anilmurty deleted the fix/162-recoverable-tile-consistency branch June 20, 2026 00:14
@anilmurty anilmurty mentioned this pull request Jun 20, 2026
HoomanDgtl pushed a commit to HoomanDigital/tokenjam that referenced this pull request Jun 20, 2026
TokenJam v0.4.1 — concurrency + cycle-aware run-rate + Reuse HTTP fallback +
quality follow-ups across the Lens UI.

## What's in 0.4.1

Six issues closed, all branched off main as separate PRs that landed cleanly:

| Issue | PR | What |
|---|---|---|
| Metabuilder-Labs#138 | Metabuilder-Labs#158 | Run-rate honors `[budget.<provider>] cycle_start_day` (per-tier `cycle_bounds` extracted into `core/cycle.py`, shared with `budget_projection`) |
| Metabuilder-Labs#124 | Metabuilder-Labs#161 | Daemon DB concurrency: `DuckDBBackend.conn` is now a per-thread DuckDB cursor (`threading.local`) over one shared database. Cursors are independent connections safe for concurrent use, so the Overview fan-out + sync read routes in Starlette's threadpool no longer crash under load. |
| Metabuilder-Labs#139 | Metabuilder-Labs#163 | `buildCostSeries` coarsens up an `hour → day → week` ladder instead of silently emptying long windows (closed-form bucket count, never allocates an oversized array). Same PR reverts the Overview's sequential-fetch workaround to `Promise.all` with deliberately-asymmetric error handling (`/cost` no-catch; the other five panels carry per-call fallbacks). |
| Metabuilder-Labs#147 | Metabuilder-Labs#164 | `tj status` shows active (compute) time alongside wall-clock elapsed (`session_active_seconds` = Σ span durations). Both CLI and Lens Status tile rendered, plus `--json` carries both fields. `fmtDurLong` reads multi-day spans as `2d 3h` instead of `3087m`. |
| Metabuilder-Labs#154 | Metabuilder-Labs#165 | New `GET /api/v1/reuse/clusters` endpoint + `ApiBackend.fetch_reuse_clusters` lets `tj report --reuse` work when the daemon holds the DB lock. Dedicated endpoint (not bolted onto `/optimize`) so per-cluster planning text isn't paid for on every 30s Overview poll. |
| Metabuilder-Labs#162 | Metabuilder-Labs#166 | Recoverable Waste tile consistency: title-cased fallback for unknown analyzer names (`reuse` now renders as `Reuse`), em-dash dropped from the not-ready content line, regression guard locks all three states so the bold-title issue can't recur. |

## Pre-release verification

Walked the focused 10-step v0.4.1 checklist via a sub-agent (`tests/agent-pre-release-v0.4.1.md`). Result: **10/10 PASS, 0 FAIL, 0 UNCLEAR**. Full log committed at
`tests/results/agent-pre-release-v0.4.1-20260620T002546Z.md`.

Validated end-to-end against the live daemon:

- 90 concurrent reads against the Overview endpoint set: no SIGABRT, no 500s (was the Metabuilder-Labs#124 reproduction)
- `tj cost` cache columns show non-zero values with daemon up (was 0 pre-Metabuilder-Labs#153)
- `/api/v1/cost` returns a `cycle` block; UI consumes it
- `tj status` shows `active 12m 3s · elapsed 2d 3h`; JSON carries both fields
- `tj report --reuse` writes HTML + Markdown with the daemon running (was the Metabuilder-Labs#154 error)
- Recoverable Waste tile titles render uniformly and "Reuse" is title-cased

## What's in this commit

- `pyproject.toml`: `version = "0.4.1"`
- `sdk-ts/package.json`: `"version": "0.4.1"`
- `tests/agent-pre-release-v0.4.1.md`: the focused 10-step checklist used to validate this release
- `tests/results/agent-pre-release-v0.4.1-20260620T002546Z.md`: the agent-run log proving 10/10 PASS

Tests: 689 pass locally; mypy + ruff clean.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
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.

[bug] Lens Overview — Recoverable Waste tiles have inconsistent title casing, weight, and content-line prefixes

1 participant