Skip to content

feat: tell a second browser from a second tab with a per-room session hash - #815

Merged
josephfusco merged 8 commits into
mainfrom
feat/presence-session
Oct 12, 2026
Merged

josephfusco merged 8 commits into
mainfrom
feat/presence-session

Conversation

@josephfusco

Copy link
Copy Markdown
Collaborator

I went with the column, as the issue recommends, and only a row someone writes for themselves gets a session, so WP-CLI, cron, application passwords, reserved rows and rows written on another user's behalf store an empty string; I haven't tested a real second device, only sessions faked from cookies in PHPUnit.

Fixes #725

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5.5
Used for: Assisting with the column, the REST and export fields, and the tests.

@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

🛝 WordPress Playgrounds

Built from f9bf712

Post locks RTC Synced patterns Settings
Single site Launch post locks, single site Launch RTC, single site Launch synced patterns, single site Launch settings, single site
Multisite Launch post locks, multisite Launch RTC, multisite Launch synced patterns, multisite Launch network settings, multisite

@josephfusco
josephfusco force-pushed the feat/presence-session branch from 26e4142 to a11bfb0 Compare October 9, 2026 13:34
github-actions Bot added a commit that referenced this pull request Oct 9, 2026
@codecov

codecov Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.09%. Comparing base (1b115a9) to head (f9bf712).

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #815      +/-   ##
============================================
+ Coverage     97.08%   97.09%   +0.01%     
- Complexity      269      271       +2     
============================================
  Files            30       30              
  Lines          4354     4370      +16     
============================================
+ Hits           4227     4243      +16     
  Misses          127      127              
Flag Coverage Δ
multisite 97.09% <100.00%> (+0.01%) ⬆️
phpunit 77.13% <100.00%> (+0.08%) ⬆️

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.

@josephfusco josephfusco added [Type] Enhancement A suggestion for improvement of an existing feature [Area] Database Issues for the wp_presence table and cron cleanup [Area] REST API Issues for the REST API subsystem Privacy Work relates to privacy of presence data Public API Adds a hook, route, constant, or global that third parties can depend on php Pull requests that update php code labels Oct 9, 2026
@github-actions github-actions Bot removed the Public API Adds a hook, route, constant, or global that third parties can depend on label Oct 9, 2026
github-actions Bot added a commit that referenced this pull request Oct 9, 2026
@josephfusco
josephfusco marked this pull request as ready for review October 9, 2026 17:34
@github-actions

github-actions Bot commented Oct 9, 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, rejaulalomkhan, joefusco.

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

@rejaulalomkhan

Copy link
Copy Markdown
Contributor

Great implementation Joe. Hashing the session token per room cleanly groups tabs into browsers without leaking replayable tokens across rooms.

Two small suggestions:

  1. In \wp_presence_write_row()\ (\plugins/presence-api/includes/presence.php), the \LAST_INSERT_ID()\ case checks whether state changed to distinguish a change (\1) from a timestamp refresh (\2):
    \\sql
    CASE WHEN data <> VALUES(data) OR user_id <> VALUES(user_id) OR expires_gmt <= %s THEN 1 ELSE 2 END
    \
    Now that \session_hash\ is a column representing the client's browser, adding \session_hash <> VALUES(session_hash)\ ensures that a session change with identical data is recognized as a room change rather than a refresh.
  2. The branch is currently 5 commits behind \main\ and would benefit from a rebase.

Comment thread plugins/presence-api/includes/presence.php
Comment thread plugins/presence-api/tests/test-session-hash.php Outdated
@josephfusco
josephfusco force-pushed the feat/presence-session branch from dea09e8 to 182336b Compare October 12, 2026 16:03
github-actions Bot added a commit that referenced this pull request Oct 12, 2026
@josephfusco

Copy link
Copy Markdown
Collaborator Author

Thanks, you caught the CASE first. Both are in: 103715c adds session_hash to it, and the branch is rebased onto main.

github-actions Bot added a commit that referenced this pull request Oct 12, 2026
@josephfusco
josephfusco merged commit e89901e into main Oct 12, 2026
25 checks passed
@josephfusco
josephfusco deleted the feat/presence-session branch October 12, 2026 17:02
@github-actions github-actions Bot added this to the 0.18.0 milestone Oct 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Area] Database Issues for the wp_presence table and cron cleanup [Area] REST API Issues for the REST API subsystem php Pull requests that update php code Privacy Work relates to privacy of presence data [Type] Enhancement A suggestion for improvement of an existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A room can tell people from tabs, but not a second device from a second tab

3 participants