Skip to content

Conversation

@gmjuhasz
Copy link
Contributor

@gmjuhasz gmjuhasz commented Dec 1, 2025

Closes SOCIAL-253
Fixes SOCIAL-240

Proposed changes:

Reused the generic AI modal from ai-client, and integrated it into our media selector section

Testing instructions:

Prerequisites:

  • You need the new feature flag to test this: Add the feature flag to your site: Run wpsh > add_blog_sticker( 'jetpack-social-unified-ui-v1', null, null, <your-blog-id> );
  • The new preview modal is not functional, so you need to use the old one: In projects/js-packages/publicize-components/src/components/form/index.tsx negate siteHasFeature( features.UNIFIED_UI_V1 ) so you have the old modal
  • Have the Jetpack Social plan

Testing:

  • Create a new post
  • Go to the Social sidebar
  • In the new media section select generate image
  • The AI generation modal should pop up.
  • Generate an image you like, then select it.
  • The media section should switch to the custom image type, with your image selected from the media lib.
  • Check the previews, they should reflect the image.
  • Share the post and check what gets shared, it should have the AI generated image.
CleanShot.2025-12-04.at.11.54.08.mp4

@github-actions
Copy link
Contributor

github-actions bot commented Dec 1, 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 add/social/ai-image-generation-modal-poc branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack add/social/ai-image-generation-modal-poc
bin/jetpack-downloader test jetpack-mu-wpcom-plugin add/social/ai-image-generation-modal-poc

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
Copy link
Contributor

github-actions bot commented Dec 1, 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 🤖


🔴 Action required: We would recommend that you add a section to the PR description to specify whether this PR includes any changes to data or privacy, like so:

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

My PR adds *x* and *y*.

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: January 6, 2026

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.


Social plugin:

No scheduled milestone found for this plugin.

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 Dec 1, 2025
@github-actions github-actions bot added [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] Social Issues about the Jetpack Social plugin [Tests] Includes Tests labels Dec 2, 2025
@gmjuhasz gmjuhasz force-pushed the add/social/ai-image-generation-modal-poc branch from bd6fa0d to 0876eee Compare December 2, 2025 12:15
@github-actions github-actions bot added the [Extension] Social Previews Social Preview block editor plugin label Dec 4, 2025
@gmjuhasz gmjuhasz changed the title [POC] Reuse GeneralPurposeImage component in the Social sidebar Social: Generate AI image for media from the sidebar Dec 4, 2025
@gmjuhasz gmjuhasz marked this pull request as ready for review December 4, 2025 10:56
@gmjuhasz gmjuhasz self-assigned this Dec 4, 2025
@gmjuhasz gmjuhasz requested a review from a team December 4, 2025 10:56
@gmjuhasz gmjuhasz added the [Type] Feature Development of a new feature label Dec 4, 2025
@gmjuhasz gmjuhasz added Coverage tests to be added later Use to ignore the Code coverage requirement check when tests will be added in a follow-up PR 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 Dec 4, 2025
Copy link
Contributor

@robertsreberski robertsreberski left a comment

Choose a reason for hiding this comment

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

It simply works good 👌

I had a couple of questions below - will approve once we discuss them, but in general everything works good!

// Use 'media-library' as the source since the AI image is uploaded to the media library
updateJetpackSocialOptions( {
media_source: 'media-library',
attached_media: [ { id, url, type: 'image/png' } ],
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we assume it's always image/png?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes - AI-generated images are always PNG (they're returned as base64-encoded PNG from the AI service). Added a comment to clarify. e4d1448

Copy link
Contributor

Choose a reason for hiding this comment

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

Alright, I see that now.

What I would propose here is to support the parameter mime_type in the function - to be coherent with WPMediaObject type in handleAiImageSelect(), with mime being optional and defaulting to image/png.

While I see that it's AI code that isn't considering other types, and that it might be replaced soon by Image Studio, it's good to be prepared for the correct object (or at least typed) to reach the input of this function. Otherwise, we end up with a hardcoded logic that requires a refactor - and I'm not sure whether all AI providers produce the png same as DALL-e.

I've run Claude to backtrack where it comes from:

CleanShot 2025-12-08 at 16 30 15@2x

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in efc7a83

media.push( {
type: attachedItem.type,
url: attachedItem.url,
alt: '',
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't the attachedItem have the alt text? Should we maybe set one here?

I would assume that AI generated image has the alt, as of the description of what is happening on the image 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. Simplified the code to always fetch from the entity record, which includes alt_text from the media library. However, the AI image generation flow doesn't currently set alt text on the media item when saving - that would require changes in ai-client. Worth tracking as a follow-up?

Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps worth tracking - but I also understand they are working on this Image Studio, right?

Definitely better to keep it as it comes - instead of building our own logic that might become a bottleneck

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes they are, so not sure if it's worth fixing before that

robertsreberski
robertsreberski previously approved these changes Dec 9, 2025
Copy link
Contributor

@robertsreberski robertsreberski left a comment

Choose a reason for hiding this comment

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

Code looks good to me, works great as well!

Just last comment about making sure the typing in consistent with what we already have in Publicize


// Handle AI image selection
const handleAiImageSelect = useCallback(
( { id, url, mime_type }: { id: number; url: string; mime_type?: string } ) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we use WPMediaObject type here, rather than introducing inline custom typing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Coverage tests to be added later Use to ignore the Code coverage requirement check when tests will be added in a follow-up PR [Extension] Social Previews Social Preview block editor plugin [Feature] Publicize Now Jetpack Social, auto-sharing [JS Package] AI Client [JS Package] Publicize Components [Package] Publicize [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] Social Issues about the Jetpack Social plugin RNA [Status] In Progress [Tests] Includes Tests [Type] Feature Development of a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants