Page MenuHomePhabricator

Enable performing conflict resolution in VisualEditor
Open, Needs TriagePublicFeature

Description

Proposed by @jsn.sherman

Feature summary: Suppose, while an editor has a page open in VE, a new revision is saved by someone else. Provide a way to merge that revision into the current edit session, using the rich diff information available to resolve conflicts better than can be done on the server side.

Use case(s): Server-side automatic merges fail in many cases, for instance when there are adjacent (but non-overlapping) changes not separated by enough unchanged context.

Benefits: Better automatic merge handling. Better experience for the editor who has invested in authoring a revision. Less chance of inadvertent content loss/corruption during manual merge.

Event Timeline

This could be implemented by:

  • importing the remote revision and displaying it as a ve.dm.VisualDiff;
  • then, if the user chooses to proceed, converting the remote revision into a single ve.dm.Change that applies to the common base document (=the document at the start of the edit session);
  • then rebasing that change against the current document's completeHistory (=the transactions that correspond to the changes during the edit session), before applying it;
  • then applying the rebased change.

Change #1039728 had a related patch set uploaded (by Zoe; author: Zoe):

[mediawiki/extensions/VisualEditor@master] WIP: Super hacky demo of performing a diff against a newer revision

https://gerrit.wikimedia.org/r/1039728

The current status is I've worked out how to load various revisions into the codebase and how to do a diff between them. I'm currently pursuing two lines of enquiry: working out how to get a VisualDiff object (or something upstream from that) into a ve.dm.Change format, and building a dialog that allows diffs against various targets, such as between the user's changes and the base document, between the base document and the current version on wiki, and so on. The objective at this point remains getting enough of this corner of this codebase into my head as to be useful, do not expect this ticket to be closed quickly.

This week I've worked out to highlight text inline and spent some time learning how dialogs are built in OOUI

@zoe and I managed to write code where you can merge a remote revision into your open edit session 🎉

Caveats:

  • The UI is way below MVP
  • We haven't tested thoroughly for correctness, and it's certain some cases won't be correct

How it works:

  • It loads the next remote revision after the revision your edit session started with
  • Then it builds a correct ve.dm.Change from the revision you started with to the remote revision
  • Then it prompts you to merge that change
  • If you choose to merge, the change is rebased over your edit history and (if there are no conflicts) applied
  • You are told whether the merge was successful

@dchan and I built live merge, as noted above. I've worked out how to add things to toolbars, with my main difficulty having been that the package I'd put the code in didn't load before the toolbar was constructed. I've learned about InputWidget which simplified my dialog code and I've now got a dialog that changes a message depending on the user's input. Now to simply (!) wire that up to the diff mechanisms. The main issue I'm anticipating here is working out the linkage between the MW code and the VE code: I think I need to pass the various documents as arguments.

I've built a dialog that presently only shows you the diff between the start of your edit session and the current version of the document. Next steps are to (a) fetch whatever the latest version of a document is; (b) figure out how to show a three-way diff between the user input and the latest version on the wiki and (c) integrate the merging technology of last week