Skip to content

fix(newsletter): render Prompt custom sections#5884

Merged
bokelley merged 1 commit into
mainfrom
render-prompt-custom-sections
Jul 17, 2026
Merged

fix(newsletter): render Prompt custom sections#5884
bokelley merged 1 commit into
mainfrom
render-prompt-custom-sections

Conversation

@bokelley

Copy link
Copy Markdown
Contributor

Summary

  • render The Prompt custom sections in generated email HTML, plain text, and Slack output
  • include custom sections and pasted content in published perspective markdown
  • route scheduled perspective publishing through the canonical Prompt markdown builder while preserving non-blocking failure handling

Root cause

The admin editor persisted custom sections, but The Prompt's normal generated-content render paths did not consume them. Scheduled perspective publishing also used a separate legacy markdown builder, so it could diverge from test sends and admin-triggered sends.

Impact

Custom text blocks saved in the newsletter editor now appear in test sends, scheduled delivery, Slack, web previews, and published perspectives. Position 0 renders before generated sections and positive positions render after them, matching The Build's existing behavior.

Closes #5873.

Validation

  • focused Prompt renderer, cover-image, and weekly-digest job tests
  • npm run typecheck
  • git diff --check
  • independent code, test, and newsletter-workflow expert reviews

No changeset is required because this is server-side newsletter behavior only.

@bokelley
bokelley marked this pull request as ready for review July 16, 2026 23:54

@aao-secretariat aao-secretariat Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean fix. Custom sections were persisted by the editor but never consumed by the generated-content render paths — this closes that gap across all four surfaces and consolidates scheduled publishing onto the canonical Prompt markdown builder.

Things I checked

  • Tracking-id stability (server/src/addie/templates/weekly-digest.ts:148-156): index is captured via .map((section, index) => ({ section, index })) before the placement .filter, so IDs stay stable and non-colliding across the before/after passes. Test asserts custom_1_1 and custom_2_1 — only passes if the index precedes the filter. Right shape.
  • Placement logic is consistent across all four paths — email HTML, plain text, Slack, and perspective markdown all treat position 0 as before generated content and position >0 as after. Matches The Build's existing behavior.
  • digest-publisher refactor (server/src/addie/services/digest-publisher.ts): buildFullMarkdown (74 lines) deleted, the single caller now takes a markdown param, and DigestContent is still load-bearing via extractTags/openingTake — no dead import, no orphaned caller. The scheduled path and test/admin sends can no longer diverge.
  • Non-blocking failure handling preserved (server/src/addie/jobs/weekly-digest.ts:337): void (async () => { ... })().catch(...) keeps publishing off the critical path; import() and buildMarkdown throws are caught. Happy path is unchanged.
  • No changeset, correctly. No file touches static/schemas/source/**, docs/reference/**, mintlify-docs/reference/**, or the schema-build pipeline. Nothing on the wire. MUST FIX #6 doesn't fire.

Minor nits (non-blocking)

  1. position doc comment now overstates its role. server/src/newsletters/config.ts documents CustomSection.position as an insertion index, but the placement model is binary (0 = before, >0 = after) — sections at positions 1 and 5 render in array order, not position order. Intentional (matches The Build), but worth tightening the comment to "0 = before generated content, >0 = after."
  2. Dynamic import intent. The import('../../newsletters/the-prompt/index.js') inside the IIFE at weekly-digest.ts:337 is presumably breaking a circular import. A one-line comment saying so keeps a future maintainer from "cleaning it up" into a static import and reintroducing the cycle.

code-reviewer: ready to push — no blockers, no majors. Note that the reviewer's environment blocked the PR-branch fetch, so the suite wasn't run locally; confirm CI is green before merge.

LGTM. Follow-ups noted below.

@bokelley
bokelley merged commit fdd3c21 into main Jul 17, 2026
16 checks passed
@bokelley
bokelley deleted the render-prompt-custom-sections branch July 17, 2026 02:08
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.

Newsletter custom sections not rendering

1 participant