-
Notifications
You must be signed in to change notification settings - Fork 843
Jetpack AI: allow site editors to use Jetpack AI features #43181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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
|
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 Summary1 file is newly checked for coverage.
Full summary · PHP report · JS report Coverage check overridden by
I don't care about code coverage for this PR
|
9453f37 to
ad63467
Compare
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.
CGastrell
left a comment
There was a problem hiding this 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
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).

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:

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.

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?)
|
@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. |
dhasilva
left a comment
There was a problem hiding this 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
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 <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. |
dhasilva
left a comment
There was a problem hiding this 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!
CGastrell
left a comment
There was a problem hiding this 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:

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:


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:

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:

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:

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.
|
This PR has been marked as stale. This happened because:
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. |
|
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. |
Build upon #42750 to allow site editors to use Jetpack AI features.
Proposed changes:
has_connected_adminmethod to check if the site has an admin with a connected account.Other information:
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:
Please go through all these features and play with admin, non-admin users, and not connected site.