Skip to content

feat(workflows): draft and publish edits to transactional email templates - #118664

Merged
trunk-io[bot] merged 5 commits into
masterfrom
posthog/transactional-email-drafts
Oct 19, 2026
Merged

trunk-io[bot] merged 5 commits into
masterfrom
posthog/transactional-email-drafts

Conversation

@mayteio

@mayteio mayteio commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Problem

  • A person editing a transactional email template changes the live email on every save. There is no way to work on a change, test it, and then ship it.
  • Workflows already work this way: edits autosave to a draft, and the live version keeps running until you publish. This brings the same flow to transactional templates, as requested by the person driving the transactional email work.
  • Follows #117726, which added transactional templates.

Changes

  • Edits to a transactional template's subject and body autosave to a draft about 1.5 seconds after typing stops. An "Editing draft" tag shows while there are unpublished changes.
  • Sends keep using the published content. The backing workflow does not change until you publish.
  • The Save button becomes Publish. Publishing writes a new workflow version and clears the draft.
  • Discard draft sits in the Publish button's menu, behind a confirm. It brings back the published version.
  • Send test already sends what is in the editor, so it tests the draft.
  • Name and description still save on Publish. Templates that are not transactional keep the old Save flow.

Before (every save goes live):

pr-before

After, with an unpublished edit:

pr-after-draft

pr-after-menu

How it works:

  • MessageTemplate.draft_content is a new nullable JSON column, added in migration 0007 on a non-hot table.
  • A PATCH that only sets draft_content skips the sendability check and the workflow sync. A draft may have a blank subject while you type.
  • A PATCH that sets content publishes it and clears the draft. Setting draft_content to null discards it.
  • The MCP email template tools exclude draft_content, so agents keep editing the live content as before.

Mechanical: regenerated OpenAPI types and MCP code, kea typegen, and one ENUM_NAME_OVERRIDES entry. The draft serializer reuses the templating choice field, so the generated enum name needs pinning.

Note

The design action (MCP surgical edits) still edits the live content. If a draft exists, the next publish overwrites that edit. That stays out of scope here.

How did you test this code?

Test rationale:

  • test_saving_a_draft_leaves_the_sent_email_unchanged catches a draft write that syncs the workflow or gets rejected for a blank subject.
  • The extended test_saving_a_transactional_template_writes_a_new_workflow_version catches a publish that leaves the draft behind.
  • Two kea logic tests catch an edit that goes to content instead of draft_content, and a publish that sends the draft field back.

Checked by hand in a local dev stack with a seeded transactional template:

  • An edit shows "Editing draft", and the database keeps the live subject with the new subject in the draft.
  • A reload brings the draft back.
  • Publish wrote workflow version 2 and cleared the draft.
  • Discard cleared the draft and brought the live subject back into the editor.

Once, before the final runs, an autosave right after publish created a new draft with the subject but no body. Three more publish runs did not reproduce it. Worth watching in review.

👉 Stay up-to-date with PostHog coding conventions for a smoother review.

Release status

  • This change is behind a feature flag and is not available to users

Docs update

None. Transactional email is not documented yet.

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Agent: Claude Code, Opus 5.5 (claude-opus-5-5)

  • Skills: /django-migrations, /improving-drf-endpoints (via repo rules), /adopting-generated-api-types, /writing-tests, /writing-user-facing-copy, /writing-pr-descriptions.
  • The draft holds content only, following the workflow editor, where name and description are not part of the draft either.
  • No duplicate open PR found.

Created with PostHog Desktop

@mayteio mayteio self-assigned this Oct 16, 2026
@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

🤖 CI report

⚠️ Trunk lane — backend Python lane

This PR is assigned to the backend Python lane. It runs backend Python tests and may merge in parallel with PRs in other lanes.

⚠️ Complexity (TypeScript) — 1 function above the limit (max 43)

Cyclomatic complexity above the limit in changed typescript files (10 for production files, 15 for test files). Warn only: worth simplifying when you next touch these functions.

Function Location Complexity Limit
MessageTemplate products/workflows/frontend/TemplateLibrary/MessageTemplate.tsx:54 43 10
✅ Duplication (Python) — clean

New Python code duplication introduced by this branch. Fails at 70+ tokens in app code, or 150+ tokens when both copies live in test files. Advisory while the gate proves itself: extract a shared helper instead of copying.

⚠️ Duplication (TypeScript) — 1 new duplicated block (worst 118 tokens)

New TypeScript code duplication introduced by this branch. Fails at 70+ tokens in app code, or 150+ tokens when both copies live in test files. Advisory while the gate proves itself: extract a shared helper instead of copying.

First copy Second copy Lines Tokens
products/workflows/frontend/TemplateLibrary/messageTemplateLogic.ts:332 products/workflows/frontend/TemplateLibrary/messageTemplateLogic.ts:361 29 118
⚠️ Comment density — 3% of added code lines are comments (16 of 508)

This section warns when comments are more than 3% of the code lines a PR adds, and alerts above 6%. Before agent-assisted PRs, the typical share was about 2%. Only full-line comments count. Docstrings, generated files, snapshots, migrations, and workflow files are left out.

Comments that restate the code, record how the change came about, or narrate the next line add noise for the next reader. Keep the comments that explain a reason the code cannot show, and remove the rest. See .agents/skills/writing-code-comments/SKILL.md for the house rules.

Files with the most added comment lines:

File Comment lines Added lines
products/workflows/frontend/TemplateLibrary/messageTemplateLogic.ts 9 285
products/messaging/backend/presentation/views/message_templates.py 3 25
products/messaging/backend/models/message_template.py 1 2
products/messaging/backend/services/message_templates.py 1 7
products/messaging/backend/tests/api/test_transactional_email.py 1 15
products/workflows/frontend/TemplateLibrary/messageTemplateLogic.test.ts 1 74

This check does not block merging. It updates on every push and clears when the share drops.

⚠️ Bundle size — 🔺 +3.9 KiB (+0.0%)

Uncompressed size of every built .js bundle, compared against the base branch.

Total: 76.33 MiB · 🔺 +3.9 KiB (+0.0%)

File Size Δ vs base
posthog-app/_parent/products/workflows/frontend/TemplateLibrary/MessageTemplate.js 33.7 KiB 🔺 +3.5 KiB (+11.6%)

Posted automatically by build-bundle-size-report · uncompressed bytes from dist-report

✅ Eager graph — within budget

How much code each root ships on the eager path — downloaded and parsed before the surface is interactive. Measured from the esbuild output chunks (post-tree-shake, static imports only); lazy import() / React.lazy chunks are not counted.

Root Eager (shipped) Δ vs base Budget
entry (logged-out pages, app bootstrap)
src/index.tsx
1019.1 KiB · 24 files 🔺 +105 B (+0.0%) █████████░ 87.0% of 1.14 MiB
logged-out boot: index + App + bootApp (preloaded by every page, including /login)
src/index.tsx + src/scenes/App.tsx + src/scenes/bootApp.ts
2.89 MiB · 608 files 🔺 +105 B (+0.0%) ██████████ 95.3% of 3.03 MiB
authenticated shell (every logged-in page)
src/scenes/AuthenticatedShell.tsx
7.33 MiB · 2,535 files 🔺 +105 B (+0.0%) ██████████ 97.8% of 7.50 MiB
dashboard scene
src/scenes/dashboard/Dashboard.tsx
9.47 MiB · 3,621 files 🔺 +105 B (+0.0%) █████████░ 94.5% of 10.01 MiB
today home path
src/scenes/AuthenticatedShell.tsx + src/scenes/project-homepage/ProjectHomepage.tsx + src/scenes/project-homepage/today/TodayHome.tsx
7.72 MiB · 2,872 files 🔺 +105 B (+0.0%) ██████████ 99.8% of 7.74 MiB
events scene
src/scenes/activity/explore/EventsScene.tsx
9.02 MiB · 3,439 files 🔺 +105 B (+0.0%) █████████░ 94.0% of 9.59 MiB
web analytics scene
src/scenes/web-analytics/WebAnalyticsScene.tsx
9.87 MiB · 3,655 files 🔺 +105 B (+0.0%) █████████░ 91.1% of 10.83 MiB
replay detail scene
src/scenes/session-recordings/detail/SessionRecordingDetail.tsx
8.62 MiB · 3,266 files 🔺 +105 B (+0.0%) █████████░ 91.0% of 9.47 MiB

🟢 node_modules/monaco-editor/ stays out of src/index.tsx
🟢 src/lib/components/ActivityLog/describers stays out of src/index.tsx
🟢 node_modules/@posthog/brand/dist/generated/hoggies/svg/ stays out of src/index.tsx
🟢 node_modules/@posthog/brand/dist/generated/hoggies/components/ stays out of src/index.tsx
🟢 node_modules/monaco-editor/ stays out of src/index.tsx + src/scenes/App.tsx + src/scenes/bootApp.ts
🟢 src/layout/navigation-3000/navigationLogic.tsx stays out of src/index.tsx + src/scenes/App.tsx + src/scenes/bootApp.ts
🟢 src/scenes/dashboard/dashboardLogic.tsx stays out of src/index.tsx + src/scenes/App.tsx + src/scenes/bootApp.ts
🟢 src/lib/lemon-ui/LemonMarkdown/ stays out of src/index.tsx + src/scenes/App.tsx + src/scenes/bootApp.ts
🟢 src/lib/components/RichContentEditor/ stays out of src/index.tsx + src/scenes/App.tsx + src/scenes/bootApp.ts
🟢 src/lib/components/CodeSnippet/ stays out of src/index.tsx + src/scenes/App.tsx + src/scenes/bootApp.ts
🟢 src/taxonomy/core-filter-definitions-by-group.json stays out of src/index.tsx + src/scenes/App.tsx + src/scenes/bootApp.ts
🟢 node_modules/zod/ stays out of src/index.tsx + src/scenes/App.tsx + src/scenes/bootApp.ts
🟢 src/scenes/billing/billingLogic.tsx stays out of src/index.tsx + src/scenes/App.tsx + src/scenes/bootApp.ts
🟢 src/lib/components/ProductEmptyState/productSetupPreloadLogic.ts stays out of src/index.tsx + src/scenes/App.tsx + src/scenes/bootApp.ts
🟢 node_modules/monaco-editor/ stays out of src/scenes/AuthenticatedShell.tsx
🟢 src/lib/components/ActivityLog/describers stays out of src/scenes/AuthenticatedShell.tsx
🟢 products/dashboards/frontend/widgets/previews/ stays out of src/scenes/AuthenticatedShell.tsx
🟢 src/scenes/session-recordings/player/sessionRecordingPlayerLogic.ts stays out of src/scenes/AuthenticatedShell.tsx
🟢 products/wizard/frontend/runs/WizardRunDetailsDrawer.tsx stays out of src/scenes/AuthenticatedShell.tsx
🟢 zod/v4/locales/de.js stays out of src/scenes/AuthenticatedShell.tsx
🟢 node_modules/@posthog/brand/dist/generated/hoggies/svg/ stays out of src/scenes/AuthenticatedShell.tsx
🟢 node_modules/@posthog/brand/dist/generated/hoggies/components/ stays out of src/scenes/AuthenticatedShell.tsx
🟢 src/scenes/session-recordings/playlist/SessionRecordingsPlaylist.tsx stays out of src/scenes/dashboard/Dashboard.tsx
🟢 src/scenes/web-analytics/tiles/WebAnalyticsTile.tsx stays out of src/scenes/dashboard/Dashboard.tsx
🟢 src/queries/validators.js stays out of src/scenes/dashboard/Dashboard.tsx
🟢 src/scenes/project-homepage/ai-first/AiFirstHomepage.tsx stays out of src/scenes/AuthenticatedShell.tsx + src/scenes/project-homepage/ProjectHomepage.tsx + src/scenes/project-homepage/today/TodayHome.tsx
🟢 src/scenes/project-homepage/today/TodayReportPage.tsx stays out of src/scenes/AuthenticatedShell.tsx + src/scenes/project-homepage/ProjectHomepage.tsx + src/scenes/project-homepage/today/TodayHome.tsx
🟢 src/queries/Query/Query.tsx stays out of src/scenes/AuthenticatedShell.tsx + src/scenes/project-homepage/ProjectHomepage.tsx + src/scenes/project-homepage/today/TodayHome.tsx
🟢 src/scenes/session-recordings/playlist/SessionRecordingsPlaylist.tsx stays out of src/scenes/activity/explore/EventsScene.tsx
🟢 src/scenes/web-analytics/tiles/WebAnalyticsTile.tsx stays out of src/scenes/activity/explore/EventsScene.tsx
🟢 src/queries/validators.js stays out of src/scenes/activity/explore/EventsScene.tsx
🟢 src/scenes/web-analytics/LiveMetricsDashboard/LiveWebAnalyticsMetrics.tsx stays out of src/scenes/web-analytics/WebAnalyticsScene.tsx
🟢 products/product_analytics/frontend/insights/trends/WorldMap/countryVectors.tsx stays out of src/scenes/web-analytics/WebAnalyticsScene.tsx
🟢 src/scenes/settings/SettingsMap.tsx stays out of src/scenes/session-recordings/detail/SessionRecordingDetail.tsx
🟢 @jspm/core/nodelibs/browser/fs stays out of src/scenes/session-recordings/detail/SessionRecordingDetail.tsx

Largest files eagerly shipped from src/index.tsx
Size File
126.8 KiB ../node_modules/.pnpm/react-dom@18.3.1_react@18.3.1/node_modules/react-dom/cjs/react-dom.production.min.js
24.6 KiB ../node_modules/.pnpm/buffer@6.0.3/node_modules/buffer/index.js
6.3 KiB ../node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react.production.min.js
4.5 KiB ../node_modules/.pnpm/@jspm+core@2.1.0/node_modules/@jspm/core/nodelibs/browser/process.js
3.9 KiB ../node_modules/.pnpm/scheduler@0.23.2/node_modules/scheduler/cjs/scheduler.production.min.js
1.4 KiB ../node_modules/.pnpm/base64-js@1.5.1/node_modules/base64-js/index.js
1.4 KiB src/index.tsx
1.3 KiB src/RootErrorBoundary.tsx
1.0 KiB src/lib/utils/bootTiming.ts
912 B ../node_modules/.pnpm/ieee754@1.2.1/node_modules/ieee754/index.js
Largest files eagerly shipped from src/index.tsx + src/scenes/App.tsx + src/scenes/bootApp.ts
Size File
321.6 KiB ../node_modules/.pnpm/posthog-js@1.438.12_@types+react@18.3.27_react@18.3.1/node_modules/posthog-js/dist/module.mjs
221.3 KiB ../node_modules/.pnpm/@posthog+icons@0.38.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@posthog/icons/dist/posthog-icons.es.js
126.8 KiB ../node_modules/.pnpm/react-dom@18.3.1_react@18.3.1/node_modules/react-dom/cjs/react-dom.production.min.js
106.0 KiB src/products.tsx
99.3 KiB src/lib/api.ts
69.0 KiB src/lib/lemon-ui/icons/icons.tsx
38.7 KiB ../node_modules/.pnpm/@dnd-kit+core@6.0.8_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@dnd-kit/core/dist/core.esm.js
33.9 KiB ../node_modules/.pnpm/kea@4.0.0-pre.6_patch_hash=139b8d1f1304f9d9da452a9a1244c94ea679dbcb85687d8999563146879fb6f5_react@18.3.1/node_modules/kea/lib/index.cjs.js
28.9 KiB src/scenes/scenes.ts
27.7 KiB src/lib/constants.tsx
Largest files eagerly shipped from src/scenes/AuthenticatedShell.tsx
Size File
321.6 KiB ../node_modules/.pnpm/posthog-js@1.438.12_@types+react@18.3.27_react@18.3.1/node_modules/posthog-js/dist/module.mjs
279.0 KiB src/taxonomy/core-filter-definitions-by-group.json
221.3 KiB ../node_modules/.pnpm/@posthog+icons@0.38.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@posthog/icons/dist/posthog-icons.es.js
185.6 KiB ../packages/quill/packages/quill/dist/index.js
153.7 KiB ../node_modules/.pnpm/re2js@0.4.1/node_modules/re2js/build/index.esm.js
126.8 KiB ../node_modules/.pnpm/react-dom@18.3.1_react@18.3.1/node_modules/react-dom/cjs/react-dom.production.min.js
106.0 KiB src/products.tsx
99.3 KiB src/lib/api.ts
93.3 KiB ../node_modules/.pnpm/prosemirror-view@1.40.1/node_modules/prosemirror-view/dist/index.js
90.6 KiB ../node_modules/.pnpm/@tiptap+core@3.20.6_@tiptap+pm@3.20.6/node_modules/@tiptap/core/dist/index.js
Largest files eagerly shipped from src/scenes/dashboard/Dashboard.tsx
Size File
321.6 KiB ../node_modules/.pnpm/posthog-js@1.438.12_@types+react@18.3.27_react@18.3.1/node_modules/posthog-js/dist/module.mjs
279.0 KiB src/taxonomy/core-filter-definitions-by-group.json
221.3 KiB ../node_modules/.pnpm/@posthog+icons@0.38.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@posthog/icons/dist/posthog-icons.es.js
185.6 KiB ../packages/quill/packages/quill/dist/index.js
153.7 KiB ../node_modules/.pnpm/re2js@0.4.1/node_modules/re2js/build/index.esm.js
139.9 KiB ../packages/quill/packages/primitives/dist/index.js
126.8 KiB ../node_modules/.pnpm/react-dom@18.3.1_react@18.3.1/node_modules/react-dom/cjs/react-dom.production.min.js
106.0 KiB src/products.tsx
99.3 KiB src/lib/api.ts
93.3 KiB ../node_modules/.pnpm/prosemirror-view@1.40.1/node_modules/prosemirror-view/dist/index.js
Largest files eagerly shipped from src/scenes/AuthenticatedShell.tsx + src/scenes/project-homepage/ProjectHomepage.tsx + src/scenes/project-homepage/today/TodayHome.tsx
Size File
321.6 KiB ../node_modules/.pnpm/posthog-js@1.438.12_@types+react@18.3.27_react@18.3.1/node_modules/posthog-js/dist/module.mjs
279.0 KiB src/taxonomy/core-filter-definitions-by-group.json
221.3 KiB ../node_modules/.pnpm/@posthog+icons@0.38.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@posthog/icons/dist/posthog-icons.es.js
185.6 KiB ../packages/quill/packages/quill/dist/index.js
153.7 KiB ../node_modules/.pnpm/re2js@0.4.1/node_modules/re2js/build/index.esm.js
126.8 KiB ../node_modules/.pnpm/react-dom@18.3.1_react@18.3.1/node_modules/react-dom/cjs/react-dom.production.min.js
106.0 KiB src/products.tsx
99.3 KiB src/lib/api.ts
93.3 KiB ../node_modules/.pnpm/prosemirror-view@1.40.1/node_modules/prosemirror-view/dist/index.js
90.6 KiB ../node_modules/.pnpm/@tiptap+core@3.20.6_@tiptap+pm@3.20.6/node_modules/@tiptap/core/dist/index.js
Largest files eagerly shipped from src/scenes/activity/explore/EventsScene.tsx
Size File
321.6 KiB ../node_modules/.pnpm/posthog-js@1.438.12_@types+react@18.3.27_react@18.3.1/node_modules/posthog-js/dist/module.mjs
279.0 KiB src/taxonomy/core-filter-definitions-by-group.json
221.3 KiB ../node_modules/.pnpm/@posthog+icons@0.38.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@posthog/icons/dist/posthog-icons.es.js
185.6 KiB ../packages/quill/packages/quill/dist/index.js
153.7 KiB ../node_modules/.pnpm/re2js@0.4.1/node_modules/re2js/build/index.esm.js
139.9 KiB ../packages/quill/packages/primitives/dist/index.js
126.8 KiB ../node_modules/.pnpm/react-dom@18.3.1_react@18.3.1/node_modules/react-dom/cjs/react-dom.production.min.js
106.0 KiB src/products.tsx
99.3 KiB src/lib/api.ts
93.3 KiB ../node_modules/.pnpm/prosemirror-view@1.40.1/node_modules/prosemirror-view/dist/index.js
Largest files eagerly shipped from src/scenes/web-analytics/WebAnalyticsScene.tsx
Size File
321.6 KiB ../node_modules/.pnpm/posthog-js@1.438.12_@types+react@18.3.27_react@18.3.1/node_modules/posthog-js/dist/module.mjs
279.0 KiB src/taxonomy/core-filter-definitions-by-group.json
221.3 KiB ../node_modules/.pnpm/@posthog+icons@0.38.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@posthog/icons/dist/posthog-icons.es.js
185.6 KiB ../packages/quill/packages/quill/dist/index.js
182.6 KiB src/queries/validators.js
153.7 KiB ../node_modules/.pnpm/re2js@0.4.1/node_modules/re2js/build/index.esm.js
139.9 KiB ../packages/quill/packages/primitives/dist/index.js
126.8 KiB ../node_modules/.pnpm/react-dom@18.3.1_react@18.3.1/node_modules/react-dom/cjs/react-dom.production.min.js
106.0 KiB src/products.tsx
99.3 KiB src/lib/api.ts
Largest files eagerly shipped from src/scenes/session-recordings/detail/SessionRecordingDetail.tsx
Size File
321.6 KiB ../node_modules/.pnpm/posthog-js@1.438.12_@types+react@18.3.27_react@18.3.1/node_modules/posthog-js/dist/module.mjs
315.9 KiB ../node_modules/.pnpm/posthog-js@1.438.12_@types+react@18.3.27_react@18.3.1/node_modules/posthog-js/dist/rrweb.js
279.0 KiB src/taxonomy/core-filter-definitions-by-group.json
221.3 KiB ../node_modules/.pnpm/@posthog+icons@0.38.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@posthog/icons/dist/posthog-icons.es.js
185.6 KiB ../packages/quill/packages/quill/dist/index.js
153.7 KiB ../node_modules/.pnpm/re2js@0.4.1/node_modules/re2js/build/index.esm.js
126.8 KiB ../node_modules/.pnpm/react-dom@18.3.1_react@18.3.1/node_modules/react-dom/cjs/react-dom.production.min.js
106.0 KiB src/products.tsx
99.3 KiB src/lib/api.ts
93.3 KiB ../node_modules/.pnpm/prosemirror-view@1.40.1/node_modules/prosemirror-view/dist/index.js

Posted automatically by check-eager-graph · sizes are eager output bytes (shipped, post-tree-shake) from the esbuild metafile · part of #32479

✅ Toolbar bundle — eager 2.24 MiB within budget

What the toolbar ships to customer pages, measured from the esbuild output (minified, post-tree-shake). The eager set is the entry plus everything statically imported from it — fetched before any feature runs; deferred chunks load lazily. The eager guardrail is 5.72 MiB. Each output file must also stay below 10 MB, where CloudFront stops compressing it. The module boundary is enforced separately by check-toolbar-graph.

Metric Size Δ vs base Budget
Eager (shipped)
entry + static imports
2.24 MiB · 19 files 🔺 +105 B (+0.0%) ████░░░░░░ 39.2% of 5.72 MiB
Deferred (lazy) 2.10 MiB · 40 files no change n/a — loads on demand
Loader dist/toolbar.js 1.2 KiB no change █░░░░░░░░░ 6.0% of 19.5 KiB
Largest eagerly-shipped chunks
Size File
880.3 KiB dist/toolbar/toolbar-app-A7SVOYGQ.css
666.3 KiB dist/toolbar/chunk-chunk-J6NSSCWQ.js
258.3 KiB dist/toolbar/chunk-chunk-CIAPY32H.js
131.8 KiB dist/toolbar/chunk-chunk-FDH2IBXT.js
129.6 KiB dist/toolbar/chunk-chunk-2MQZG3OR.js
74.8 KiB dist/toolbar/toolbar-app-BTEYN2RX.js
69.0 KiB dist/toolbar/chunk-chunk-TSAL54PB.js
35.6 KiB dist/toolbar/chunk-chunk-VKMYPNSE.js
21.7 KiB dist/toolbar/chunk-chunk-UQHARVTB.js
6.8 KiB dist/toolbar/chunk-chunk-DV7IWQNF.js

Posted automatically by check-toolbar-size · sizes are toolbar output bytes (shipped, post-tree-shake) from the esbuild metafile

✅ Dist folder size — 🔺 +54.6 KiB (+0.0%)

Total size of the built frontend/dist folder (all assets), compared against the base branch.

Total: 1013.50 MiB · 🔺 +54.6 KiB (+0.0%)

ℹ️ MCP UI apps size — 33 app(s), 26949.4 KB JS

Built size of each MCP UI app (main.js + styles.css).

App JS CSS
debug 836.6 KB 206.9 KB
action 760.6 KB 206.9 KB
action-list 827.6 KB 206.9 KB
cohort 759.6 KB 206.9 KB
cohort-list 826.6 KB 206.9 KB
email-template 759.5 KB 206.9 KB
error-details 764.5 KB 206.9 KB
error-issue 761.0 KB 206.9 KB
error-issue-list 828.2 KB 206.9 KB
experiment 824.7 KB 206.9 KB
experiment-list 828.3 KB 206.9 KB
experiment-results 827.2 KB 206.9 KB
feature-flag 827.0 KB 206.9 KB
feature-flag-list 830.7 KB 206.9 KB
feature-flag-testing 762.9 KB 206.9 KB
inline-scan 760.1 KB 206.9 KB
insight-actors 826.1 KB 206.9 KB
llm-costs 823.3 KB 206.9 KB
session-recording 761.9 KB 206.9 KB
survey 761.2 KB 206.9 KB
survey-global-stats 823.4 KB 206.9 KB
survey-list 828.3 KB 206.9 KB
survey-stats 823.4 KB 206.9 KB
trace-span 760.0 KB 206.9 KB
trace-span-list 827.5 KB 206.9 KB
vision-observation-list 826.7 KB 206.9 KB
workflow 760.0 KB 206.9 KB
workflow-list 826.9 KB 206.9 KB
workflow-setup-status 759.7 KB 206.9 KB
query-results 1078.1 KB 206.9 KB
render-ui 1151.1 KB 206.9 KB
visual-review-snapshots 764.5 KB 206.9 KB
workflow-data-suggestions 762.3 KB 206.9 KB
ℹ️ MCP agent API — agent-facing tool changes

What this PR changes for agents, from the tool schema snapshots and tool definitions.

Tools changed (2):

Tool Params Scopes Annotations Schema chars
workflows-create-email-template 2,624 -> 2,697
workflows-update-email-template 2,710 -> 2,783
✅ Playwright — all passed

All tests passed.

View test results →

⚠️ Backend coverage — 97.0% of changed backend lines covered — 1 uncovered

🧪 Backend test coverage

Patch coverage — changed backend lines (products + core): ███████████████████░ 97.0% (40 / 41)

File Patch Uncovered changed lines
products/messaging/backend/facade/templates.py 66.7% 38

🤖 Agents: add a test only if an uncovered line exposes a realistic regression that existing tests miss. Otherwise explain why no new test is needed under "How did you test this code?". Gap list: the patch-coverage artifact on this run (gh run download 493643152257162 -n patch-coverage), or the coverage-data block at the end of this comment.

Per-product line coverage (touched products)
Product Coverage Lines
demo ███████████░░░░░░░░░ 56.3% 1,540 / 2,736
batch_exports ████████████████░░░░ 81.4% 22,368 / 27,474
engineering_analytics █████████████████░░░ 85.1% 11,427 / 13,432
mcp_analytics █████████████████░░░ 85.4% 5,527 / 6,475
commands █████████████████░░░ 85.5% 1,618 / 1,893
warehouse_suggestions █████████████████░░░ 87.3% 2,252 / 2,580
posthog_ai ██████████████████░░ 87.9% 4,285 / 4,874
dashboards ██████████████████░░ 88.4% 7,420 / 8,390
notebooks ██████████████████░░ 88.5% 15,330 / 17,330
mcp_registry ██████████████████░░ 89.0% 1,596 / 1,794
cohorts ██████████████████░░ 89.6% 8,497 / 9,480
product_tours ██████████████████░░ 89.7% 1,355 / 1,510
signals ██████████████████░░ 90.4% 74,015 / 81,842
tasks ██████████████████░░ 90.7% 79,383 / 87,513
data_warehouse ██████████████████░░ 90.9% 14,898 / 16,398
canvas ██████████████████░░ 91.0% 7,822 / 8,598
today ██████████████████░░ 91.1% 3,495 / 3,838
exports ██████████████████░░ 91.3% 4,473 / 4,900
data_modeling ██████████████████░░ 91.4% 9,959 / 10,901
cdp ██████████████████░░ 91.4% 10,091 / 11,040
managed_warehouse ██████████████████░░ 91.4% 11,612 / 12,699
metrics ██████████████████░░ 91.5% 9,774 / 10,684
autoresearch ██████████████████░░ 91.5% 11,465 / 12,529
slack_app ██████████████████░░ 91.6% 19,606 / 21,409
wizard ██████████████████░░ 91.6% 6,444 / 7,035
business_knowledge ██████████████████░░ 91.6% 9,960 / 10,873
error_tracking ██████████████████░░ 91.7% 17,100 / 18,642
streamlit_apps ██████████████████░░ 91.9% 3,139 / 3,415
conversations ██████████████████░░ 92.1% 29,922 / 32,498
review_hog ██████████████████░░ 92.2% 17,693 / 19,187
stamphog ███████████████████░ 92.6% 8,762 / 9,466
early_access_features ███████████████████░ 92.6% 1,339 / 1,446
alerts ███████████████████░ 92.9% 8,376 / 9,016
notifications ███████████████████░ 93.0% 1,198 / 1,288
web_analytics ███████████████████░ 93.1% 25,250 / 27,109
surveys ███████████████████░ 93.4% 6,893 / 7,382
cross_project_dashboards ███████████████████░ 93.4% 880 / 942
approvals ███████████████████░ 93.4% 4,576 / 4,898
messaging ███████████████████░ 93.5% 4,477 / 4,789
context_layer ███████████████████░ 93.6% 3,367 / 3,598
marketing_analytics ███████████████████░ 93.8% 20,220 / 21,547
mcp_store ███████████████████░ 93.9% 9,084 / 9,676
billing_alerts ███████████████████░ 93.9% 2,090 / 2,226
customer_analytics ███████████████████░ 93.9% 26,350 / 28,052
workflows ███████████████████░ 94.0% 20,835 / 22,165
ai_observability ███████████████████░ 94.1% 26,603 / 28,265
logs ███████████████████░ 94.2% 17,716 / 18,815
replay_vision ███████████████████░ 94.4% 31,326 / 33,201
alerts_platform ███████████████████░ 94.4% 6,239 / 6,612
actions ███████████████████░ 94.7% 1,001 / 1,057
reminders ███████████████████░ 94.8% 760 / 802
skills ███████████████████░ 94.9% 7,126 / 7,512
growth ███████████████████░ 94.9% 11,347 / 11,959
endpoints ███████████████████░ 94.9% 9,433 / 9,935
annotations ███████████████████░ 95.1% 1,078 / 1,134
tracing ███████████████████░ 95.2% 3,631 / 3,815
experiments ███████████████████░ 95.5% 37,147 / 38,892
data_catalog ███████████████████░ 95.6% 4,512 / 4,721
access_control ███████████████████░ 95.6% 8,016 / 8,385
product_analytics ███████████████████░ 95.6% 30,227 / 31,602
revenue_analytics ███████████████████░ 95.9% 1,877 / 1,958
data_quality ███████████████████░ 95.9% 8,619 / 8,983
feature_flags ███████████████████░ 96.3% 27,337 / 28,402
subscriptions ███████████████████░ 96.3% 11,119 / 11,541
warehouse_sources ███████████████████░ 96.4% 455,124 / 472,359
account_audits ███████████████████░ 96.7% 768 / 794
pulse ███████████████████░ 97.4% 2,023 / 2,078
analytics_platform ████████████████████ 98.0% 2,779 / 2,836
groups ████████████████████ 98.2% 1,823 / 1,856

Report-only. Patch coverage = changed backend lines covered vs origin/master. Sorted lowest first.
Known gaps: lines covered only by Temporal tests show as uncovered; core line numbers may drift if master changed the same file.

⚠️ MCP snapshots — 2 updated (2 modified, 0 added, 0 deleted)

Snapshots: MCP unit test snapshots updated

Changes: 2 snapshots (2 modified, 0 added, 0 deleted)

What this means:

  • Snapshots have been automatically updated to match current output

Next steps:

  • Review the changes to ensure they're intentional
  • If unexpected, investigate what caused the output to change

Review snapshot changes →

⚠️ Django migration SQL — 1 new migration to review

We've detected new migrations on this PR. Review the SQL output for each migration:

products/messaging/backend/migrations/0007_messagetemplate_draft_content.py

/home/runner/work/tmp/tool_cache/Python/3.14.7/x64/lib/python3.14/site-packages/anyio/from_thread.py:119: SyntaxWarning: 'return' in a 'finally' block
  return result
/home/runner/work/tmp/tool_cache/Python/3.14.7/x64/lib/python3.14/site-packages/structlog/stdlib.py:1166: UserWarning: Remove `format_exc_info` from your processor chain if you want pretty exceptions.
  ed = p(logger, meth_name, ed)  # type: ignore[arg-type]
2026-10-19T13:21:25.729630Z [error    ] Path must be a valid database or directory containing databases. [posthog.exceptions_capture] pid=5721 tid=139774355622784
Traceback (most recent call last):
  File "/home/runner/work/posthog/posthog/posthog/geoip.py", line 15, in <module>
    geoip: Optional[GeoIP2] = GeoIP2(cache=8)
                              ~~~~~~^^^^^^^^^
  File "/home/runner/work/tmp/tool_cache/Python/3.14.7/x64/lib/python3.14/site-packages/django/contrib/gis/geoip2.py", line 116, in __init__
    raise GeoIP2Exception(
        "Path must be a valid database or directory containing databases."
    )
django.contrib.gis.geoip2.GeoIP2Exception: Path must be a valid database or directory containing databases.
/home/runner/work/tmp/tool_cache/Python/3.14.7/x64/lib/python3.14/site-packages/sshtunnel.py:1040: SyntaxWarning: 'return' in a 'finally' block
  return (ssh_host,
/home/runner/work/tmp/tool_cache/Python/3.14.7/x64/lib/python3.14/site-packages/langchain_core/_api/deprecation.py:27: UserWarning: Core Pydantic V1 functionality isn't compatible with Python 3.14 or greater.
  from pydantic.v1.fields import FieldInfo as FieldInfoV1
System check identified some issues:

WARNINGS:
?: (axes.W001) You are using the django-axes cache handler for login attempt tracking. Your cache configuration is however invalid and will not work correctly with django-axes. This can leave security holes in your login systems as attempts are not tracked correctly. Reconfigure settings.AXES_CACHE and settings.CACHES per django-axes configuration documentation.
?: (staticfiles.W004) The directory '/home/runner/work/posthog/posthog/frontend/dist' in the STATICFILES_DIRS setting does not exist.
BEGIN;
--
-- Add field draft_content to messagetemplate
--
ALTER TABLE "posthog_messagetemplate" ADD COLUMN "draft_content" jsonb NULL;
COMMIT;

Last updated: 2026-10-19 13:22 UTC (319bd30)

✅ Django migration risk — migration analysis complete

We've analyzed your migrations for potential risks.

Summary: 1 Safe | 0 Needs Review | 0 Blocked

✅ Safe

Brief or no lock, backwards compatible

messaging.0007_messagetemplate_draft_content
  └─ #1 ✅ AddField
     Adding nullable field requires brief lock
     model: messagetemplate, field: draft_content

📚 How to Deploy These Changes Safely

AddField:

This operation acquires a brief lock but doesn't rewrite the table.

Deployment uses lock timeouts with automatic retries, so lock contention will cause retries rather than connection pile-up.

Last updated: 2026-10-19 13:22 UTC (319bd30)

✅ Hogbox preview — ready, open the preview

▶ Open the preview

🔑 Login test@posthog.com / 12345678 (demo data)
🧩 Running this PR's backend and frontend, on the PostHog :master base
🔗 Link stable across rebuilds: a re-push swaps the box underneath, the URL stays
🔒 Access tailnet only (PostHog VPN)
🛠️ Admin inspect & debug state in hogland
💤 Idle sleeps after ~30 min idle (snapshot to S3, zero node cost) and wakes on your next visit in ~30s, behind a brief "waking up" screen

commit 319bd30 · box box-f4fef8e477f7 · ready in 1538s (push → usable) · build log · rebuilds on every push, torn down on close

@trunk-io

trunk-io Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Static Badge   Static Badge   Static Badge

Failed Test Failure Summary Logs
Scenes-Other/Startup program NeedsBillingDetails smoke-test The test timed out while waiting for loading indicators or spinners to disappear. Logs ↗︎
Scenes-App/Experiments ExperimentWithHealthFindings play-test The UI test could not find an element with the text “Why?”. Logs ↗︎

View Full Report ↗︎ ⋅ Docs

…ates

Edits to a transactional template autosave to a draft. Sends keep using the published content until the draft is published. Discarding the draft restores the published version.

Generated-By: PostHog Desktop
Task-Id: 99e627ce-b3db-4380-a8bc-6a4ad5482c51
@mayteio
mayteio force-pushed the posthog/transactional-email-drafts branch from cca9bf5 to aeac703 Compare October 19, 2026 09:12
@mayteio
mayteio changed the base branch from posthog/transactional-email-ui to master October 19, 2026 09:12
@trunk-io

trunk-io Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

😎 Merged successfully - details.

@mayteio mayteio added the posthog-review label Oct 19, 2026 — with PostHog
Generated-By: PostHog Desktop
Task-Id: 99e627ce-b3db-4380-a8bc-6a4ad5482c51

@posthog posthog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

PostHog Review · Standard · reviewed aeac703: 2 Must fix, 2 Should fix.

This Standard review started from the posthog-review label. Comment @posthog review --deep for a Deep review, or @posthog help to see all commands.

Comment on lines +476 to +478
if fields.keys() == {"draft_content"}:
# Sends never read the draft, so it skips the sendability check and the workflow sync.
updated = update_template(self.team_id, template.id, fields)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 · Prevent draft saves from overwriting published fields

When a draft PATCH overlaps a publish, update_template reads without a lock and calls save() on every field. If publish commits between that read and save, the draft request restores old content while the workflow retains the new version; it also overwrites concurrent deletion or conversion. Lock before reading, or update only draft_content and updated_at.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in e86a9a5: draft saves go through a new save_template_draft, which updates only draft_content and updated_at, so it can't restore old content or undo a delete or conversion.

Comment on lines +476 to +480
if fields.keys() == {"draft_content"}:
# Sends never read the draft, so it skips the sendability check and the workflow sync.
updated = update_template(self.team_id, template.id, fields)
self._emit_resource_edited(updated)
return Response(self._serialize(updated))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 · Enforce workflow editor access on draft-only updates

A project member denied access to the linked transactional workflow can PATCH only draft_content to replace or discard its unpublished email. This early return bypasses _require_workflow_editor; the template's object permission check does not enforce the linked workflow's restrictions. Apply the workflow editor check before accepting draft writes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in e86a9a5: draft writes on a transactional template now need workflow editor access. Added a case to test_a_member_denied_the_workflow_cannot_send_or_change_it, which fails without the check.

Comment on lines +720 to +724
if (
!values.draftOutOfDate ||
values.isTemplateSubmitting ||
values.isSavingDraft ||
values.isDiscardingDraft

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 · Pause autosave while an external-edit conflict is unresolved

When two editors change the same template, templateEditedElsewhere raises the conflict banner, but this debounce still calls saveDraft while externallyEdited is true. It overwrites the other editor's draft before the person chooses Reload or Keep mine, defeating the existing conflict flow. Pause autosave until the conflict is explicitly resolved.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in e86a9a5: autosave skips while externallyEdited is set, and "Keep mine" restarts it. Added a logic test for that.

Comment on lines +764 to +768
confirmDiscardDraft: async () => {
try {
const updated = await messagingTemplatesPartialUpdate(String(values.currentTeamIdStrict), props.id, {
draft_content: null,
})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 · Serialize discard with pending draft saves

When an autosave starts while the discard dialog is open, confirmDiscardDraft sends its PATCH without waiting for it. If the autosave response arrives after discard completes, saveDraftDone restores savedDraft and schedules another autosave, leaving a draft immediately after a successful discard. Serialize discard with pending saves and ignore stale completions.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in e86a9a5: discard waits for an in-flight draft save before it sends its PATCH, and autosave already holds while a discard runs, so a late save can't bring the draft back.

@posthog posthog Bot removed the posthog-review label Oct 19, 2026
… access gaps

A draft save writes only draft_content and updated_at, so it can't undo a publish, delete or conversion that lands meanwhile. It also needs editor access to the template's workflow, like a publish. Autosave pauses while the edited-elsewhere banner is up, and discard waits for an in-flight draft save.

Generated-By: PostHog Desktop
Task-Id: 99e627ce-b3db-4380-a8bc-6a4ad5482c51
@mayteio
mayteio marked this pull request as ready for review October 19, 2026 12:57
@parameterai

parameterai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Risk: No findings

This increment only edits two MCP tool-schema snapshot descriptions (test fixtures) to clarify that a template subject is required in content but may be blank in draft_content until publish. No production code or security-relevant behavior changed since the last review; no new risks.

Sentinel reviewed 319bd30 · Review settings

@pr-assigner-resolver-posthog
pr-assigner-resolver-posthog Bot requested a review from a team October 19, 2026 12:58
@mayteio mayteio added the stamphog Request AI approval (no full review) label Oct 19, 2026 — with PostHog

@stamphog stamphog 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.

Not approved — this change needs a human reviewer.

Re-add the stamphog label to request another review once you have addressed this.

The current code addresses all four substantive review findings, and the author has owning-team assurance, but the new enum override matches an explicit repository refusal rule. Route the override to team-devex for human review before re-requesting.

  • Author wrote 49% of the modified lines and has 31 merged PRs in these paths (familiarity MODERATE).
  • Repository guard-suppression rule: posthog/settings/web.py adds a new name to ENUM_NAME_OVERRIDES, which the repository steering explicitly prohibits for automated approval. Request a human review from team-devex before re-requesting; Haven and Meikel Ratz are suggested reviewers familiar with the modified lines.
Gate mechanics and policy version
Gate Result
prerequisites ✓ all clear
deny-list ✓ no deny categories matched
size ✓ 475L, 11F substantive, 965L/18F incl. docs/generated/snapshots — within ceiling
tier ✓ T1-agent / T1d-complex (965L, 18F, cross-cutting, feat)
stamphog 2.6.0 .stamphog/policy.yml @ e86a9a5 · reviewed head e86a9a5

@stamphog stamphog Bot removed the stamphog Request AI approval (no full review) label Oct 19, 2026
The draft had its own copy of the content serializer so its subject could be blank, which forced an enum name override. The subject now allows blank at field level, and validate() requires it only in published content. The override and the copied serializer go away, and so does a large part of the generated code.

Generated-By: PostHog Desktop
Task-Id: 99e627ce-b3db-4380-a8bc-6a4ad5482c51
@mayteio mayteio added the stamphog Request AI approval (no full review) label Oct 19, 2026 — with PostHog
@stamphog stamphog Bot removed the stamphog Request AI approval (no full review) label Oct 19, 2026
@stamphog

stamphog Bot commented Oct 19, 2026

Copy link
Copy Markdown

No review started. stamphog started a review of this pull request less than 10 minutes ago, and a label can request at most one review per 10 minutes. The stamphog label has been removed. Add it again at 13:16 UTC (in about 3 minutes) to request a fresh review.

@stamphog stamphog 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.

Approved.

The current code addresses all four substantive review findings, but the only top-level review is on an older commit. The author provides owning-team assurance for workflows; request current-head review covering the MCP contract changes from @PostHog/team-context-and-mcp, with Meikel Ratz or Haven as suggested reviewers.

  • Author wrote 51% of the modified lines and has 28 merged PRs in these paths (familiarity MODERATE).
Gate mechanics and policy version
Gate Result
prerequisites ✓ all clear
deny-list ✓ no deny categories matched
size ✓ 464L, 10F substantive, 866L/21F incl. docs/generated/snapshots — within ceiling
tier ✓ T1-agent / T1d-complex (866L, 21F, two-areas, feat)
stamphog 2.6.0 .stamphog/policy.yml @ 319bd30 · reviewed head 319bd30

@trunk-io
trunk-io Bot merged commit 022348f into master Oct 19, 2026
320 of 321 checks passed
@trunk-io
trunk-io Bot deleted the posthog/transactional-email-drafts branch October 19, 2026 14:34
@deployment-status-posthog

deployment-status-posthog Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Deploy status

Environment Status Deployed At Workflow
dev ✅ Deployed 2026-10-19 15:04 UTC Run
prod-us ✅ Deployed 2026-10-19 15:18 UTC Run
prod-eu ✅ Deployed 2026-10-19 15:21 UTC Run

This branch was successfully deployed

1 active deployment
hogbox-preview — 319bd304 Deployed Oct 19, 2026 by github-actions[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stamphog Request AI approval (no full review)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant