Skip to content

User Awareness and Awareness Session for Collaborative Editing

Hannes Moser requested to merge awareness-session into master

What does this MR do and why?

This MR introduces the concept of Awareness. It eventually allows users to start real-time collaboration sessions by being "aware" of another users' presence. A present user is identified by a persistent connection (web socket). A user state is split into a global and a document-local state. A user can be online/offline and an online user can present or away on a document. A document is identified by a global unique ID.

This MR does not add any user facing features or actually any code that gets executed. It is adding the capabilities to build collaborative sessions by adding an Awareness concern and an AwarenessSession model (backed by Redis). This allows us to identify the presence of a user in a session and also return all members of a session.

The persistence layer of the model makes heavy use of keys with the expiry set, to ensure sessions and user states always get cleaned up eventually. This is necessary, due to the detection of users being online and present is not always reliable. The memory requirements for this feature are discussed in this issue.

id = request.env['PATH_INFO']

session = AwarenessSession.for(id)

user = User.find(1)

user.join(session)
session.present?(user) # true

session.users_with_last_activity # [ [user, 1656315219] ]

user.leave(session)
session.present?(user) # false

Screenshots or screen recordings

Lifecycle of Redis keys

Screen_Shot_2022-06-30_at_10.34.21

This screenshot shows a potential use case for this implementation. A Google Docs like awareness bar in the top navigation (not part of this MR).

slide-8

UI Prototype:

Screen_Shot_2022-06-29_at_09.58.55

For a more detailed explanation, there are two videos about the awareness concept and how they fit into the collaborative session model.

How to set up and validate locally

There are no furthers steps required to set up a local env for this MR as long as specs run.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Hannes Moser

Merge request reports

Loading