Repository navigation
fix: bump page updated-at on insert, move, and delete - #13402
Conversation
9d12b80 to
4bd03ed
Compare
|
E2E-verified the
Note on UI freshnessThe All-pages "Updated At" cells showed stale values until a hard Ctrl+R (sort order was already correct) — a views-layer freshness quirk, not the stamping; DB values verified via worker REPL. |
There was a problem hiding this comment.
Devin Review found 1 new potential issue.
1 flag not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)
| (:db/ident (d/entity db (:db/id restore-from-property))) | ||
| [:block/uuid new-id]]])) | ||
| top-level-blocks))) | ||
| page-updated-tx (page-updated-at-tx (get-target-block-page target-block sibling?)) |
There was a problem hiding this comment.
🔴 Source page stays stale after reparenting
When insert-blocks reparents a live block across pages, it stamps only the destination. The source page loses content but retains its old updated time.
Learn more
An identity-preserving insert can update an existing block rather than create a new one. uuid-for-insert retains live UUIDs for non-paste inserts, and build-insert-block-tx assigns those blocks the destination page. The existing non-paste keep-UUID test exercises this cross-page reparenting. Only the destination page receives an updated timestamp, leaving the source page out of date.
Example: Restore a live block from Source into Destination with :keep-uuid? true. The block moves to Destination, but Source keeps its earlier :block/updated-at.
Recommended fix: Before constructing the insert transaction, identify live inserted entities whose original container differs from their resulting container. Stamp each affected source page as well as the destination, without stamping pages that the operation retracts. Add a regression test using a live cross-page keep-UUID insert.
Was this helpful? React with 👍 or 👎 to provide feedback.
Page :block/updated-at was only touched from save-block. Child insert, reorder, and move-blocks now stamp the affected page timestamps. Co-authored-by: Tienson Qin <[email protected]>
Co-authored-by: Tienson Qin <[email protected]>
Page entities have no :block/page, so move-blocks now uses the previous :block/parent when that parent is a page. Co-authored-by: Tienson Qin <[email protected]>
Deleting a child block changes page content, same as insert/move. Stamp each deleted entity's container page, excluding ids that are being retracted (stamping a retracted entity would resurrect it).
The delete assertions read get-edit-content synchronously, racing the worker roundtrip that remounts the editor. Stamping the page's :block/updated-at on delete adds a few ms to that path, which the slow CI runner could not absorb. Every other post-delete assertion in this file already calls wait-editor-visible; these two were outliers.
Identity-preserving insert-blocks can move a live block across pages. Stamp the original container page as well as the destination. Co-authored-by: Tienson Qin <[email protected]>
8f51e40 to
b5473a7
Compare
* fix: bump page updated-at on insert and move Page :block/updated-at was only touched from save-block. Child insert, reorder, and move-blocks now stamp the affected page timestamps. Co-authored-by: Tienson Qin <[email protected]> * test: avoid shadowing cljs.core/second in updated-at tests Co-authored-by: Tienson Qin <[email protected]> * fix: bump former parent page updated-at when moving pages Page entities have no :block/page, so move-blocks now uses the previous :block/parent when that parent is a page. Co-authored-by: Tienson Qin <[email protected]> * fix: bump page updated-at on delete-blocks too Deleting a child block changes page content, same as insert/move. Stamp each deleted entity's container page, excluding ids that are being retracted (stamping a retracted entity would resurrect it). * test: split page updated-at delete case into own deftest * test(e2e): wait for editor after deleting blocks The delete assertions read get-edit-content synchronously, racing the worker roundtrip that remounts the editor. Stamping the page's :block/updated-at on delete adds a few ms to that path, which the slow CI runner could not absorb. Every other post-delete assertion in this file already calls wait-editor-visible; these two were outliers. * fix: stamp source page on keep-uuid insert reparent Identity-preserving insert-blocks can move a live block across pages. Stamp the original container page as well as the destination. Co-authored-by: Tienson Qin <[email protected]> --------- Co-authored-by: Cursor Agent <[email protected]>
* fix: bump page updated-at on insert and move Page :block/updated-at was only touched from save-block. Child insert, reorder, and move-blocks now stamp the affected page timestamps. Co-authored-by: Tienson Qin <[email protected]> * test: avoid shadowing cljs.core/second in updated-at tests Co-authored-by: Tienson Qin <[email protected]> * fix: bump former parent page updated-at when moving pages Page entities have no :block/page, so move-blocks now uses the previous :block/parent when that parent is a page. Co-authored-by: Tienson Qin <[email protected]> * fix: bump page updated-at on delete-blocks too Deleting a child block changes page content, same as insert/move. Stamp each deleted entity's container page, excluding ids that are being retracted (stamping a retracted entity would resurrect it). * test: split page updated-at delete case into own deftest * test(e2e): wait for editor after deleting blocks The delete assertions read get-edit-content synchronously, racing the worker roundtrip that remounts the editor. Stamping the page's :block/updated-at on delete adds a few ms to that path, which the slow CI runner could not absorb. Every other post-delete assertion in this file already calls wait-editor-visible; these two were outliers. * fix: stamp source page on keep-uuid insert reparent Identity-preserving insert-blocks can move a live block across pages. Stamp the original container page as well as the destination. Co-authored-by: Tienson Qin <[email protected]> --------- Co-authored-by: Cursor Agent <[email protected]>
* fix: bump page updated-at on insert and move Page :block/updated-at was only touched from save-block. Child insert, reorder, and move-blocks now stamp the affected page timestamps. Co-authored-by: Tienson Qin <[email protected]> * test: avoid shadowing cljs.core/second in updated-at tests Co-authored-by: Tienson Qin <[email protected]> * fix: bump former parent page updated-at when moving pages Page entities have no :block/page, so move-blocks now uses the previous :block/parent when that parent is a page. Co-authored-by: Tienson Qin <[email protected]> * fix: bump page updated-at on delete-blocks too Deleting a child block changes page content, same as insert/move. Stamp each deleted entity's container page, excluding ids that are being retracted (stamping a retracted entity would resurrect it). * test: split page updated-at delete case into own deftest * test(e2e): wait for editor after deleting blocks The delete assertions read get-edit-content synchronously, racing the worker roundtrip that remounts the editor. Stamping the page's :block/updated-at on delete adds a few ms to that path, which the slow CI runner could not absorb. Every other post-delete assertion in this file already calls wait-editor-visible; these two were outliers. * fix: stamp source page on keep-uuid insert reparent Identity-preserving insert-blocks can move a live block across pages. Stamp the original container page as well as the destination. Co-authored-by: Tienson Qin <[email protected]> --------- Co-authored-by: Cursor Agent <[email protected]>
Fixes logseq/db-test#1278
Problem
Adding a child block, changing block order, or deleting a block did not bump the page
updated at/:block/updated-at.Ctrl+Shift+M(:editor/move-blocks) and othermove-blockspaths had the same gap.:block/updated-aton the page was only written fromsave-block. Structural ops that change page content (insert-blocks,move-blocks,move-blocks-up-down,delete-blocks) left the page timestamp unchanged.Fix
Reuse a small
page-updated-at-txhelper plus acontainer-page-eidhelper (the page that contains an entity::block/pagefor ordinary blocks,:block/parentfor page-like entities which have no:block/page):insert-blocksstamps the destination pagemove-blocksstamps the source and destination pages (covers reorder, indent/outdent, and the move-blocks API/handler)delete-blocksstamps each deleted entity's container page, excluding entity ids being retracted in the same tx (stamping a retracted page would resurrect it — e.g. a comment area whose:block/pageis the deleted page):block/tx-id/ renderer revision is unchanged.:block/updated-atis already excluded from revision stamping.Tests
logseq.outliner.core-test/page-updated-at-bumps-on-child-insert-reorder-move-and-delete(nbb)logseq.outliner.page-updated-at-test(bb dev:test)Coverage: child insert, sibling reorder, cross-page
move-blocks,apply-ops! :move-blocks, moving a page between parent pages, and child delete.Verification
logseq.outliner.core-test: 17 tests / 69 assertions, greenbb dev:test -v logseq.outliner.page-updated-at-test: 16 assertions, green-r outliner): 34 tests / 236 assertions, green:block/updated-atdoes not bump:block/tx-idLink to Devin session: https://app.devin.ai/sessions/18bcb4a459c64c8f9e037c7292ffdfea
Open in Devin Desktop: https://app.devin.ai/desktop/session/18bcb4a459c64c8f9e037c7292ffdfea?variant=devin
Requested by: @tiensonqin