# Do transactions dispatched via \`undo\` retain their source's Annotations?

**URL:** <https://discuss.codemirror.net/t/do-transactions-dispatched-via-undo-retain-their-sources-annotations/9674>\
**Category:** v6\
**Created:** [February 9, 2026, 4:23pm UTC](https://discuss.codemirror.net/t/do-transactions-dispatched-via-undo-retain-their-sources-annotations/9674 "2026-02-09T16:23:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![franknoirot2](https://discuss.codemirror.net/user_avatar/discuss.codemirror.net/franknoirot2/32/5388_2.png) [@franknoirot2](https://discuss.codemirror.net/u/franknoirot2)\
**Post date:** [February 9, 2026, 4:23pm UTC](https://discuss.codemirror.net/t/do-transactions-dispatched-via-undo-retain-their-sources-annotations/9674/1 "2026-02-09T16:23:07Z")

</div>

Currently I apply some Annotations to transactions to exclude them an “always on” effect running via an `UpdateListener` extension. I was under the impression that history undo transactions would retain these annotations as well, and thus would also get this exclusion behavior, but I don’t think that is the case (my notes [here](https://github.com/KittyCAD/modeling-app/issues/9286#issuecomment-3872606531) for anyone interested in the debugging that led here).

In order to achieve the effect I’m looking for, where this `UpdateListener`’s effects are ignored both forwards and while undoing, should I make use of [`invertedEffects`](https://codemirror.net/docs/ref/#commands.invertedEffects) somehow? I thought I could only apply `effects` through that, so I’m unclear on how to configure my annotations to apply in the undo case.

---

<div class="post-metadata">

**Author:** ![marijn](https://discuss.codemirror.net/user_avatar/discuss.codemirror.net/marijn/32/136_2.png) [@marijn](https://discuss.codemirror.net/u/marijn)\
**Post date:** [February 9, 2026, 4:41pm UTC](https://discuss.codemirror.net/t/do-transactions-dispatched-via-undo-retain-their-sources-annotations/9674/2 "2026-02-09T16:41:40Z")

</div>

Indeed, they do not. An undo/redo effect is a new transaction, with no annotations of the transaction(s) that the changes originate in. The history tracks changes and effects, not the transactions they come from, and may combine changes and effects from multiple transactions into a single history ‘event’, so there’s not really a meaningful way to preserve annotations in history.

---

<div class="post-metadata">

**Author:** ![franknoirot2](https://discuss.codemirror.net/user_avatar/discuss.codemirror.net/franknoirot2/32/5388_2.png) [@franknoirot2](https://discuss.codemirror.net/u/franknoirot2)\
**Post date:** [February 9, 2026, 10:19pm UTC](https://discuss.codemirror.net/t/do-transactions-dispatched-via-undo-retain-their-sources-annotations/9674/3 "2026-02-09T22:19:30Z")

</div>

Okay, yes that makes sense, especially with the grouping behavior that would break things to group Annotations from multiple Transactions.

I probably shouldn’t be operating that “always on” effect via `UpdateListener` anyway, that seems like an anti-pattern. I’ll rework it to be an explicit opt-in effect of its own. Then when that is a StateEffect, undo will still fire it, but if it’s left out of a transaction it (of course) won’t have an effect then as well.

Thank you!
