Gate image generation UI on provider support detection#679
Conversation
Connectors may be authenticated without exposing an image-generation-capable model. Detect this server-side via has_image_generation_support() and surface it to the editor so the prompt form and featured-image action show a clear "connect a provider" notice instead of failing on generate. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The actions prop was added with inconsistent inline indentation. Reformat it to match the surrounding code style for readability. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
| $connectors = get_ai_connectors(); | ||
|
|
||
| foreach ( array_keys( $connectors ) as $connector_id ) { | ||
| if ( ! has_connector_authentication( $connector_id ) ) { |
There was a problem hiding this comment.
What do you think about using is_connector_configured() here instead? I think there are models that allow image generation without requiring auth.
There was a problem hiding this comment.
The check for has_connector_authentication() is performed locally. However, when using is_connector_configured(), I think it actually sends a request to the external provider API.
Although I haven't investigated thoroughly yet, I believe we'll need to implement caching in the is_connector_configured helper function to likely suppress unnecessary token consumption and requests.
For now, leaving it as has_connector_authentication() might be acceptable.
|
This idea has been brought up multiple times and the conclusion we've come to in the past is to leave things as they are:
The discussion in the past has mostly focused on if we should completely remove the UI if there isn't a valid Connector while this PR approaches it differently, where the general UI is still there but you can't fully trigger it. I'm fine with considering this approach but ideally these are things that should be talked through prior to trying to implement so we can ensure we're all on the same page first. For example, my opinion here is if we implement this for image generation, we should likely implement this for all Features to keep parity. |
|
Thanks for the review. The purpose of this PR is to prevent users from engaging in futile tasks. For example, users would be disappointed if they entered a long prompt text, clicked the Generate button, and then encountered an error. I am happy to follow up if there are any other areas that need to be addressed. |
Related to https://core.trac.wordpress.org/ticket/64917#comment:14
What?
The server checks if any connectors supporting image generation are registered and passes this information to the client side. If no connectors supporting image generation are found, a warning is displayed without sending a REST request.
Why?
It is unhelpful that users can attempt to generate images by entering prompts, even though there are no connectors supporting image generation.
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 4.8
Used for: Drafting this pull request description. Implementation was reviewed by me.
Testing Instructions
Screenshot
Image Block:

Media Library:

Featured Image:

Changelog Entry