Skip to content

My Jetpack: Show the highest-priority global notice first - #53400

Merged
xavier-lc merged 4 commits into
trunkfrom
fix/my-jetpack-notice-priority-stale-state
Oct 13, 2026
Merged

xavier-lc merged 4 commits into
trunkfrom
fix/my-jetpack-notice-priority-stale-state

Conversation

@xavier-lc

@xavier-lc xavier-lc commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Fixes MYJP-351

When several notice watchers set a notice in the same render, setNotice compared each one against the notice from the previous render, so the last caller won regardless of priority, and the right notice replaced it a render later. For example, the bad-installation notice flashed before "Missing site connection", and each swap re-fired jetpack_myjetpack_global_notice_view.

Proposed changes

  • setNotice decides priority against the latest queued state, so the highest-priority notice wins on the first render and lower ones are ignored.
  • Drop the resetNotice() call inside setNotice; it was a no-op under React 18 batching, and would make every call win with the new check.
  • On a tie, the notice set first now stays (trunk kept the last one set). Watchers run in a fixed order, so a site with a failed backup and a missing site connection now sees the backup notice first.
  • Add a test for two setNotice calls in one effect pass.

Related product discussion/links

Does this pull request change what data or activity we track or use?

No new data. jetpack_myjetpack_global_notice_view stops firing a second time when a notice is swapped on load.

Testing instructions

  • jp test js packages/my-jetpack. notice-context.test.tsx covers a lower- and an equal-priority notice set after a high one in the same pass; on trunk both render the second notice.
  • Dismissing a dismissible notice still shows the next pending one: setNotice keeps changing identity on each notice change, which re-runs the watchers.

🤖 Generated with Claude Code

https://claude.ai/code/session_01QqfKRQfxuwm723Y1prq8mM

setNotice compared each call against the notice from the last render, so
when several watchers set a notice in one effect pass the last caller won
and the right notice only replaced it a render later.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QqfKRQfxuwm723Y1prq8mM
@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack), and enable the fix/my-jetpack-notice-priority-stale-state branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack fix/my-jetpack-notice-priority-stale-state

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!


Jetpack plugin:

No scheduled milestone found for this plugin.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.


Backup plugin:

No scheduled milestone found for this plugin.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.


Boost plugin:

No scheduled milestone found for this plugin.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.


Search plugin:

No scheduled milestone found for this plugin.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.


Social plugin:

No scheduled milestone found for this plugin.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.


Protect plugin:

No scheduled milestone found for this plugin.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.


Videopress plugin:

No scheduled milestone found for this plugin.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.


Stats Data plugin:

No scheduled milestone found for this plugin.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

@jp-launch-control

jp-launch-control Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Code Coverage Summary

Coverage changed in 1 file.

File Coverage Δ% Δ Uncovered
projects/packages/my-jetpack/_inc/context/notices/noticeContext.tsx 10/11 (90.91%) 32.58% -4 💚

Full summary · PHP report · JS report

@xavier-lc
xavier-lc requested review from a team and LiamSarsfield October 9, 2026 10:41
LiamSarsfield
LiamSarsfield previously approved these changes Oct 12, 2026

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

LGTM. I gave it a try and My Jetpack no longer crashes when two notices land together.

One side effect: with two notices of the same priority, the first one set now wins, where trunk kept the last. So a site with a failed backup and a missing connection now sees the backup notice first. I'm fine with that, but could you say so in the description and the setNotice comment, and add a tie row to the new test?

Could you also add plugin changelog entries, like the last notice fix did? And maybe soften the entry to "Notices: Show the highest-priority notice first when several are set at once.", since a notice that arrives later can still crash until #53004 lands.

@xavier-lc

Copy link
Copy Markdown
Contributor Author

@LiamSarsfield Thanks! Done in f9005a3: the tie behaviour is in the description and the setNotice comment, the test has a tie row (both rows fail on trunk), and the plugin entries use your wording, prefixed "My Jetpack:" in the plugins.

@github-actions github-actions Bot added [Plugin] Backup A plugin that allows users to save every change and get back online quickly with one-click restores. [Plugin] Boost A feature to speed up the site and improve performance. [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] Protect A plugin with features to protect a site: brute force protection, security scanning, and a WAF. [Plugin] Search A plugin to add an instant search modal to your site to help visitors find content faster. [Plugin] Social Issues about the Jetpack Social plugin [Plugin] Stats Data [Plugin] VideoPress A standalone plugin to add high-quality VideoPress videos to your site. labels Oct 13, 2026

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

LGTM 🚀

@xavier-lc
xavier-lc merged commit 0d3df8b into trunk Oct 13, 2026
169 of 170 checks passed
@xavier-lc
xavier-lc deleted the fix/my-jetpack-notice-priority-stale-state branch October 13, 2026 11:09
@github-actions github-actions Bot removed the [Status] Needs Review This PR is ready for review. label Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] My Jetpack [Plugin] Backup A plugin that allows users to save every change and get back online quickly with one-click restores. [Plugin] Boost A feature to speed up the site and improve performance. [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] Protect A plugin with features to protect a site: brute force protection, security scanning, and a WAF. [Plugin] Search A plugin to add an instant search modal to your site to help visitors find content faster. [Plugin] Social Issues about the Jetpack Social plugin [Plugin] Stats Data [Plugin] VideoPress A standalone plugin to add high-quality VideoPress videos to your site. [Tests] Includes Tests [Type] Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants