Repository navigation
Description
Summary
Undo of deleting a property or a tag restores the page but not what the delete did to other nodes. The cause is one gap: the change is recorded under a label that describes less than the change.
The gap
delete! in deps/outliner/src/logseq/outliner/page.cljs deletes a property or tag by transacting the list from build-page-retract-tx:
[:db/retractEntity ...]for every block on the page (a property's choices);[:db/retract e a v]for every value of the property on other blocks;- child tags re-parented to Root Tag (
restore-class-parent-tx); - references to the page in other blocks' titles rewritten to plain text (
db-refs->page); [:db/retractEntity page-id], which also removes every reference to the page (tags on blocks, a tag's list of tag properties).
It records the change as [:delete-page [page-uuid ...]]. The undo inverse is built from that label (build-inverse-*): it re-creates the page and does not reverse the rest of the list. Each item of the list is a place where the undo goes wrong:
| List item | Undo bug |
|---|---|
| 1 | #1309: the choices come back through a re-insert, which also sets the property's own value to a choice |
| 2 | #1304: the blocks' values are not restored; the value blocks show as child blocks |
| 3 | #1312: child tags stay under Root Tag |
| 4 | #1310: references in other blocks stay plain text |
| 5 | #1305: blocks stay untagged; #1311: tags lose the property from their tag properties |
All reproduce on master 16c4ed1a0 with no sync and one user.
The question
What is the unit of a change for undo: the operation label, or the facts the database recorded? Today undo uses the label, and falls back to the stored datoms only when no label has an inverse. Wherever an operation does more than its label says, undo loses the difference. #1339 proposes the facts on graphs without sync, where they are exact by construction: DataScript's tx-data of the change, flipped and in reverse order. On synced graphs, either every label must describe everything its operation does, or undo must be derived from the facts and checked against later remote changes.
Activity