fix: update_page properties now update in-place via upsertBlockProperty#49
Open
nlsn wants to merge 1 commit into
Open
fix: update_page properties now update in-place via upsertBlockProperty#49nlsn wants to merge 1 commit into
nlsn wants to merge 1 commit into
Conversation
setPageProperties was appending properties as a new block body instead of updating the existing page-level property lines, making them invisible to Logseq's property system and rendering tag lists as Python repr strings. Switch update_page_with_blocks to use _update_page_properties, which calls upsertBlockProperty on the first block for each key. This updates properties in-place, preserves unspecified keys implicitly, and fixes tag serialization. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Author
|
Hi @ergut - before merging, I want to flag a potential secondary issue I haven't had time to investigate yet. The fix routes tag values through Could you hold off on merging until I've had a chance to test this? Thanks for your patience. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #48
Problem
update_pagecalled with apropertiesdict and nocontentwas routingthrough
_set_page_level_properties→logseq.Editor.setPageProperties.In practice,
setPagePropertiesappended a new block to the page body withproperties serialized as text, rather than updating the existing page-level
property lines in place. The appended block was invisible to Logseq's property
system and the success message was misleading.
Secondary bug: tag values were serialized as Python list repr (
['mcp-test'])instead of Logseq syntax (
[[mcp-test]]).Fix
In
src/mcp_logseq/logseq.py,update_page_with_blocks: replaced the_set_page_level_propertiescall (and the pre-fetch via_get_page_level_properties) with a single call to_update_page_properties.That method calls
logseq.Editor.upsertBlockPropertyonce per key on thefirst block (the page-properties pre-block), updating values in place and
implicitly preserving untouched keys.
The tags serialization bug is also resolved —
upsertBlockPropertyreceives aproper Python list and Logseq renders it correctly as
[[tag]]references.Tests Added
test_update_page_properties_only_updates_in_place— regression test;asserts no
setPageProperties/appendBlockInPagecall, and exactly NupsertBlockPropertycalls targeting the first blocktest_update_page_append_mode_merges_propertiesandtest_update_page_replace_mode_replaces_propertiesto match new API callsequence and result shape