Skip to content

feat: Support threadId in gmail_createDraft#212

Merged
allenhutchison merged 2 commits intomainfrom
adh/feat/gmail-draft-thread-id
Feb 12, 2026
Merged

feat: Support threadId in gmail_createDraft#212
allenhutchison merged 2 commits intomainfrom
adh/feat/gmail-draft-thread-id

Conversation

@allenhutchison
Copy link
Copy Markdown
Contributor

This PR adds support for creating draft replies linked to existing email threads in gmail_createDraft. Closes #191.

This change adds support for creating draft replies linked to existing email threads using the `gmail_createDraft` tool.

Closes #191
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @allenhutchison, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the email drafting capabilities by introducing support for creating reply drafts within existing email threads. By allowing a threadId to be specified, the system can now automatically link new drafts to ongoing conversations, improving the user experience for managing email replies. This change involves updating the API schema, modifying the draft creation logic to fetch relevant thread information, and ensuring proper MIME header generation for threaded messages.

Highlights

  • Gmail Draft Threading: The gmail_createDraft function now supports an optional threadId parameter, allowing users to create draft replies linked to existing email threads.
  • Reply Header Generation: When a threadId is provided, the service fetches the last message's Message-ID from the specified thread and uses it to generate appropriate In-Reply-To and References headers in the MIME message.
  • Robust Error Handling: The system gracefully handles cases where fetching thread information fails, ensuring that a draft can still be created even if reply headers cannot be generated.
  • API Schema Update: The gmail.createDraft tool's input schema has been updated to reflect the new threadId parameter, including a clear description for its usage.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • workspace-server/src/tests/services/GmailService.test.ts
    • Added test case for creating a reply draft with a threadId, verifying thread fetching and MIME header generation.
    • Added test case for handling thread fetch failures gracefully while still creating the draft.
  • workspace-server/src/tests/utils/MimeHelper.test.ts
    • Added test case to confirm In-Reply-To and References headers are included when provided.
    • Added test case to confirm In-Reply-To and References headers are not included when not provided.
  • workspace-server/src/index.ts
    • Updated the gmail.createDraft input schema to include an optional threadId parameter.
  • workspace-server/src/services/GmailService.ts
    • Defined CreateDraftParams type to include an optional threadId.
    • Modified createDraft method to accept threadId.
    • Implemented logic to fetch Message-ID from the last message of a given threadId.
    • Added error handling for thread fetching, logging warnings instead of failing.
    • Passed inReplyTo and references headers to MimeHelper.createMimeMessage.
    • Conditionally included threadId in the Gmail API drafts.create request body.
  • workspace-server/src/utils/MimeHelper.ts
    • Updated createMimeMessage function signature to accept optional inReplyTo and references parameters.
    • Added logic to include In-Reply-To and References headers in the generated MIME message.
Activity
  • No human activity has been recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a valuable feature to gmail_createDraft, enabling the creation of draft replies within existing email threads via a threadId. The implementation correctly fetches the parent thread to construct reply headers and passes the threadId to the Gmail API. The changes are well-structured and include appropriate tests for the new logic. I have one suggestion to improve the construction of the References header to better align with email standards, which will enhance threading compatibility across various email clients.

Comment thread workspace-server/src/services/GmailService.ts
Copy link
Copy Markdown
Contributor

@abhipatel12 abhipatel12 left a comment

Choose a reason for hiding this comment

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

LGTM!

…g `Message-ID` to existing references and using case-insensitive header lookups.
@allenhutchison allenhutchison merged commit 5febdd9 into main Feb 12, 2026
14 checks passed
@allenhutchison allenhutchison deleted the adh/feat/gmail-draft-thread-id branch February 12, 2026 20:22
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.

Feature request: Support threadId in gmail_createDraft for reply drafts

2 participants