Transaction metadata and undo/redo

When a transaction is re-applied from history (redo) it seems it no longer has the original metadata attached.

This can be problematic, for example: My app stores individual blocks in the db. I have a plugin that watches for added/deleted nodes, assigning new IDs and deleting old ones. The app also supports folding. In order to avoid the ID plugin from seeing the fold as a bunch of blocks being deleted, my first thought was to use metadata to indicate the transaction should be ignored by the ID manager.

(btw - I’m aware of the strategy to put folded node json into an attribute, which my ID plugin could also use to behave correctly. That doesn’t work in my context for other reasons. I also don’t want to use addToHistory false, because the user should be able to make edits in a foldable region, fold them up, and still be able to undo them later)

But the metadata solution breaks down when the user undoes or redoes a fold/unfold: the metadata is missing.

This seems like a general problem for many situations where you might use transaction metadata - which makes me think I’m missing something.

Any advice much appreciated!

You’re not missing something. The undo history doesn’t store transactions, just (groups of) changes. As such, it won’t help you with transaction metadata.

I think what I was missing is that transaction metadata is not the right way to capture extra semantic information about the transaction, because this information won’t be captured in the history.

A better idea that’s just occurred to me, could be to capture fold/unfold as semantic operations, by defining Step subclasses. It should be possible to define these very minimally by subclassing ReplaceAroundStep, so it seems like a clean solution.

Thanks for the help!