Skip to content

fix: Avoid saving the draft to the wrong mailbox when switching the mailbox - #3084

Merged
tevincent merged 2 commits into
mainfrom
fix-access-draft-wrong-mailbox
Oct 2, 2026
Merged

tevincent merged 2 commits into
mainfrom
fix-access-draft-wrong-mailbox

Conversation

@tevincent

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI balanced review requested due to automatic review settings September 29, 2026 12:01

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Realm selection in NewMessageViewModel can still race with account switching and save a draft under the previous user.

Review effort: Balanced
Findings: 1 High severity

Open (1)
What changed in this PR

Targets draft persistence and processing at the mailbox explicitly associated with each draft.

Changes:

  • Opens mailbox-specific Realm instances for draft creation and workers.
  • Refactors draft queries to accept explicit Realm instances.
  • Adds worker coverage for mailbox switching.
File Description
MailActionsManager.kt Uses the worker’s targeted Realm.
DraftsActionsWorker.kt Opens Realm using work input IDs.
NewMessageViewModel.kt Selects a Realm for the draft mailbox.
RealmDatabase.kt Restricts implicit current-mailbox Realm creation.
DraftController.kt Exposes Realm-specific draft operations.
MailActionsManagerTest.kt Updates calls for refactored APIs.
DraftsActionsWorkerTest.kt Tests targeted-mailbox draft processing.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

Explicit mailbox targeting is consistently applied and covered by a focused regression test.

Review effort: Balanced
Findings: None

Resolved since last review (1)

@tevincent
tevincent force-pushed the fix-access-draft-wrong-mailbox branch from 274c50b to 2b68628 Compare October 2, 2026 06:11
@tevincent
tevincent enabled auto-merge October 2, 2026 06:11
@sonarqubecloud

sonarqubecloud Bot commented Oct 2, 2026

Copy link
Copy Markdown

@tevincent
tevincent merged commit d2608bb into main Oct 2, 2026
10 checks passed
@tevincent
tevincent deleted the fix-access-draft-wrong-mailbox branch October 2, 2026 06:24
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.

3 participants