Skip to content

Keep command metadata when loading saved state - #80

Merged
matt-edmondson merged 1 commit into
mainfrom
fix/preserve-metadata-on-load
Sep 26, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
fix/preserve-metadata-on-load

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #77

Summary

JsonUndoRedoSerializer serialized each command's Metadata, but PlaceholderCommand never used it on load. The placeholder passed only ChangeType and AffectedItems to BaseCommand, which then built fresh metadata. As a result, after a reload:

  • every change showed a timestamp of load time
  • every change showed a size of 1
  • any CustomData was gone

That contradicts the serializer comment saying the placeholder "preserves metadata".

PlaceholderCommand now overrides Metadata to return the deserialized ChangeMetadata.

Tests

SerializationTests.UndoRedoService_SaveLoadState_PreservesCommandMetadata round-trips a command with size: 42, a custom ChangeType, affected items and CustomData. It asserts that Timestamp, Size, ChangeType, AffectedItems and CustomData all 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

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
@sonarqubecloud

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit f6c63be into main Sep 26, 2026
12 checks passed
@matt-edmondson
matt-edmondson deleted the fix/preserve-metadata-on-load branch September 26, 2026 03:48
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.

SaveState/LoadState discards command metadata: timestamps reset to load time, ChangeSize to 1, CustomData lost

2 participants