Skip to content

Undo made offline of deleting a first child puts it above a block the other person placed first #1315

Open

Description

@yuxi-liu-wired

Steps

Alice and Bob edit the same synced graph. Block "tmpl" has 1 child, "tmpl child". Block "c" sits elsewhere.

  1. Alice goes offline.
  2. Alice deletes "tmpl child".
  3. Alice presses Ctrl+Z. "tmpl child" is back under "tmpl".
  4. Bob, online, drags "c" onto "tmpl" so it becomes the first child of "tmpl".
  5. Alice goes online.

Expected

Alice's delete and her undo cancel out, so the result is Bob's change alone: under "tmpl", "c" and then "tmpl child".

Actual

Under "tmpl": "tmpl child" and then "c", for Alice and for Bob.

When Alice goes online, her client applies her delete and her undo again after Bob's move. The replayed undo has no sort key: canonicalize-insert-ops builds the replayed insert through sanitize-insert-block-payload (deps/outliner/src/logseq/outliner/op/construct.cljc:205-209), which removes :block/order. So the undo, applied again, inserts "tmpl child" as the first child of "tmpl", above "c". Undoing from the delete's stored inverse datoms instead puts "tmpl child" back at its old sort key, below "c".

Found with a 2-person property-based test of undo under sync (random requests of 2 people, random sync points), replayed on upstream master 16c4ed1a0.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions