Skip to content

enhance: improve actions e-mail template#38396

Open
silverwind wants to merge 11 commits into
go-gitea:mainfrom
silverwind:mail-template-color-scheme
Open

enhance: improve actions e-mail template#38396
silverwind wants to merge 11 commits into
go-gitea:mainfrom
silverwind:mail-template-color-scheme

Conversation

@silverwind

@silverwind silverwind commented Jul 10, 2026

Copy link
Copy Markdown
Member
  • declare color-scheme and drop the light-only colors, so mails follow the client theme
  • extract the shared <head> and footers into templates/mail/base/
  • use the Gitea primary color for links
  • workflow run mail: subject is now [owner/repo] Failure: build.yml (main - 35996c2c80)
  • workflow run mail: replace the job cards with a compact table, each status marked by an icon, a word and a color
  • use unicode glyphs as icons, (can't use svg because at least gmail does not support it)
  • preview both schemes side by side in /devtest/mail-preview, including the subject
  • assignment mails now show the "reply to this email" hint, they already carried a Reply-To

Screenshot from /devtest/mail-preview:

image

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
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jul 10, 2026
@silverwind silverwind changed the title Support dark mode in mails, redesign workflow run mail Improve workflow mail template Jul 10, 2026
@silverwind silverwind changed the title Improve workflow mail template Improve actions e-mail template Jul 10, 2026
@silverwind silverwind changed the title Improve actions e-mail template enhance: improve actions e-mail template Jul 10, 2026
@github-actions github-actions Bot added the type/enhancement An improvement of existing functionality label Jul 10, 2026
@silverwind silverwind requested a review from Copilot July 10, 2026 09:21

Copilot AI 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.

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 into templates/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.

Comment thread routers/web/devtest/mail_preview.go
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

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

No, never base/head templates

Such fragile trick only makes it is more difficult to maintain "web" base and "mail" base templates.

@GiteaBot GiteaBot added lgtm/blocked A maintainer has reservations with the PR and thus it cannot be merged and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Jul 10, 2026
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
@silverwind

silverwind commented Jul 10, 2026

Copy link
Copy Markdown
Member Author

No, never base/head templates

So what do you suggest instead? accept the duplications in header/footer? They already drifted.

@wxiaoguang

Copy link
Copy Markdown
Contributor

No, never base/head templates

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 mail/xxx/yyy (mail/user/auth/activate), remove the strings.TrimPrefix(name, "mail/"), then at least: mail/head and mail/foot or mail/base/head

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
Comment thread modules/templates/mail.go Outdated
@silverwind silverwind marked this pull request as draft July 10, 2026 10:08
@wxiaoguang wxiaoguang dismissed their stale review July 10, 2026 10:13

dismiss

@GiteaBot GiteaBot added lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. and removed lgtm/blocked A maintainer has reservations with the PR and thus it cannot be merged labels Jul 10, 2026
@silverwind

Copy link
Copy Markdown
Member Author

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
@silverwind silverwind marked this pull request as ready for review July 14, 2026 08:35
@silverwind

Copy link
Copy Markdown
Member Author

Updated subject to [owner/repo] Failure: workflow.yml (main - sha), this is the most consistent format with existing mails and a strict improvement over the previous incomplete subjects.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. type/enhancement An improvement of existing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants