Jetpack AI: say in the hub when custom code holds the AI module off - #52062
Jetpack AI: say in the hub when custom code holds the AI module off#52062t-wright wants to merge 1 commit into
Conversation
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
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:
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:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
Code Coverage SummaryCoverage changed in 3 files.
1 file is newly checked for coverage.
|
da56d0f to
275af5b
Compare
There was a problem hiding this comment.
🟡 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_aias 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.
275af5b to
7f65adc
Compare
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.
7f65adc to
c0c4aa5
Compare
Proposed changes
aimodule existed, keepsaioff 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, viaJetpack_Modules_Overrides, and the feature-settings read reports it asmaster_forced_off.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-offneeds 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
jetpack_active_modulesto a list withoutai.