Keep command metadata when loading saved state - #80
Merged
Merged
Conversation
PlaceholderCommand passed only the change type and affected items to BaseCommand, which built fresh metadata, so a reload reset every command's timestamp to load time, its size to 1, and dropped its CustomData. Use the deserialized ChangeMetadata instead. Fixes #77 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L2BLMsT5ih3DnMNxTyGUHh
|
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 #77
Summary
JsonUndoRedoSerializerserialized each command'sMetadata, butPlaceholderCommandnever used it on load. The placeholder passed onlyChangeTypeandAffectedItemstoBaseCommand, which then built fresh metadata. As a result, after a reload:CustomDatawas goneThat contradicts the serializer comment saying the placeholder "preserves metadata".
PlaceholderCommandnow overridesMetadatato return the deserializedChangeMetadata.Tests
SerializationTests.UndoRedoService_SaveLoadState_PreservesCommandMetadataround-trips a command withsize: 42, a customChangeType, affected items andCustomData. It asserts thatTimestamp,Size,ChangeType,AffectedItemsandCustomDataall survive.With the fix reverted, the new test fails on the timestamp. With the fix, the whole suite passes (51/51) on net10.0.
🤖 Generated with Claude Code
https://claude.ai/code/session_01L2BLMsT5ih3DnMNxTyGUHh
Generated by Claude Code