awareness.clientID out of sync with document.clientID
Description If Yjs detects that another client is already using the local clientID it will generate a new one. The awareness.clientID is not updated which leads to bugs in code where they are assumed to be the same.
An example is @tiptap/extension-collaboration-cursor which uses yCursorPlugin. In https://github.com/yjs/y-prosemirror/blob/master/src/plugins/cursor-plugin.js#L86C5-L86C54 it checks the yDoc.clientID with the clientId coming from the awareness states. With the above situation, it will incorrectly detect your own awareness changes as coming from another client and you will effectively see the collaboration cursor follow your own cursor.
Steps to reproduce the bug Steps to reproduce the behavior:
- Clone https://github.com/daveychu/hocuspocus/tree/client-id-out-of-sync
- Run
npx ava tests/provider/onClientIdChanged.ts - Test will fail on
t.is(provider2.document.clientID, provider2.awareness.clientID)
Expected behavior Test should succeed. awareness.clientID and document.clientID are kept in sync.
+1, same here
hmm. Why do you have non-unique client IDs? Are you setting them manually?
I don't think we can get notified on a change of the client id (it happens here https://github.com/yjs/yjs/blob/main/src/utils/Transaction.js#L355), so this would probably be hard to do.