Skip to content

feat: Auto-generate email subject when composing a new email#151

Draft
Copilot wants to merge 1 commit into
mainfrom
copilot/generate-email-subject-feature
Draft

feat: Auto-generate email subject when composing a new email#151
Copilot wants to merge 1 commit into
mainfrom
copilot/generate-email-subject-feature

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 29, 2026

When composing a new email, the AI only generated the body — the subject field had to be filled manually. This adds automatic subject generation when the subject field is empty.

Changes

OpenAI provider

  • Prompt now requests subject generation when no subject is provided, using Subject: [subject here] as a format marker at the top of the response
  • Response parser extracts and strips the Subject: line, setting it separately on the Respond object

GenereteEmailAction

  • JSON response now includes a subject field alongside the existing respond

Frontend (sendPostRequest.js / bundle)

  • On successful generation, if the response includes a subject and compose-subject is empty, the field is auto-filled
  • Existing subjects (replies, already-generated) are never overwritten

Tests

  • Updated all prompt string assertions to match the new format
  • Added testGenerateEmailParsesSubjectFromResponse — subject extracted, body cleaned
  • Added testGenerateEmailNoSubjectInResponse — null subject when AI omits the line

Prompt format change

// Before (no subject case):
"... Without a subject ..."
The format should be as follows:
Greeting
...

// After:
"... Generate a suitable subject for this email. ..."
The format should be as follows:
Subject: [subject here]

Greeting
...

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.

feat: Auto-Generate Email Subject When Composing a New Email

2 participants