Repository navigation
DB: Selected-block EDN roundtrip moves an internally referenced target to the end on first import #1389
Description
What happened
A selected-block EDN roundtrip changes sibling order when one selected block refers to another selected block.
The source page and export's Text preview show:
order alphaorder beta [[order alpha]](a genuine block UUID reference)order gamma control
After one import into another local DB graph where these entities do not exist, the imported page shows:
order beta [[order alpha]]order gamma controlorder alpha
The referenced target has moved to the end. Ctrl+R preserves the wrong order. There is only one visible alpha block, and the reference still renders its title.
Native UI reproduction
Use disposable local DB graphs with sync disabled.
- In graph A, create a page named
QA-EDN-Order. - Create three ordinary sibling blocks in this exact order:
order alpha,order beta,order gamma control. No tags, properties, children or templates are needed. - Right-click alpha's bullet and choose Copy block ref.
- Edit beta, append a space, then paste the copied reference. Save. Confirm beta's reference displays
order alpha. - Reload and verify the source still has alpha, beta, gamma in that order.
- Select all three blocks in document order. Tested keyboard route: edit alpha, Escape to select the block, then Shift+Down twice.
- Right-click a selected area away from the bullet, then choose Copy / Export as.... The multiselect menu must retain all three blocks. Right-clicking a bullet opens the single-block menu instead.
- Verify the Text preview has alpha, beta, gamma in order. Switch to EDN and click Copy to clipboard.
- Switch to a separate local DB graph in which this page and these block UUIDs have never been imported.
- Ctrl+K → choose Import EDN data under Commands → paste the unchanged export → click Import exactly once.
- Open Pages and open
QA-EDN-Order. Use Pages because the separate search-index problem DB: Partial EDN import leaves new pages and blocks missing from search until index rebuild #1385 can omit newly imported content from Ctrl+K. - Observe beta, gamma, alpha. Reload: the same incorrect order remains.
Expected: the selected sibling order alpha, beta, gamma survives export/import.
Actual: the selected target alpha is placed after its referring sibling and the unrelated gamma block.
Exact minimal native export
This is the unmodified EDN saved from the UI in the reproduction above. It can also be pasted directly into Import EDN data in a fresh disposable graph. The source's three blocks appear first in their correct order; the exporter then adds another map for alpha with the same UUID.
{:pages-and-blocks
[{:page {:block/title "QA-EDN-Order"},
:blocks
[{:block/title "order alpha",
:block/uuid #uuid "6abed62b-0dcd-4ff6-9919-91c064e27dcb",
:build/keep-uuid? true}
{:block/title
"order beta [[6abed62b-0dcd-4ff6-9919-91c064e27dcb]]"}
{:block/title "order gamma control"}
{:block/title "order alpha",
:block/uuid #uuid "6abed62b-0dcd-4ff6-9919-91c064e27dcb",
:build/keep-uuid? true}]}],
:logseq.db.sqlite.export/export-type :selected-nodes}Saved export SHA-256: 05833e5a0535be90f1d0cd13184d5d7a998093c6e3863f7c6b44658af4b3df37.
Reproducibility and controls
Observed in 2/2 independently created/exported fixtures, each imported only once into previously absent page/UUID identities in the same separate destination graph:
- Two roots: target with one child, Number=17, checked Checkbox and a user tag extending another user tag; source refers to the target and tag. Source order target/source becomes source/target.
- Minimal three-root fixture above: alpha/beta/gamma becomes beta/gamma/alpha, without any properties, tags or children.
Both wrong orders persist after reload. The native source selection and Text preview were checked before switching to EDN, so this is not reverse selection order.
In the richer fixture, the child, typed values, tag inheritance and reference navigation were preserved. Renaming the imported target updated the imported source reference; changing its Number to 18 persisted. Reopening and reloading graph A retained the original target title, Number=17 and original order. No source data loss or duplicate visible target was observed.
Environment
- Logseq 2.0.1 Electron development build
- Exact master SHA:
22263c36204c86949df6cb4bfa278be0aa215353 - Live renderer and Node worker verified at
22263c3, build2026-10-01T17:19:25Z - Electron 42.3.0 / Chromium 148.0.7778.180
- Debian GNU/Linux 13, x86_64, cloud Linux desktop
- Native mouse/keyboard testing; synthetic local DB graphs; no sync
- Web not tested: the available cloud browser blocks the local development server
The minimal source baseline was verified after reload at 21:55 UTC; its one import was submitted at 22:04 UTC; incorrect imported ordering was observed at 22:06 and after reload at 22:07 UTC on 2026-10-01.
Source pointers / suspected mechanism
The saved export contains a second same-UUID alpha map after the selected roots. Current selected-node export separately collects referenced targets, and merge-export-maps combines their block vectors. The import block builder can assign a later order to the repeated keep-UUID target.
This is a source-based explanation consistent with the UI result, not a confirmed runtime root cause. No source patch or direct DB write was used.
Related reports checked
- EDN Data Import duplicates content when run multiple times #959 concerns duplicate content on a second import; this happens on the first import and changes order.
- DB: Partial EDN import leaves new pages and blocks missing from search until index rebuild #1385 concerns search indexing; the wrong order is visible through Pages and persists after reload.
- Graph EDN export should contain the parent/child relationships between Library pages #489 concerns Library hierarchy export, rather than sibling blocks inside one page.
- Open logseq/logseq#12929 hardens partial import, but its inspected diff does not change the selected-target reference-stub/order path.
Open and closed db-test searches and active EDN PRs were checked; no exact report for this selected-block first-import ordering case was found.
Activity