Skip to content

Real-time Collaboration: Add collaborators presence UI - #75065

Merged
chriszarate merged 14 commits into
WordPress:trunkfrom
Automattic:add/rtc-avatars
Feb 4, 2026
Merged

chriszarate merged 14 commits into
WordPress:trunkfrom
Automattic:add/rtc-avatars

Conversation

@maxschmeling

@maxschmeling maxschmeling commented Jan 29, 2026 •

Copy link
Copy Markdown
Contributor

What?

Adds the collaborators presence UI in the header. Closes #74708

Why?

When there are other connected collaborators in a real-time collaboration session, the current user needs to be able to know who else is in the post.

How?

Uses the useActiveUsers hook added in #75009 to populate data in a new <CollaboratorsPresence> component.

Testing Instructions

  1. Check out the PR
  2. Open an existing post or create a post and save
  3. Copy the URL and open in another tab
  4. See the collaborators list populated in the header

Testing Instructions for Keyboard

  1. When a collaborator is connected to a session you are in, click the collaborators button in the header
  2. The menu should open
  3. Press the escape key
  4. The menu should close

Screenshots or screencast

CleanShot 2026-01-29 at 14 30 30@2x

@github-actions github-actions Bot added [Package] Core data /packages/core-data [Package] Editor /packages/editor [Package] Sync /packages/sync labels Jan 29, 2026
@github-actions github-actions Bot removed the [Package] Sync /packages/sync label Jan 29, 2026
@maxschmeling
maxschmeling marked this pull request as ready for review January 29, 2026 23:15
@maxschmeling
maxschmeling requested a review from nerrad as a code owner January 29, 2026 23:15
@github-actions

Copy link
Copy Markdown

Warning: Type of PR label mismatch

To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.

  • Required label: Any label starting with [Type].
  • Labels found: [Package] Core data, [Package] Editor.

Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task.

@github-actions

github-actions Bot commented Jan 29, 2026 •

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: maxschmeling <maxschmeling@git.wordpress.org>
Co-authored-by: ingeniumed <ingeniumed@git.wordpress.org>
Co-authored-by: chriszarate <czarate@git.wordpress.org>
Co-authored-by: shekharnwagh <shekharnwagh@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@ingeniumed ingeniumed added [Feature] Real-time Collaboration Phase 3 of the Gutenberg roadmap around real-time collaboration [Type] Experimental Experimental feature or API. labels Jan 29, 2026
@ingeniumed ingeniumed changed the title [Real-time Collaboration] Add collaborators presence UI Real-time Collaboration: Add collaborators presence UI Jan 29, 2026

@ingeniumed ingeniumed left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work getting this in place. Most of my comments are about code cleanup and comments, but I do have one concern that needs to be tested to make sure it's not a problem.

Comment thread packages/editor/src/components/collaborators-presence/index.tsx Outdated
Comment thread packages/editor/src/components/collaborators-presence/list.tsx Outdated
Comment thread packages/editor/src/components/collaborators-presence/list.tsx Outdated
Comment thread packages/editor/src/components/collaborators-presence/list.tsx Outdated
Comment thread packages/editor/src/components/collaborators-presence/list.tsx Outdated
const isLargeViewport = useViewportMatch( 'medium' );
const isTooNarrowForDocumentBar = useMediaQuery( '(max-width: 403px)' );
const {
postId,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the postType, it looks like there are a lot of possible post types here. We are interested in mainly the postType for posts. We do handle if the awareness instance isn't found, and perhaps the active users would be empty for cases where the post type isn't post. What happens if this is triggered for cases where the post type isn't post? Is there any error or does it work as expected?

This looks like it might have more side effects, and I'm not sure what that'd look like.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's already using getCurrentPostType() here, I just added getCurrentPostId() which shouldn't be problematic. The hook will always just return the default/empty state if it doesn't find anything.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems fine

Comment thread packages/editor/src/components/collaborators-presence/avatar.tsx Outdated
Comment thread packages/editor/src/components/collaborators-presence/avatar.tsx Outdated
Comment thread packages/editor/src/components/collaborators-presence/avatar.tsx Outdated
<div
className={ className }
style={ avatarStyles }
aria-hidden="true"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it marked with aria-hidden? Will we rely on collaborators-list for announceable text?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was done by @shekharnwagh originally, but I do believe the reason is because you don't want to go through this list and then also the dropdown list. You just want the items in the interactive list to be announced.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the text in collaborators-list is enough and this doesn't add meaningful content for screen readers

Comment thread packages/editor/src/components/collaborators-presence/index.tsx Outdated
* @param root0.postType
*/
export function CollaboratorsPresence( { postId, postType }: AvatarsProps ) {
const activeUsers = useActiveUsers( postId, postType ) as UserState[];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

harmful as. can you just rely on the return type, or is the type lost somehow?

Suggested change
const activeUsers = useActiveUsers( postId, postType ) as UserState[];
const activeUsers = useActiveUsers( postId, postType );

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type is lost because of the private API file. If there is a way to preserve it, I'd definitely like to

Comment thread packages/editor/src/components/collaborators-presence/index.tsx Outdated
Comment thread packages/editor/src/components/collaborators-presence/list.tsx Outdated
Comment thread packages/editor/src/components/collaborators-presence/list.tsx Outdated
className="editor-collaborators-presence__list-item"
onClick={ () => {} }
disabled={ ! userState.isConnected }
aria-label="Clicking scrolls to cursor position in the editor"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it? This button is a no-op, can it just be removed?

@maxschmeling maxschmeling Jan 30, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the label and disabled the button per Gopal's review. Wanted to leave the button because the cursor registry stuff is coming back in a follow-up PR

Comment thread packages/editor/src/components/collaborators-presence/list.tsx Outdated
Comment thread packages/editor/src/components/collaborators-presence/list.tsx Outdated
Comment thread packages/core-data/src/private-apis.js Outdated
@chriszarate
chriszarate enabled auto-merge (squash) February 3, 2026 16:42
}

/**
* Hook to get the active users for a post editor.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change users -> collaborators. This applies to the docs, as well as the return type. The return type should be ActiveCollaborator.

postId,
postType,
}: CollaboratorsPresenceProps ) {
const activeUsers = useActiveCollaborators(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

users -> collaborators

@chriszarate
chriszarate merged commit 8e5a003 into WordPress:trunk Feb 4, 2026
39 checks passed
@chriszarate
chriszarate deleted the add/rtc-avatars branch February 4, 2026 09:47
@github-actions github-actions Bot added this to the Gutenberg 22.6 milestone Feb 4, 2026
@ingeniumed

Copy link
Copy Markdown
Contributor

Noting that because auto-merge was enabled, this got merged in. But a follow up PR is needed to change users to collaborators.

@Mamaduka

Mamaduka commented Feb 5, 2026

Copy link
Copy Markdown
Member

I was testing the feature and noticed a couple of bugs, or at least unexpected results.

  • My current user was listed as a collaborator in my session, even though I see a condition in this PR.
  • Refreshing the browser adds the same user as a collaborator again and again.
  • Eventually, there's a fun jiggle in the dropdown.

P.S. Let me know if I should create a separate issue.

Screencast

CleanShot.2026-02-05.at.17.06.14.mp4

@chriszarate

Copy link
Copy Markdown
Contributor

I was testing the feature and noticed a couple of bugs, or at least unexpected results.

Hey @Mamaduka , thanks so much for that report. We happen to have just replicated that bug and are tracking down a fix. An issue would be welcome but not necessary.

@Mamaduka

Mamaduka commented Feb 5, 2026

Copy link
Copy Markdown
Member

Thanks, @chriszarate!

Feel free to ping me for testing or review.

MaggieCabrera pushed a commit that referenced this pull request Feb 10, 2026
Co-authored-by: maxschmeling <maxschmeling@git.wordpress.org>
Co-authored-by: ingeniumed <ingeniumed@git.wordpress.org>
Co-authored-by: chriszarate <czarate@git.wordpress.org>
Co-authored-by: shekharnwagh <shekharnwagh@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] Real-time Collaboration Phase 3 of the Gutenberg roadmap around real-time collaboration [Package] Core data /packages/core-data [Package] Editor /packages/editor [Type] Experimental Experimental feature or API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RTC: [Interface] Show collaborators in the document header

5 participants