Skip to content

fix: skip tag template auto-insert on undo/redo replay - #13553

Merged
tiensonqin merged 2 commits into
masterfrom
devin/1790843491-template-redo-dup
Oct 1, 2026
Merged

tiensonqin merged 2 commits into
masterfrom
devin/1790843491-template-redo-dup

Conversation

@tiensonqin

@tiensonqin tiensonqin commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Redoing a tag-driven template auto-insert duplicated the template children.

When a block gains a tag listed in a template's :logseq.property/template-applied-to, insert-tag-templates in compute-extra-tx-data fires on the :block/tags :added datom. History replay has two paths in apply-history-action!:

  • Verbatim tx-data replay ([:transact [tx-data nil]] fallback when no semantic outliner ops are recorded, e.g. :set-block-property tagging): the replayed datoms already contain the pipeline-generated children, so re-running insert-tag-templates inserts a second copy — the reported bug.
  • Semantic op replay (e.g. :insert-blocks of a tagged block): replayed ops run on a temp conn where the pipeline is skipped (:skip-validate-db?), so the batch tx-data contains no children and the final transact's pipeline must fire to regenerate them.

So the guard skips insert-tag-templates only when the tx is a verbatim replay of recorded tx-data — marked via :db-sync/replayed-tx-data? in apply-history-action! (and the same [:transact] fallback in rebase-local-op!, which had the same latent duplication on RTC rebase). (:undo? tx-meta) is also skipped, matching every other pipeline side effect in compute-extra-tx-data; redoing ops still re-fires the pipeline so children are regenerated.

Test coverage: redo-tag-template-auto-insert-does-not-duplicate-test (fails without the fix: children count is 2 after redo) and redo-semantic-op-tag-template-auto-insert-test (covers the semantic-op replay path) in frontend.worker.undo-redo-test.

Link to Devin session: https://app.devin.ai/sessions/13b8cda5422746018061c355f8ad3638
Open in Devin Desktop: https://app.devin.ai/desktop/session/13b8cda5422746018061c355f8ad3638?variant=devin
Requested by: @tiensonqin


Devin Review

@devin-ai-integration

Copy link
Copy Markdown
Contributor

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@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 resolved the finding on b784b42

Fixed by Devin (1)

  • Redo loses tagged block template children

View all findings in Devin Review

Devin Review

@tiensonqin
tiensonqin force-pushed the devin/1790843491-template-redo-dup branch from b784b42 to 1f3dff2 Compare October 1, 2026 17:03
@tiensonqin
tiensonqin merged commit 22263c3 into master Oct 1, 2026
13 checks passed
@tiensonqin
tiensonqin deleted the devin/1790843491-template-redo-dup branch October 1, 2026 17:03
devin-ai-integration Bot pushed a commit that referenced this pull request Oct 8, 2026
* fix: skip tag template auto-insert on undo/redo replay

* fix: only skip tag template insert for verbatim tx-data replays
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.

1 participant