Skip to content

feat: expose the room's collaborator count as JS hooks - #503

Merged
josephfusco merged 6 commits into
mainfrom
feat/502-collaborator-js-hooks
Sep 18, 2026
Merged

josephfusco merged 6 commits into
mainfrom
feat/502-collaborator-js-hooks

Conversation

@josephfusco

@josephfusco josephfusco commented Sep 11, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #502

presence-ping.js now fires presence-api.watchingRoom (once, before Heartbeat's first tick) and presence-api.collaboratorsChanged (on the 1-to-2+ and 2+-to-1 edges) through wp.hooks. External code, like Gutenberg's sync poll loop, can react to a room's editor count instead of polling for it separately. Covered by new PHPUnit and Playwright tests, and documented in the README's JS Actions section.

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Sonnet 5
Used for: Implementation (PHP config plumbing, JS event wiring, PHPUnit and Playwright tests) and README docs, drafted end to end and reviewed by me.

@github-actions

Copy link
Copy Markdown
Contributor

🚩 New public surfaces

  • (js-action) presence-api.collaboratorsChanged - requires documentation
  • (js-action) presence-api.watchingRoom - requires documentation

@github-actions github-actions Bot added the Public API Adds a hook, route, constant, or global that third parties can depend on label Sep 11, 2026
@josephfusco josephfusco added [Area] Heartbeat 💓 Issues for the heartbeat subsystem [Type] Feature A new feature within an existing module labels Sep 11, 2026
@github-actions

github-actions Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

🛝 WordPress Playgrounds

Built from 967a146

5 users 40 users
Single site Launch single site, 5 users Launch single site, 40 users
Multisite Launch multisite, 5 users Launch multisite, 40 users

@codecov

codecov Bot commented Sep 11, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 79.31034% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.74%. Comparing base (87c323e) to head (967a146).

❌ Your patch check has failed because the patch coverage (79.31%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #503      +/-   ##
============================================
- Coverage     95.92%   95.74%   -0.19%     
  Complexity      255      255              
============================================
  Files            21       21              
  Lines          3071     3076       +5     
============================================
- Hits           2946     2945       -1     
- Misses          125      131       +6     
Flag Coverage Δ
multisite 95.74% <79.31%> (-0.19%) ⬇️
phpunit 70.96% <79.31%> (-0.15%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

presence-heartbeat-collaborators (#451) only reached presence-ping.js's
own tick handler. wp.hooks lets external code, like Gutenberg's sync
poll loop, react to a room's editor count instead of polling for it.
@josephfusco
josephfusco force-pushed the feat/502-collaborator-js-hooks branch from 0624271 to 45e1a17 Compare September 11, 2026 23:07
github-actions Bot added a commit that referenced this pull request Sep 11, 2026
@josephfusco
josephfusco marked this pull request as ready for review September 11, 2026 23:12
@github-actions

github-actions Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

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.

Core Committers: Use this line as a base for the props when committing in SVN:

Props iamchitti, joefusco.

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

Copilot AI 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.

🟡 Changes recommended

Cross-site tab coordination can emit another multisite site's collaborator count.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Exposes room and collaborator-state changes through JavaScript hooks for integrations such as Gutenberg sync.

Changes:

  • Adds watchingRoom and edge-triggered collaboratorsChanged actions.
  • Passes the editor room to JavaScript and adds wp-hooks.
  • Adds documentation and PHPUnit/Playwright coverage.
File summaries
File Description
assets/js/presence-ping.js Emits the new JavaScript actions.
includes/heartbeat.php Supplies room configuration and hook dependency.
tests/test-heartbeat.php Tests configuration and dependency wiring.
tests/e2e/presence-collaborator-hooks.test.js Tests action behavior.
README.md Documents the actions.
Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 1
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread assets/js/presence-ping.js
Co-authored-by: josephfusco <6676674+josephfusco@users.noreply.github.com>
Co-authored-by: josephfusco <6676674+josephfusco@users.noreply.github.com>

@i-am-chitti i-am-chitti left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM 🚀, two minor suggestions.

Comment thread assets/js/presence-ping.js Outdated
Comment thread .github/workflows/phpunit.yml Outdated
github-actions Bot added a commit that referenced this pull request Sep 17, 2026
github-actions Bot added a commit that referenced this pull request Sep 18, 2026
@josephfusco
josephfusco enabled auto-merge (squash) September 18, 2026 00:58
@josephfusco
josephfusco merged commit 4129ccf into main Sep 18, 2026
24 checks passed
@josephfusco
josephfusco deleted the feat/502-collaborator-js-hooks branch September 18, 2026 01:06
@josephfusco josephfusco added this to the 0.6.0 milestone Sep 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Area] Heartbeat 💓 Issues for the heartbeat subsystem Public API Adds a hook, route, constant, or global that third parties can depend on [Type] Feature A new feature within an existing module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The collaborator count only reaches code already listening to heartbeat-tick

4 participants