Repository navigation
A sign-in open in the browser holds only its own account's jobs - #1600
Conversation
Busy::blocks took a sign-in as global, so one account's sign-in page left open held the Inbox check, the calendar, the to-dos, the rules, the automatic replies and free/busy of every account. Busy now names the account being signed in, and blocks asks for whose job it is: only that account's jobs (and a shared mailbox's read through it) wait; everything else at work still holds a job whichever account it is for (Busy::blocks_every). Human-reviewed, AI-assisted, nobody's mailbox harmed.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
benandez
left a comment
There was a problem hiding this comment.
Thanks @SetsuaD, this is a clean split: blocks_every for what holds every account and blocks(job, account) for the sign-in, and the tests go through every row. No P1/P2. Sign-in and sync changes get every finding fixed before merge, P3s included, so I'm requesting changes for three small ones.
Checked
- Head
b3c5570fc459cf5890d641a4e85a3d716e6f100b. CI is green (run 44123680467, plus Fuzz, CodeQL and CLA; 19 pass, 1 skipped). Merges cleanly with main and with #1599, #1575, #1572 and #1573. cargo test -p mailcraft-engine --lib sync_driver: 139 passed, 0 failed. The ui-egui tests (inbox_pass_tests) and clippy were not run locally; CI ran them green.- Read:
sync_driver/jobs.rs,auto_replies.rs,calendar_plan.rs,calendar.rs,free_busy.rs,rules.rs/tasks.rsdue, uijobs.rs,inbox_pass.rs,calendar_sync.rs,lib.rs(begin_sign_in),task_sync.rs,scheduling.rs,Mailbox::owner_of, and the new tests. - Every row minus
signingequals the old row withsigning = false(checked row by row injobs.rs). No caller is left on the oldblocks(job)signature. Another account's job wanting a sign-in while one is open is refused bybegin_sign_in, so there's no double sign-in. - Not checked: a live two-account browser sign-in. Keeping Send/Receive global and a public
blocks_everyare fine for this PR.
To fix
- [P3] The calendar's "ask at once" wish is lost for the signing account (
crates/engine/src/sync_driver/calendar_plan.rs:140-146,calendar.rs:212-221).CalendarDriver::dueis one flag, andstarted()clears it for any job withown_days. With A signing in and the calendar brought to the front, B's job starts and clearsdue, so A's calendar waits for its interval after the sign-in. The test passes because it callscalendar_none_startedand never starts B's plan. Could the wish be kept per held account (or not cleared while an account was held), with a test that starts B's plan? - [P3] A held automatic-replies change can be overwritten (
auto_replies.rs:269,:293-299).waitingholds one change, so A's change, held for A's sign-in, is replaced without a word when the owner changes B's replies meanwhile. This predates the PR, but the PR makes "held for its sign-in" an ordinary state. Couldwaitingbe per account likeheld, with a test? - [P3]
crates/ui-egui/src/inbox_pass.rs:105:busyis read once before the queue loop. That's right while the loop starts at most one pass; a one-line comment would keep a later change from starting several passes on a staleBusy.
Human-reviewed, AI-assisted, nobody's mailbox harmed.
…nt's doesn't replace it AutoRepliesDriver::waiting held one change: a change held for its account's sign-in was replaced, without a word, when the owner changed another account's replies meanwhile. It is now kept per account, like the changes held for the permission: a newer change of the same account still takes the place of the one before, and the changes go one at a time, each when its account isn't signing in. Human-reviewed, AI-assisted, nobody's mailbox harmed.
…ning in CalendarDriver::due is one flag, and the first job to start clears it: with one account signing in and the calendar brought to the front, another account's job started and took the wish with it, so the account that signed in waited for its interval. The look now keeps the wish for each account it holds for a sign-in (due_for), and that account's own job is what lets go of it. Human-reviewed, AI-assisted, nobody's mailbox harmed.
Human-reviewed, AI-assisted, nobody's mailbox harmed.
|
Thanks @benandez. All three are fixed in new commits on top of
Tested at b1dacd5 with Human-reviewed, AI-assisted, nobody's mailbox harmed. |
benandez
left a comment
There was a problem hiding this comment.
Thanks: all three earlier points are fixed (due_for, the per-account auto-replies map, the inbox comment), and I found nothing new that blocks.
It needs a merge with main first. Main's #790 (category sync) added Start::Categories, and category_sync.rs:157 calls self.job_busy().blocks(Start::Categories) before its per-account loop. Please resolve it like the other drivers:
blocks_everybefore the loop;- in the loop, skip any account where
blocks(Start::Categories, account); - add a Categories row to
blocks_every(main's row minussigning); - add
categoriestoeverything_else_at_work_holds_a_job_whichever_account_it_is_for.
Converting it to plain blocks_every would let a signing-in account's categories job run during its sign-in, and the old blanket rule would bring back #1557 for categories.
There was a problem hiding this comment.
🤖 Automated review of b1dacd5
The change is safe to merge. This PR addresses a critical synchronization bug by correctly scoping job blocking during an account sign-in process. By refactoring Busy::signing_in from a global boolean flag to an optional, account-specific ID (Option<Id>), the system now ensures that only jobs belonging to the currently signing-in account are paused, allowing all other accounts' background checks (Inbox, Calendar, Tasks, etc.) to proceed normally. The extensive refactoring across multiple drivers and the addition of comprehensive tests validate this complex state management fix.
No issues found.
✅ Approved: no unresolved findings at [P4] MINOR (Quality) or above.
Model google/gemma-4-e4b · skill code-change-review · 20 files reviewed. Reply to an inline comment to discuss it.
Human-reviewed, AI-assisted, nobody's mailbox harmed.
…nt's Human-reviewed, AI-assisted, nobody's mailbox harmed.
… is kept for its own account Main's auto_replies_allowed set the single waiting change; on this branch each account keeps its own. Human-reviewed, AI-assisted, nobody's mailbox harmed.
|
Thanks, @benandez. Three commits on top of
Tested. Human-reviewed, AI-assisted, nobody's mailbox harmed. |
|
✅ Review posted on
The review is posted here. |
|
🛑 Daily review limit reached. This organization has had 114 of its 100 reviews for the last 24 hours, so I won't review this pull request, or further pushes to it, for now. Reviews resume automatically from about 2026-11-23 23:08 UTC. I'll still answer replies in my review threads. The limit is set by the bot's administrator. |
|
There was a problem hiding this comment.
🤖 Automated re-review of c5f63c1
Bot review number 2 of 15.
The per-account busy rule is built correctly: every blocks_every row is exactly the old row minus the sign-in term (verified row by row), blocks(job, account) restores the old behaviour for the account that is signing in, and the waiting map for automatic replies also fixes a latent bug where one account's queued change clobbered another's, with a regression test. No blocking defects found; the only finding is a placeholder link in the release-notes fragment. Reviewed from the diff alone (not independently verified); worth a human glance: free_busy.rs (passes account.id) and category_sync.rs (passes the raw account) are the only new blocks(...) call sites without the owner-of-shared-mailbox mapping every other site applies, which only holds if those paths never see a shared mailbox id.
No new issues found in this update.
✅ Approved: no unresolved findings at [P3] MINOR (Defect) or above.
1 lower-priority or previously reported findings were omitted.
Model glm-5.3-flash · skill code-change-review · 22 files reviewed. Reply to an inline comment to discuss it.
benandez
left a comment
There was a problem hiding this comment.
Thanks @SetsuaD, the merge is done the way we asked, and everything from the earlier rounds is still in place. Approving.
Checked
- Head
c5f63c1. CI is green (CI, Fuzz, CodeQL, CLA), and it still merges cleanly with main. - Categories: the row in
blocks_everyis main's row minus the sign-in, the Calendar row keeps main'sself.categories,categories_tick_atasksblocks_everybefore the loop and skips the signing account inside it (category_sync.rs:157-165), andcategoriesis in the every-field test.category_accountsleaves shared mailboxes out, so passing the raw account id is right there.free_busy_accountonly returns accounts that sign in with Microsoft themselves, and a shared mailbox never does, soaccount.idis right infree_busy_looktoo. - The merge puts the calendar's sign-in skip before main's #851 rename note, so a held account gets its note once it's free.
c5f63c1makes main'sauto_replies_alloweduse the per-accountwaitingmap, the same as the engine's own path. - The three earlier points (
due_for, per-account automatic replies, the Inbox comment) are unchanged.
Optional, not blocking
crates/ui-egui/src/category_sync.rs:163: no test covers the new skip. If someone later deleted thecontinue, the signing account's category job could start in the middle of its sign-in. If they put the blanket hold back, #1557 would come back for categories. Either way every test would still pass. A short window test like the Inbox one (sign-in open on one account, the other account's list job starts and the signing one's doesn't) would pin it down. That can go in this PR or a later one, up to you.
Human-reviewed, AI-assisted, nobody's mailbox harmed.



Closes #1557.
What was wrong.
Busy::signing_inwas a bool, set fromMailApp::signing_in.is_some(), and every row ofBusy::blocksheld its job on it. The drivers askblocksonce, before their loop over the accounts (calendar_due,tasks_due,rules_due,auto_replies_due), and the window asks it once for the Inbox check (inbox_check_tick) and for free/busy, so the account a job was for never came into it. With two accounts, a sign-in page left open for one held the other's Inbox check, calendar, to-dos, rules, automatic replies and free/busy until the page was finished or cancelled.The fix.
jobs.rs:Busy::signing_inisOption<Id>, the account whose sign-in is open (SigningIn::accountin the window).Busy::blocks(job, account)holds a job when it is that account's, or when anything else at work holds it.Busy::blocks_every(job)is the old rows less the sign-in: what holds a job whichever account it is for. The rows are otherwise as they were.blocks_every, and skip in the loop an account whose sign-in is open:tasks_due,rules_due,auto_replies_due,calendar_due. A shared mailbox's calendar is held by its owner's sign-in (owner_of, ascalendar_jobsigns it in).calendar_dueleavesmay_askfalse when it held an account, so the wish to ask at once is kept for that account (as it was kept before for all of them), and the shared-calendars question still waits for the sign-in. Inauto_replies_due, a waiting change for the account that is signing in stays queued, and the other accounts' replies are read meanwhile; the change goes first once the sign-in is over.free_busy_lookasks for the calendar's account. In the window,calendar_job_aroundandcheck_calendarask for theirs, andinbox_check_tickasksblocks_everyonce (the minute starts again, as before, while a round is under way) and skips an account, or a shared mailbox read through it, whose sign-in is open; the others are checked.account == 0) holds none of the existing accounts' jobs.Nothing else is changed:
AskWindow::signing_instays global (no question to the owner is put over an open sign-in page), and so does the Send/Receive round's own wait inauto_sync(one Send/Receive at a time).Tests.
jobs_tests.rs:a_sign_in_goes_first_for_every_job_of_its_own_account_and_holds_no_other_accounts;everything_else_at_work_holds_a_job_whichever_account_it_is_for(each other field, every job, both accounts); anda_sign_in_left_open_on_one_account_holds_its_jobs_and_none_of_the_others, which has two accounts with a sign-in open on one: the other's calendar, to-dos, rules and automatic replies are due and the signing account's are not, the wish to ask at once is kept, and once the sign-in is over both accounts' jobs are due.auto_replies_tests.rs:a_change_for_an_account_that_is_signing_in_waits_for_it_and_the_others_are_read_meanwhile.tasks_tests.rs,auto_replies_tests.rs,free_busy_tests.rs: the existing sign-in rows name the account, plus a row where another account's sign-in holds nothing.inbox_pass_tests.rs:a_sign_in_left_open_on_one_account_holds_only_its_own_check. With the owner (and a shared mailbox under it) and another account, it leaves a browser sign-in open on the other account: the owner's and the shared mailbox's Inboxes are checked. Then it leaves one open on the owner: only the other account is checked. Then it cancels: all three are checked. The stand-in host's check that every pass is signed as the owner (MB3.18) now expects an account's own sign-in, with the owner's for the shared mailbox, since this test adds an account of its own beside them.Every new test fails with the old rule put back (a sign-in holding every account's jobs): six in
mailcraft-engineand the Inbox check inmailcraft-ui-egui.cargo xtask cipasses: all 14 steps (cargo-deny wasn't installed on the machine, sodenywas skipped).There's no live check against a server for this: a browser sign-in is the Microsoft OAuth path, and the change is in the order the jobs start, which the stand-ins show.
For you to look at.
auto_sync,ui.sync). I left that alone, since a round is one at a time and often is what opened the page. If you want a round of the other accounts to go while a page is open, that's a change to the round rather than toBusy, and I'd do it separately.blocks_everyis public because the drivers need it before their loops. If you'd rather keep one method, the drivers could askblocksper account and drop the check before the loop, butcalendar_duewould then have to tell "something global" from "this account's sign-in" some other way.Human-reviewed, AI-assisted, nobody's mailbox harmed.
Summary by CodeRabbit