Skip to content

fix(outliner): keep recycle parent until both sides restore - #13514

Merged
tiensonqin merged 1 commit into
masterfrom
logseq/fix-restore-namespace-parent-5fc1
Sep 29, 2026
Merged

tiensonqin merged 1 commit into
masterfrom
logseq/fix-restore-namespace-parent-5fc1

Conversation

@tiensonqin

@tiensonqin tiensonqin commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Fixes logseq/db-test#1350

Problem

Deleting a namespace child then its parent, and restoring the child first, left the child as a top-level page. Restoring the parent later could not reattach it.

restore-target only reused a parent that was already live. restore-tx-data then retracted :logseq.property.recycle/original-parent, so the later parent restore had nothing to re-link.

Restoring the parent first already worked.

Change

  • If a restored page's original parent is still in Recycle, keep :logseq.property.recycle/original-parent and :logseq.property.recycle/original-order.
  • When that parent is restored, reattach live children that still record it as their original parent and do not already have another live parent.
  • A child that was moved elsewhere after restore keeps its new parent; the leftover recycle metadata is cleared.

Tests

Added recycle tests in deps/outliner/test/logseq/outliner/recycle_test.cljs for:

  • child then parent
  • parent then child
  • apply-ops restore of child then parent
  • multiple children restored before the parent
  • child moved elsewhere before the parent returns

Verified with pnpm exec nbb-logseq -cp test -m nextjournal.test-runner in deps/outliner (140 tests, 0 failures) plus clj-kondo, large-vars, and carve lint on the touched files.

Open in Web Open in Cursor 

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 found 1 potential issue.

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

Devin Review

Restoring a namespace child while its parent is still in Recycle no longer
drops :logseq.property.recycle/original-parent. When the parent comes back,
waiting live children are reattached.

Co-authored-by: Tienson Qin <[email protected]>
@tiensonqin
tiensonqin force-pushed the logseq/fix-restore-namespace-parent-5fc1 branch from 8f577ea to 9f448d9 Compare September 29, 2026 05:29
@tiensonqin
tiensonqin merged commit 74b6125 into master Sep 29, 2026
14 checks passed
@tiensonqin
tiensonqin deleted the logseq/fix-restore-namespace-parent-5fc1 branch September 29, 2026 05:36
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.

Restoring a namespace child before its parent loses the parent

2 participants