Skip to content

Jetpack AI: Hide the legacy panel once a site is eligible for the WordPress Agent - #51819

Open
t-wright wants to merge 7 commits into
trunkfrom
update/wordpress-agent-notice-eligibility
Open

Jetpack AI: Hide the legacy panel once a site is eligible for the WordPress Agent#51819
t-wright wants to merge 7 commits into
trunkfrom
update/wordpress-agent-notice-eligibility

Conversation

@t-wright

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

Copy link
Copy Markdown
Contributor

Relates to: FORNO-476

Proposed changes

Screen.Recording.2026-09-02.at.13.32.31.mov

Related product discussion/links

  • p7DVsv-qkD-p2

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

Testing instructions

  • On Simple site with a paid plan and Atomic:
    • Install this branch
    • Visit https://my.wordpress.com/sites//settings/ai-tools and disable WordPress Agent
    • Open the post editor
    • Verify the notice is displayed in the "Improve with AI" panel
    • Follow the link in the notice to enable the agent
    • Return to the post editor and verify the notice is still displayed with the the updated message allowing you to open the agent
    • Dismiss the notice. Verify the "Improve with AI" panel is no longer displayed
    • Use wp.data.dispatch( 'core/preferences' ).set( 'jetpack/ai-assistant', 'wordpressAgentNoticeDismissed', null ); to reset the preference to test multiple times on the same site.
  • On JN site
    • Install this branch
    • Open post editor
    • Verify the "Improve with AI" panel is displayed
    • Enable the Jetpack AI sidebar by adding an mu plugin by adding an mu-plugin containing add_filter( 'jetpack_ai_sidebar_enabled', '__return_true' );
    • Verify the WordPress Agent is displayed
    • Verify the notice is shown
  • On Simple sites that aren't eligible for WordPress Agent (e.g. Free plan), the legacy "Improve with AI" panel should remain.

@github-actions github-actions Bot added [Extension] AI Assistant Plugin [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Status] In Progress [Tests] Includes Tests labels Sep 1, 2026
@github-actions

github-actions Bot commented Sep 1, 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 1, 2026
@github-actions

github-actions Bot commented Sep 1, 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 update/wordpress-agent-notice-eligibility branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack update/wordpress-agent-notice-eligibility

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

@jp-launch-control

jp-launch-control Bot commented Sep 1, 2026

Copy link
Copy Markdown

Code Coverage Summary

Coverage changed in 3 files.

File Coverage Δ% Δ Uncovered
projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/ai-sidebar/class-jetpack-ai-sidebar.php 209/234 (89.32%) 0.80% 1 ❤️‍🩹
projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/wordpress-agent-notice/index.tsx 39/39 (100.00%) 0.00% 0 💚
projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/wordpress-agent-notice/open-agent.ts 22/22 (100.00%) 0.00% 0 💚

Full summary · PHP report · JS report

@t-wright
t-wright force-pushed the update/wordpress-agent-notice-eligibility branch 2 times, most recently from a4b283c to 92fb25e Compare September 2, 2026 05:54
@t-wright
t-wright marked this pull request as ready for review September 2, 2026 07:20
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.
@t-wright
t-wright force-pushed the update/wordpress-agent-notice-eligibility branch from 92fb25e to ada071b Compare September 9, 2026 02:42
@t-wright
t-wright requested a lite review from Copilot September 9, 2026 04:52

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.

🟢 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.

Comment on lines +53 to +56
/**
* 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.
@t-wright
t-wright requested a review from a team September 9, 2026 05:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Extension] AI Assistant Plugin [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