Skip to content

#1745: An agent's Undo no longer asks about a subscribed calendar's event that it keeps - #1750

Merged
benandez merged 1 commit into
UCSLabs:mainfrom
DonielMoins:fix/undo-subscribed-prediction
Nov 20, 2026
Merged

benandez merged 1 commit into
UCSLabs:mainfrom
DonielMoins:fix/undo-subscribed-prediction

Conversation

@DonielMoins

@DonielMoins DonielMoins commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Closes #1745

What changes for the person using MailCraft

Before an agent's Undo or Redo, MailCraft works out which appointments it would take away, so that it can ask about any of their windows with unsaved changes. It no longer counts an event of a subscribed (Internet) calendar among them, since Undo and Redo keep those events as they are. Before this change it did when the calendar's refresh had brought the event after the step and the computer had then moved to another time zone, and also, with no zone move at all, when the calendar was subscribed after the step (or removed and subscribed to again). The owner could then be asked about a window that the Undo wouldn't close. The answer was only ever too cautious; it never missed an event that goes. Nothing else changes: where a subscribed calendar's events show after an Undo across a zone move is #1709, and this doesn't fix it.

This answers CodeRabbit's last comment on #1710 (undo.rs, event_as_then), which was merged before it was addressed.

How it was checked

  • crates/engine/src/cmd/remote/undo_gate_tests.rs › a_subscribed_event_a_refresh_brought_is_said_to_stay_through_an_undo_after_a_zone_move: CodeRabbit's case, Undo and then Redo, with the zone move settled or not. It fails with main's undo.rs (logs/red-01.log: "Unsettled: Match two said to go with the undo") and passes with the fix (logs/green-02.log).

  • Same file › a_calendar_subscribed_after_the_step_keeps_its_events_through_the_undo_and_is_said_to: the calendar subscribed after the step, in all five zone states including no move at all; it also checks that the Undo and Redo really ran (the step's appointment goes and comes back). It fails with main's undo.rs at the first state, no move (logs/red-01.log: "Not: Match one said to go with the undo"), and passes with the fix.

  • Same file › the_undo_gate_says_exactly_what_happens_to_the_subscribed_calendars_events: for every subscribed event, over 6 steps × 3 things done to the subscriptions after the step (nothing, another calendar subscribed, the calendar removed and subscribed again) × 5 downloads × 5 zone states × a redo with or without another move, what is said is compared with what the real edit.undo/edit.redo then does. With main's undo.rs: 564 mismatches, all "said to go, stayed" and all before an Undo; with the fix: none (logs/red-01.log, logs/green-02.log). Each check is counted once, and floors make sure it reaches subscribed events (2,880 compared, in 900 worlds that each run a real Undo and Redo), a zone moved among them (768) and a calendar subscribed after the step (1,260).

  • The existing the_undo_gate_never_says_less_than_the_undo_does passes with main's undo.rs and with the fix, so over its matrix no event the Undo takes away is said to stay.

  • Mutants of the changed function, each run against the engine's 249 undo tests (mutants.txt, logs/mut-*.log). A no-op baseline passes, and main's own body fails 3 tests. Of 13 mutants, 11 are killed. The two that look at the step's calendar instead of the current one (subscribed(then) == Some(true), and subscribed(now) only when the step's mailbox has that calendar) passed every test before this change. They now fail the calendar-subscribed-after-the-step test and the matrix (420 mismatches each). Two survive, and are believed equivalent in every state that commands can reach (reasoned, not proven):

    • a calendar missing from the mailbox counted as subscribed: an event without its calendar can't arise through commands;
    • the early answer skipped for an event the step changed: no step changes a subscribed calendar's event, because they are read-only.
  • Reviewed, not a test (on the same undo.rs change over 3e04914, whose undo.rs, session.rs and undo_gate_tests.rs main has unchanged): across the full gate matrix every other answer is the same before and after (74,504 for other events, 30,000 for ids that aren't events, 6,000 Delete questions); only the too-cautious answers for subscribed events changed. A reviewer's differential over 258,770 predictions found 0 under-reports added and every over-report for subscribed events gone, and a window probe showed a subscribed appointment's window can hold unsaved changes, so the extra question was visible.

  • cargo xtask ci, all 14 steps, on the committed head of this branch (rebased on main b1e2d1c), with a clean tree before and after; also on the same four files over 198fac9 before the rebase.

  • Not exercised: the window itself in this branch (no window run), other platforms.

  • 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

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

Summary by CodeRabbit

  • Bug Fixes
    • Undo and Redo no longer prompt about open subscribed calendars with unsaved changes. This also applies to calendars subscribed after the change and calendars viewed in a different time zone. Events from subscribed calendars are preserved across undo and redo.

…dar's event that it keeps

Before an agent's Undo or Redo, MailCraft works out which appointments it
would take away, so that it can ask about any of their windows with unsaved
changes. It counted an event of a subscribed calendar among them when the
calendar's refresh had brought the event after the step and the clock had
then moved to another zone, or when the calendar was subscribed after the
step. Undo and Redo keep those events, so the question was asked for
nothing. event_as_then now answers "stays" first for an event of a calendar
subscribed now. Where those events show after a zone move is UCSLabs#1709 and is
not changed here.

This answers CodeRabbit's last comment on UCSLabs#1710.

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

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Undo and redo removal prediction now treats events in currently subscribed calendars as staying, regardless of other event or calendar conditions. Regression tests check this prediction against event retention across subscription, download, history-step, and time-zone scenarios.

Changes: Subscribed calendar undo behavior

Layer / File(s) Summary
Currently subscribed event prediction
crates/engine/src/undo.rs
event_as_then now returns false for events in calendars subscribed now, before checking other conditions. The documentation describes this precedence.
Undo and redo regression coverage
crates/engine/src/cmd/remote/undo_gate_tests.rs, packaging/release-notes.d/fixes/1745.md
Tests compare removal predictions with event retention across subscription, download, history-step, and time-zone scenarios. The release note describes the behavior.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix · Severity of issue fixed: Low

Possibly related issues

  • Issue 1709 concerns subscribed-calendar event display after a time-zone change. This PR does not change that behavior.

Possibly related PRs

Merge Risk: Minimal · up to 2748e

Undo and Redo should no longer ask about unsaved changes in subscribed calendars that stay open after the step. The change is small and well covered by engine tests. I found no merge-blocking risk.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main behavior change: an agent's Undo no longer asks about an event of a subscribed calendar that is kept. The raw summary and objectives confirm the change makes the Undo/Redo pre…
Description check Passed The description follows the repository template. It has the Closes line (Closes #1745), a 'What changes for the person using MailCraft' section that explains the user-visible effect and the unchanged …
Linked Issues check Passed [#1745] The issue requires that Undo and Redo predictions never say an event of a calendar subscribed now goes away, because Undo and Redo keep those events. The reviewed change reorders the logic in …
Out of Scope Changes check Passed The reviewed changes fall into three groups. (1) crates/engine/src/undo.rs: the change is limited to event_as_then, the function the issue names. (2) `crates/engine/src/cmd/remote/undo_gate_tests.…
Full details: Title check

Explanation

The title names the main behavior change: an agent's Undo no longer asks about an event of a subscribed calendar that is kept. The raw summary and objectives confirm the change makes the Undo/Redo prediction treat events of currently subscribed calendars as staying. The title is specific and references the linked issue #1745, so it is clear to a teammate scanning history.

Full details: Description check

Explanation

The description follows the repository template. It has the Closes line (Closes #1745), a 'What changes for the person using MailCraft' section that explains the user-visible effect and the unchanged #1709 scope, and a 'How it was checked' section with specific tests, logs, mutation results, and the cargo xtask ci run. The checklist is present and ticked. The 'Builds on' line is not needed because this is not a multi-part feature, and the template's optional comments are not required content. The description is complete.

Full details: Linked Issues check

Explanation

[#1745] The issue requires that Undo and Redo predictions never say an event of a calendar subscribed now goes away, because Undo and Redo keep those events. The reviewed change reorders the logic in event_as_then in crates/engine/src/undo.rs. The function now returns false for any event whose calendar is subscribed in now, before it checks the zone change, touched events, or the calendar's state in then. This covers both reported cases: a refresh after a zone move, and a calendar subscribed after the step (or removed and subscribed again). The change does not alter the other answers for non-subscribed events, as the new change scope shows only the subscribed-event branch. Automated tests in crates/engine/src/cmd/remote/undo_gate_tests.rs cover both reported scenarios, with Undo and Redo, zone move settled and unsettled, and a matrix that compares predictions with the real edit.undo and edit.redo results. The existing reverse-direction test (the_undo_gate_never_says_less_than_the_undo_does) is kept. The issue's exclusion of #1709 (subscribed event display after a zone move) is respected: no display code is changed. The window behavior was not run; the issue reports engine-level results, so this does not block the engine requirement. The excluded file docs/log.d/ROADMAP/progress/1745.md matches the ignore rule !docs/**; it is non-coding and was not inspected.

Full details: Out of Scope Changes check

Explanation

The reviewed changes fall into three groups. (1) crates/engine/src/undo.rs: the change is limited to event_as_then, the function the issue names. (2) crates/engine/src/cmd/remote/undo_gate_tests.rs: new fixture scenarios for a calendar subscribed after the step, plus tests for the reported cases and the comparison matrix. These support the objective directly. (3) packaging/release-notes.d/fixes/1745.md: a one-line release note describing the fixed behavior. It documents the change and does not add behavior. No change touches window code, display of subscribed events (#1709), or unrelated modules. The ignored docs/log.d/ROADMAP/progress/1745.md is excluded by rule !docs/** and was not inspected; it is documentation and is not evidence of out-of-scope code.

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.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between b1e2d1c and 2748e95.

Files ignored due to path filters: 1

  • docs/log.d/ROADMAP/progress/1745.md is excluded by !docs/**
Files selected for processing: 3

  • crates/engine/src/cmd/remote/undo_gate_tests.rs
  • crates/engine/src/undo.rs
  • packaging/release-notes.d/fixes/1745.md

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

@sonarqubecloud

Copy link
Copy Markdown

@omg-review-bot omg-review-bot Bot 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.

🤖 Automated review of 2748e95

The change correctly implements the logic to exclude subscribed calendar events from the Undo/Redo gate's questions. By checking if the current mailbox (now) has a subscribed calendar for an event, the function now returns false, preventing the agent from asking about these read-only events, which aligns with the intended behavior that they persist through undo/redo operations. The extensive test coverage provided confirms this fix across numerous complex state transitions (zone moves, subscriptions, history steps). No defects found.

No issues found.

✅ Approved: no unresolved findings at [P4] MINOR (Quality) or above.

Model google/gemma-4-e4b · skill code-change-review · 4 files reviewed. Reply to an inline comment to discuss it.

@benandez benandez left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Read event_as_then against subscribed_stay and events_stay in crates/engine/src/undo.rs. subscribed_stay runs last and re-inserts every event whose calendar is subscribed in now from now, whatever then has, so answering "not taken away" first for those events matches what Undo and Redo do. For events of other calendars the new expression is equal to the old one: (None, _) => true and (Some(was), _) => was && is != Some(true) collapse to is_none_or(|was| was) once the now-subscribed case has returned early. The matrix test compares the gate with the real edit.undo/edit.redo both ways, and the existing "never says less than the undo does" test still covers the other direction. No findings. Fragments are present.

@benandez
benandez added this pull request to the merge queue Nov 20, 2026
Merged via the queue into UCSLabs:main with commit 95ea541 Nov 20, 2026
20 checks passed
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.

An agent's Undo is said to take away a subscribed calendar's event that the Undo keeps

2 participants