feat(emails): confirm a new schedule to the account holder (chat#1889 row 14)

SW
4mo ago
+546-44

Matrix row 14 in recoupable/chat#1889 — the last genuine gap in the email journey. Stacked on #784 (shared email layout), which the issue lists as its blocker. Review/merge after #784.

Why

A signup finishes onboarding, schedules a report, and then hears nothing until a report lands days later. There is no confirmation that anything was actually scheduled, and no record of when it will arrive — the weakest link between signup and the first delivered value.

What changed

  • buildScheduleConfirmationEmail — subject Scheduled: <title>, body naming the report and its cadence, CTA to /tasks. Renders through the shared renderEmailLayout so it reads as one family with the welcome, valuation, and weekly-report emails.
  • describeCronCadence — turns 0 13 * * 1 into Mondays at 13:00 UTC, honouring an explicit IANA zone when the task has one. Deliberately narrow: it describes only the fixed-weekday and fixed-daily shapes onboarding actually creates, and otherwise falls back to the schedule <cron>. An honest cron string in an email beats a confidently wrong sentence about when someone's report will arrive.
  • sendScheduleConfirmationEmail — fires from createTaskHandler after the schedule is materialized (the same rule the welcome and valuation emails follow), deduped per task id via a "task_id":"…" marker in email_send_log.raw_body, and swallows its own failures so a Resend or DB problem can never fail task creation. A wallet/phone-only login with no address is skipped silently.

Verification

TDD, red → green on both new units (each RED as "Cannot find module", then green):

```
✓ lib/emails/tests/buildScheduleConfirmationEmail.test.ts (4 tests)
✓ lib/emails/tests/describeCronCadence.test.ts (4 tests)
```

createTaskHandler.test.ts gained two behavioural tests — that a successful create does confirm with the right payload, and that a failed create does not send. Adding the send also surfaced that this suite loaded the Resend client transitively (RESEND_API_KEY is not configured); it now mocks the sender, mirroring how createAccountHandler.test.ts mocks sendWelcomeEmail.

```
pnpm exec vitest run lib/tasks lib/emails
Test Files 49 passed (49)
Tests 285 passed (285)

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

pnpm exec tsc --noEmit clean for the touched files (repo baseline of 236 pre-existing errors in lib/trigger/__tests__ is unchanged).

Live send verification pending.

Tracked in chat#1889 (matrix row 14).


Summary by cubic

Adds a schedule confirmation email after task creation so users know what was scheduled and when. Introduces a shared email layout adopted by welcome, valuation, and weekly-report emails for a consistent look; addresses chat#1889 (row 14).

  • New Features

    • Schedule confirmation email: subject "Scheduled: .
    • Triggered post-creation; deduped per task via email_send_log; skips accounts without an email; never blocks task creation.
    • Shared renderEmailLayout used by welcome and valuation builders, and by weekly reports via processAndSendEmail.
  • Bug Fixes

    • Font stack uses single quotes to avoid breaking style attributes in email clients.