Skip to content

fix(ui-egui): an inserted date or time can be undone - #187

Merged
mameen merged 1 commit into
mainfrom
fix/undo-insert-date/agent-1
Nov 12, 2026
Merged

mameen merged 1 commit into
mainfrom
fix/undo-insert-date/agent-1

Conversation

@mameen

@mameen mameen commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Inserting a date or time into the page did not record an undo step, so Ctrl+Z could not take it back.
  • The step is now recorded before the insert.

Tests

  • New test undo_takes_back_an_inserted_date in crates/ui-egui/tests/ui.rs, written first and seen to fail.

Checks

  • cargo xtask ci: all checks passed, on the branch rebased onto origin/main (d0cc38d).

🤖 Generated with Claude Code

Inserting text into the page did not record an undo step, so Ctrl+Z could
not take an inserted date back. The step is now recorded before the insert.
A test was written first.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
@DWAA1660

Copy link
Copy Markdown
Collaborator

Audit finding: Undo works in the new test, but Redo cannot restore the inserted date. Reproduced on this PR's exact head 99b994ca389809c8988889ec0ddbc7b14e3f4906 in a separate clone by extending its existing real UI test, without changing production code:

// Save this immediately after the existing "the date was inserted" assertion:
let inserted = h.state().body().unwrap_or_default().to_string();
// Keep the existing Ctrl+Z and "undo takes the inserted date back" assertion, then:
ask(&mut h, "ui.key", json!({"key": "Y", "ctrl": true})).expect("redo");
settle(&mut h);
assert_eq!(h.state().body().unwrap_or_default().to_string(), inserted,
           "redo restores the inserted date");

cargo test -p notecraft-ui-egui --test ui undo_takes_back_an_inserted_date -- --exact --nocapture fails at the added Redo assertion:

left:  "plain text"
right: "plain textThursday, 12 November 2026\n"

Repeated with a normal newline-terminated plain text\n fixture: same failure; Undo's assertion passes, Redo's fails. The new remember_step is before the insertion, so the inserted value is not recorded for Redo. Please record the resulting edit as well and cover the full Undo/Redo round trip. Holding this PR out of the merge batch until that history behavior is fixed.

@mameen
mameen merged commit 7057b20 into main Nov 12, 2026
16 of 17 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.

3 participants