Undo issue in collaboration

I’m encountering a problem where the editor cannot undo. It’s caused by the rebase in my collaborative operation, but I’m not sure how to fix it. I think it’s something about the setMirror of transform. Here’s my workflow:

Client A generates StepsA, records it locally, sends it to the server, creates a version, returns it to Client A, and pushes it to all Clients. When receiving the Steps and version, it sorts them locally based on the version, undoes StepsA, performs Mapping based on the offset (calculates the base version and the generated version), and applies the mapped steps in order.

Client B receives StepsA, performs Mapping based on the offset (calculates the base version and the generated version), and applies the mapped steps in order.

And here’s the mermaid flowchart for the described workflow: