Repository navigation
Closed as not planned
Labels
Description
Map: Map: send code-managed email templates with one PostHog call
Spec: Spec: copy-as-code and open-a-PR for code-managed templates, sections "Open a PR in the UI (stack B)", "Usage events"
Cast: Opus 5.5, high
Repository: PostHog/posthog (frontend)
Stack: B, second slice
Question
With GitHub connected, does the same button open a draft PR with exactly the bytes Copy code produces, and does Copy code stay when it cannot?
Delivers end to end.
- Connected. With a GitHub integration on the project, the Copy code slot reads "Open a PR" and Copy code moves into the side menu.
- Not connected. Copy code stays primary. The menu shows "Open a PR" disabled with "Connect GitHub to open a PR" and a link to the integration settings.
- Dialog. "Open a PR" awaits the flush, encodes the snapshot and opens a confirm dialog with:
- the repository, prefilled, or chosen with the existing GitHub repository combobox (per Card 3);
- the path, prefilled and editable;
- "Base: default branch";
- "Opens a draft pull request. Nothing changes in PostHog."
- Request. Confirm creates the
request_id, sends the request withbase_content_hashfrom the version the edit started from, and disables the button with a loading state while in flight. A retry reuses therequest_id. - Errors show
detailandfix; local edits and Copy code stay. - Success. The notice links the PR, and the button reads "View PR" until the local edits change.
- Events:
message template pull request requested,opened,failed. - Use the generated API client and types from Open a PR: draft PR route for a code-managed template's file #505.
Test seams.
- Kea logic tests on
messageTemplateLogicat the API boundary:- the request carries the same bytes the copy produces;
- a double click sends one request;
- a retry after
503reuses therequest_id; - an error keeps local edits;
- success switches to "View PR", and an edit after success switches back.
- Stories for connected, disconnected, dialog, error and success.
- Prior art:
messageTemplateLogic.test.ts, the GitHub repository combobox infrontend/src/lib/integrations/.
Write scope.
products/workflows/frontend/TemplateLibrary/:MessageTemplate.tsx,messageTemplateLogic.ts,MessageTemplateMenu.tsx, a new PR dialog component and its story,templateCopy.ts.
Proof.
- Red: the "same bytes as copy" test fails.
- Green: the logic tests pass.
- Local: against the private scratch repository
Silthus/posthog-workflows-github-scratch:- upload a template from its file there;
- edit locally, open a PR from the UI, and screenshot dialog and success;
- show the PR diff is one file equal to the copied bytes, and the template's hash unchanged;
- disconnect or use a project without GitHub, and screenshot Copy code as primary.
- Screenshots at 1280px with the side panel open and at full width. If no dev App installation reaches the scratch repository, record the gap and prove with stories and mocked API only.
Acceptance criteria
- The PR's file equals what Copy code puts on the clipboard.
- Without GitHub, Copy code is the primary action.
- One click opens at most one PR, also after a lost response.
- Screenshots in the PR.
Blockers
Blocked by #505 (the route and generated types) and #504 (local edit mode and the flush).
How to build (map #461)
/tddred-green-refactor, outside-in, at the seams named above. Real Postgres, Valkey and ClickHouse; mock only what the seam section allows.- Repo skills apply where the diff touches their area:
/writing-tests,/writing-ui-components,/writing-kea-logics,/writing-user-facing-copy,/writing-code-comments,/improving-drf-endpoints,/routing-outbound-api-calls. - Read code from
origin/spec/code-managed-templates(the fork's integration branch for feat(messaging): upload, send and lock code-managed email templates PostHog/posthog#118924), not frommaster. - Public repo: no usage numbers, customer names, internal metrics, Slack content or security reasoning in code, commits or the PR. Fixture addresses use
example.com. The private note the map points at is background only; never quote it. - Shipped means a draft PR handed off for review (see the map's Notes for remotes and branches). Never mark ready, enqueue or merge. The conductor names the stack's integration branch.
Activity
Silthus commentedon Oct 17, 2026
Note
🤖 Opus 5.5 responding on behalf of Michael
Closed: no longer applies. After Card 1 (2026-10-17) nothing is edited in PostHog, so a PostHog-side PR has no content of its own. What stack B becomes is Card 4 on #502. If it picks "Run with PostHog Code", a new ticket replaces this one.
Silthus commentedon Oct 17, 2026
Note
🤖 Opus 5.5 responding on behalf of Michael
Card 4 picked "Run with PostHog Code". Replaced by #514 (the web button) and #515 (PostHog AI and the Slack bot).