Skip to content

Alert when an admin screen goes stale due to another user's save#22

Open
josephfusco wants to merge 4 commits into
mainfrom
feat/stale-screen-detection
Open

Alert when an admin screen goes stale due to another user's save#22
josephfusco wants to merge 4 commits into
mainfrom
feat/stale-screen-detection

Conversation

@josephfusco

@josephfusco josephfusco commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

Each covered admin screen tracks a revision that increments on save and is broadcast over Heartbeat; when a viewer's page-load baseline falls behind, a dismissible notice prompts them to reload and names the user who saved.

Stale-screen notice on Settings → General: actor avatar, 'Alex Smith updated this screen a few seconds ago.' message, and a primary Reload button. Below: the demo-helper notice with four 'Save as ...' buttons.

Related: #12

How to test

  • Playground preview → Settings → General → click a Save as <name> button → yellow notice appears within seconds. Repeat on post, term, user, and comment edit screens.
  • WP-CLI option updates and self-saves do not fire the notice.

Follow-ups

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 4.7
Used for: Implementation of the screen-revisions module, the JS banner client, the test suite, and the Playground demo helper. All changes were reviewed and verified by me.

@josephfusco josephfusco force-pushed the feat/stale-screen-detection branch 3 times, most recently from 8313b82 to 6ee2edf Compare June 10, 2026 00:29
@WordPress WordPress deleted a comment from github-actions Bot Jun 10, 2026
@josephfusco josephfusco force-pushed the feat/stale-screen-detection branch from 6ee2edf to 22f8b78 Compare June 10, 2026 00:56
@github-actions

github-actions Bot commented Jun 10, 2026

Copy link
Copy Markdown

▶ Preview in WordPress Playground

Open in WordPress Playground

Boots 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 bf6beb49cc9b6eb8f03be18a6a3969d37671ecc3. Auto-updates when you push.

@josephfusco josephfusco force-pushed the feat/stale-screen-detection branch 3 times, most recently from 2d92f9b to 3548f47 Compare June 10, 2026 14:12
@josephfusco josephfusco force-pushed the feat/stale-screen-detection branch 4 times, most recently from fd6434e to 69a9f1c Compare June 10, 2026 15:17
@josephfusco josephfusco marked this pull request as ready for review June 10, 2026 15:42

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.

Pull request overview

Adds “stale admin screen” detection to Presence API by tracking per-screen revision counters that bump on classic admin save flows and are surfaced to viewers via Heartbeat, enabling a client-side banner prompting a reload (including attribution to the saving user).

Changes:

  • Introduces a new screen-revisions module that bumps per-screen revisions on Settings/post/user/term/comment saves and returns the current revision + actor metadata via Heartbeat.
  • Enqueues a new admin JS/CSS banner client that detects when the viewer’s baseline revision is behind and renders a dismissible reload notice.
  • Adds a comprehensive PHPUnit test suite for screen-revision bumping, Heartbeat payloads, and screen-key derivation; updates demo helper copy and uninstall cleanup.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
uninstall.php Deletes the new wp_presence_screen_revisions option on uninstall.
presence-api.php Registers the new module and hooks (enqueue + save/heartbeat handlers).
includes/screen-revisions.php Implements revision storage/bumping, screen key derivation, Heartbeat payload, and banner enqueue.
assets/js/stale-screen.js Heartbeat client that shows a stale-screen warning banner and reload button.
assets/css/stale-screen.css Styling for the injected stale-screen notice layout.
tests/test-screen-revisions.php New unit tests covering bump logic, Heartbeat responses, and screen key behavior.
tests/e2e/screen-stale-demo-helper.php Updates demo helper notice wording.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread includes/screen-revisions.php
Comment thread includes/screen-revisions.php
Comment thread tests/test-screen-revisions.php Outdated
@WordPress WordPress deleted a comment from github-actions Bot Jun 10, 2026
@josephfusco josephfusco marked this pull request as draft June 10, 2026 18:11
josephfusco added a commit that referenced this pull request Jun 10, 2026
wp-env's Docker build runs `composer global require --dev phpunit/phpunit`
which pulls the Sebastian Bergmann package tree from
`api.github.com/repos/.../zipball/...`. Unauthenticated, that endpoint
is throttled to 60/hour per IP — easily exhausted by GitHub Actions
runners sharing NAT'd IPs — and starts 504-ing partway through the
build. `GITHUB_TOKEN`-authenticated requests are bumped to 5000/hour,
which our CI volume doesn't come anywhere near.

Uses `composer config --global --auth` (the documented composer
pattern) instead of hand-writing `~/.composer/auth.json`. Adds a
`shivammathur/setup-php` step to each workflow so composer is on the
host. Net change: +1 step, -2 heredoc lines, identical end-result
file that wp-env's Dockerfile mounts into its `cli` build stage.

Applies to `phpunit.yml` and `multisite.yml`; both build wp-env the
same way and have the same failure mode on PRs like #22 where the
runner happens to hit a depleted rate-limit bucket.
josephfusco added a commit that referenced this pull request Jun 10, 2026
wp-env's Docker build runs `composer global require --dev phpunit/phpunit`
which pulls the Sebastian Bergmann package tree from
`api.github.com/repos/.../zipball/...`. Unauthenticated, that endpoint
is throttled to 60/hour per IP — easily exhausted by GitHub Actions
runners sharing NAT'd IPs — and starts 504-ing partway through the
build. `GITHUB_TOKEN`-authenticated requests are bumped to 5000/hour,
which our CI volume doesn't come anywhere near.

Uses `composer config --global --auth` (the documented composer
pattern) instead of hand-writing `~/.composer/auth.json`. Adds a
`shivammathur/setup-php` step to each workflow so composer is on the
host. Net change: +1 step, -2 heredoc lines, identical end-result
file that wp-env's Dockerfile mounts into its `cli` build stage.

Applies to `phpunit.yml` and `multisite.yml`; both build wp-env the
same way and have the same failure mode on PRs like #22 where the
runner happens to hit a depleted rate-limit bucket.
josephfusco and others added 4 commits June 10, 2026 15:48
Each covered admin screen tracks a revision that increments on save and
is broadcast over Heartbeat. When a viewer's page-load baseline falls
behind, a dismissible notice prompts them to reload and names the user
who saved.

Coverage: Settings (options.php), post.php, user-edit / profile.php,
edit-tags.php, comment.php. The wp_presence_current_screen_key filter
lets custom and JS-driven screens opt in.

Refs #12
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@josephfusco josephfusco force-pushed the feat/stale-screen-detection branch from c94a8a3 to bf6beb4 Compare June 10, 2026 19:48
@josephfusco josephfusco marked this pull request as ready for review June 10, 2026 19:52
@github-actions

Copy link
Copy Markdown

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 joefusco.

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

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.

2 participants