Skip to content

fix(engine): say which history an edit's memory check dropped (#2431) - #2460

Merged
pick2510 merged 1 commit into
opengeos:mainfrom
pick2510:fix/undo-redo-room
Nov 19, 2026
Merged

pick2510 merged 1 commit into
opengeos:mainfrom
pick2510:fix/undo-redo-room

Conversation

@pick2510

@pick2510 pick2510 commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #2445 (#2431 fix 3, part 1), from its last reviews.

  • The notice when steps are freed to make room says what was dropped. The count includes Redo steps, which go first, so the old "older Undo steps are dropped" was wrong when Redo steps were dropped. It now reads: "Memory is nearly full: Redo steps, then the oldest Undo steps, are dropped to make room for edits (2 before editing rows). An edit that still doesn't fit is refused."
  • Steps a background edit set aside get their own notice when they can't go back. That case isn't about making room: they were set aside, never taken by a copy, and the Undo history changed while the edit ran. It is said each time, as it's rare: "Undo history set aside for a background edit of calc is dropped (3 Undo or Redo steps), as the Undo history changed while the edit ran."
  • The user guide lists what isn't checked: Paste Special (it makes a layer of its own), and any computer where RustGIS can't read the memory, not only the web app. It also says that Undo and Redo aren't checked.
  • A regression test shows Undo and Redo run when an edit wouldn't fit. A review on fix(engine): check that an edit's copy fits beside what the session holds #2445 said they could be refused. They can't: both are .view() commands, so they don't count as edits. The test pins that.

Not changed: an edit whose own rules refuse it after it wrote (calculation rules, validation in design::apply) has used the steps set aside for it. The guide already says so: "One that fails after it started copying has used them, as a finished edit would have."

Reach every surface

  • Desktop, command line, Python and the phone: the notices go through Session::notify_text, as before.
  • The browser: nothing is checked there, as before, and the guide now says so.
  • Ribbon, shortcuts, the Assistant, MCP and plugins: unchanged; they dispatch the same commands.
  • The way back: Undo and Redo are pinned by the new test. No saved file, setting or parameter changes.

Testing

  • cargo fmt, clippy -D warnings (engine), cargo test -p rustgis-engine, cargo xtask test-hygiene, and RUSTFLAGS='-D warnings' cargo build --locked --target wasm32-unknown-unknown -p rustgis-web.
  • undo_and_redo_run_when_an_edit_would_not_fit, which is new, and the cancelled-edit test, which now checks the new text and that it doesn't say "make room".

UI evidence

No change to panes or dialogs. Two notice texts changed; they are quoted above.

Related issue

Part of #2431

Summary by CodeRabbit

  • Bug Fixes
    • Undo and Redo remain available when an edit is refused for insufficient memory.
    • Notices now distinguish steps dropped because history changed during a background edit from steps freed to make room. The memory notice clarifies that Redo steps are dropped before the oldest Undo steps.
  • Documentation
    • Clarified which operations are excluded from undo-memory checks and documented the additional notice for background edits.

@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The change distinguishes notices for Undo history dropped after a background edit from notices for history dropped to make room. It adds tests for cancellation and refused edits, and updates documentation about the notices and edit-copy exemptions.

Changes: Undo Memory Notices

Layer / File(s) Summary
Undo-history drop notices and validation
crates/engine/src/lib.rs, crates/engine/src/undo_memory.rs, docs/user-guide/analysis.md
Session::return_steps now reports set-aside steps dropped after the Undo history changes during a background edit. When steps are dropped to make room, the notice specifies that Redo steps and then the oldest Undo steps are dropped. Tests cover cancellation and verify that Undo and Redo still run after a refused edit. The documentation describes the notice and edit-copy exemptions.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related issues

  • Issue 2431 concerns Undo memory growth and bounding history by memory. This change updates notices for steps dropped under that memory limit.

Possibly related PRs

  • opengeos/RustGIS#2437: Adds the Undo and Redo memory budget and eviction order that these notices describe.
  • opengeos/RustGIS#2445: Adds the pre-copy memory check and set-aside behavior covered by the changed notices and tests.

Suggested reviewers: mavrick-f

Merge Risk: Minimal · up to 4366e

This change clarifies the notices shown when Undo history is dropped and updates the user guide. It adds tests covering cancelled and refused edits. No actionable merge-blocking risk is evident.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the engine fix and the specific behavior changed: the memory-check notice now says which history an edit's memory check dropped. The raw summary and objectives confirm the main change …
Description check Passed The description follows the template's Summary, Testing, and Related issue sections. Summary explains both notice changes, the user guide updates, and the new regression test. Testing lists the comman…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the engine fix and the specific behavior changed: the memory-check notice now says which history an edit's memory check dropped. The raw summary and objectives confirm the main change is the clearer notice text for freed Redo/Undo steps, plus a separate notice for set-aside history that cannot be restored. The title is specific and matches the changeset. It omits the guide and test updates, which is acceptable.

Full details: Description check

Explanation

The description follows the template's Summary, Testing, and Related issue sections. Summary explains both notice changes, the user guide updates, and the new regression test. Testing lists the commands run and the new and updated tests. The UI evidence section states there is no visible UI change to panes or dialogs, and quotes the two changed notice texts. Related issue says 'Part of #2431'. Minor gaps: the template's 'No visible UI change.' line is replaced by a description rather than kept verbatim, and the Related issue text does not use the template's Closes/Part of format exactly, though it does state the link. These are non-critical.

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

A rabbit reads the Undo trail,
Redo steps hop off the rail.
Old Undo steps make room to spare,
A dropped edit gets a notice there.
The tests keep both directions fair.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 98592699-29dd-4bc8-a301-6d2b5a60791b
Commits

Reviewing files that changed from the base of the PR and between 17f9496 and 4366e46.

Files selected for processing: 3

  • crates/engine/src/lib.rs
  • crates/engine/src/undo_memory.rs
  • docs/user-guide/analysis.md

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

}
session.active_layer = Some(session.map().layer_by_name("rows").unwrap().id);
session.undo_memory.memory = Some(4);
assert!(session.run("edit.setValue", &json!({"layer": "rows", "row": 0, "field": "text", "value": "d"})).is_err());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Test coverage (confidence ~80%). This assertion only checks that the edit fails. It does not check why, so the premise of the test ("the edit would not fit even with no history") is unverified: an unrelated error, such as a wrong layer or field, would also pass. The neighbouring tests at lines 683-684 and 727-730 check the message. Suggested change:

Suggested change
assert!(session.run("edit.setValue", &json!({"layer": "rows", "row": 0, "field": "text", "value": "d"})).is_err());
let err = session.run("edit.setValue", &json!({"layer": "rows", "row": 0, "field": "text", "value": "d"})).unwrap_err();
assert!(err.contains("not enough memory"), "{err}");

Comment thread crates/engine/src/lib.rs
// Not taken by a copy, but the history changed while a background edit ran (another
// edit, Undo, trimming): the steps can't follow on from it. Rare, and not about making
// room, so said each time.
Some(_) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

AGENTS.md (confidence ~45%, a judgment call for maintainers). AGENTS.md says a loss gets "one notice per kind with a count". This arm says the drop again on every occurrence (the PR body says so on purpose, as it is rare). The earlier say_room() gate limits the make-room notice to once a project, so this arm is now the only path that can repeat a notice of the same kind. Either keep the per-occurrence notice and say so in the PR's Suggested AGENTS.md additions, or gate it the same way. The message text and the (N Undo or Redo steps) count look right: the foreground path always passes in_place = true, so this arm is only reached from the background and reclaim paths where history moved on.

@github-actions

Copy link
Copy Markdown
Contributor

Code review

Bugs

  • None found. I traced the put_back and reclaim_rooms callers. The foreground path always passes in_place = true, so the new Some(_) arm is reached only from the background and reclaim paths where history moved on, as the PR intends. The None arm keeps its once-a-project gate, and the existing make-room tests still match the reworded text. Undo and Redo are .view() with only Effect::History, so the claim that they are not checked holds. (confidence: high)

Security

  • None found.

Performance

  • None found.

Quality

  • crates/data/src/lib.rs:245: the before_rows_copy doc says the session "frees older Undo steps". Redo steps now go first, so the comment is incomplete. (confidence: high, low impact)
  • docs/user-guide/analysis.md, the paragraph around line 85: one line runs about 125 characters while its neighbours wrap near 100. Reflow it. (confidence: high, cosmetic)
  • Per the release-quality-pass rule, these two nits are left for the release quality pass and not posted inline.

AGENTS.md

  • crates/engine/src/lib.rs:2056: the new Some(_) arm repeats the notice on every occurrence, which conflicts with "one notice per kind with a count". The PR body acknowledges the choice. Posted inline for a maintainer decision. (confidence: ~45%)

Test coverage

  • crates/engine/src/undo_memory.rs:748: the new test asserts only is_err() on the refused edit, so the premise that the copy does not fit is never checked. Posted inline with a suggested fix that asserts "not enough memory". (confidence: ~80%)

Prior reviews

  • No prior review threads exist on this PR, so none were left alone.

Change size

Compared with the base branch: the whole PR, merge base 82526c3 to head 4366e46.

Measure Value
Files changed 3 (0 added, 3 modified, 0 removed, 0 renamed)
Size before 386 KB
Size after 388 KB
Total size change +2.1 KB
Path Before After Change
crates/engine/src/undo_memory.rs 35.9 KB 37.1 KB +1.2 KB
crates/engine/src/lib.rs 180.2 KB 180.8 KB +655 B
docs/user-guide/analysis.md 170.0 KB 170.2 KB +281 B

@github-actions

Copy link
Copy Markdown
Contributor

📖 Docs preview

Item Value
Preview https://preview.rustgis.app/pr-2460/
Web app https://preview.rustgis.app/pr-2460/app/
Commit 4366e46

GitHub Pages takes a minute or two to publish a new commit.

@pick2510
pick2510 added this pull request to the merge queue Nov 19, 2026
Merged via the queue into opengeos:main with commit c71f6ff Nov 19, 2026
24 checks passed
@pick2510
pick2510 deleted the fix/undo-redo-room branch November 19, 2026 14:59
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.

1 participant