Fix #665: give every rule condition its own checkbox - #666
Merged
Conversation
The rule editor reached by Ctrl+Shift+T prefilled the message's From and Subject and offered no way to say which of them the rule was meant to use, so it used both. "Rule for someone@example.com" therefore matched that sender only when the subject was the exact line it was made from — the one conversation it was created from. Each free-text condition in ServerRuleEditorWindow now has a checkbox in front of it: From addresses and Subject contains, plus Sender contains, Sent to addresses, Subject or body contains and Body contains under Advanced. Clearing one leaves the text in its box (read-only and out of the tab order, as in the client Rules Manager), so a prefilled value stays one keystroke from being used rather than something to retype. The switches are authoritative everywhere, not just in the UI: the VM routes saving, the client-rule mapping and the server/client classification through private Effective* accessors, so a switched-off condition is invisible to all three. They default on, matching the client Rules Manager, so a hand-made rule behaves exactly as before — an empty field was, and still is, no condition. Loading an existing rule clears the switch on every empty field so the editor reads back what the rule actually does. CreateRuleFromMessage now builds its template with UseSubjectCondition false: the subject comes across so it is there to switch on, but the rule you get by default is the one its name claims. RuleEditorConditionWiringTests is the regression guard — a Sites-style table of the six condition fields, asserting each has a CheckBox bound to its switch and binds both IsReadOnly and IsTabStop to it. Adding a seventh condition field without a checkbox fails it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
… guard Three findings from the independent review. ToClientRule dropped the text of a switched-off condition, so saving a QuickMail rule from the unified editor lost what the editor had promised was one keystroke away — while the standalone Rules Manager, editing the same rule, has always kept it. The text is now carried with the flag left clear, which is MailRule's own meaning (engine, row summary and validation all require the flag AND text), so the same rule no longer means two different things depending on which window saved it. Carrying only ever fills a slot the switched-on conditions left empty, so a populated-but-off Sender cannot displace the From address that is actually in use. HasAdvancedContent asked whether an advanced field was switched on, which broke its own invariant that editing never hides a populated field: a client rule with Body switched off but populated opened with Advanced collapsed and the text invisible. It asks about text again. RuleEditorConditionWiringTests checked only the binding path of IsReadOnly, so binding it straight to the switch without InverseBoolConverter — the inversion that makes a box editable exactly when its condition is off — passed. It now asserts the converter, and that the checkbox is the element immediately in front of its field rather than merely somewhere in the window. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #665.
The problem
The rule editor reached by Ctrl+Shift+T (Create Rule from Message) prefilled the message's
From and Subject and offered no way to say which of them the rule was meant to use, so it used
both. "Rule for someone@example.com" therefore matched that sender only when the subject was the
exact line it was made from — in practice, the one conversation it was created from.
The reported editor is
ServerRuleEditorWindow, the one the unified Rules Manager opens for aprofile with a Microsoft 365 account. The client-only
RulesManagerWindowhas had conditioncheckboxes since #333; this window never got them.
The change
Each free-text condition now has a checkbox in front of it — From addresses and Subject
contains, plus Sender contains, Sent to addresses, Subject or body contains and
Body contains under Advanced. Clearing one leaves the text in its box (read-only and out of
the tab order, the same shape the client Rules Manager already uses), so a prefilled value stays
one keystroke from being used rather than something to retype.
The switches are authoritative everywhere, not only in the UI:
ToModel,ToClientRule,ServerOnlyFeaturesUsedandHasAdvancedContentall read privateEffective*accessors, so aswitched-off condition is invisible to saving, to the client-rule mapping and to the
server/client classification. A consumer that reads the raw text property instead is the
regression the tests are aimed at.
They default on, matching the client Rules Manager, so a hand-made rule behaves exactly as
before — an empty field was, and still is, no condition. Loading an existing rule clears the
switch on every empty field, so the editor reads back what the rule actually does.
One behaviour change worth calling out:
CreateRuleFromMessagenow builds its template withUseSubjectCondition = false. The subject still comes across, so it is sitting in the box readyto switch on — but the rule you get by default is the one its name claims: everything from that
sender. This is the half of #665 that the checkbox alone would not have fixed.
Keyboard walkthrough (Ctrl+Shift+T, Microsoft 365 account)
Ctrl+Shift+Ton a message. The rule editor opens with focus in Rule name, holding"Rule for someone@example.com".
Move to folder. To use the subject after all, Shift+Tab back to its checkbox, press Space
(announced as checked), then Tab into the box, which now holds the message's subject and is
editable.
Infrastructure changes
AccessibilityHelper.Announcecalls. Toggling acheckbox is reported by the platform; nothing here announces on top of it.
UseFromAddresses,UseSubjectContains,UseSenderContains,UseSentToAddresses,UseBodyOrSubjectContains,UseBodyContains).AutomationProperties.Name: theirContentis the field'slabel, and restating it in different words is how a label/name mismatch gets in.
migration and no config change.
Out of scope
RulesManagerWindowis unchanged apart from receiving the same template — italready had checkboxes.
Importance combo, whose "Not set" entry is its own off state.
Ctrl+Shift+Tis registered by bothmail.createRuleFromMessageandview.focusTabs. Nottouched here, but noted.
Tests
RuleConditionSwitchTests— 13 tests over the prefill, the round trip,ToClientRule, and theclassifier (a switched-off server-only condition must stop blocking the client mapping).
RuleEditorConditionWiringTests— a Sites-style table of the six condition fields, assertingeach has a CheckBox bound to its switch and binds both
IsReadOnlyandIsTabStopto it.Adding a seventh condition field without a checkbox fails it.
Not run:
scripts/ui-probe.ps1. Itsrulessurface captures the Rules Manager list window, notthis editor, so the plan does not cover the changed window either way. The new checkboxes use the
EditorCheckBoxstyle already used six times in the same window.🤖 Generated with Claude Code