Skip to content

The confirmation and the worker emails each build the same participant props, and two props interfaces declare them twice #1036

Open

Description

@richshaw

What happens

Two functions build the same props from a commitment row, line for line:

  • confirmationFor in src/email/notify.ts
  • workerEmailParts in src/jobs/worker-email.ts

Both compute locale from localeOfSignup(row.signup.settings.locale), then set participantName, signupTitle, manageUrl (via commitmentEditUrl), ...slotText(…) and notes. Each also declares its own local CommitmentRow type.

The props are declared twice as well. CommitmentConfirmationEmailProps (commitment-confirmation.tsx) and ReminderEmailProps (reminder.tsx) each list locale, participantName, signupTitle, manageUrl, slotDetails, slotSummary and notes. #813 merged only the reminder with the slot-change email, so the confirmation's copy is still separate.

As a result, a change to how the manage link or the language is chosen has to be made in two builders and two interfaces.

Fix, in outline

  • In src/email/commitment-row.ts (already shared by the web and worker paths), add an exported CommitmentRow type and participantEmailProps(db, row, editToken). Make slotText private if nothing else uses it.
  • Add a ParticipantEmailProps base interface (e.g. in templates/layout.tsx), and have both props interfaces extend it.
  • confirmationFor spreads the helper and adds quantity and promisesReminder. workerEmailParts spreads participantEmailProps(db, row, editTokenFor(row.commitment.id)) and adds unsubscribeUrl.

Watch for

  • Keep the editToken parameter. Every production value equals editTokenFor(id) today, but dropping it touches the routes, scripts/confirmation-email.ts and the e2e helper for almost no gain. It would also stop the e2e check from using the server's own token.
  • This is close to line-neutral (a trial came to about +70/−63). Its value is one place for the rule, not fewer lines.
  • Rendered emails must not change.

Done when

  • One helper builds the shared participant props, and both builders use it.
  • One base interface declares the shared props.
  • pnpm lint && pnpm format:check && pnpm typecheck && pnpm knip && pnpm test pass, and pnpm test:db src/email src/jobs passes.

Found by the pipeline's refactor scout in the email code (src/email, src/jobs/worker-email.ts), at c47d56b. Checked by an independent verify agent. It traced every source of the edit token and made the change in a scratch worktree. Typecheck (web and worker tsconfigs), lint, knip, format and pnpm test src/email src/jobs all passed. The props both builders produced for a fixed row were deep-equal before and after. Then it reverted. pnpm test:db couldn't run there. Held back by the scout's cap. Add pipeline:ready to queue it. https://claude.ai/code/session_016YZ9STGBofRAhmGUZoyzWK

Activity

  1. added
    enhancement
    on Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions