Skip to content

Support multiple templates, a templates list and a sent emails log - #63

Merged
vadim9999 merged 11 commits into
masterfrom
feat/multiple-templates
Dec 1, 2026
Merged

vadim9999 merged 11 commits into
masterfrom
feat/multiple-templates

Conversation

@vadim9999

Copy link
Copy Markdown
Contributor

What

  • Pages. / now redirects to the templates list:
    • /templates lists the templates and lets you create, rename and delete them.
    • /templates/[id] is the editor for one template. It shows the template's name and a "Send email" button. An unknown id shows "Template not found".
    • /sent is the log of sent emails. You can filter it by template, and clicking a row opens the email in a drawer, rendered in a sandboxed EmailFrame.
  • Send email dialog. You enter recipients and a subject. The email is only recorded in the log, and the dialog says that delivery is not set up yet.
  • Sidebar. It now has "Templates" and "Sent emails", and the highlighted item follows the current page. The "coming soon" placeholder is gone.
  • API client.
    • Every tree, element and generate call now takes templateId.
    • New calls: listTemplates, createTemplate, getTemplate, renameTemplate, deleteTemplate, sendEmail, listSentEmails, getSentEmail.
    • The contract is synced from the backend PR.
  • AI assistant. Its tools work on the template that is currently open, and the chat resets when you switch templates.
  • Shared preview frame. The sandboxed iframe was moved out of Preview into EmailFrame. Both the preview and the sent-emails drawer use it.
  • Tests and docs. Unit and e2e tests are updated, and there are new e2e specs templates.spec.ts and sent.spec.ts. The coverage thresholds went up. AGENTS.md, docs/AI_AGENT.md, README and the skills are updated.

Why

The editor supported only one template. Now you can keep several templates, see them in a list, and see the emails you sent. Real delivery (SMTP) is out of scope; for now, sending only adds an entry to the log.

Depends on LLazyEmail/email-template-editor-nodejs#7, which moves the routes under /templates/:templateId. Merge the backend first, then run npm run api:sync to confirm src/api/openapi.json matches the backend's main.

How to verify

  • npm run lint, npm run typecheck, npm run format:check, npm run test:coverage (149 tests), npm run build and npm run test:e2e (16/16) all pass.
  • Manual check against the real backend branch, started on a copy of the old v2 db.json:
    • The migrated "Default template" opens in the editor.
    • Two templates keep separate trees and elements.
    • Send adds an entry to /sent, and the drawer renders the HTML.
    • Light and dark themes look right, and at 400px wide the page does not scroll sideways.

Checklist

  • One concern per PR (no drive-by refactors)
  • npm run lint, npm run typecheck, npm run format:check pass
  • npm run test:coverage passes; new behavior has a test
  • npm run test:e2e passes if a user flow changed
  • New external origin added to the CSP (src/security/contentSecurityPolicy.ts), if any (none, same backend origin)
  • AGENTS.md, docs/AI_AGENT.md or a skill updated if conventions or file layout changed

The sandboxed iframe (sandbox="", no referrer, srcdoc) moves into its own component.
The preview keeps its height; the frame's border and white background move with it.
Syncs src/api with the backend's multi-template contract. Tree, elements and generate calls
take the template id first and go to /templates/:templateId/...; new client functions cover
templates, sending and the sent-emails log.

The editor moves to /templates/[id] and passes the id to the tree, the elements panel, the
AI tools and the chat (remounted per template, so a chat never spans two templates).
The home page redirects to /templates. E2E specs open /templates/t1.
/templates lists the templates in a table: the name opens the editor, and each row can be
renamed or deleted (with confirmation). "New template" asks for a name, creates it and
opens it. With no templates the table offers to create the first one.

The sidebar now has Templates and Sent emails; the current section is highlighted from the
path (the editor counts as Templates). The disabled "coming soon" entry and the separate
Editor item are gone.
A table of sent emails, newest first: when, template, recipients (three, then +N), subject
and status ("Logged": delivery is not configured yet). The template column filters on the
client. The subject or the row opens a drawer that loads the email and shows its HTML in the
same sandboxed EmailFrame as the editor's preview.
The editor loads the template for its heading, with a link back to the list. A template
that does not exist (404 from the template or its tree) shows "Template not found"
instead of error toasts.

"Send email" (disabled while the tree is empty) opens a dialog for recipients (tags, checked
as email addresses, at most 50) and a subject prefilled with the template's name. Sending
records the email in the log; the success message says delivery is not configured yet and
links to Sent emails.
clearOnDestroy cleared the form on StrictMode's simulated unmount, after initialValues had
been applied, so in next dev the rename dialog opened empty and the subject was blank. The
dialogs are destroyed when hidden and own their form store, so each opening starts fresh
without it. Tests now render these dialogs in StrictMode. Also use Select's suffix prop
(suffixIcon is deprecated in antd 6).
templates.spec: / redirects to the list, a new template opens in the editor with its name,
and an unknown template shows "Template not found". sent.spec: Send email from the editor,
then open the log from the success message and view the email in its sandboxed frame.
…late API

AGENTS.md: directory map (app routes, src/templates, src/sent, SendEmailModal, EmailFrame,
e2e/backend.ts), client components, the backend routes under /templates/:templateId and
/sent-emails. docs/AI_AGENT.md: pages, data flow with templateId, file roles, one chat per
template. README: the three pages, diagrams and layout. Skills and docs/playwright.md: how
to mock the API in unit and e2e tests now.
The new pages, dialogs and API functions come with tests: statements 84.9 → 90.1 %, branches
77.6 → 79.5 %, functions 80.5 → 88.4 %, lines 86.6 → 91.8 %.
The template name and back link now share a row with the toolbar, so the preview
height (calc(100vh - 160px)) is right again and the editor column no longer scrolls
for the header. Padding and the header gap are shared variables for all pages.
The 404 page offers a primary Back to templates button.
Tables scroll inside their own container on narrow screens, row actions are small
link buttons, the status tag explains that nothing was delivered, the drawer lists
every recipient as a tag, and the send dialog says delivery is not configured.
@vadim9999
vadim9999 merged commit d72ed30 into master Dec 1, 2026
4 checks passed
@vadim9999
vadim9999 deleted the feat/multiple-templates branch December 1, 2026 11:54
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.

1 participant