-
Notifications
You must be signed in to change notification settings - Fork 822
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
base: trunk
Are you sure you want to change the base?
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 reverts commit ad63467.
85a8628
to
88f87d4
Compare
In order to allow non-admin users to use Jetpack AI we need to make the request as blog instead of user because the editor won't have connection token. Luckily, we don't need the user_id in any of the Jetpack AI endpoints as we're only relying on the blog_id.
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 #42750 by allowing site editors to use Jetpack AI features, adjusting the connection check from general user to admin status.
- Replaces calls to isUserConnected with isAdminConnected in the AI Assistant block files.
- Introduces a new isAdminConnected utility in the shared-extension-utils package and updates its export.
Reviewed Changes
Copilot reviewed 4 out of 11 changed files in this pull request and generated no comments.
File | Description |
---|---|
projects/plugins/jetpack/extensions/blocks/ai-assistant/extensions/lib/can-ai-assistant-be-enabled.ts | Replaces isUserConnected with isAdminConnected to check for a connected admin. |
projects/plugins/jetpack/extensions/blocks/ai-assistant/edit.js | Updates import and connection check to leverage isAdminConnected. |
projects/js-packages/shared-extension-utils/src/is-admin-connected.js | Adds a new function to determine admin connection status. |
projects/js-packages/shared-extension-utils/index.js | Exports the new isAdminConnected function. |
Files not reviewed (7)
- projects/js-packages/shared-extension-utils/changelog/is-admin-connected: 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/jetpack/_inc/lib/class-jetpack-ai-helper.php: 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
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.
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. |
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. |
Build upon #42750 to allow site editors to use Jetpack AI features.
Proposed changes:
has_connected_admin
method 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.