Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/colliding patches #344

Merged
merged 9 commits into from
Feb 25, 2024
Merged

Conversation

loreanvictor
Copy link
Contributor

This PR is stacked on top of #343

Checklist

  • I documented the TypeScript code using JSDoc style.
  • I added multiple screenshots/screencasts of my UI changes
  • I translated all the newly inserted strings into German and English (NA)

Motivation and Context

In realtime collaboration, sometimes patches without any apparent conflict will result in cancellation of local changes on a client. This PR fixes this issue.

Description

In realtime collaboration, one client might be in the middle of making some changes while a patch to the diagram state is received from some remote. Upon receiving a patch, the patcher will apply the received patch to its own snapshot of the state, and then the reducer will set the local state to that patched state. If unsaved local changes are not synced with patcher's snapshot, the changes will be reverted.

This particularly happens a lot with continuous syncing (using .subscribeToAllModelChangePatches() method for realtime collaboration), as a stream of incoming patches will repeatedly cancel local changes the user is trying to do simultaneously. Note that the patcher's snapshot is intentionally kept behind local state to ensure small continuous changes don't result in patches not being sent enough (the patcher always sends the diffs with the last discrete changes).

This PR adds the option to update patcher's snapshot upon patching, and ensures the reducer will update the patcher's snapshot before merging the state with incoming patches. This solution will keep patcher's snapshot behind the local state to ensure sufficient emission of necessary patches, while resolving the issue at hand.

Steps for Testing

  1. Clone this branch,
  2. Clone Apollon_standalone and link the cloned Apollon code,
  3. On Apollon_standalone, use continuous sync by ensuring .subscribeToAllModelChangePatches() method is used here,
  4. Run two clients (ideally separate machines) working on the same diagram. The two clients should be able to smoothly change things at the same time without getting stuck.

Test Coverage

File Branch Line
components/store/model-store.tsx 100% 100%
services/patcher/patcher.ts 96.77% 100%
services/patcher/patcher-reducer.ts 90.9% 100%

Screenshots

ScreenRecording2024-02-19at08 52 32-ezgif com-video-to-gif-converter

@matthiaslehnertum matthiaslehnertum merged commit cae2d6d into develop Feb 25, 2024
5 checks passed
@matthiaslehnertum matthiaslehnertum deleted the bugfix/colliding-patches branch February 25, 2024 20:43
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.

2 participants