Skip to content

Better implement collaborator presence & prevent flickering #4057

@doc-han

Description

@doc-han

User story

When a user is on the collaborative editor with other users, we want to

  1. know exactly what state the other users are in whether active|away|idle
  2. when users leave their tab to another tab, there's a change JS execution in the tab gets throttled which makes these users flicker. we need to resolve that.

Details

  • [a] Initial solution for this has been implemented via fix: flickering of active collaborator icons between states #3951 which caches all remote users to prevent the flickering. It also makes use of the lastSeen variable to determine the activity state of a user.
  • [b] There's another PR fix: flickering of inactive collaborator #4053 which uses a different method, two states, 1. lastSeen to keep updating ydoc and 2. lastState to determine the actual state of a user. It also solves flickering by only caching away users. This is because we can assert that, throttling is likely to only happen for away users.

Implementation notes

Since [a] has already been merged into main. there doesn't seem to be much conflict from [b] to main tho. but we need to make few changes to make sure [b] can land in main safe and beautifully.

  1. do we still need the caching at the useAwareness level? this is because [b] puts the caching at the useRemoteUsers level. useRemoteUsers is just like useAwareness but shows a single user for their several connections sorted by the active connection then lastSeen.

  2. rebase [b] onto main

  3. resolve the difference in tests between [b] and [a]

Release notes

User acceptance criteria

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Tech Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions