Skip to content

fix: stop orphaning :default property value blocks - #13063

Open
tiensonqin wants to merge 2 commits into
masterfrom
logseq/fix-default-property-value-orphans-ef64
Open

fix: stop orphaning :default property value blocks#13063
tiensonqin wants to merge 2 commits into
masterfrom
logseq/fix-default-property-value-orphans-ef64

Conversation

@tiensonqin

Copy link
Copy Markdown
Contributor

Updating a cardinality-one :default or :url property with a new string used to mint a new value block and only retract the old attribute ref. The previous value block stayed as an invisible child of the host (:logseq.property/created-from-property, unreferenced), so each edit accumulated another orphan.

This change does two things in the outliner set/batch-set path:

  • Reuse the host's exclusive generated value block and edit its title in place when the current value is not shared.
  • Reclaim unreferenced generated value blocks when the property is replaced with a different entity, matching batch-remove-property!.

Shared values (closed values, pages, empty placeholder, a property's configured default value, and values still referenced by other blocks) are left alone. UI in-place title edits of the existing value block are unchanged.

Fixes logseq/db-test#1073

Tests

  • Added default-property-string-updates-do-not-orphan-value-blocks covering set-block-property!, batch-set-property!, in-place title edits, entity replacement, :url, independent hosts, and many-cardinality add vs replace.
  • remove-block-property! now asserts the unreferenced value block is deleted.
  • deps/outliner unit tests: 100 tests, 370 assertions, 0 failures.
Open in Web Open in Cursor 
Reuse an exclusive :default/:url value block on string updates, and
reclaim unreferenced generated value blocks when set/batch-set replace
the previous value. Three successive writes now leave one child.

Fixes logseq/db-test#1073

Co-authored-by: Tienson Qin <tiensonqin@gmail.com>
@tiensonqin
tiensonqin marked this pull request as ready for review August 18, 2026 07:24
Copilot AI lite review requested due to automatic review settings August 18, 2026 07:24
@tiensonqin
tiensonqin force-pushed the logseq/fix-default-property-value-orphans-ef64 branch from c724cf9 to 6a3f5f8 Compare August 18, 2026 07:24
@tiensonqin tiensonqin self-assigned this Aug 18, 2026

Copilot AI 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.

Pull request overview

Fixes accumulation of orphaned generated property value blocks when updating cardinality-one :default / :url properties by reusing an exclusive existing value block for successive string updates and reclaiming now-unreferenced generated value blocks when values are replaced/removed (aligning behavior with batch-remove-property!).

Changes:

  • Reuse a block’s exclusive generated :default/:url value block and update its title in place, instead of minting a new value block per edit.
  • Reclaim generated property value blocks that become unreferenced after replace/remove operations (while preserving shared values like pages, closed values, empty placeholder, and configured default values).
  • Add unit tests to ensure no orphaning occurs across set-block-property!, batch-set-property!, entity replacement, :url, many-cardinality add vs replace, and remove-block-property!.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
deps/outliner/src/logseq/outliner/property.cljs Adds reuse + safe reclamation logic for generated property value blocks during set/batch-remove paths.
deps/outliner/test/logseq/outliner/property_test.cljs Adds regression coverage ensuring string updates don’t orphan generated value blocks and that removals reclaim unreferenced ones.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants