Skip to content

Allow enabling RTC when encountering a locked post#77380

Open
JDeepD wants to merge 1 commit intoWordPress:trunkfrom
JDeepD:feat/allow-rtc-on-locked-post
Open

Allow enabling RTC when encountering a locked post#77380
JDeepD wants to merge 1 commit intoWordPress:trunkfrom
JDeepD:feat/allow-rtc-on-locked-post

Conversation

@JDeepD
Copy link
Copy Markdown

@JDeepD JDeepD commented Apr 15, 2026

What?

When a user who can enable RTC encounters a locked post being edited by someone else, they are provided with an option to enable RTC in the Post Locked modal.

This patch implements this using the heartbeats that are sent from the server to the clients.

The user who enables the RTC updates the setting directly through their client. All the other clients are informed through the heartbeat that RTC has been enabled in settings which prompts them to save and reload their client so that RTC is enable for their client as well.

This change also requires to update the heartbeat processing logic in Core to send real_time_collaboration state as in this branch.

Closes #76666

Why?

This change is necessary so that we do not have to ask the client editing the post to exit out of the editor and edit again after we have enabled RTC.

How?

  • Consider that RTC is disabled on the site.
  • User A is editing a post
  • User B wants to edit that same post but receives a popup that the post is being edited by User A. If they have necessary permissions, they are given the option to enable RTC in the modal itself.
  • When they click on the button to enable RTC, the admin setting is updated through the REST API and User B's screen reloads to update the window with the appropriate RTC states.
  • To notify User A that RTC has been enabled, we modify the heartbeat messages to include real_time_collaboration state. This state is taken from the admin options and always reflects the state as it is in the backend. When User A's client finds that real_time_collaboration is true in the heartbeat but it is false in the window, it informs the user that RTC has been enabled by someone else and asks them to save and reload the page to update the window state with appropriate RTC states.

Testing Instructions

Here are the complete testing instructions to add to your PR. They cover the happy path, the heartbeat sync, and the security permissions check we implemented.

Testing Instructions

  1. Ensure RTC is disabled (Settings > Writing > Collaboration).
  2. Create 2 Users who have permissions for editing admin settings (e.g., two Administrators).
  3. Log in as User A in one browser (or a standard window) and create or edit a post. Add some text to the post, but do not save or exit. Leave the editor open.
  4. Log in as User B in a different browser (or an incognito window) and navigate to edit the exact same post.
  5. Verify that User B sees the "Post Locked" modal ("This post is already being edited").
  6. Verify that the "Enable real-time collaboration" button is visible in this modal for User B.
  7. Click the "Enable real-time collaboration" button as User B.
  8. Verify that User B's page automatically reloads and successfully enters the editor.
  9. Switch back to User A's browser. Wait for the next heartbeat tick (heartbeat in editor happens in interval of 10 seconds so there might be a bit of delay).
  10. Verify that a new modal appears for User A stating: "Another user has just enabled real-time collaboration. To join them and avoid losing your recent changes, please save and reload the editor."
  11. Click the "Save and Reload" button as User A.
  12. Verify that User A's page saves the unsaved text, reloads without triggering a native browser "leave site" warning, and successfully joins the editor alongside User B.
  13. Test Permissions Check: Go to Settings and disable RTC again.
  14. Log in as a user without permissions to edit global settings (e.g., a standard Author or Contributor).
  15. Have User A lock a post again, and have the Author open it.
  16. Verify that the Author sees the locked post modal, but does not see the "Enable real-time collaboration" button.

Screenshots or screencast

rtc-colab.mov

Use of AI Tools

  • Used Claude Sonnet 4.5, Gemini 3.1 Pro and Minimax2.5 for research, editor code suggestions and code review.

When a user who can enable RTC encounters a locked
post being edited by someone else, they are provided
with an option to enable RTC in the Post Locked modal.

This patch implements this using the heartbeats that
are sent from the server to the clients.
@github-actions github-actions Bot added [Package] Editor /packages/editor First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository labels Apr 15, 2026
@github-actions
Copy link
Copy Markdown

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @JDeepD! In case you missed it, we'd love to have you join us in our Slack community.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

return $response;
}

$is_rtc_enabled = get_option( 'wp_collaboration_enabled', false );
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Currently, it sends back whatever is set in wp_collaboration_enabled setting. However, #75072 discusses on a more granular option for enabling RTC per CPT. Depending on how the granular control is implemented, we will have to change this accordingly.

@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] Editor, First-time Contributor.

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
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: JDeepD <jdeep@git.wordpress.org>
Co-authored-by: maxschmeling <maxschmeling@git.wordpress.org>

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Package] Editor /packages/editor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RTC: [Interface] Allow enabling RTC when encountering a locked post

1 participant