Skip to content

Migrate credentials from the AI Credentials setup to the new Connectors setup#286

Merged
dkotter merged 5 commits intoWordPress:developfrom
dkotter:feature/migrate-credentials
Mar 11, 2026
Merged

Migrate credentials from the AI Credentials setup to the new Connectors setup#286
dkotter merged 5 commits intoWordPress:developfrom
dkotter:feature/migrate-credentials

Conversation

@dkotter
Copy link
Collaborator

@dkotter dkotter commented Mar 9, 2026

What?

Partially closes #244

Migrates credentials to the new Connectors format

Why?

When using the bundled WP AI Client, credentials were stored under a single option and used on the AI Credentials screen. With the version of the AI Client that is in WP 7.0, there's a new Connectors setting screen and it stores credentials under separate options. We want to ensure existing users don't those their credentials so we migrate those over.

How?

  • Add a new Credential Migration class
  • Initiate this class early in our load process
  • If coming from a version less than 0.5.0 (assuming this will be our next version) it will check if we have existing credentials and migrates those to the new format
  • Adds unit tests

Use of AI Tools

Used Claude Code running Sonnet 4.6 to plan the migration approach and write most of the code (including tests). Fixed a few issues myself after manual testing

Testing Instructions

  1. Install the current released version of the plugin (v0.4.1)
  2. Add credentials for Anthropic, Google and OpenAI under Settings > AI Credentials
  3. Update the plugin to this PR
  4. Load a screen in the admin to trigger migration
  5. Ensure the wp_ai_client_provider_credentials option no longer exists
  6. Ensure these three options do exist: connectors_ai_anthropic_api_key, connectors_ai_google_api_key, and connectors_ai_openai_api_key
  7. Ensure you see these settings reflected on the new Settings > Connectors screen
Open WordPress Playground Preview

@dkotter dkotter added this to the 0.5.0 milestone Mar 9, 2026
@dkotter dkotter self-assigned this Mar 9, 2026
@github-actions
Copy link

github-actions bot commented Mar 9, 2026

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 <dkotter@git.wordpress.org>
Co-authored-by: jeffpaul <jeffpaul@git.wordpress.org>
Co-authored-by: Jameswlepage <isotropic@git.wordpress.org>

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 Mar 9, 2026

Codecov Report

❌ Patch coverage is 95.65217% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 58.01%. Comparing base (078c9f0) to head (3d58538).
⚠️ Report is 12 commits behind head on develop.

Files with missing lines Patch % Lines
includes/bootstrap.php 0.00% 1 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             develop     #286      +/-   ##
=============================================
+ Coverage      57.72%   58.01%   +0.29%     
- Complexity       567      576       +9     
=============================================
  Files             36       37       +1     
  Lines           2933     2956      +23     
=============================================
+ Hits            1693     1715      +22     
- Misses          1240     1241       +1     
Flag Coverage Δ
unit 58.01% <95.65%> (+0.29%) ⬆️

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 review from felixarntz and jeffpaul March 9, 2026 16:10
@dkotter dkotter changed the title Feature/migrate credentials Migrate credentials from the AI Credentials setup to the new Connectors setup Mar 10, 2026
@jeffpaul
Copy link
Member

Testing results....

Here's the AI Credentials screen on WP 7.0-beta3 and AIEx v0.4.1 before applying this PR:
Credentials-before-PR

Here's the same screen after applying this PR:
Credentials-after-PR

Here's the same screen after clicking Save Changes:
Credentials-after-save

Here's the Connectors screen after applying this PR and clicking Save Changes on the AI Credentials screen:
Connectors-after-PR

And here's the Connectors screen after installing the OAI provider plugin:
Connectors-after-OAI-install

Some thoughts...

  1. Should we add some text on the AI Credentials screen to direct folks to the Connectors page? Perhaps "Credentials for AI providers has moved to the Connectors settings page."? Probably worth a @todo message to remind us to come back and remove the AI Credentials page at some point as it'll confuse things to have that still around when Connectors is the primary/only route to add those in.
  2. Additionally to the above, after someone clicks Save Changes perhaps we redirect them to the Connectors page with a message there on which provider plugins to install based on their previously entered credentials?
  3. I'm not seeing the credentials carry over (had expected OAI to show valid credentials after installing that provider), is that something we can ensure works via this PR and when someone installs the right provider plugin?

@dkotter
Copy link
Collaborator Author

dkotter commented Mar 10, 2026

@jeffpaul Looking at those screenshots, I think you might have missed a step in testing here. That AI Credentials screen came from the old WP AI Client. That screen will no longer exist going forward for anyone running the latest version of this plugin (which those changes are also in this branch). So if you're seeing that screen, I think you're still running v0.4.1 instead of this branch.

It's tricky here to test as you need to follow these steps:

  1. Install WP 6.9
  2. Install the latest version of this plugin from .org, version 0.4.1
  3. Add credentials
  4. Update your environment to WP 7.0-beta3
  5. Update/replace the plugin so it's running this branch, which will include all the changes merged into develop that remove the AI Client
  6. At this point, the AI Credentials screen won't exist anymore and credentials should be migrated

In regards to your questions:

Should we add some text on the AI Credentials screen to direct folks to the Connectors page?

Additionally to the above, after someone clicks Save Changes perhaps we redirect them to the Connectors page with a message there on which provider plugins to install based on their previously entered credentials?

As mentioned above, this screen no longer exists so nothing to add or change here.

I'm not seeing the credentials carry over (had expected OAI to show valid credentials after installing that provider), is that something we can ensure works via this PR and when someone installs the right provider plugin?

Just tested again and this did work for me, both in scenarios where an AI Provider plugin was already installed and active and when the plugin wasn't active / installed but was activated / installed as part of the Connectors flow. I think it's not working for you due to the above note around ensuring you're testing with this branch.

Copy link
Member

@jeffpaul jeffpaul left a comment

Choose a reason for hiding this comment

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

Ok, ran through things again and can't seem to get to the AI Credentials screen with that Save Changes button and things work as expected.

Nice touch updating the Credentials row action from the Plugins list to Connectors!

@dkotter dkotter merged commit f8de37d into WordPress:develop Mar 11, 2026
18 of 19 checks passed
@dkotter dkotter deleted the feature/migrate-credentials branch March 11, 2026 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pathway to 7.0

2 participants