You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Split out of #1845, as asked in #1845 (comment). There is no issue of its own for it; say so if you want one opened first.
What changes for the person using MailCraft
The Rules dialog has one more action, Mark as junk: the mail a rule finds goes to its account's Junk Email folder, as Home › Junk does.
For the control channel and agents: {"type": "markJunk"} among rules.add's actions. It takes no value.
It moves with the rule's other moves, after the marks, so a rule can mark mail as read and junk it. Mail in Junk Email already, or in a folder under it, or in an account with no such folder, stays where it is, and Run Rules Now doesn't count it.
A Microsoft account's server has no such rule action. The rule is kept on this computer; asking for it on the server ("server": true) is refused with "the server can't mark mail as junk". A server's rule that claims the action is read as a part not known here, like the other actions no server takes.
Nothing else from #1845 is in here: no rules.edit, no contact conditions, no contacts folders.
How it was checked
New tests: a_rule_marks_mail_as_junk (model), a_rule_that_marks_as_junk_is_made_and_moves_mail_to_junk_email (engine).
Extended tests: the server refusals in rules_remote_tests.rs and graph/rules_tests.rs, and the Rules form's keep_tests.rs (every action the builder offers is one rules.add takes).
The three new interface texts are translated in every catalogue and marked #, fuzzy.
cargo xtask ci on Rust 1.98.1, Linux: all 15 steps passed. Not run on macOS or Windows.
cargo xtask ci passes
A crash or data-loss fix has its regression test (not one)
"Allow edits by maintainers" is ticked (the box beside Create pull request)
I have signed the CLA, or will by commenting on this pull request
Added a Mark as junk action to the Rules builder. Matching messages move to the account’s Junk folder, and rules can still apply other actions, such as marking messages as read.
Rules using this action stay on your computer because Microsoft account servers don’t support it.
A rule can move the mail it finds to its account's Junk Email folder, as
Home › Junk does: `{"type": "markJunk"}` in `rules.add`, "Mark as junk" in
the Rules dialog.
- It moves with the rule's other moves, after the marks. Mail in Junk Email
already, or under it, or in an account with no such folder, stays where it
is and isn't counted by Run Rules Now.
- A Microsoft account's server has no such action: the rule is kept on this
computer, `"server": true` is refused with the reason, and a server's rule
that claims it is read as a part not known here.
Split out of UCSLabs#1845.
Human-reviewed, AI-assisted, nobody's mailbox harmed.
The change adds a MarkJunk rule action to the model, command interface, and rules builder. When a rule runs, eligible matching mail moves to the account’s Junk folder. Server-rule handling rejects or omits this action because servers do not support it.
Changes: Junk rule action
Layer / File(s)
Summary
Define and expose the junk action crates/model/src/rule.rs, crates/engine/src/cmd/rules.rs, crates/ui-egui/src/forms.rs, crates/ui-egui/src/forms/rules/*, crates/i18n/po/*, packaging/release-notes.d/new/2249.md
The rule model, command parser, and rules builder add MarkJunk as a value-free action. Localization catalogs and the release note include text for the action and server limitation.
Apply the action to matching mail crates/model/src/mailbox.rs, crates/model/src/mailbox_tests.rs, crates/engine/src/cmd/rules_parts_tests.rs
Mailbox::act moves eligible mail to the account’s Junk folder. Tests cover matching and nonmatching mail, existing Junk locations, action ordering, and command execution.
Server-rule checks and downloaded-rule handling identify MarkJunk as unsupported. Tests cover local storage by default and rejection of an explicit request for server storage.
UCSLabs/mailcraft#1177: Adds the rule-edit flow that opens a MarkJunk rule for editing and supports saving it unchanged.
Suggested reviewers:kartas39
Merge Risk: Low · up to 808ae
Mark as junk works as described for ordinary rules. A rule that lists Mark as junk twice around another move may file mail in a different folder than expected, which is a narrow edge case and does not block merging.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title "Rules: a Mark as junk action" names the main change: a new Mark as junk action for mail rules. It matches the rules.rs, mailbox.rs, rule.rs, and UI changes, and it is short and specific.
Description check
The description follows the repository template. It has the Closes line (left blank with a note that there is no issue), the user-facing changes section, the how-it-was-checked section, and the checkl…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Description check
Explanation
The description follows the repository template. It has the Closes line (left blank with a note that there is no issue), the user-facing changes section, the how-it-was-checked section, and the checklist. The author ticked the CI, maintainer-edit, and CLA boxes and left the regression-test box unticked with a note. The Closes line is empty, but the author explains there is no linked issue. The description is mostly complete and clearly states the behavior, server limits, and test coverage.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
The reason will be displayed to describe this comment to others. Learn more.
Checked the rule builder and editor, command validation, saved rule encoding, incoming-mail and manual execution paths, Graph refusal and import paths, translation catalogs, and merged source against current main.
Source review only. I did not build the project, run tests, or check CI.
The reason will be displayed to describe this comment to others. Learn more.
P1. Handle MarkJunk in the rule editor added on main
The merge with current main produces a non-exhaustive match in crates/ui-egui/src/forms.rs at Act::of. Main added rule editing after this branch split off, and Act::of explicitly matches every previous Action variant. The new MarkJunk variant makes mailcraft-ui-egui fail to compile after a clean merge. Add A::MarkJunk => Act { kind: Do::Junk, ..base } to the editor conversion and check that opening and saving an existing junk rule preserves its action.
The reason will be displayed to describe this comment to others. Learn more.
Approve. Mark as junk uses the same move path as Delete and MoveTo; every exhaustive Action match is updated; Graph export refuses it with a clear reason; stage ordering (last move wins, marks first) and stop-processing are consistent and tested; all 16 catalogues are filled and marked fuzzy.
Non-blocking:
The params help and two comments say "Junk E-mail"; the folder is "Junk Email".
No test for an account without a Junk folder (the _ => false arm); rules.add could say when a single-account rule's account has none.
As with earlier new actions, an older build refuses a mailbox file containing markJunk (no data lost). A lenient Unknown action variant would be a separate, project-wide change.
The reason will be displayed to describe this comment to others. Learn more.
Additional comments: 1
crates/engine/src/cmd/rules.rs: 1
473-476: Minor · Functional Correctness · Quick win
Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.
Preserve the last occurrence of folder-changing actions.
For [markJunk, moveTo Archive, markJunk], once_each removes the final MarkJunk. The stage-sorted executor then leaves the message in Archive instead of Junk. This contradicts the documented “last listed move wins” behavior.
Retain the last identical folder-changing action rather than the first. Keep duplicate-copy suppression unchanged.
Reviewing files that changed from the base of the PR and between ee6df7c and 808ae84.
Files selected for processing: 23
crates/engine/src/cmd/rules.rs
crates/engine/src/cmd/rules_remote_tests.rs
crates/i18n/po/cs.po
crates/i18n/po/de.po
crates/i18n/po/es.po
crates/i18n/po/fr.po
crates/i18n/po/he.po
crates/i18n/po/hu.po
crates/i18n/po/it.po
crates/i18n/po/ja.po
crates/i18n/po/ka.po
crates/i18n/po/messages.pot
crates/i18n/po/nl.po
crates/i18n/po/pl.po
crates/i18n/po/pt_BR.po
crates/i18n/po/pt_PT.po
crates/i18n/po/ro.po
crates/i18n/po/sl.po
crates/i18n/po/zh_CN.po
crates/model/src/mailbox.rs
crates/net/src/graph/rules.rs
crates/ui-egui/src/forms.rs
crates/ui-egui/src/forms/rules/tests.rs
Files skipped from review as they are similar to previous changes: 17
crates/i18n/po/cs.po
crates/i18n/po/de.po
crates/i18n/po/es.po
crates/i18n/po/fr.po
crates/i18n/po/he.po
crates/i18n/po/hu.po
crates/i18n/po/it.po
crates/i18n/po/ja.po
crates/i18n/po/ka.po
crates/i18n/po/messages.pot
crates/i18n/po/nl.po
crates/i18n/po/pl.po
crates/i18n/po/pt_BR.po
crates/i18n/po/pt_PT.po
crates/i18n/po/ro.po
crates/i18n/po/sl.po
crates/i18n/po/zh_CN.po
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.
Merged main and added the Mark as junk case to the rules form's new edit path from #1177 (plus a test that a junk rule opens and saves back unchanged), so it builds with main; re-queued.
This branch has not been deployed
No deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Split out of #1845, as asked in #1845 (comment). There is no issue of its own for it; say so if you want one opened first.
What changes for the person using MailCraft
{"type": "markJunk"}amongrules.add's actions. It takes no value."server": true) is refused with "the server can't mark mail as junk". A server's rule that claims the action is read as a part not known here, like the other actions no server takes.Nothing else from #1845 is in here: no
rules.edit, no contact conditions, no contacts folders.How it was checked
New tests:
a_rule_marks_mail_as_junk(model),a_rule_that_marks_as_junk_is_made_and_moves_mail_to_junk_email(engine).Extended tests: the server refusals in
rules_remote_tests.rsandgraph/rules_tests.rs, and the Rules form'skeep_tests.rs(every action the builder offers is onerules.addtakes).The three new interface texts are translated in every catalogue and marked
#, fuzzy.cargo xtask cion Rust 1.98.1, Linux: all 15 steps passed. Not run on macOS or Windows.cargo xtask cipassesA crash or data-loss fix has its regression test (not one)
"Allow edits by maintainers" is ticked (the box beside Create pull request)
I have signed the CLA, or will by commenting on this pull request
Human-reviewed, AI-assisted, nobody's mailbox harmed.
Summary by CodeRabbit