Skip to content

fix: bump page updated-at on insert, move, and delete - #13402

Merged
tiensonqin merged 7 commits into
masterfrom
logseq/fix-page-updated-at-c734
Sep 24, 2026
Merged

tiensonqin merged 7 commits into
masterfrom
logseq/fix-page-updated-at-c734

Conversation

@tiensonqin

@tiensonqin tiensonqin commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

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 other move-blocks paths had the same gap.

:block/updated-at on the page was only written from save-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-tx helper plus a container-page-eid helper (the page that contains an entity: :block/page for ordinary blocks, :block/parent for page-like entities which have no :block/page):

  • insert-blocks stamps the destination page
  • move-blocks stamps the source and destination pages (covers reorder, indent/outdent, and the move-blocks API/handler)
  • delete-blocks stamps 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/page is the deleted page)

:block/tx-id / renderer revision is unchanged. :block/updated-at is 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

  • nbb logseq.outliner.core-test: 17 tests / 69 assertions, green
  • full outliner nbb suite: 133 tests / 663 assertions, green
  • bb dev:test -v logseq.outliner.page-updated-at-test: 16 assertions, green
  • cljs outliner tests (-r outliner): 34 tests / 236 assertions, green
  • pipeline revision regression: :block/updated-at does not bump :block/tx-id

Link 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

@tiensonqin
tiensonqin marked this pull request as ready for review September 24, 2026 06:23
devin-ai-integration[bot]

This comment was marked as resolved.

@devin-ai-integration devin-ai-integration Bot changed the title fix: bump page updated-at on insert and move fix: bump page updated-at on insert, move, and delete Sep 24, 2026
@tiensonqin
tiensonqin force-pushed the logseq/fix-page-updated-at-c734 branch from 9d12b80 to 4bd03ed Compare September 24, 2026 13:29
@devin-ai-integration

Copy link
Copy Markdown
Contributor

E2E-verified the updated-at stamping on this branch in the web dev app (pnpm watch, Demo DB graph). All ops were performed through the real UI; exact :block/updated-at values were read via shadow-cljs cljs-repl db-worker on the live datascript conn.

Op Result (ms before → after)
Control: click + Escape, no change no bump — baseline clean
Reorder (Alt+Shift+Down) → 1790256455655
Insert child block → 1790256498197
Delete block — new commit → 1790256547278
Delete last block on page → 1790256596224, page intact
Ctrl+Shift+M move block A→B both pages 1790256660341 (same tx)
Reparent page → Library former parent + Library 1790257039313
No-op move no stamp — good

All pages Updated At after ops

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.

Written by Devin

@devin-ai-integration devin-ai-integration Bot 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.

Devin Review found 1 new potential issue.

1 flag not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)

Devin Review

(: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?))

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.

🔴 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.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

cursoragent and others added 7 commits September 24, 2026 22:02
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]>
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]>
@tiensonqin
tiensonqin force-pushed the logseq/fix-page-updated-at-c734 branch from 8f51e40 to b5473a7 Compare September 24, 2026 14:02
@tiensonqin
tiensonqin merged commit 1e07062 into master Sep 24, 2026
13 checks passed
@tiensonqin
tiensonqin deleted the logseq/fix-page-updated-at-c734 branch September 24, 2026 14:02
devin-ai-integration Bot pushed a commit that referenced this pull request Oct 1, 2026
* 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]>
devin-ai-integration Bot pushed a commit that referenced this pull request Oct 8, 2026
* 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]>
devin-ai-integration Bot pushed a commit that referenced this pull request Oct 8, 2026
* 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Page updated at is not updated when adding child blocks or reordering blocks

2 participants