enhance: improve actions e-mail template#38396
Conversation
Mail templates hardcoded light-only colors without declaring a color scheme, so dark-mode clients force-inverted them: backgrounds flipped while text colors did not, leaving grey-on-grey headings and unreadable text after switching themes. Declare "color-scheme: light dark", drop the light-only backgrounds and text colors so mails inherit the client theme, and keep only scheme-aware accents. Extract the duplicated <head> and the two footer variants into templates/mail/base/, and exclude those partials from the preview list while keeping them in the compiled template set. Rework the workflow run mail: prefix the subject with the repository and ref, and replace the job cards with a compact bordered table that marks each status with an icon, a localized word and a color. Mail clients strip svg, so the icons are unicode glyphs. Render the mail preview in both schemes side by side. Since a page can force "color-scheme" on an embedded document but never "prefers-color-scheme", the devtest handler toggles the mail's dark media query instead, otherwise a pane would mix one scheme's colors with the other's canvas. Assisted-by: Claude:Opus 4.8
There was a problem hiding this comment.
Pull request overview
This PR modernizes and de-duplicates Gitea’s HTML email templates, adds explicit light/dark scheme support, and improves both the Actions workflow-run notification email and the /devtest/mail-preview experience.
Changes:
- Extract common mail
<head>and footer fragments intotemplates/mail/base/*and refactor existing templates to use them. - Rework the workflow-run email subject and job list rendering (compact table with status icon/text/color).
- Improve mail preview to render light/dark variants side-by-side and to show the mock-data subject.
Reviewed changes
Copilot reviewed 29 out of 29 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| templates/mail/user/auth/reset_passwd.tmpl | Switch to shared base head + copyright footer. |
| templates/mail/user/auth/reset_passwd.devtest.yml | Add mock Subject for preview display. |
| templates/mail/user/auth/register_notify.tmpl | Switch to shared base head + copyright footer. |
| templates/mail/user/auth/register_notify.devtest.yml | Add mock Subject for preview display. |
| templates/mail/user/auth/activate.tmpl | Switch to shared base head + copyright footer. |
| templates/mail/user/auth/activate.devtest.yml | Add mock Subject for preview display. |
| templates/mail/user/auth/activate_email.tmpl | Switch to shared base head + copyright footer. |
| templates/mail/user/auth/activate_email.devtest.yml | Add mock Subject for preview display. |
| templates/mail/repo/transfer.tmpl | Switch to shared base head + shared footer block. |
| templates/mail/repo/transfer.devtest.yml | Update mock repo name. |
| templates/mail/repo/release.tmpl | Switch to shared base head + shared footer block. |
| templates/mail/repo/issue/default.tmpl | Switch to shared base head + shared footer block. |
| templates/mail/repo/issue/default.devtest.yml | Add mock Subject for preview display. |
| templates/mail/repo/issue/assigned.tmpl | Switch to shared base head + shared footer block. |
| templates/mail/repo/issue/assigned.devtest.yml | Update mock repo full name. |
| templates/mail/repo/collaborator.tmpl | Switch to shared base head + shared footer block. |
| templates/mail/repo/collaborator.devtest.yml | Update mock repo name. |
| templates/mail/repo/actions/workflow_run.tmpl | Redesign workflow-run mail body for theme inheritance and compact job table. |
| templates/mail/repo/actions/workflow_run.devtest.yml | Update mock subject + job presentation fields (icon/class/text). |
| templates/mail/org/team_invite.tmpl | Switch to shared base head + copyright footer. |
| templates/mail/org/team_invite.devtest.yml | Add mock Subject for preview display. |
| templates/mail/base/head.tmpl | New shared head partial with color-scheme meta + common styles. |
| templates/mail/base/footer.tmpl | New shared footer partial for “view it on” / optional reply link. |
| templates/mail/base/footer_copyright.tmpl | New shared copyright footer partial. |
| templates/devtest/mail-preview.tmpl | Render light/dark previews side-by-side; border uses theme variable. |
| services/mailer/mail_workflow_run.go | Update workflow-run subject format and job data mapping for new template. |
| services/mailer/mail_workflow_run_test.go | Add unit test for workflow job status icon/class mapping. |
| routers/web/devtest/mail_preview.go | Render mail HTML to a buffer for scheme manipulation and subject preview support. |
| modules/templates/mail.go | Exclude mail/base/* partials from the preview template list while still compiling them. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The "base/" partials are excluded from MailRender.TemplateNames but must remain in the compiled template set, otherwise every mail that includes them fails to render. Guard the invariant with a test instead of a comment. Assisted-by: Claude:Opus 4.8
Appending the scheme override after </html> relied on the parser fostering it into the body. Insert it before </head> instead, and match the mail's dark media query with a pattern, so reformatting the stylesheet does not silently leave the preview showing one scheme's colors on the other's canvas. Assisted-by: Claude:Opus 4.8
The status follows the repository in the subject, so it reads "[owner/repo] run failed: build.yml - main (35996c2c80)". Assisted-by: Claude:Opus 4.8
So what do you suggest instead? accept the duplications in header/footer? They already drifted. |
I believe we should refactor all mail templates to be used as |
The mail renderer trimmed "mail/" from the template name and added it back when reading the file, so a mail template name no longer matched its asset path. The page renderer relies on that match, and so does the template error prettier, which resolves a name back to a file. With the prefix trimmed, the "mail/base/head" partial was named "base/head" and aliased the web template of the same name. Keep the full path as the name, like the page renderer does. Assisted-by: Claude:Opus 4.8
|
Will do more tweaks to the mail subject, not totally happy with it yet. |
The subject now reads "[owner/repo] Failure: build.yml (main - 35996c2c80)", matching the "[owner/repo]" prefix of the issue mails and reusing the status word already shown in the mail body and the web UI. The dedicated mail.repo.actions.run.* strings are removed. Assisted-by: Claude:Opus 4.8
Mail partials carried their own base indentation, so an included partial's
content rendered one level too deep. Start them at column 0 like the web
partials, keeping the {{template}} includes at the HTML indentation level.
Assisted-by: Claude:Opus 4.8
|
Updated subject to |
TemplateNames only feeds the devtest mail preview list, and previewing a partial renders it harmlessly, so filtering the base partials out was not needed. Keep the test that asserts the partials stay compiled. Assisted-by: Claude:Opus 4.8
The preview now shows the mock Subject, so the placeholder subjects of the collaborator, transfer and assigned mails were misleading. Use the real subject format instead. Assisted-by: Claude:Opus 4.8
The job list was cached in one struct and then rebuilt into a second struct per recipient language, recomputing the locale-independent icon and class each time. Use a single struct built once and fill only the localized status text per language. Assisted-by: Claude:Opus 4.8
color-schemeand drop the light-only colors, so mails follow the client theme<head>and footers intotemplates/mail/base/[owner/repo] Failure: build.yml (main - 35996c2c80)svgbecause at least gmail does not support it)/devtest/mail-preview, including the subjectReply-ToScreenshot from
/devtest/mail-preview: