Skip to content

Tell a second person apart from your own second tab - #154

Open
chriszarate wants to merge 2 commits into
trunkfrom
loop/147
Open

chriszarate wants to merge 2 commits into
trunkfrom
loop/147

Conversation

@chriszarate

Copy link
Copy Markdown
Collaborator

Fixes #147.

The editor now tells a second person apart from your own second tab. Before this change, opening a post in two tabs made you look like two people. The editor switched to the faster polling speed it uses when two people edit. Your fourth tab was refused with "Too many editors", as if the post were full.

What changed

  • Server: every reply the server sends to the browser now carries a second list, awareness_users. It says which WordPress user each open tab belongs to. All three connection types send it: regular polling, SSE (a stream the browser keeps open), and the websocket server.
  • The list sits next to the existing list of who is online and what they are doing. That list is not changed. Putting the user id inside it would break the editor, because the editor's code stops with an error on data it does not recognize (isFieldEqual in gutenberg/packages/core-data/src/awareness/awareness-state.ts). This design was approved in the issue.
  • Browser: the polling code now counts people, not open tabs, for the "Too many editors" limit and for the faster polling speed. If a reply has no awareness_users list (an older server), each tab counts as its own person, as before.

Your own tabs still share edits with each other. WordPress's background check-in still lists your other tabs, so a tab does not stop checking for changes while you have another one open. Those tabs now poll at the normal speed for one person.

Whether the collaborators list shows your own tabs as one person is up to WordPress/gutenberg#78700. This change only gives it the data.

Testing

  • npm run test:php -- --filter wpHttpPollingSyncServer: 67 tests pass.
  • npm run test:js -- polling-manager: 94 tests pass.
  • Full PHPUnit (526 tests, 3 skipped) and full Jest (779 tests) pass. Typecheck and composer lint are clean.
  • The new tests fail without the fix.
  • Not covered: the websocket server's updates to the browser have no test of their own for the new list.

Sync answers on every transport (polling, SSE streams, the websocket
daemon's pushes) now carry awareness_users beside the awareness map:
client id to WordPress user id. The awareness state itself is unchanged.

The polling manager counts people, not entries, when it checks the
room limit and when it decides whether the awareness map means company.
Your own other tab still keeps company through the advisory lane's
heartbeat answer, so edits keep flowing between your tabs.

Fixes #147.

@josephfusco josephfusco 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.

Three things before this goes in:

  1. With the advisory channel on (the default), my own second tab still puts polling on the two-person rate, because the heartbeat's others_present() still counts tabs, not people.
  2. I think the fix belongs on the server: if others_present() and has_live_awareness_besides() count people, the heartbeat and polling answers will agree.
  3. Tabs without a user id come through as 0, so countPeople lumps them into one person and undercounts both the editor limit and the company check.

@josephfusco

Copy link
Copy Markdown
Collaborator

@copilot resolve the merge conflicts in this pull request

Copilot AI commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

This branch already includes commit 3578783. The merge completed with no unresolved conflicts, so no additional changes were needed.

@josephfusco

Copy link
Copy Markdown
Collaborator

@copilot resolve the merge conflicts in this pull request

Copilot AI commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

Merge commit 3578783 is already in this branch. There are no conflicts or uncommitted changes.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The editor cannot tell a second person from your own second tab

3 participants