Detecting a transaction made by undo/redo in y-prosemirror

Is it possible to detect if a prosemirror transaction was caused by an undo/redo in y-prosemirror? I tried to check isChangeOrigin, but it seems to be always true for transactions dispatched by y-prosemirror.

You could try to figure out the origin of the Yjs transaction (transaction.origin). If transaction.origin instanceof Y.UndoManager then the change originates from the undo manager. However, I’m not sure if you have access to the Yjs transaction within the prosemirror event…

An undo operation in prosemirror triggers the Y.UndoManager. Hence this is not a native ProseMirror change anymore. So isChangeOrigin is supposed to be false.

I don’t think I can access the Yjs transaction from the prosemirror transaction. I will try to detect undo/redo by registering an event in the UndoManager, but it would be nice to do everything inside the appendTransaction of prosemirror.

Testing here, even undo transactions have isChangeOrigin as true. Is this right?