Repository navigation
feat: add RTC collaboration hooks and server authority - #290
Conversation
- Add wp_presence_editor_state filter for state enrichment - Add wp_presence_editor_active action on heartbeat ticks - Add wp_presence_check_collaboration_threshold() function - Fire wp_presence_collaboration_started when 1→2+ editors - Fire wp_presence_collaboration_ended when 2+→1 editor - Add X-WP-Collaboration-Active header to REST responses - Add X-WP-Editor-Count header to REST responses
|
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 Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
▶ Preview in WordPress PlaygroundBoots a fresh WordPress with this PR's presence-api build, seeds 5 demo users, and drops you on the dashboard. Stress-test variant: 40 demo users · Built from |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #290 +/- ##
============================================
+ Coverage 77.82% 78.01% +0.18%
Complexity 190 190
============================================
Files 14 14
Lines 1998 2015 +17
============================================
+ Hits 1555 1572 +17
Misses 443 443
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
- Test wp_presence_editor_state filter - Test wp_presence_editor_active action - Test wp_presence_collaboration_started action (1→2+ editors) - Test wp_presence_collaboration_ended action (2+→1 editor) - Test X-WP-Collaboration-Active header in REST responses - Test X-WP-Editor-Count header in REST responses - Test headers only present for postType/ rooms
Fixes division by zero error when per_page defaults to 0 in direct controller calls.
Fixes negative OFFSET in SQL queries when calling controller directly without the page parameter set.
Removed: - wp_presence_editor_active action (unused by realtime-collaboration) - X-WP-Collaboration-Active and X-WP-Editor-Count headers (unused) - Tests for removed functionality Kept: - wp_presence_editor_state filter (extensibility for cursor positions) - wp_presence_check_collaboration_threshold() function - wp_presence_collaboration_started/ended actions (used by realtime-collaboration)
The test was comparing the response timestamp against gmdate() called after tick(), which could cross a second boundary and fail. Now captures before/after timestamps around tick() and verifies the response falls within that window.
Summary
Adds collaboration lifecycle hooks for RTC server authority.
Changes
Use Case
These hooks enable the realtime-collaboration plugin to implement server authority for Gutenberg RTC. The server determines when collaboration should activate based on active editor count.
What Was Removed
Earlier commits included:
wp_presence_editor_active action- Removed (unused, high frequency)X-WP-Collaboration-Active header- Removed (unused)X-WP-Editor-Count header- Removed (unused)These were dropped to keep the surface area minimal and avoid overhead.
Related
Assisting with: Implementation and testing.