Skip to content

Conversation

@vianasw
Copy link
Contributor

@vianasw vianasw commented Apr 21, 2025

Build upon #42750 to allow site editors to use Jetpack AI features.

Proposed changes:

  • In this approach, I'm relying on has_connected_admin method to check if the site has an admin with a connected account.

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

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

Testing instructions:

Since we're changing the way we block/allow things, we need to review all our features and test them with both admin and non-admin users (like editors).

Below is a list of our current features:

  • AI Assistant Block
  • Voice to Content
  • Excerpt
  • Post Feedback
  • Write Brief
  • SEO Enhancer
  • Title Generation
  • AI Image
  • Text Block Extension
  • Image Block Extension

Please go through all these features and play with admin, non-admin users, and not connected site.

@vianasw vianasw requested a review from Copilot April 21, 2025 21:55
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR builds on a previous implementation to allow site editors to use Jetpack AI features by switching the connection check from user-based to admin-based.

  • Updated the import and usage from isUserConnected to isAdminConnected in both the block enabling logic and the block editor.
  • Introduced a new utility module (isAdminConnected) and updated type exports in the ai-client package.

Reviewed Changes

Copilot reviewed 8 out of 23 changed files in this pull request and generated no comments.

Show a summary per file
File Description
projects/plugins/jetpack/extensions/blocks/ai-assistant/extensions/lib/can-ai-assistant-be-enabled.ts Replaced isUserConnected with isAdminConnected to validate admin connection status.
projects/plugins/jetpack/extensions/blocks/ai-assistant/edit.js Updated connection checks in the editor from user to admin.
projects/js-packages/shared-extension-utils/src/is-admin-connected.js New module to determine if an admin is connected.
projects/js-packages/shared-extension-utils/index.js Export update to include the new isAdminConnected module.
projects/js-packages/ai-client/src/types.ts Updated type export references from .js to .ts for consistency.
Files not reviewed (15)
  • projects/js-packages/ai-client/changelog/ai-assistant-for-site-editors: Language not supported
  • projects/js-packages/shared-extension-utils/changelog/ai-assistant-for-site-editors: Language not supported
  • projects/packages/my-jetpack/changelog/feature-ai-assistant-editor: Language not supported
  • projects/packages/my-jetpack/src/class-rest-ai.php: Language not supported
  • projects/plugins/backup/changelog/is-admin-connected: Language not supported
  • projects/plugins/boost/changelog/is-admin-connected: Language not supported
  • projects/plugins/classic-theme-helper-plugin/changelog/is-admin-connected: Language not supported
  • projects/plugins/crm/changelog/is-admin-connected: Language not supported
  • projects/plugins/jetpack/_inc/lib/class.core-rest-api-endpoints.php: Language not supported
  • projects/plugins/jetpack/changelog/feature-ai-assistant-editor: Language not supported
  • projects/plugins/jetpack/extensions/plugins/ai-content-lens/ai-content-lens.php: Language not supported
  • projects/plugins/mu-wpcom-plugin/changelog/is-admin-connected: Language not supported
  • projects/plugins/protect/changelog/is-admin-connected: Language not supported
  • projects/plugins/search/changelog/is-admin-connected: Language not supported
  • projects/plugins/social/changelog/is-admin-connected: Language not supported

@github-actions
Copy link
Contributor

github-actions bot commented Apr 21, 2025

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 or WordPress.com Site Helper), and enable the feature/ai-assistant-editor branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack feature/ai-assistant-editor
bin/jetpack-downloader test jetpack-mu-wpcom-plugin feature/ai-assistant-editor

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 [Block] AI Assistant [Extension] AI Content Lens [JS Package] AI Client [JS Package] Shared Extension Utils [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] Classic Theme Helper Plugin [Plugin] CRM Issues about the Jetpack CRM plugin [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] mu wpcom jetpack-mu-wpcom plugin [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] Starter Plugin [Plugin] VideoPress A standalone plugin to add high-quality VideoPress videos to your site. [Plugin] Wpcomsh RNA labels Apr 21, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Apr 21, 2025

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 a "[Type]" label (Bug, Enhancement, Janitorial, Task).
  • ✅ 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: May 6, 2025
    • Code freeze: May 5, 2025

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 Apr 21, 2025
@vianasw vianasw requested a review from a team April 21, 2025 21:58
@jp-launch-control
Copy link

jp-launch-control bot commented Apr 21, 2025

Code Coverage Summary

1 file is newly checked for coverage.

File Coverage
projects/js-packages/shared-extension-utils/src/is-admin-connected.js 0/3 (0.00%) 💔

Full summary · PHP report · JS report

Coverage check overridden by I don't care about code coverage for this PR Use this label to ignore the check for insufficient code coveage. .

@vianasw vianasw force-pushed the feature/ai-assistant-editor branch from 9453f37 to ad63467 Compare April 21, 2025 22:27
@vianasw vianasw changed the title Feature/ai assistant editor Jetpack AI: allow site editors to use Jetpack AI features Apr 21, 2025
@vianasw vianasw added the I don't care about code coverage for this PR Use this label to ignore the check for insufficient code coveage. label Apr 21, 2025
@vianasw vianasw removed [Package] My Jetpack [Plugin] Social Issues about the Jetpack Social plugin [Plugin] Starter Plugin [Plugin] Protect A plugin with features to protect a site: brute force protection, security scanning, and a WAF. [Plugin] VideoPress A standalone plugin to add high-quality VideoPress videos to your site. [Plugin] CRM Issues about the Jetpack CRM plugin [Plugin] mu wpcom jetpack-mu-wpcom plugin [Plugin] Wpcomsh [Plugin] Classic Theme Helper Plugin labels Apr 23, 2025
This is the only request to an AI endpoint that is made as a user and it
should stay that way because we check if the current user has edit
rights to the site in that endpoint.
@github-actions github-actions bot added [Package] My Jetpack [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Apr 23, 2025
@vianasw vianasw added [Status] Needs Review This PR is ready for review. [Type] Bug When a feature is broken and / or not performing as intended and removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Apr 23, 2025
Copy link
Contributor

@CGastrell CGastrell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI Assistant: works

Though, weirdly enough, ai-assistant-feature endpoint seems not to be working

image

Featured Image

Dropdown on the sidebar is not available to my editor user. I used the AI panel button to generate a featured image. It seems to be counting free requests and charging 10 requests per image (though the site has an AI plan).
image

Generate title

Worked both from the AI Assistant block and from the sidebar panel.

Generate feedback: works

Generate excerpt: works

Write Brief: works

Image generation:

As with featured image, I see no button to generate with AI and the toolbar button is greyed out:
image

NOTE: at this point I purchased a JP Complete plan, to test the SEO features. I now see 19 requests available. This doesn't make much sense, but also as ai-assistant-feature endpoint is not working, maybe we're getting some default values there.
image

Generating another featured image got me again the not-enough-requests notice.

SEO Enhancer:
Manual trigger works on all features. Toggle to enable auto-generation can't be switched with the editor user (403 - Forbidden response)

Overall the AI features work. The request counter is a bit odd but I think we didn't get to test how we were gonna count requests on these cases. But (maybe) it all comes down to the ai-assistant-feature endpoint not working. IDK.

The SEO toggle is a different beast, being something only admins can switch, it might get tricky to figure out what to do with it (maybe disable it with an info popover?)

@vianasw
Copy link
Contributor Author

vianasw commented Apr 24, 2025

@CGastrell I think that what happened is that my last commit didn't get in because the build failed, and you tested the previous build. My bad for not realizing it. I've tested again, and I don't see those issues.

@vianasw vianasw requested a review from a team April 24, 2025 15:14
Copy link
Contributor

@dhasilva dhasilva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most issues are solved, though the image generation button is not visible for editors

@vianasw
Copy link
Contributor Author

vianasw commented Apr 25, 2025

Most issues are solved, though the image generation button is not visible for editors

The code that replaces the Media Library original button in the image block checks if there is a user connection, and it appears that a user connection is indeed necessary. The problem is that the Generate with AI button is intertwined with the Select Image button, and separating that would require a surgical refactor.

<MediaButtonMenu
				{ ...props }
				setSelectedSource={ setSelectedSource }
				isReplace={ isReplaceMenu( mediaProps ) }
				isFeatured={ isFeatured }
				hasImage={ mediaProps.value > 0 }
			/>
			{ isGeneralPurposeImageGeneratorBetaEnabled() && ! isFeatured && hasAiButtonSupport && (
				<MediaAiButton setSelectedSource={ setSelectedSource } />
			) }

			{ ExternalLibrary && (
				<ExternalLibrary
					{ ...mediaProps }
					externalSource={ externalSource }
					onClose={ closeLibrary }
				/>
			) }

I think it would be better to address it in a different PR.

@vianasw vianasw requested review from CGastrell and dhasilva April 29, 2025 15:20
Copy link
Contributor

@dhasilva dhasilva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to address it in a different PR.

Makes sense!

Copy link
Contributor

@CGastrell CGastrell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI Assistant:
Continues to work well, it doesn't show as free requests anymore. Though the ai-assistant-feature request continues to fail:
image

Title generation
Works well both from the JP sidebar as well as from the AI Assistant block

Featured Image
Worked well, now not showing any warnings regarding free requests

Feedback
Worked well

AI Excerpt
Worked well

AI Image Extension
Caption generation worked well
Alt-text failed due to exceeding quota. This might be a sign that even without any warnings on the frontend, requests are being counted on backend? Maybe a false positive? I see no count and as ai-assistant-feature continues to "fail to fetch" I can't be sure where this is coming from:
image
image

From this point on, I couldn't make any more requests as the upgrade nudge shows on the AI Assistant block, which is inconsistent with the sidebar not showing any signs of free requests or being over quota:
image
Reloading the editor gets me back at usable AI Assitant block, but as soon as I make any request, the upgrade nudge is shown again as in the image above

Switching back to my admin user and I now see the same upgrade nudge, but the site has an AI plan, at least the sidebar is now consistent:
image

image

New site
I created a new site and added a role editor user. Switching back and forth, both admin and editor users seem to be consuming requests from the same pool. But once I reloaded the block editor with the editor user, I'm seeing the same as the previous test: AI Assistant fails to fetch and shows as if it wasn't on free requests. Admin user keeps seeing things normally and can upgrade.

Upgrade
After upgrading with the admin user, things wen't back to normal. No upgrade buttons nor request counts are shown.

SEO Enhancer
Worked well. Toggle is still available for editor user, but we never settled on how that should work.

For a moment, ai-assistant-feature endpoint responded well. After a while, it started to return as "failed to fetch" again, yet no feature was unavailable. Weird, but no blocker? Looking at the store that handles all AI features, it's simply the default, I can't figure out how is it still working:
image

I'm leaving this just as a comment for your consideration. I didn't run into any "major" issues, but I also can't explain why it works.

@github-actions
Copy link
Contributor

This PR has been marked as stale. This happened because:

  • It has been inactive for the past 3 months.
  • It hasn't been labeled `[Pri] BLOCKER`, `[Pri] High`, `[Status] Keep Open`, etc.

If this PR is still useful, please do a [trunk merge or rebase](https://github.com/Automattic/jetpack/blob/trunk/docs/git-workflow.md#keeping-your-branch-up-to-date) and otherwise make sure it's up to date and has clear testing instructions. You may also want to ping possible reviewers in case they've forgotten about it. Please close this PR if you think it's not valid anymore — if you do, please add a brief explanation.

If the PR is not updated (or at least commented on) in another month, it will be automatically closed.

@github-actions
Copy link
Contributor

This PR has been automatically closed as it has not been updated in some time. If you want to resume work on the PR, feel free to restore the branch and reopen the PR.

@github-actions github-actions bot closed this Sep 30, 2025
@github-actions github-actions bot deleted the feature/ai-assistant-editor branch September 30, 2025 06:42
@anomiex anomiex removed the [Status] Needs Review This PR is ready for review. label Dec 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Block] AI Assistant [Extension] AI Content Lens I don't care about code coverage for this PR Use this label to ignore the check for insufficient code coveage. [JS Package] AI Client [JS Package] Shared Extension Utils [Package] My Jetpack [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ RNA [Status] Stale [Type] Bug When a feature is broken and / or not performing as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants