Skip to content

#566: Edit Rule changes a rule once it is made, on its server too - #787

Draft
kartas39 wants to merge 47 commits into
UCSLabs:mainfrom
kartas39:566-edit-rule
Draft

kartas39 wants to merge 47 commits into
UCSLabs:mainfrom
kartas39:566-edit-rule

Conversation

@kartas39

@kartas39 kartas39 commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Builds on #786. Part of #566; it doesn't close it. A draft until that PR is merged.

What changes for the person using MailCraft

  • A rule's "⋯" menu has Edit Rule. It opens the rule's page filled in with what the rule is, with Save and Cancel.
  • Edit Rule is greyed, and its tooltip says why, for:
    • a rule the server doesn't let be changed;
    • a rule made in another program or on the web, with parts MailCraft can't show;
    • a rule the server is still making;
    • a rule that looks for several categories at once, or for words with a semicolon in them, which the page can't show.
  • A changed rule stays for its account, where it is kept, switched on or off, and in its place.
  • A rule on a Microsoft account's server is changed there at the next Send/Receive. Its name, conditions, exceptions and actions are sent whole (PATCH), so an exception taken away here is taken away there too.
  • If the change asks for something the server can't keep, the page says what and Save is greyed.
  • If the rule is changed here and the server makes it read-only, or gives it parts MailCraft can't show, before the change is sent: the server's version stays, and the app says the change made here was let go of.
  • An agent's rules.edit asks the owner the way making that rule would: Delete when the rule, switched on, comes to delete mail permanently or to delete mail on its server, or while a rule on this computer that deletes permanently is switched on (the question names those rules). Send when it comes to move or copy mail onto another account's server. Settings otherwise. The buttons are Allow and Don't Allow.

Edit Rule in the menu, and a rule's page opened by it, in light and dark:

Edit Rule in the menu
Edit Rule, light
Edit Rule, dark

How it was checked

  • cargo xtask ci passes on 73fc640. See below.

  • crates/engine/src/cmd/rules_edit_tests.rs: the command and what it refuses; the change sent whole and its answers (taken, refused, not allowed yet, and changed again while a taken or a refused one was on its way); a rule still waiting to go; the server locking the rule, or giving it parts MailCraft can't show, before the change goes; the agent's question and class.

  • crates/net/src/graph/rules_tests.rs: a changed rule is sent whole against the fake Graph server, and one the server couldn't keep is not sent.

  • crates/ui-egui/src/forms/rules/page_tests.rs: every part a rule can have comes back unchanged from the page; Edit Rule, Save and Cancel in the window; Edit Rule greyed on a rule the server locks.

  • Code owners' paths: crates/net/src/graph/rules.rs (the PATCH body) and crates/net/src/graph/rules_tests.rs, and the release note packaging/release-notes.d/new/566-edit-rule.md.

  • cargo xtask ci passes

  • A crash or data-loss fix has its regression test

  • "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

Not changed

After the review (2026-11-04)

  • #566: the Rules window laid out as Outlook's list of rules #786's new head is merged in: the rule in words in the window's language, and CodeQL's two "salt" alerts gone with the parameter's new name.
  • Not changed: Edit Rule's page doesn't ask before Escape, the back arrow, Cancel or × drop the change. No Microsoft source says that Outlook asks.
  • cargo xtask ci passes on 397c711. See below.

After the decision on rules for every account (2026-11-04)

  • #566: the Rules window laid out as Outlook's list of rules #786's new head is merged in: rules for every account are listed apart, under All accounts.
  • A rule under All accounts has For One Account ▸ and the accounts in its menu, as decided in #566. The rule then runs on that account's mail alone, kept on this computer, first of that account's rules here (rules.forAccount).
  • A rule that moves or copies mail to another account's folder opens on its page with no folder for that action. Save is greyed until a folder is chosen, and the rule is given when it is saved (rules.edit with account). Cancel leaves it under All accounts, as it was.
  • Edit Rule is greyed for a rule under All accounts: it is changed as it is given to one account.
  • An agent's rules.forAccount asks the owner as any change to the rules does: Settings, or Delete while a rule here that deletes permanently is switched on.

The menu, and the rule's page when its folder is another account's, in light and dark:

For One Account in the menu
The rule's page, its folder chosen again, light
The rule's page, its folder chosen again, dark

  • Tests: rules_edit_tests.rs (giving, what is refused, the folder chosen again, the agent's question) and page_tests.rs (For One Account in the menu; the page, Cancel and Save).
  • cargo xtask ci passes on 12cde0f.

Human-reviewed, AI-assisted, nobody's mailbox harmed.

…d actions, and a desktop alert

- Conditions: from and sent to people, sent only to me, my address in To or Cc, subject or body,
  a header, sensitivity, size, a meeting invitation, an automatic reply, a category, a flag, the
  days received; several words or addresses in one. Each can be an exception (Except if).
- Actions: copy to folder, delete permanently, flag with a due day, clear the flag, clear
  categories; a desktop alert beside Stop processing more rules.
- On a Microsoft account the server keeps what it can; the rest stays on this computer and says
  why. Rules made in Outlook with these parts are shown whole.
- Agents: rules.add takes the new parts and refuses wrong or too many; making, switching on or
  running a rule that deletes for good asks as a delete.
- Also fixed: a Graph copy then delete before Send/Receive lost the message when the copy was
  refused; rules.add cut a rule's parts past 20.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
- Run Rules Now reads a calendar part for "is a meeting invitation" only when it is small enough
  to be shown, as the reading pane does.
- An agent's question before Run Rules Now names the rules that delete mail permanently, also
  when the run files mail onto another server.
- The test of a loaded rule that moves mail to an Outbox matches the message again, and shows
  the rule acting on an ordinary folder.
- The Graph round trip checks that sizes go up in kilobytes.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
…nged (code scanning read their fixed clock as a nonce)

Human-reviewed, AI-assisted, nobody's mailbox harmed.
…ge isn't an invitation; a rule that can't act deletes nothing

- "Is a meeting invitation" can't be told of a message whose calendar part wasn't brought in
  (one too large to be read): a rule with it as a condition or an exception leaves the message
  alone, as for a body not here yet.
- A rule with no conditions or with parts this version doesn't know acts on nothing, so the
  agent gate doesn't count it as one that deletes mail permanently, nor names it.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
…t for good is asked as a delete; before Run Rules Now the question says which rules copy and which move

A yes to the question about sending alone made such a rule: the Delete grant was asked only
when Send was allowed in advance. Now it is asked as a delete until that is allowed, once, and
the question names the server and the deleting.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
…e; the MCP doc says when one question covers both grants

Human-reviewed, AI-assisted, nobody's mailbox harmed.
…owhere to go yet, too

A copy into a folder the server hadn't listed let the original's delete go first; the copy
then went from a server id that was gone, and a refusal lost the message on both sides.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
…count puts nothing on another server

Human-reviewed, AI-assisted, nobody's mailbox harmed.
…or good is kept on this computer when refused

A copy waiting to be made on another account's server (Microsoft or IMAP, a shared mailbox too)
was taken away when refused, as if its original were still here. Deleted for good meanwhile, by
the owner or by a rule that copies and then deletes, the message was then lost on both sides.
Now the placement names its source, and a refused copy whose source is gone stays in Imported.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
…nother account, and a refused copy brings the original back

The original's delete on its own server (IMAP, Microsoft, Exchange server) is held while a copy of it
waits to be made on another account's server. A copy refused or called off puts the original back
where its server has it, from what was kept of it; a copy made lets the delete go. An original that
can't be put back (on this computer, its folder gone here, its mailbox numbered anew) leaves the copy
kept on this computer, as before.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
…e rule beside it that deletes for good

When rules.add, rules.fromMessage, rules.enable, rules.keepOnServer, rules.move or rules.remove is
asked as a delete because a rule switched on here deletes mail for good for the same mail, the
question names that rule (at most five) and says why. The condition is one function for the gate
and the text, as the rules window's redesign has it for rules.edit.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
…to another account

Human-reviewed, AI-assisted, nobody's mailbox harmed.
…box is opened again, and a copy moved on still holds it

What a held delete keeps of the original is where and how it lay; its text and files come back
from the copy, which names them for the mailbox file (a message kept with a delete is written
without the names of content kept on disk, so after a reopen it came back empty, and its next
move would have deleted the server's whole original). The same for a refused copy within a
Microsoft or Exchange server account. A copy moved on into a third account before it was made
still names its source, so the delete keeps waiting for it.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
… a copy moved on

Human-reviewed, AI-assisted, nobody's mailbox harmed.
Human-reviewed, AI-assisted, nobody's mailbox harmed.
…here it lay

A message moved out of an IMAP account into a Microsoft account, made there, then copied into a
third account and deleted for good, had both deletes held; a refused copy brought it back on the
Microsoft account and again in the IMAP account, there with the Microsoft server's id. Now it is
put back once: on the Microsoft account it lay in, and the IMAP original goes as the move meant.
An IMAP account's message put back carries no Microsoft server id.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
…list has its say once the message is fetched whole

On a Microsoft, JMAP or Exchange server account, new mail comes as headers and a preview. A rule
on this computer that reads the text, a header, the size or whether it is a meeting invitation
couldn't tell, and nothing ran it again after the fetch. Now the rules that couldn't tell wait with
the message (Message::rules_waiting, in the order they ran, with the folder they left it in) and
run once it is fetched (graph_mail::apply_graph_fetch, which the JMAP and Exchange fetches go
through too). A rule that acted on arrival isn't run again; a delete for good that waited on an
earlier stop rule that couldn't tell goes once that rule doesn't apply. A message moved meanwhile
is let alone. file-format-parity.md says what an older build does with the new rule parts.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
…f Microsoft, and keeps the copy when the original was deleted on its server meanwhile

Small check of 54263e8:
- Deleted on a phone while its delete for good waited for a copy: the delta's removal (or a
  fresh listing without it) is now noted on the held delete (graph_down::there_still), so a
  refused copy doesn't put the message back as one the server no longer has, to be swept away
  with the refused copy already taken. It comes back from the IMAP account it was moved there
  from, or the copy stays in Imported.
- A Microsoft message being moved out into an IMAP account, not put there yet: a refused copy
  brings it back as that server's message, and its copy there isn't deleted.
- Put back on the IMAP server, the deletion of the Microsoft original it was moved from goes
  as the move meant it to, and a refusal of that deletion adds no second message.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
…d once, not once a word

Human-reviewed, AI-assisted, nobody's mailbox harmed.
…a day, or a flag or the categories cleared has parts this version doesn't know

Human-reviewed, AI-assisted, nobody's mailbox harmed.
…han it can keep, and the box for the server judges its exceptions as they are

Human-reviewed, AI-assisted, nobody's mailbox harmed.
# Conflicts:
#	crates/ui-egui/src/forms/rules/keep_tests.rs
#	docs/file-format-parity.md
…ount keeps the message when its original was deleted on the server meanwhile

Human-reviewed, AI-assisted, nobody's mailbox harmed.
…wered "no such message" while its original waits to be deleted for good keeps the message

Human-reviewed, AI-assisted, nobody's mailbox harmed.
…umber for is refused, rather than putting one of them after the locked rule on the server

Human-reviewed, AI-assisted, nobody's mailbox harmed.
Human-reviewed, AI-assisted, nobody's mailbox harmed.
…where they put it, and after "no such message" the original's delete still goes

Human-reviewed, AI-assisted, nobody's mailbox harmed.
…e for good is called off again

A copy within the account answered 404 confirms the message nowhere: the
server may still have the original (the copy's folder there gone), and the
copy here may be only its headers. So the held delete is dropped, the copy
is kept in Imported when it is still in this account, and one the owner moved
on stays where they put it. Tests cover a copy moved on and refused with the
original deleted on a phone, and one moved on with the original not deleted.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
Conflicts: an undo's approval keeps both causes for Delete, mail the undo
takes away (UCSLabs#473) and a rule switched on that deletes for good (UCSLabs#566); the
docs keep both sides' rows.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
…s answer stays where it was put

Human-reviewed, AI-assisted, nobody's mailbox harmed.
… waits is taken as a refusal

The server may still have the original (the copy's folder there gone) or
not (deleted on a phone). Either way no copy was made, so the original is put
back as on a refusal: where the server has it, or in Imported once the server
says it is gone. Before, the delete was only called off and the original,
still on the server, wasn't shown here again. A test covers the copy's folder
gone, with the original fetched whole or only its headers.

The release note says only a copy moved onto this computer or into another
account stays where it was put; the threat model says an undo leaving a rule
on that deletes permanently asks delete.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
… Graph answers rebuild the index

Taking that answer as a refusal (c409d88) put the original back as the
server's, and an owner's move of it, or a server index built before, could
then lose it. The copy arm is back as it was at 025f461: the delete is called
off and the copy kept in Imported; a message the server still has stays there
and shows again once its folder is read afresh, as the comment now says.

The answers to a Microsoft account's message changes now reset the index of
its server's mail, as an Exchange server account's do: an original put back
after a refusal, with the index built before without it, missed the phone's
delete in the next listing and was swept away later. Tests: a copy of mail not
here whole answered "no such message" deletes nothing there; that put-back
original is kept in Imported.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
…ce; the copy note names "no such message"

The index reset after a Microsoft account's message answers (960fdc0) also
fixes a bug on main: a copy listed after its answer showed twice in its folder
when the index was built between the copy and the answer. The release note for
a copy then deleted permanently names the "no such message" answer too.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
A search by name and New Rule over the rules; each rule with its switch,
where it is kept, Move Up and Move Down, a menu (Run Rule Now, Keep Rule on
Server, Delete Rule) and an arrow that shows what it does. New Rule opens
the new rule's page in the lists' place, its conditions, exceptions and
actions each in a box, with Add Rule and Cancel. The dialog moves by its
title, is sized by its edges and corners, and keeps its size.

Every rule moves with its arrows, one the server doesn't let be changed
too. Its new place is told to the server first; a refusal (a 403 too, or a
yes that leaves it where it was) is that rule's alone, stops the rest of
that upload, and puts it and the places that were to follow it back where
the server has them, said in words. The arrows are greyed only at the ends
of a list and past a rule still to go to the server.

A rule `rules.add` makes without `account` is the account in view's (a
shared mailbox's owner's, where the window now opens too), as the window's
is, and the agent's question names that account; it was for every
account's mail. A rule made for the placeholder of an empty mailbox goes to
the first account added, with its standard folders; it was dropped.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
Edit Rule, in a rule's menu, opens the rule's page filled in with what the
rule is, with Save and Cancel; it is greyed, with why, for a rule the server
doesn't let be changed, one with parts MailCraft can't show, one the server
is still making and one the page can't show. `rules.edit` changes the rule
in place: it stays for its account, where it is kept, switched on or off and
in its place. One on a Microsoft account's server is sent there whole at the
next Send/Receive (PATCH with its name, conditions, exceptions and actions),
and what the server can't keep is said on the page and not saved. An agent's
change asks as making that rule would, and names the rules beside it that
delete for good.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
@coderabbitai

coderabbitai Bot commented Nov 4, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

/// ([`sized_window`]); the rest share one.
pub(crate) fn layer(&self) -> egui::LayerId {
match self {
Dialog::Form(Form::Rules(_)) => sized_layer("rules"),
let title = form.title();
let mut done = false;
let kept = vec2(app.ui.rules_width, app.ui.rules_height);
let (open, sized) = sized_window(ctx, &title, "rules", (kept, vec2(form.width(), 640.0)), |ui| done = form.show(app, ui));
…indow's layer is named, not salted

What a rule looks for and what it does went to the Rules window in English in
every language. The conditions, exceptions and actions, the words that join
them, a move's folder, the stop and the alert now go through the catalogues
(Condition::describe_in, Action::describe_in, Rule::looks_for_in), with fuzzy
drafts in the five; the English that rules.list and the agent's question read
is what it was. A rule's "When" has a context of its own, as German says
"Wenn" there and "Wann" for a meeting's time.

sized_window's and sized_layer's `salt` parameter is `name`: CodeQL read the
Rules window's name as a hard-coded salt.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
…nto Edit Rule

Human-reviewed, AI-assisted, nobody's mailbox harmed.
nl.po: the two rule strings UCSLabs#780 translated take its translation.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
…esktop alert then; the copy marker's time is a stamp

A rule on this computer that reads what a server's list of new mail doesn't give (the text, a
header, the size) acted once the message was fetched whole, but never showed the desktop alert it
asks for. It now marks the message for one, the fetch names it, and the window shows it once the
download is over, after the Send/Receive under way if there is one, and not for a message the
run's end told of already as new mail.

copy_message_marked's parameter is a stamp, not a nonce: code scanning took the test clock that
reaches it for one.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
… in one Send/Receive; what was told isn't kept past a restart

Human-reviewed, AI-assisted, nobody's mailbox harmed.
…il is downloaded, main's translations) into the Rules window

Human-reviewed, AI-assisted, nobody's mailbox harmed.
… in Rules for

Rules from before a rule was for one account still run on every
account's mail, now after the server's rules and before the account's
own of this computer, and move among themselves. They are no longer in
each account's list; New Rule is greyed under All accounts.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
…new head into Edit Rule

Human-reviewed, AI-assisted, nobody's mailbox harmed.

# Conflicts:
#	ROADMAP.md
#	crates/ui-egui/src/forms.rs
…dit Rule meets All accounts

A rule under All accounts has For One Account and the accounts in its
menu (rules.forAccount): it then runs on that account's mail alone, kept
on this computer and first of its rules there. One that moves or copies
mail to another account's folder opens on the rule page with no folder
for it, and is given as it is saved (rules.edit with account); Cancel
leaves it under All accounts. Edit Rule is greyed for such a rule.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
…l accounts

A rule made before the first account is that account's once it is
added, not one for every account: the window's first line no longer
names All accounts then.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
…o Edit Rule

Human-reviewed, AI-assisted, nobody's mailbox harmed.

# Conflicts:
#	crates/ui-egui/src/forms/rules/page_tests.rs
Edit Rule showed a folder deleted since as it was, and Save was refused
after it; it now shows Choose a folder, and Save waits for one. Given
to an account, a rule keeps that account's own folders even where the
list of folders leaves them out.

Human-reviewed, AI-assisted, nobody's mailbox harmed.

This branch has not been deployed

No deployments
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.

2 participants