Skip to content

fix: undo after shallow snapshot import#1013

Open
zxch3n wants to merge 2 commits into
mainfrom
codex/fix-shallow-snapshot-undo
Open

fix: undo after shallow snapshot import#1013
zxch3n wants to merge 2 commits into
mainfrom
codex/fix-shallow-snapshot-undo

Conversation

@zxch3n

@zxch3n zxch3n commented Jun 13, 2026

Copy link
Copy Markdown
Member

Summary

Fixes #1012.

Shallow snapshot imports that need to materialize latest state currently emit their internal checkout as a Checkout event. UndoManager treats checkout as a user-visible version switch, clears its stacks, and sets next_counter to None, so the first local commit after import only reinitializes the undo baseline instead of becoming an undo item.

This change keeps explicit checkout behavior unchanged, but lets the shallow snapshot import materialization path emit that internal checkout as an Import event using the original import origin. That preserves subscriber visibility for the imported state while avoiding the UndoManager reset.

Validation

  • cargo test -p loro --test loro_rust_test undo_records_first_local_commit_after_shallow_snapshot_import -- --nocapture
  • cargo test -p loro --test loro_rust_test shallow_snapshot -- --nocapture
  • cargo test -p loro --test issue -- --nocapture
  • cargo test -p loro --test contracts events_subscriptions -- --nocapture
  • cargo check -p loro-internal

Note: cargo check still reports the existing loro-common/src/lib.rs unused import warning, unrelated to this change.

@zxch3n zxch3n marked this pull request as ready for review June 13, 2026 15:22
@zxch3n zxch3n changed the title [codex] fix undo after shallow snapshot import fix: undo after shallow snapshot import Jun 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

WASM Size Report

  • Original size: 3031.64 KB
  • Gzipped size: 1000.25 KB
  • Brotli size: 702.27 KB

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.

UndoManager never records the first local commit after importing a shallow snapshot rooted at the empty (genesis) frontier

1 participant