Skip to content

Conversation

@dkotter
Copy link
Collaborator

@dkotter dkotter commented Dec 1, 2025

What?

Remove the check for valid AI credentials when checking if an Experiment is enabled.

Why?

In #100, I added checks that run on our settings screen to verify we have valid AI credentials set and if not, show an error message alerting the user. This is helpful for users first setting things up, as this will help guide them through the process of adding AI credentials before turning on an Experiment.

In addition, I added a similar check when we run our is_enabled check at the Experiment level. The goal here was to avoid showing an Experiment if the AI credentials are no longer valid (for instance, if someone revoked their API key).

The issue I just realized is that our is_enabled check runs basically everywhere, so by running our validation check there, we end up making an API request to the models endpoint on each page load, including the front-end. While this request runs pretty quickly, it's not great for performance to have that always run.

How?

I considered two different approaches here to fix the problem:

  1. Just remove the validation check all together from the is_enabled check and ensure we have proper error handling in each Experiment for situations where the AI credentials no longer work
  2. Move the validation check into the Experiment level. For example, for Title Generation, add this check prior to enqueuing assets and within our permission or execution callback of the Ability

Open to thoughts but after thinking it over, actually feels like a better user experience to go with the former. So the Experiment stays enabled, the UI is still available but when triggered, an error message is shown that let's the user know something went wrong and hopefully prompts them to go check their credentials.

Testing Instructions

  1. Check out this PR
  2. Go to the AI Experiments settings page and ensure an error message is shown, prompting you to enter credentials
  3. Add invalid credentials and go back to the AI Experiment settings page and ensure a new error message is shown
  4. Add valid credentials and ensure you can now enable Experiments
  5. Enable the Title Generation Experiment and ensure this works as expected
  6. Go update your AI credentials with a random value, making that invalid now
  7. Go try out the Title Generation Experiment again and ensure the UI exists but you get an error message

@dkotter dkotter self-assigned this Dec 1, 2025
@dkotter dkotter added this to the 0.2.0 milestone Dec 1, 2025
@github-actions
Copy link

github-actions bot commented Dec 1, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: dkotter <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@codecov
Copy link

codecov bot commented Dec 1, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 27.41%. Comparing base (4bbc5ea) to head (f2b6cc3).
⚠️ Report is 11 commits behind head on develop.

Additional details and impacted files
@@              Coverage Diff              @@
##             develop     #120      +/-   ##
=============================================
- Coverage      29.37%   27.41%   -1.97%     
- Complexity       145      152       +7     
=============================================
  Files             14       14              
  Lines            885      901      +16     
=============================================
- Hits             260      247      -13     
- Misses           625      654      +29     
Flag Coverage Δ
unit 27.41% <ø> (-1.97%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dkotter dkotter requested a review from felixarntz December 1, 2025 18:47
@jeffpaul jeffpaul merged commit 2ca5afd into WordPress:develop Dec 1, 2025
22 of 24 checks passed
@dkotter dkotter deleted the fix/remove-api-check branch December 1, 2025 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

3 participants