Skip to content

Add Gmail remote draft edit/send support - #170

Open
mohammedahmed18 wants to merge 24 commits into
mainfrom
codex/gmail-remote-draft-edit-send
Open

Add Gmail remote draft edit/send support#170
mohammedahmed18 wants to merge 24 commits into
mainfrom
codex/gmail-remote-draft-edit-send

Conversation

@mohammedahmed18

@mohammedahmed18 mohammedahmed18 commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Project remote Gmail drafts under draft/ with stable gmail-draft: ids while keeping outbox/ as the direct-send staging surface.
  • Support Gmail draft update and draft-to-outbox send push flows, including connector guidance/docs and live Gmail script coverage.
  • Repair legacy Gmail draft message-id state safely across pull, scheduled reconcile, virtual refresh, and repeated scheduled pass preservation cases.
  • Preserve the current remote draft subject when sending a moved draft from outbox/ without an explicit subject edit.
  • Enable the protected connector live Gmail workflow to run the real send-gated E2E path on main/manual runs.

Test Plan

  • cargo fmt --all --check
  • git diff --check origin/main...HEAD
  • cargo test -p localityd reconcile::tests::scheduled_pull_gmail_draft -- --nocapture
  • cargo test -p localityd pull::tests::pull_gmail_draft -- --nocapture
  • cargo test -p localityd virtual_fs::tests::refresh_children_repairs_legacy_gmail_draft_message_id_collision -- --nocapture
  • cargo test -p locality-store
  • cargo test -p locality-gmail
  • cargo test -p localityd --test source_descriptor
  • cargo test -p localityd --test push_preparation
  • cargo test -p localityd --test push_execution
  • cargo test -p loc-cli --test mount mount_writes_gmail_attachment_guidance
  • cargo test -p locality-desktop agent_guidance::tests::skill_teaches_connector_aware_locality_cli_workflow
  • cargo test -p localityd push::tests
  • cargo test -p loc-cli --test status
  • LOCALITY_LIVE_GMAIL_SELFTEST=1 tests/live_gmail_vfs_roundtrip.sh
  • bash -n tests/live_gmail_vfs_roundtrip.sh
  • LOCALITY_LIVE_GMAIL_VFS=0 tests/live_gmail_vfs_roundtrip.sh (skip path)
  • cargo test --workspace -- --test-threads=1
  • LOCALITY_LIVE_GMAIL_VFS=1 LOCALITY_LIVE_GMAIL_SEND=1 LOCALITY_GMAIL_LIVE_CONNECTION_ID=gmail-default LOCALITY_GMAIL_LIVE_MOUNT_ID=gmail-live LOCALITY_GMAIL_LIVE_TO_EMAIL=mohammed182001180@gmail.com LOCALITY_GMAIL_LIVE_CREDENTIAL_JSON=<refreshed ali@codeflash.ai credential> tests/live_gmail_vfs_roundtrip.sh
  • python3 -c 'import yaml; yaml.safe_load(open(".github/workflows/connector-live-e2e.yml", encoding="utf-8")); print("yaml ok")'

Live Verification Notes

  • Real Gmail API, CLI, daemon, and Linux FUSE draft, direct-send, remote draft edit, and remote draft send checks passed against ali@codeflash.ai.
  • Gmail OAuth scopes allow compose/send but do not allow trashing sent scratch messages, so final sent-message cleanup is best-effort and emitted a warning during the run.
  • GitHub's connector-live-e2e Gmail job now sets LOCALITY_LIVE_GMAIL_SEND=1, so the protected live workflow covers the send path on main/manual runs.

Review

  • Subagent spec review approved.
  • Final code-quality review approved after fixing the repeated scheduled reconcile legacy-stub preservation issue.

@vercel

vercel Bot commented Aug 4, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
locality Ready Ready Preview Aug 4, 2026 6:46pm

@mohammedahmed18 mohammedahmed18 changed the title WIP: Add Gmail remote draft edit/send support Add Gmail remote draft edit/send support Aug 4, 2026
@mohammedahmed18
mohammedahmed18 marked this pull request as ready for review August 4, 2026 17:16
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

Codex review

  • major: crates/locality-gmail/src/render.rs / crates/locality-gmail/src/dto.rs
    Editing an existing Gmail draft replaces the draft with MIME that only contains To, optional Cc/Bcc, Subject, and body, and the update DTO only sends message.raw. For existing reply drafts, this drops threadId, References, and In-Reply-To, so an edited reply can be sent as a detached new conversation instead of staying in its original Gmail thread. Gmail’s API requires the requested threadId plus compliant References and In-Reply-To headers to add a draft/message to a thread. (developers.google.com)
    Minimal fix: preserve the original draft’s message.threadId and reply headers when building update MIME, include threadId in GmailRawMessage/GmailDraftUpdateRequest, and add a test with a draft containing In-Reply-To/References that verifies the update request preserves them.

  • minor: crates/locality-gmail/src/render.rs
    Adding bcc: [] to every rendered Gmail message changes the persisted canonical frontmatter shape for existing Gmail shadows. shadows_match compares frontmatter properties exactly apart from sync metadata, so an upgraded user with an old shadow lacking bcc can hit a false “remote entity changed since the Synced Tree shadow” guardrail when pushing an otherwise clean draft edit after upgrade.
    Minimal fix: either avoid emitting empty bcc, normalize missing bcc and empty bcc as equivalent for Gmail shadow/concurrency comparison, or add a persisted-format migration/component-version repair. Add a compatibility test with an old Gmail draft shadow without bcc and a remote render with bcc: [].

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.

1 participant