Repository navigation
Rest API/Gutenberg: Alert when an admin screen goes stale due to another user's save - #77
Conversation
- Expose restUrl and nonce configurations in PHP for stale screen scripts - Add window.wp.presence.markScreenStale method to trigger background stale bumps
|
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 Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
▶ Preview in WordPress PlaygroundBoots 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 |
josephfusco
left a comment
There was a problem hiding this comment.
Hey @Intenzi thank you for your contributions, these are really solid changes!
The permission refactor into wp_presence_current_user_can_access_screen() is the right move and the demo video made it easy to understand the issue. Nice work!
Left a few inline suggestions, the main one is around actor_id as client input. Happy to clarify anything!
There was a problem hiding this comment.
This looks good to me, thank you for your work on this @Intenzi
Closes: #28
Follow-up to: #22
How?
This PR implements the stale-screen detection enhancements by introducing a new client-side API and a supporting REST route to handle non-redirecting, JS-driven saves:
Server-Side Changes
wp_presence_screen_heartbeat_received()into a new shared helper function:wp_presence_current_user_can_access_screen()./wp-presence/v1/presence/screen-revisions/staletoWP_REST_Presence_Controller.wp_presence_bump_screen_revision()to increment the revision.wp_presence_enqueue_stale_screen_banner()to pass down therestUrland thenonceto the client.Client-Side Changes
wp.presence.markScreenStale(): Added this new global method on thewindow.wp.presencenamespace.POSTrequest to the new REST endpoint.Additionally added unit tests for the bump wrapper methods success, failure and updated README with info on Stale Screen Detection.
Demo Video
8mb.video-Stale.Screen.Detection.API.mp4
Use of AI Tools
AI assistance: Yes
Tool(s): Antigravity IDE
Model(s): Gemini 3.1 Pro (Low)
Used for: Identifying relevant code files, deciding on implementation and architecture for enhancement. Unit tests were implemented via it. Final implementation and tests were reviewed and edited by me.