Skip to content

fix(delete): deleting a tag page turns refs to it into its title, also next to refs to its blocks - #13686

Closed
yuxi-liu-wired wants to merge 1 commit into
logseq:masterfrom
yuxi-liu-wired:fix/delete-tag-page-refs
Closed

yuxi-liu-wired wants to merge 1 commit into
logseq:masterfrom
yuxi-liu-wired:fix/delete-tag-page-refs

Conversation

@yuxi-liu-wired

Copy link
Copy Markdown
Contributor

Deleting a tag (or property) page leaves the deleted page's [[uuid]] in any block that references the page next to one of the page's own blocks. Example: a block says "see [[Foo]] and [[fb]]", where Foo is a tag and fb a block on Foo's page. After deleting the tag Foo, the block reads see [[<Foo's uuid>]] and fb: a reference to a node that no longer exists, instead of see Foo and fb.

Cause: outliner-page/delete! sends the page's ref rewrite (the block's title with [[Foo]] turned into "Foo") and the retracts in one transaction. ldb/transact! then appends delete-blocks/update-refs-history, which writes the same block's title again, computed from its title before the transaction with only the retracted blocks replaced (fb); pages are not block-entity?, so [[Foo]] stays. Two values for the cardinality-one :block/title in one transaction: the later one wins. When the block references only the page, both rewrites agree, which is why the common case works.

Fix: build-retracted-tx also turns refs to pages retracted in the same transaction into their titles, so its rewrite agrees with the page's own. Which entities count as blocks (for expanding a delete to children) is unchanged.

Test: logseq.outliner.delete-tag-page-refs-test (app test build: the title rewrite reads :block/raw-title, an entity-plus lookup nbb does not have) deletes a tag page with outliner-page/delete! and checks a block referencing the page and its block ("see Foo and fb") and a block referencing only the page ("see Foo"). On master it fails on the first; with the fix it passes. Also with the fix: logseq.db.common.delete-blocks-test, logseq.db-test (33 tests), logseq.outliner.page-test, logseq.outliner.property-test (56 tests) under nbb, and frontend.worker.pipeline-test (45 tests, including page deletes) in the app build: 0 failures. Lint as in CI for deps/db and the app.

Found by mutation testing: and to or in block-entity? made no existing test fail, and the changed version gave "see Foo and fb".

@yuxi-liu-wired

Copy link
Copy Markdown
Contributor Author

Combined with the other PRs that change the same files into #13786.

@yuxi-liu-wired
yuxi-liu-wired deleted the fix/delete-tag-page-refs branch October 21, 2026 18:02
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.

1 participant