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

Baton Passing Basic Edition #4665

Merged
merged 4 commits into from
Jan 2, 2024
Merged

Conversation

seanparsons
Copy link
Contributor

Problem:
If a user opens the editor in multiple tabs they can end up in a nightmare scenario of different editors updating their own variant of the project and potentially work can be lost.

Fix:
This PR implements a first come-first served baton passing system of claiming ownership over the project. While there is no user interface for relinquishing or passing the baton actively to another user, closing the tab or not contacting the server for a period of over 20 seconds will result in control being released.

The underlying implementation is a simple database table containing the project ID and a collaboration editor ID, where the latter is generated by a client on startup and remains a secret to other editors.

Commit Details:

  • Added Baton Passing For Control feature switch.
  • Add a call to release control of the projects to the existing beforeunload event listener.
  • Added claimControlOverProject and releaseControl calls to the server powered by callCollaborationEndpoint.
  • Added allowedToEditProject and associated hook function useAllowedToEditProject, to replace some existing functions like useIsViewer.
  • Added currentlyHolderOfTheBaton to ProjectServerState.
  • Updated getProjectServerState to call claimControlOverProject.
  • ProjectServerStateUpdater now defers to a new function restartServerStateWatcher, which updates on an interval if the appropriate feature flag is enabled.
  • Added project_collaboration table to the database.
  • Implemented collaborationEndpoint in the server to dispatch the various cases of collaboration request.
  • Extracted out some functions into Utopia.Web.Endpoints.Common module.
  • Added ClaimCollaborationOwnership and ClearCollaboratorOwnership cases to service types in the backend.

- Added `Baton Passing For Control` feature switch.
- Add a call to release control of the projects to the existing `beforeunload`
  event listener.
- Added `claimControlOverProject` and `releaseControl` calls to the server
  powered by `callCollaborationEndpoint`.
- Added `allowedToEditProject` and associated hook function
  `useAllowedToEditProject`, to replace some existing functions like
  `useIsViewer`.
- Added `currentlyHolderOfTheBaton` to `ProjectServerState`.
- Updated `getProjectServerState` to call `claimControlOverProject`.
- `ProjectServerStateUpdater` now defers to a new function
  `restartServerStateWatcher`, which updates on an interval if the appropriate
  feature flag is enabled.
- Added `project_collaboration` table to the database.
- Implemented `collaborationEndpoint` in the server to dispatch the various
  cases of collaboration request.
- Extracted out some functions into `Utopia.Web.Endpoints.Common` module.
- Added `ClaimCollaborationOwnership` and `ClearCollaboratorOwnership`
  cases to service types in the backend.
Copy link
Contributor

github-actions bot commented Dec 15, 2023

Try me

Copy link

relativeci bot commented Dec 15, 2023

Job #9660: Bundle Size — 62.18MiB (+0.07%).

4267c3e(current) vs df0030c master#9654(baseline)

Warning

Bundle contains 66 duplicate packages – View duplicate packages

Bundle metrics  Change 5 changes Regression 3 regressions
                 Current
Job #9660
     Baseline
Job #9654
Regression  Initial JS 45.39MiB(+0.09%) 45.35MiB
No change  Initial CSS 0B 0B
Change  Cache Invalidation 19.79% 0%
No change  Chunks 26 26
No change  Assets 30 30
Change  Modules 4360(+0.02%) 4359
Regression  Duplicate Modules 470(+0.43%) 468
Regression  Duplicate Code 30.75%(+0.1%) 30.72%
No change  Packages 462 462
No change  Duplicate Packages 65 65
Bundle size by type  Change 1 change Regression 1 regression
                 Current
Job #9660
     Baseline
Job #9654
Regression  JS 62.17MiB (+0.07%) 62.13MiB
Not changed  HTML 11.53KiB 11.53KiB

View job #9660 reportView feature/baton-passing-basic branch activity

Copy link
Contributor

github-actions bot commented Dec 15, 2023

Performance test results:
(Chart1)
(Chart2)

Copy link
Contributor

@ruggi ruggi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did a first pass and will re-pass, but it looks 🆗 to me!

@seanparsons seanparsons merged commit d5661e5 into master Jan 2, 2024
13 of 14 checks passed
@seanparsons seanparsons deleted the feature/baton-passing-basic branch January 2, 2024 15:55
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.

5 participants