Repository navigation
refactor(email): use the shared WEEKS_PER_ROW in the life PDF grid - #5187
Conversation
The reflection life PDF renders the same week grid as the web Life View,
and its own comment says so ("Keep the Life View grid"). LifeGrid.tsx
derives that grid from the exported WEEKS_PER_ROW, but the PDF renderer
hardcoded 52 for both the row length and the dot index while already
importing DEFAULT_LIFESPAN and getCompletedLifeWeeks from the same
module.
That left one divergent copy of a domain constant: the attachment's
percentage line comes from reflectionLifeProgress -> getTotalLifeDots ->
WEEKS_PER_ROW, so a change to WEEKS_PER_ROW would silently desync the
grid drawn in the PDF from the percentage printed beside it.
Use the shared constant in both expressions, and stop the test
re-encoding the same literals as 79 * 52.
Behavior preserving: WEEKS_PER_ROW is 52.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HmwVQGU4sTAu5rbJPLsEbE
Tech-debt sweep, 2026-11-02 to 2026-11-09 (50 merges)Addressed: 1 item — the Examined and deliberately left alone, so the next sweep does not redo them:
A note worth raising, since it concerns this sweep more than this PR: 8 of the week's 50 merges were tech-debt refactors, and 5 of them rework the same date-picker hint cluster. Each of those is individually defensible, but in aggregate they are churn on code that was already fine, carrying real review and regression cost for no user-visible change. The honest read of this week is that there was roughly one thing worth fixing, not eight. Recommend either narrowing this routine to mechanically-verifiable findings (knip/lint/type signal, drifted shared constants) or dropping its cadence, rather than letting it keep finding something to do in the same files. Happy to leave the date-picker cluster off the sweep list entirely if you prefer. Generated by Claude Code |
What and why
The reflection life PDF renders the same week grid as the web Life View, and its own comment says so ("Keep the Life View grid, with a plain white background for the attachment").
LifeGrid.tsxderives that grid from the exportedWEEKS_PER_ROW, butreflection-life-image.tshardcoded52for both the row length and the dot index, while already importingDEFAULT_LIFESPANandgetCompletedLifeWeeksfrom that same@core/life/life-mathmodule.That left one divergent copy of a domain constant, and it is a live coupling rather than a cosmetic one: the percentage line printed in the same attachment comes from
reflectionLifeProgress->getTotalLifeDots->WEEKS_PER_ROW. A change toWEEKS_PER_ROWwould silently desync the grid drawn in the PDF from the percentage printed beside it, with no test catching it, because the test re-encoded the same literals as79 * 52.This uses the shared constant in both expressions and derives the test's expected rect count from
DEFAULT_LIFESPAN * WEEKS_PER_ROWinstead. Behavior preserving:WEEKS_PER_ROWis52, so the rendered PDF is byte-identical. Deliberately unchanged: the renderer still usesDEFAULT_LIFESPANfor the row count rather than a user lifespan, since reflection emails do not carry one.Found by a tech-debt sweep of the last 7 days of merges. It was the only genuine finding;
bun knipandbun lintare clean, and theproviderVersionand date-picker-keys clusters from this week have already converged on shared helpers.Verify
VERDICT: FAILfrombun run verify --strict, on a pre-existing environmental failure only.Checks run:
type-check,lint,knip(all pass),test:backend:fast.PRE-EXISTING:
test:backend:fastfails 13 tests inGET /api/configandSSE Server(Timeout waiting for SSE event,500 GET /api/events/stream). This sandbox has nocompass.yaml, whichAGENTS.mdlists as required for backend, auth, MongoDB, sync and SSE. Verify does not baselinetest:backendautomatically, so I ran it on a cleanorigin/maintree: 13 failures there too, the same suites. This diff touches only an SVG grid constant in the email package and adds no new failures.FLAKY: none.
bun test packages/backend/src/email/reflection-life-image.test.ts: 4 pass, 0 fail.Generated by Claude Code