Skip to content

Jetpack AI: say in the hub when custom code holds the AI module off - #52062

Open
t-wright wants to merge 1 commit into
trunkfrom
add/ai-module-forced-off-notice
Open

Jetpack AI: say in the hub when custom code holds the AI module off#52062
t-wright wants to merge 1 commit into
trunkfrom
add/ai-module-forced-off-notice

Conversation

@t-wright

@t-wright t-wright commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Proposed changes

  • A filter that pins Jetpack's module list, such as a host allowlist written before the ai module existed, keeps ai off no matter what the site stores. My Jetpack then offers a switch that cannot stick, and the AI hub says AI is merely off.
  • Jetpack_AI_Settings::is_master_forced_off() asks the module filters directly, via Jetpack_Modules_Overrides, and the feature-settings read reports it as master_forced_off.
  • The hub shows a notice for that state, "Jetpack AI is turned off by custom code running on this site, so it can’t be turned on here", with a Learn more link to jetpack-ai-hub-docs-module-forced-off. The "Manage in My Jetpack" notice is hidden, since it cannot help. Reads only; feature toggles still save.

The redirect slug jetpack-ai-hub-docs-module-forced-off needs to exist in the registry before this merges.

Related product discussion/links

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

No.

Testing instructions

  • On a connected site with AI on, add an mu-plugin that filters jetpack_active_modules to a list without ai.
  • Open Jetpack → AI. Expect the custom-code notice on the Overview and AI Features tabs, no toggles, and no "Manage in My Jetpack" notice.
  • Remove the mu-plugin. Expect the toggles back.

@github-actions

github-actions Bot commented Sep 8, 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 add/ai-module-forced-off-notice branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack add/ai-module-forced-off-notice

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 added [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Status] In Progress [Tests] Includes Tests Admin Page React-powered dashboard under the Jetpack menu labels Sep 8, 2026
@github-actions

github-actions Bot commented Sep 8, 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:

The Jetpack plugin has different release cadences depending on the platform:

  • WordPress.com Simple releases happen as soon as you deploy your changes after merging this PR (PCYsg-Jjm-p2).
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly:
    • Scheduled release: October 6, 2026

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

@github-actions github-actions Bot added the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label Sep 8, 2026
@jp-launch-control

jp-launch-control Bot commented Sep 8, 2026

Copy link
Copy Markdown

Code Coverage Summary

Coverage changed in 3 files.

File Coverage Δ% Δ Uncovered
projects/plugins/jetpack/src/class-jetpack-modules-overrides.php 26/28 (92.86%) -7.14% 2 ❤️‍🩹
projects/plugins/jetpack/_inc/lib/class-jetpack-ai-settings.php 59/71 (83.10%) 2.15% 0 💚
projects/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-ai-feature-settings.php 110/123 (89.43%) 0.09% 0 💚

1 file is newly checked for coverage.

File Coverage
projects/plugins/jetpack/_inc/client/ai/components/ai-unavailable-notice/index.jsx 6/6 (100.00%) 💚

Full summary · PHP report · JS report

@t-wright
t-wright force-pushed the add/ai-module-forced-off-notice branch from da56d0f to 275af5b Compare September 8, 2026 05:10
@t-wright t-wright changed the title Jetpack AI: say when code is holding the AI module off Jetpack AI: show the host notice when a filter holds the AI module off Sep 8, 2026
@t-wright
t-wright marked this pull request as ready for review September 8, 2026 05:41
@t-wright
t-wright requested a lite review from Copilot September 8, 2026 05:43

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.

🟡 Changes recommended

There is at least one documentation/maintainability issue in the updated test file (a now-detached docblock) that should be corrected before merging.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR improves the Jetpack AI hub’s gating behavior when the site has the ai module stored as active but a host/module-list filter prevents it from actually being active, by reporting AI as “not available” to the client.

Changes:

  • Add Jetpack_AI_Settings::is_master_unavailable() to detect “stored active, but effectively inactive” on non-Simple sites.
  • Adjust the AI feature settings REST payload to report host_allows_ai as false when the master is unavailable (so existing UI shows the “not available” notice).
  • Add/extend PHPUnit coverage for the new “master unavailable” state and REST response behavior, plus a changelog entry.
File summaries
File Description
projects/plugins/jetpack/_inc/lib/class-jetpack-ai-settings.php Adds is_master_unavailable() to detect when ai is stored active but can’t be enabled due to filtering.
projects/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-ai-feature-settings.php Updates the settings response to treat “master unavailable” as “host does not allow AI” for UI gating.
projects/plugins/jetpack/tests/php/general/Jetpack_AI_Settings_Test.php Adds unit tests for is_master_unavailable() and new helper for filtering ai out of active modules.
projects/plugins/jetpack/tests/php/core-api/wpcom-endpoints/WPCOM_REST_API_V2_Endpoint_AI_Feature_Settings_Test.php Adds REST endpoint test asserting host_allows_ai becomes false when a filter holds the module off.
projects/plugins/jetpack/changelog/add-ai-module-forced-off-notice Documents the user-facing behavior change in the Jetpack plugin changelog.
Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@t-wright
t-wright force-pushed the add/ai-module-forced-off-notice branch from 275af5b to 7f65adc Compare September 8, 2026 06:35
@t-wright
t-wright requested a review from a team September 8, 2026 06:37
A host or agency filter that pins Jetpack's module list, commonly one written before the `ai` module existed, keeps `ai` off no matter what the site stores. My Jetpack then offers a switch that cannot stick and the AI hub says AI is merely off. Ask Jetpack_Modules_Overrides, which already resolves both the option and module filters against the real module list, report the result as `master_forced_off` on the feature-settings read, and show a notice in the hub that says a plugin or the hosting configuration is holding AI off.
@t-wright
t-wright force-pushed the add/ai-module-forced-off-notice branch from 7f65adc to c0c4aa5 Compare September 9, 2026 02:11
@t-wright t-wright changed the title Jetpack AI: show the host notice when a filter holds the AI module off Jetpack AI: say in the hub when custom code holds the AI module off Sep 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Admin Page React-powered dashboard under the Jetpack menu [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Status] In Progress [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. [Tests] Includes Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants