Text: File changes from outside

Created on 15 Apr 2019  路  5Comments  路  Source: nextcloud/text

Since we discussed going for a file based solution, we need to take care that file changes from outside are handled properly. If no one is currently editing a file in the collaborative editor this is not an issue, since once the first session is opened, we just read the current file and continue from that. But once there is a user editing, we have a base version and a list of changes on top of that managed by prosemirror. There is no way we can properly apply the changes in the original file (done when overwriting the file) to the collaborative editing. So we would either need to lock the file for the whole time any user is using the collaborative editor or have some conflict resolution. That would for example be to let the user choose if the file version or the current editing version should be used.

Just for reference, the current collaborative editing works the following way:

  1. On first open a copy of the file is made and used as the base document
  2. Prosemirror is converting markdown to a prosemirror own json format
  3. Changes made are pushed to the server and distributed to the active editing sessions
  4. The clients can apply the changes to the base document
  5. Writing back the file needs to happen at some point (see #4 for that)

I don't feel comfortable with just locking the file for the whole time, this is why I thought once a collision happens, we could just ask the user which of the two versions we should keep. After that we would re-initiate all collaborative sessions to use the new file as base document.

Any input on that is welcome, maybe someone also has some different idea.

cc @rullzer

enhancement

Most helpful comment

  • [x] Overwriting the file causes a conflict
  • [x] The users are able to choose which version they wish to continue editing with
    image
  • [x] Selecting the version will either overwrite the file with the collaborative state or reset the editor to start from the new file
  • [ ] A reset in one session should trigger reinstantiating the other sessions
  • [ ] Do not reset the document when a new session is started during the conflict

All 5 comments

this is why I thought once a collision happens, we could just ask the user which of the two versions we should keep

I think this is the best way, as all of this is currently working and people are used to it.

So to keep collisions of edits outside to a minimum, this step 5 needs to happen often, right?

  1. Writing back the file needs to happen at some point (see #4 for that)

Cause yes, while asking people which version to keep is something that is commonly used, it鈥檚 still a horrible experience for people. It鈥檚 best to have few changes elsewhere and a good visualization of the actual differences to be able to decide (not only a thumbnail and timestamp).

  • Chose which version to keep
  • Offer 'save current version as' option

Those are fine enough to have. This happens in a lot of places. Because we can't know what to do.

So to keep collisions of edits outside to a minimum, this step 5 needs to happen often, right?

Well not really, edits from outside will always be a problem, since regular text editors (on desktop) probably don't always reload the latest changes after the file got synced to the file system.

Cause yes, while asking people which version to keep is something that is commonly used, it鈥檚 still a horrible experience for people. It鈥檚 best to have few changes elsewhere and a good visualization of the actual differences to be able to decide (not only a thumbnail and timestamp).

We can show the two documents besides each other, so it is a bit easier to check which one you want to keep.

  • Chose which version to keep
  • Offer 'save current version as' option
    Those are fine enough to have. This happens in a lot of places. Because we can't know what to do.

Ok, let's go this way then. I also found https://gitlab.com/mpapp-public/prosemirror-recreate-steps which might allow us to apply changes from the "outside-changed" document to the collaboratively edited one, but that is something requiring more work and we can still add later on top of the manual version picking.

  • [x] Overwriting the file causes a conflict
  • [x] The users are able to choose which version they wish to continue editing with
    image
  • [x] Selecting the version will either overwrite the file with the collaborative state or reset the editor to start from the new file
  • [ ] A reset in one session should trigger reinstantiating the other sessions
  • [ ] Do not reset the document when a new session is started during the conflict
Was this page helpful?
0 / 5 - 0 ratings