Skip to content

fix(stats): count coverage against all 15 libraries - #11835

Merged
MarkusNeusinger merged 2 commits into
mainfrom
claude/magical-shannon-o8vk51
Sep 15, 2026
Merged

MarkusNeusinger merged 2 commits into
mainfrom
claude/magical-shannon-o8vk51

Conversation

@MarkusNeusinger

@MarkusNeusinger MarkusNeusinger commented Sep 15, 2026

Copy link
Copy Markdown
Owner

Summary

  • Fixes the user-reported "Polar Scatter Plot: 15/9" on https://anyplot.ai/stats — the coverage matrix divided by a hardcoded 9 (a leftover from when nine libraries were supported), so a fully covered spec rendered as 15/9 and the "of N possible" total used the wrong denominator. The API already computes coverage_percent against len(SUPPORTED_LIBRARIES) (15), so only the page was wrong.
  • /insights/dashboard now serves total_libraries and StatsPage renders the matrix against it (falling back to library_stats.length for a frontend-before-API deploy), so the denominator tracks the library set instead of drifting from it.
  • Reworks the cells for legibility, as requested in the same report: a 16 px mark (was 10 px) centred in a 24 px link so the target meets WCAG 2.2 SC 2.5.8, full coverage as solid brand green and anything below it carrying an ink outline (dashed when a spec has no implementation at all), a labelled three-state legend instead of the less/more opacity ramp, and · N below 15/15 in the summary line. The interesting signal is which specs are not complete, and those are the minority the old opacity ramp buried.

Test plan

  • uv run pytest tests/unit/api -q — 794 passed; the dashboard test now asserts total_libraries == len(SUPPORTED_LIBRARIES).
  • yarn vitest run src/pages/StatsPage.test.tsx src/pages/DebugPage.test.tsx — green, with three new cases: the summary line renders 987 of 2130 possible · 1 below 15/15, cells are labelled Basic Scatter Plot: 1/15 / Basic Line Plot: 15/15, and a payload without total_libraries still derives 15 from library_stats.
  • Gates: npx tsc --noEmit, eslint, prettier, uv run ruff check, uv run ruff format --check, uv run mypy api/routers/insights.py — all clean.
  • Visual: drove /stats in headless Chromium against a mocked dashboard (121 complete specs + 3 partial + 1 empty) at 1280×900 and 390×844, light and dark. Summary read 97.4% · 1836 of 1875 possible · 4 below 15/15; the four outliers are immediately pickable out of the strip in all four combinations. A live run against the production API was not possible here (no DB credentials in the session).

Checklist

  • changelog.d/stats-coverage-denominator.md added (Fixed + Changed, no CHANGELOG.md bullet)
  • Related documentation checked — docs/reference/api.md describes /insights/dashboard without a field list, so the new response field needs no doc change.

🤖 Generated with Claude Code

https://claude.ai/code/session_01AkKTuCSmiEeUaPQDK5kXqS

The stats-page coverage matrix divided by a hardcoded 9 — a leftover from
when nine libraries were supported — so a fully covered spec showed "15/9"
and the "of N possible" total was computed against the wrong denominator.

/insights/dashboard now serves total_libraries (len(SUPPORTED_LIBRARIES),
the same value already behind coverage_percent) and the page renders the
matrix against it, so the denominator tracks the library set.

Also reworks the cells for legibility: 14px instead of 10px, full coverage
as solid brand green and anything below it outlined in amber (dashed when a
spec has no implementation), a labelled three-state legend instead of the
less/more opacity ramp, and a count of specs below full coverage in the
summary line — the incomplete specs are the minority and were the hardest
cells to spot.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AkKTuCSmiEeUaPQDK5kXqS
Copilot AI balanced review requested due to automatic review settings September 15, 2026 10:46
@codecov

codecov Bot commented Sep 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The redesigned cells have insufficient touch-target sizing and light-theme contrast, and the compatibility fallback lacks regression coverage.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Fixes stats-page coverage calculations to use all supported libraries and improves incomplete-coverage visibility.

Changes:

  • Adds total_libraries to the dashboard API.
  • Updates coverage totals, cells, legend, and tests.
  • Documents the fix and visual changes.
File summaries
File Description
api/routers/insights.py Exposes the canonical library count.
app/src/pages/StatsPage.tsx Corrects coverage rendering and redesigns cells.
app/src/pages/StatsPage.test.tsx Tests 15-library totals and labels.
tests/unit/api/test_routers.py Verifies the API field.
changelog.d/stats-coverage-denominator.md Records the changes.
Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 3
  • Review effort level: Balanced

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread app/src/pages/StatsPage.tsx Outdated
Comment thread app/src/pages/StatsPage.tsx Outdated
Comment thread app/src/pages/StatsPage.tsx
Addresses the Copilot review on the coverage matrix:

- The amber outline was the only marker of the partial/none states, and
  amber is one of the palette colors the style guide flags as failing on
  the cream background (1.46:1, below WCAG 1.4.11's 3:1). Switched both
  incomplete branches to an ink stroke, which is theme-adaptive and keeps
  the solid/dashed distinction.
- Each cell is now a 16px mark centred in a 24px link, so the tap target
  meets WCAG 2.2 SC 2.5.8 without turning the dense strip into a grid of
  chunky blocks.
- Added a test for the library_stats fallback, so a frontend-before-API
  deploy (payload without total_libraries) keeps the right denominator.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AkKTuCSmiEeUaPQDK5kXqS
@MarkusNeusinger
MarkusNeusinger merged commit e178624 into main Sep 15, 2026
18 checks passed
@MarkusNeusinger
MarkusNeusinger deleted the claude/magical-shannon-o8vk51 branch September 15, 2026 11:36
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.

3 participants