Yjs currently has an experimental feature: Y.PermanentUserData, which can be used to meet the above requirements.
However, since it is currently in the experimental stage and the author said that it will provide a better implementation in the future, it is recommended to refer to its implementation and introduce it carefully in production.
But as you mentioned PermanentUserData, I checked the prosemirror-versions demo, I have a question about it, seems PermanentUserData uses the clientID to map the user name, if the clientID is changed for the same user, as PermanentUserData doesn’t persist the old clientID/Name mapping to somewhere, then PermanentUserData will lose the clientID/Name mapping on the old changes(if server or client all flush/reboot), when you check old snapshot and see who did the changes, it will show Unknown user.
I think we should persist the Client/Name mapping data that for PermanentUserData? ideally, also make sure each user has a unique clientID and never change?
I think clientID refers to a specific instance of Y.js rather than the user. So it’s expected to randomly change. The naming is confusing because it doesn’t refer to the user, but one particular session.