feat(emails): welcome steps mirror the app's four checkpoints (chat#1889 item 1, part 4)

SW
4mo ago
+375-74

Part 4 of item 1 in recoupable/chat#1889. Stacked on #784 (shared email layout) — it rewrites buildWelcomeEmail, so this branches off it rather than conflicting. Review/merge after #784.

Why

Three progress models disagreed:

SurfaceSteps
chat derived checkpoints (ONBOARDING_STEP_IDS)4 — artists, socials, catalog, task
This email5 — the four plus "See your baseline valuation"
chat RosterSocialsFlow2 ("Step 1 of 2")

Same account, three answers to "how much setup is left."

An earlier revision of the issue proposed fixing this by adding a fifth valuation checkpoint to the app. That was wrong on two counts, and the issue now carries a dated correction:

  1. A valuation checkpoint is not derivable. catalogs is id, name, created_at, updated_at — no persisted valuation. The number is computed live from catalog measurements at read time, so a fifth predicate would either duplicate the catalog predicate or push a network call into deriveOnboardingState, which is deliberately pure over three cheap sources.
  2. Numbering the payoff as a chore was the wrong model. The valuation is the number a lead converted on. It belongs at the end as the reward, not as item 5 on a checklist.

What changed

  • welcomeOnboardingSteps drops to the app's four checkpoints, in order.
  • New renderValuationPayoff renders the baseline valuation after the numbered list, visually distinct ("Then: your baseline valuation"), still linking /setup/valuation. So the payoff gets more prominence, not less.
  • Body copy: "five step path" → "four step path".
  • New welcomeOnboardingSteps.test.ts asserts titles, order, and paths match the app's derived checkpoints. chat and api share no package, so the list is necessarily a deliberate mirror — this test is what keeps the mirror honest instead of pretending to a shared source.

Verification

TDD, red → green:

```

RED — all three assertions fail against the 5-step list

FAIL lib/emails/welcome/tests/welcomeOnboardingSteps.test.ts
Test Files 1 failed (1)
Tests 3 failed (3)
```

Two pre-existing tests encoded the old 5-step contract and were updated to the new one (buildWelcomeEmail > walks the app's four derived checkpoints in order, and renderWelcomeSteps > points every step at its /setup route), plus a new guard that the valuation is not numbered among the steps.

```
pnpm exec vitest run lib/emails
Test Files 33 passed (33)
Tests 206 passed (206)

pnpm exec vitest run # full suite, no regressions
Test Files 786 passed (786)
Tests 4254 passed (4254)
```

pnpm exec tsc --noEmit reports 236 errors on this branch and 236 on untouched api/main — identical pre-existing baseline in lib/trigger/__tests__; none in the files this PR touches.

Live send verification pending (needs a preview send to confirm the payoff block renders in a real client).

Tracked in chat#1889 (matrix row 7).


Summary by cubic

Updates the welcome email to match the app’s four onboarding checkpoints and reframes valuation as a payoff, while adding a shared email layout so all automated emails look consistent.

  • New Features

    • Welcome steps now mirror the app’s four checkpoints in order: artists, socials, catalog, tasks (chat#1889).
    • Added a separate “Then: your baseline valuation” payoff block after the list, linking to /setup/valuation.
    • All emails now use a shared house-style layout (wordmark header, shadow-as-border card, CTA, footer) for consistency.
  • Refactors

    • Added renderEmailLayout and adopted it in the welcome email, valuation report, and the processAndSendEmail weekly-report path; removed duplicated chrome from individual builders.
    • Fixed font-stack quoting in inline styles to prevent broken attributes in some email clients; added tests and consistency checks for layout markers.

Summary by CodeRabbit

  • New Features
    • Added a consistent branded layout for emails, including standardized headers, footers, styling, and optional call-to-action buttons.
    • Updated welcome emails with a streamlined four-step onboarding flow and a dedicated baseline valuation section.
    • Added links to setup and valuation actions from relevant email content.
  • Improvements
    • Standardized valuation report and welcome email presentation for a more consistent experience across email clients.