feat: resolve UUID page references in DB mode#32
Open
arndjan wants to merge 1 commit intoergut:mainfrom
Open
Conversation
In DB-mode, Logseq stores page references as internal UUIDs, making get_page_content output unreadable for agents and users. This adds automatic UUID-to-name resolution: - Text format: [[uuid]] replaced with [[Page Name]] (default on) - JSON format: resolved_refs mapping added alongside raw content - New resolve_refs parameter (default true) for opt-out - Batch resolution with deduplication to minimize API calls - Gated behind LOGSEQ_DB_MODE — zero impact on markdown-mode users Closes ergut#21 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
Fixes #21 —
get_page_contentin DB mode returns[[uuid]]instead of[[Page Name]]for page references, making output unreadable.This PR adds automatic UUID-to-name resolution:
[[69133208-...]]→[[Administratie]](default behavior)resolved_refsmapping (uuid → name) alongside raw content, so agents can read names but use UUIDs for write operationsresolve_refsparameter: opt-out withresolve_refs=falsewhen raw UUIDs are neededHow it works
\[\[([0-9a-f-]{36})\]\]) extracts all UUID referenceslogseq.Editor.getPage, preferringoriginalNameovername_format_block_treeto replace refs during formattingDesign decisions
LOGSEQ_DB_MODE— markdown-mode users see zero change in behavior or performancerun_tool, not_format_block_tree— collect all UUIDs first, resolve once, then pass the map downTest plan
_collect_block_uuids(flat, nested, dedup)_resolve_block_refs(replace, keep unresolved, mixed)_format_block_treewith uuid_map (root, children, without map)resolve_page_uuidsAPI method (success, originalName preference, not found, dedup, API error, multiple)🤖 Generated with Claude Code