Skip to content

fix(pie): make hub % match weighted slice progress - #49

Merged
jsolly merged 1 commit into
mainfrom
cursor/pie-progress-math-356d
Jul 19, 2026
Merged

fix(pie): make hub % match weighted slice progress#49
jsolly merged 1 commit into
mainfrom
cursor/pie-progress-math-356d

Conversation

@jsolly

@jsolly jsolly commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Problem

The center “% captured” is cleared questions / all questions, but every lifecycle slice was drawn as an equal 1/8 wedge. Basics has 50 questions (~25% of the deck) while other units have 22 each (~11%). Filling Basics looked like “1/8 of the pie,” so a hub reading like 20% could look higher than the filled area when eye-averaging equal wedges.

Example that matches the reported confusion: Basics at 80% with everything else empty → hub correctly shows 20% (40/204), but under equal wedges that filled area looked closer to ~10%.

Fix

  • Weight each pie slice’s angle by its question count so filled area ≈ hub %.
  • Derive the hub percent from the same slice stats (cleared / total) used for radial fill.
  • Add src/lib/pie-progress.ts plus scripts/verify-pie-progress.mjs covering empty, Basics-heavy ~20%, single-slice, even 50%, and full-capture scenarios.

Verify

node --experimental-strip-types scripts/verify-pie-progress.mjs

UI smoke (seeded localStorage): hub matched expected for empty 0%, userLike20 20%, basics80 20%, vehicleFull 11%, halfAll 50%, thinSpread 20%; mobile 390×844 for userLike20/halfAll. Console clean.

Basics 80% → hub 20%
Vehicle full → hub 11%
Half all → hub 50%
Mobile userLike20 → hub 20%

Open in Web Open in Cursor 

Equal wedges made Basics (~25% of the deck) look like 1/8 of the
wheel, so hub % captured looked higher than the filled area. Angle
each slice by its question count and derive the hub from the same
cleared/total math so filled area matches the center percentage.

Co-authored-by: John Solly <jsolly@users.noreply.github.com>
@jsolly
jsolly marked this pull request as ready for review July 19, 2026 00:07
@jsolly
jsolly merged commit 6721d3f into main Jul 19, 2026
4 checks passed
@jsolly
jsolly deleted the cursor/pie-progress-math-356d branch July 19, 2026 00:13
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.

2 participants