Skip to content

perf: keep the collaboration edge state in the presence table - #514

Merged
josephfusco merged 6 commits into
mainfrom
fix/512-collaboration-state-off-transients
Sep 23, 2026
Merged

josephfusco merged 6 commits into
mainfrom
fix/512-collaboration-state-off-transients

Conversation

@josephfusco

Copy link
Copy Markdown
Collaborator

Fixes #512

Without a persistent object cache this was an option write per heartbeat per
collaborating room, and the plugin's only transient.

Two deviations from the issue:

  • wp_get_active_rooms() needed filtering as well. It is not in the issue's
    cost table, and the REST rooms endpoint reads it with hydration off, where
    the reserved row counts as a user.
  • Stale _transient_wp_presence_collab_* options are left to core. They expire
    on the presence TTL and delete_expired_transients sweeps them daily, so the
    upgrade routine the issue asks for would duplicate core.
Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5

Used for: Assisting with implementation and testing

@github-actions

github-actions Bot commented Sep 21, 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.

@github-actions

github-actions Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

🛝 WordPress Playgrounds

Built from 2d40f5d

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 21, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 96.04%. Comparing base (4e542cc) to head (2d40f5d).

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #514      +/-   ##
============================================
+ Coverage     95.79%   96.04%   +0.25%     
- Complexity      255      258       +3     
============================================
  Files            21       21              
  Lines          3066     3111      +45     
============================================
+ Hits           2937     2988      +51     
+ Misses          129      123       -6     
Flag Coverage Δ
multisite 96.04% <98.66%> (+0.25%) ⬆️
phpunit 71.84% <98.66%> (+0.64%) ⬆️

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.

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.

Copilot review overview

🟡 Changes recommended

REST sanitization can bypass reserved-ID validation, and the CLI no longer exposes raw rows as required.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 High severity · 2 Medium severity · 1 Low severity

Open (4)
What changed in this PR

Moves collaboration edge state from transients into reserved presence-table rows, reducing heartbeat option writes.

Changes:

  • Stores collaboration counts in _collab rows with refresh and expiry behavior.
  • Filters reserved rows from participant-facing APIs and REST endpoints.
  • Adds validation, documentation, and regression tests.
File Description
.github/​CONTRIBUTING.md Updates private-function example.
README.md Documents reserved IDs and collaboration state.
presence-api.php Defines the reserved prefix.
includes/​heartbeat.php Persists collaboration state in presence rows.
includes/​functions.php Adds raw/client row helpers and filtering.
includes/​class-wp-rest-presence-controller.php Filters and rejects reserved IDs.
tests/​test-heartbeat.php Tests collaboration-row behavior.
tests/​test-functions.php Tests active-room filtering.
tests/​test-rest-controller.php Tests REST filtering and validation.

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

Comment thread includes/class-wp-rest-presence-controller.php Outdated
Comment thread includes/functions.php
Comment thread tests/test-heartbeat.php
Comment thread README.md Outdated
github-actions Bot added a commit that referenced this pull request Sep 21, 2026
Comment thread includes/heartbeat.php
github-actions Bot added a commit that referenced this pull request Sep 22, 2026
github-actions Bot added a commit that referenced this pull request Sep 22, 2026
@josephfusco
josephfusco enabled auto-merge (squash) September 22, 2026 14:50
github-actions Bot added a commit that referenced this pull request Sep 23, 2026
@josephfusco
josephfusco merged commit cbe80d3 into main Sep 23, 2026
21 checks passed
@josephfusco
josephfusco deleted the fix/512-collaboration-state-off-transients branch September 23, 2026 11:19
@josephfusco josephfusco added [Area] Heartbeat 💓 Issues for the heartbeat subsystem Performance Work relates to query load, cache behavior, or scaling labels Sep 27, 2026
@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 Performance Work relates to query load, cache behavior, or scaling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Collaboration edge state writes to wp_options on hosts without a persistent object cache

3 participants