Skip to content

fix(undo): restore deleted pages with inner refs - #13528

Merged
tiensonqin merged 1 commit into
logseq:masterfrom
yuxi-liu-wired:fix/undo-delete-page-inner-refs
Sep 30, 2026
Merged

tiensonqin merged 1 commit into
logseq:masterfrom
yuxi-liu-wired:fix/undo-delete-page-inner-refs

Conversation

@yuxi-liu-wired

@yuxi-liu-wired yuxi-liu-wired commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Fixes logseq/db-test#1379

What changes

Undo of deleting today's journal, or a tag or property page, did nothing when one of the page's top-level blocks referred to a later one, and it cleared the undo history. For a tag page, the tag stayed deleted. This is the case #13458 fixed for block deletes, on the page-delete path. The review of #13458 pointed it out.

Steps

  1. On today's journal (or on a tag's page), type 2 blocks, "first" and "second" below it.
  2. Set the node property "related" of "first" to "second".
  3. Delete the page, then undo. Nothing comes back, and the undo history is empty.

Cause

build-inverse-delete-page (construct.cljc:944) restores the page's top-level blocks with 1 :insert-blocks op each, in both its tag/property branch and its today's-journal branch. A block whose ref value points at a block of a later op fails to insert ("Nothing found for entity id"), the replay reports :error, and undo clears the history (undo_redo.cljs:243). #13458 added defer-refs-to-later-plans to the block-delete inverse only.

Fix

restore-plans->ops (construct.cljc:844): an insert op per restore plan, then the :save-block ops that set the refs between plans. The block-delete inverse and both page-delete branches use it. The inverse of a delete without such refs is unchanged.

Tests

  • frontend.worker.undo-redo-test: 2 new tests, undo-delete-of-today-page-with-blocks-referring-to-each-other-test and undo-delete-of-tag-page-with-blocks-referring-to-each-other-test. On master they have 7 failures in 9 assertions. With the fix the namespace ran 47 tests with 247 assertions and 0 failures, in TZ=Etc/GMT+12 and in TZ=Pacific/Kiritimati.
  • logseq.outliner.move-property-value-undo-test: 4 tests, 63 assertions, 0 failures.

Allow edits from maintainers.


Devin Review

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔍 Devin Review: 1 flag

Not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)

Devin Review

yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Sep 30, 2026
Undo of deleting today's journal or a tag or property page restores the
page's top-level blocks with 1 insert op each. A block that refers to a
block of a later op (a node property value) fails to insert, the replay
reports :error and undo clears the history. The block-delete path already
defers those refs to save-block ops after all inserts; the page-delete
paths now share that step.
@tiensonqin
tiensonqin force-pushed the fix/undo-delete-page-inner-refs branch from 1d15844 to 0ab2f6b Compare September 30, 2026 09:20
@tiensonqin
tiensonqin merged commit c4d837f into logseq:master Sep 30, 2026
1 of 2 checks passed
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Sep 30, 2026
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Sep 30, 2026
logseq#13545, logseq#13546 and logseq#13547 replace the 9 open pull requests they bundle;
logseq#13468, logseq#13437, logseq#13475 and logseq#13528 are in upstream master.
@yuxi-liu-wired
yuxi-liu-wired deleted the fix/undo-delete-page-inner-refs branch September 30, 2026 20:02
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 1, 2026
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 1, 2026
logseq#13545, logseq#13546 and logseq#13547 replace the 9 open pull requests they bundle;
logseq#13468, logseq#13437, logseq#13475 and logseq#13528 are in upstream master.
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 4, 2026
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 4, 2026
logseq#13545, logseq#13546 and logseq#13547 replace the 9 open pull requests they bundle;
logseq#13468, logseq#13437, logseq#13475 and logseq#13528 are in upstream master.
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 8, 2026
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 8, 2026
logseq#13545, logseq#13546 and logseq#13547 replace the 9 open pull requests they bundle;
logseq#13468, logseq#13437, logseq#13475 and logseq#13528 are in upstream master.
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 11, 2026
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 11, 2026
logseq#13545, logseq#13546 and logseq#13547 replace the 9 open pull requests they bundle;
logseq#13468, logseq#13437, logseq#13475 and logseq#13528 are in upstream master.
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 13, 2026
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 13, 2026
logseq#13545, logseq#13546 and logseq#13547 replace the 9 open pull requests they bundle;
logseq#13468, logseq#13437, logseq#13475 and logseq#13528 are in upstream master.
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 16, 2026
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 16, 2026
logseq#13545, logseq#13546 and logseq#13547 replace the 9 open pull requests they bundle;
logseq#13468, logseq#13437, logseq#13475 and logseq#13528 are in upstream master.
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.

Undo of deleting today's journal or a tag page fails and clears the history when a block's node property points at a later block

2 participants