Skip to content

Backend/emails: Use user content as the preview line - #9122

Merged
tristanlabelle merged 6 commits into
developfrom
backend/feature/emails-preview-lines
Jun 28, 2026
Merged

Backend/emails: Use user content as the preview line#9122
tristanlabelle merged 6 commits into
developfrom
backend/feature/emails-preview-lines

Conversation

@tristanlabelle

@tristanlabelle tristanlabelle commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

We previously inconsistently either reused or paraphrased the email subject as a preview line. I think we should use it to surface the most important information from the email body not redundant with the subject, which is any quoted user content such as the message content or event description. If we don't have that, don't include a preview line (Gmail will show the beginning of the email).

Since those can contain markdown, but preview lines wouldn't display them, adds a markdown_to_plaintext function and refactors our markdown conversion to its own file, with new tests. This allowed me to find a discrepancy with respect to how newlines are interpreted vs the frontend, which I'm aso fixing (see breaks option and newline rule).

Testing

Added markdown/html-related tests. Preview lines themselves are difficult to test without the Gmail client (MailDev) doesn't surface them.

Backend checklist

  • Added tests for any new code or added a regression test if fixing a bug
  • Run the backend locally and it works
  • Added migrations if there are any database changes, rebased onto develop if necessary for linear migration history

For maintainers

  • Maintainers can push commits to my branch
  • Maintainers can merge this PR for me

@CouchersBot

CouchersBot commented Jun 15, 2026

Copy link
Copy Markdown
Member

Mobile

Install the Dev Tool (iOS via TestFlight, iOS Simulator, or Android .apk) here.

Scan the QR with your phone camera, or tap Open in Dev Tool on the device, to open this branch in the installed Dev Tool dev client.

    iOS         Android    
    QR to open the iOS build         QR to open the Android build    
    Open in Dev Tool         Open in Dev Tool    
Deep links

iOS

couchers-devtool://expo-development-client/?url=https%3A%2F%2F73a262d5--ota.preview.couchershq.org%2Fios%2Fmanifest

Android

couchers-devtool://expo-development-client/?url=https%3A%2F%2F73a262d5--ota.preview.couchershq.org%2Fandroid%2Fmanifest

Web (Vercel)

View the Vercel web preview for this branch.

Backend

Schema Schema diff Sample emails

Other

Protos Backend coverage Web coverage

@tristanlabelle tristanlabelle changed the title Add preview lines Backend/emails: Use user content as preview lines Jun 17, 2026
@tristanlabelle tristanlabelle changed the title Backend/emails: Use user content as preview lines Backend/emails: Use user content as the preview line Jun 17, 2026
@tristanlabelle
tristanlabelle marked this pull request as ready for review June 17, 2026 12:20
@tristanlabelle
tristanlabelle requested a review from aapeliv as a code owner June 17, 2026 12:20
@tristanlabelle
tristanlabelle requested a review from a team June 17, 2026 12:21

@aapeliv aapeliv left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

what about when the user puts in something naughty? i'm not opposed but we gotta be careful here.

how about instead using the subtitle similar to what we do on ios?

@tristanlabelle

tristanlabelle commented Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

@aapeliv

what about when the user puts in something naughty? i'm not opposed but we gotta be careful here.

Consider a worst case scenario: A & B are in a couple, A sees that B received a notification email for a host request message saying "let's sleep together" within its first few chars. Would B think of blaming Couchers? If A had access to B's email, they could have opened it and seen the message, if A saw an email push notification on B's locked phone, B could have disabled previews when the phone is locked, if A was looking at the Gmail client over B's shoulder, I think that relationship has other issues :P. Basically I think it's outside of Couchers' problem space.

how about instead using the subtitle similar to what we do on ios?

Emails don't have a subtitle. The email client picks up the first text from the inner HTML, which for us will by default be "Hi " and then paraphrasing the subject (not very useful). The preview line is injected at the top of the html body with styling that makes it invisible, so the client picks it up and displays it as to the right end of these:

image

@aapeliv

aapeliv commented Jun 28, 2026

Copy link
Copy Markdown
Member

what about when the user puts in something naughty? i'm not opposed but we gotta be careful here.

Consider a worst case scenario: A & B are in a couple, A sees that B received a notification email for a host request message saying "let's sleep together" within its first few chars. Would B think of blaming Couchers? If A had access to B's email, they could have opened it and seen the message, if A saw an email push notification on B's locked phone, B could have disabled previews when the phone is locked, if A was looking at the Gmail client over B's shoulder, I think that relationship has other issues :P. Basically I think it's outside of Couchers' problem space.

I was thinking more along the lines of scammy stuff where it looks like the message is system-generated because it's in the preview line.

Either way, I do not think this is any worse than our current practice of putting much user generated content in the subject line. I had a think about this and I see this as no more risky.

@tristanlabelle
tristanlabelle merged commit fab9331 into develop Jun 28, 2026
5 checks passed
@tristanlabelle
tristanlabelle deleted the backend/feature/emails-preview-lines branch June 28, 2026 15:37
@github-actions github-actions Bot added the release notes: pending Add to stuff that should be included in release notes label Jun 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📝 Release Notes

This PR should be included in the release notes.

Suggested release note:

Improved email previews to show more useful message and event content in inboxes instead of repeating the subject line
🤖 Bot Debug Information

Model: couchers.openai.gpt-5.4
Decision: include
Reasoning: This changes how notification emails appear in inbox previews by showing relevant user-generated content instead of repetitive subject text, which is a noticeable user-facing improvement to email UX. While subtle, it affects many emails users receive and makes them more informative at a glance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release notes: pending Add to stuff that should be included in release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants