Add efficient serialisation for diffs #21

Merged
schmelczer merged 8 commits from asch/serialisation into main 2025-10-27 06:59:23 +00:00
schmelczer commented 2025-10-26 21:30:13 +00:00 (Migrated from github.com)

When reconciling diffs remotely, it's no longer required to send the entire text document over the network, only the changes.

API breaks

  • No longer store Side within operations
  • No longer require Side argument to create an EditedText

Downsides

This PR add serde_json as a wasm dependency increasing the bundle size.

When reconciling diffs remotely, it's no longer required to send the entire text document over the network, only the changes. ## API breaks - No longer store `Side` within operations - No longer require `Side` argument to create an `EditedText` ## Downsides This PR add serde_json as a wasm dependency increasing the bundle size.
copilot-pull-request-reviewer[bot] (Migrated from github.com) reviewed 2025-10-26 21:30:42 +00:00
copilot-pull-request-reviewer[bot] (Migrated from github.com) left a comment

Pull Request Overview

This PR adds efficient serialization support for text diffs by introducing a ChangeSet type that can be serialized/deserialized without including the full original text. The key architectural change is removing the Side parameter from operation creation, instead tracking operation sides separately in a parallel vector within EditedText.

Key changes:

  • Introduced ChangeSet and SimpleOperation types for compact serialization of text operations
  • Refactored Operation enum to remove side field and track sides in a separate operation_sides vector
  • Added serialization/deserialization methods serialise_as_change_set() and from_change_set() to EditedText

Reviewed Changes

Copilot reviewed 13 out of 14 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/test.rs Adds test verifying serialization round-trip works correctly
src/utils/string_builder.rs Adds custom Debug implementation to StringBuilder
src/operation_transformation/utils/cook_operations.rs Removes Side parameter from operation creation functions
src/operation_transformation/transport.rs Introduces new transport types (SimpleOperation, ChangeSet) for serialization
src/operation_transformation/snapshots/* Updates snapshots to include new operation_sides field
src/operation_transformation/operation.rs Removes side field from Operation enum and updates all related methods
src/operation_transformation/edited_text.rs Adds operation_sides tracking and serialization methods; updates merge logic
src/operation_transformation.rs Updates reconcile function signature and exports ChangeSet
src/lib.rs Adds documentation example for serialization and exports ChangeSet
scripts/test.sh Consolidates test commands to always use serde feature
README.md Minor formatting fix
Cargo.toml Adds "all" feature combining all optional features
Files not reviewed (1)
  • reconcile-js/package-lock.json: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

## Pull Request Overview This PR adds efficient serialization support for text diffs by introducing a `ChangeSet` type that can be serialized/deserialized without including the full original text. The key architectural change is removing the `Side` parameter from operation creation, instead tracking operation sides separately in a parallel vector within `EditedText`. **Key changes:** - Introduced `ChangeSet` and `SimpleOperation` types for compact serialization of text operations - Refactored `Operation` enum to remove `side` field and track sides in a separate `operation_sides` vector - Added serialization/deserialization methods `serialise_as_change_set()` and `from_change_set()` to `EditedText` ### Reviewed Changes Copilot reviewed 13 out of 14 changed files in this pull request and generated 1 comment. <details> <summary>Show a summary per file</summary> | File | Description | | ---- | ----------- | | tests/test.rs | Adds test verifying serialization round-trip works correctly | | src/utils/string_builder.rs | Adds custom Debug implementation to StringBuilder | | src/operation_transformation/utils/cook_operations.rs | Removes Side parameter from operation creation functions | | src/operation_transformation/transport.rs | Introduces new transport types (SimpleOperation, ChangeSet) for serialization | | src/operation_transformation/snapshots/* | Updates snapshots to include new operation_sides field | | src/operation_transformation/operation.rs | Removes side field from Operation enum and updates all related methods | | src/operation_transformation/edited_text.rs | Adds operation_sides tracking and serialization methods; updates merge logic | | src/operation_transformation.rs | Updates reconcile function signature and exports ChangeSet | | src/lib.rs | Adds documentation example for serialization and exports ChangeSet | | scripts/test.sh | Consolidates test commands to always use serde feature | | README.md | Minor formatting fix | | Cargo.toml | Adds "all" feature combining all optional features | </details> <details> <summary>Files not reviewed (1)</summary> * **reconcile-js/package-lock.json**: Language not supported </details> --- 💡 <a href="/schmelczer/reconcile/new/main/.github?filename=*.instructions.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add Copilot custom instructions</a> for smarter, more guided reviews. <a href="https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn how to get started</a>.
@ -0,0 +1,204 @@
use std::fmt::Debug;
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2025-10-26 21:30:42 +00:00

The range description is incorrect. The actual range is -2^63 to 2^64-1 (i64::MIN to u64::MAX). The message should read 'an integer between -2^63 and 2^64-1 or a string'.

                formatter.write_str("an integer between -2^63 and 2^64-1 or a string")
The range description is incorrect. The actual range is -2^63 to 2^64-1 (i64::MIN to u64::MAX). The message should read 'an integer between -2^63 and 2^64-1 or a string'. ```suggestion formatter.write_str("an integer between -2^63 and 2^64-1 or a string") ```
Sign in to join this conversation.
No description provided.