Jetpack AI: Hide the legacy panel once a site is eligible for the WordPress Agent - #51819
Jetpack AI: Hide the legacy panel once a site is eligible for the WordPress Agent#51819t-wright wants to merge 7 commits into
Conversation
|
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. |
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
Code Coverage SummaryCoverage changed in 3 files.
|
a4b283c to
92fb25e
Compare
On WordPress.com Simple the Big_Sky class only loads once the Agent is switched on, so both the sidebar preview gate and the eligibility check failed on sites that were eligible but not yet enabled. The notice never registered on the sites it exists for. Hook the notice before the sidebar gate in init(), and drop the class_exists check from the eligibility test in favour of the always-loaded mu-plugin functions.
The notice's only action was an icon button that opened the chat, which left sites that are eligible but have not turned the Agent on with nothing to do. Replace it with two plain buttons: "Open WordPress Agent" where the chat is available, and "Enable WordPress Agent" where it is not, which sends WordPress.com sites to their AI tools settings in a new tab and self-hosted sites to My Jetpack. The click event records which one was used.
The notice sits inside a @wordpress/ui Notice, so its buttons and icon now come from the same package rather than @wordpress/components. Both actions stop shrinking so a long label pushes the docs link down instead of breaking mid-phrase. The enable link opens in the same tab: the editor's own unsaved-changes prompt guards the draft, and a fresh load on the way back shows the enabled state.
Several docblocks had grown into essays that restated what the code shows. Keep the gotchas a reader cannot see from the code and drop the rest.
The notice only knew whether Jetpack could open a chat, so a site with the Agent on but Jetpack's own sidebar gate closed was told to enable it. Add an "agent enabled" flag beside the notice flag, show the enable link only when it is off, and keep the notice hidden for disconnected users as before. The disabled open button also keeps its visible label as its accessible name, with the reason as a description, so voice control can still target it.
92fb25e to
ada071b
Compare
There was a problem hiding this comment.
🟢 Approval recommended
The eligibility/enabled split is implemented consistently across PHP+JS and is well-covered by updated PHPUnit and Jest tests.
Pull request overview
Updates the Jetpack AI sidebar/notice gating so the legacy “Improve with AI” panel is replaced not only when the WordPress Agent is enabled, but also when a site is eligible to enable it—showing either an Open or Enable action as appropriate.
Changes:
- Expand server-side eligibility logic to show the WordPress Agent notice for eligible plans (even before the agent is enabled) and expose an action-availability flag.
- Update the notice UI to support “Open WordPress Agent” vs “Enable WordPress Agent”, and record which action was clicked in Tracks props.
- Extend PHPUnit + Jest coverage for eligibility/enabled/action-availability combinations.
File summaries
| File | Description |
|---|---|
| projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/ai-sidebar/class-jetpack-ai-sidebar.php | Adds eligibility-based notice enablement and exposes agentNoticeActionAvailable plus an enabled/eligible split. |
| projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/wordpress-agent-notice/index.tsx | Updates notice copy/actions to support both enabling and opening the agent, and improves a11y for disabled state. |
| projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/wordpress-agent-notice/open-agent.ts | Adds isAgentActionAvailable() based on injected inline data. |
| projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/wordpress-agent-notice/types.ts | Extends Tracks event property typing with an optional action discriminator. |
| projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/wordpress-agent-notice/test/index.test.tsx | Expands component tests for enable/open flows, URLs, and event properties. |
| projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/ai-assistant-plugin-sidebar/test/index.test.tsx | Updates sidebar integration tests for eligible-only behavior and new button labeling. |
| projects/plugins/jetpack/extensions/index.json | Adds the new extension slug ai-sidebar-agent-enabled. |
| projects/plugins/jetpack/tests/php/extensions/plugins/ai-sidebar/Jetpack_AI_Sidebar_Test.php | Adds plan-eligibility simulation + new PHPUnit coverage for eligibility/enabled/action-availability logic. |
| projects/plugins/jetpack/changelog/update-wordpress-agent-notice-eligibility | Changelog entry describing the eligibility-based hiding of the legacy panel. |
Review details
- Files reviewed: 9/9 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.
| /** | ||
| * Where a site turns the WordPress Agent on, matching the wpcom dashboard banner. | ||
| * | ||
| * @return {string} The settings URL. |
The Big Sky plugin's Settings > Writing checkbox turns the Agent off while the plugin stays active, and then there is no Agent button in the editor. Read the option alongside the class, as the plugin itself does, so the notice offers to enable the Agent rather than point at a button that is not there. An installed plugin still proves eligibility on its own.
Relates to: FORNO-476
Proposed changes
Screen.Recording.2026-09-02.at.13.32.31.mov
Related product discussion/links
Does this pull request change what data or activity we track or use?
Testing instructions
wp.data.dispatch( 'core/preferences' ).set( 'jetpack/ai-assistant', 'wordpressAgentNoticeDismissed', null );to reset the preference to test multiple times on the same site.add_filter( 'jetpack_ai_sidebar_enabled', '__return_true' );