Skip to content

feat: add settings import/export functionality - #734

Merged
dkotter merged 25 commits into
WordPress:developfrom
coderGtm:feature/import-export-config
Jul 24, 2026
Merged

feat: add settings import/export functionality#734
dkotter merged 25 commits into
WordPress:developfrom
coderGtm:feature/import-export-config

Conversation

@coderGtm

@coderGtm coderGtm commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

What?

Closes #191

This PR implements the ability to export and import non-sensitive AI configuration settings and introduces a dedicated AI section in WordPress Site Health.

Why?

Allowing users to move AI configurations between environments (e.g., staging to production, multi-site etc.) improves the developer experience. By excluding sensitive credentials from the export, we ensure security while maintaining portability. The Site Health integration provides administrators with a quick overview of the plugin's status and credential health.

How?

  • REST API: Created includes/REST/Settings_IO_Controller.php to handle GET /ai/v1/settings/export and POST /ai/v1/settings/import.
  • Security: Implemented SENSITIVE_PATTERNS filtering to ensure API keys, tokens, and secrets are never exported or overwritten during import.
  • Site Health: Added includes/Admin/Site_Health.php to provide debug information (version, enabled features, credential status) and a status test for connectivity.
  • UI/UX:
    • Added "Export settings" and "Import settings" to the AI settings menu in routes/ai-home/stage.tsx.
    • Implemented a confirmation modal for imports.
  • Tests: Added comprehensive integration tests in tests/Integration/Includes/REST/Settings_IO_ControllerTest.php and tests/Integration/Includes/Admin/Site_HealthTest.php.

Use of AI Tools

AI assistance: Yes
Tool(s): GitHub Copilot
Model(s): Claude Sonnet 4.6, GPT-4o
Used for: Authoring the codebase exploration, UI components, and the integration test suite.

Testing Instructions

  1. Navigate to AI Settings.
  2. Open the kebab menu (three vertical dots) in the top right.
  3. Click Export settings. A JSON file containing your current toggles and developer configurations (but no API keys) should download.
  4. Toggle several features to different states.
  5. Click Import settings in the menu and select the previously downloaded file.
  6. Confirm the prompt "This will overwrite existing AI settings."
  7. Verification: The UI should update immediately to reflect the imported settings without a page refresh.
  8. Navigate to Tools > Site Health.
  9. In the Status tab, verify the "AI Plugin" test results.
  10. In the Info tab, verify the "AI Plugin" section contains correct metadata about your setup.

Screenshots or screencast

Menu Items:
Screenshot 2026-06-16 at 1 56 51 PM

Confirmation prompt before completing import:
Screenshot 2026-06-16 at 1 57 51 PM

Changelog Entry

Added - Import/Export functionality for non-sensitive AI settings.
Added - AI-specific Site Health integration and status tests.

Open WordPress Playground Preview

@github-actions

Copy link
Copy Markdown

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

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

@coderGtm
coderGtm marked this pull request as draft June 16, 2026 09:26
@coderGtm

Copy link
Copy Markdown
Contributor Author

The failing JavaScript quality check is due to a conflict between eslint and typescript. While eslint prefers dot notation, typescript complains about it (TS4111). Should I suppress the eslint error?

@dkotter

dkotter commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

The failing JavaScript quality check is due to a conflict between eslint and typescript. While eslint prefers dot notation, typescript complains about it (TS4111). Should I suppress the eslint error?

We do have a number of these that we already ignore with inline statements so I think that's fine

@coderGtm
coderGtm marked this pull request as ready for review June 19, 2026 12:34

@dkotter dkotter left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Overall this looks really good, left a few comments. In addition, an E2E test here would be nice to verify the import/export options are available

),
'description' => sprintf(
'<p>%s</p>',
__( 'At least one AI connector has credentials configured and is ready to use.', 'ai' )

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

So this isn't entirely accurate. The has_ai_credentials function will tell us if a Provider has credentials set but doesn't tell us if the credentials are valid. We do have a new is_connector_configured function that we could use here instead

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Well, I am not entirely convinced that Site Health checks should also check the validity of the credentials. But if you insist, I can implement it that way as I am not able to side either way on this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't feel strongly on if we should check validity of credentials here but we can't accurately say At least one AI connector has credentials configured and is ready to use if we just check if credentials exist. I'd suggest we at least modify that message and just remove the and is ready to use part

Comment thread routes/ai-home/stage.tsx Outdated
Comment thread includes/REST/Settings_IO_Controller.php Outdated
Comment thread includes/REST/Settings_IO_Controller.php Outdated
Comment thread includes/Main.php Outdated
@dkotter dkotter added this to the Future Release milestone Jun 23, 2026
@coderGtm

Copy link
Copy Markdown
Contributor Author

Thanks @dkotter for reviewing this. I will work on the feedback over the days and request a review again.

@jeffpaul jeffpaul modified the milestones: Future Release, 1.2.0 Jun 26, 2026
@coderGtm
coderGtm requested a review from a team July 7, 2026 05:59
@codecov

codecov Bot commented Jul 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.29915% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.18%. Comparing base (35a15e1) to head (4e62810).

Files with missing lines Patch % Lines
includes/Admin/Site_Health.php 94.50% 5 Missing ⚠️
includes/REST/Settings_IO_Controller.php 96.42% 5 Missing ⚠️
includes/Main.php 50.00% 1 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             develop     #734      +/-   ##
=============================================
+ Coverage      79.83%   80.18%   +0.35%     
- Complexity      2475     2526      +51     
=============================================
  Files            104      106       +2     
  Lines          10006    10240     +234     
=============================================
+ Hits            7988     8211     +223     
- Misses          2018     2029      +11     
Flag Coverage Δ
unit 80.18% <95.29%> (+0.35%) ⬆️

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

☔ View full report in Codecov by Harness.
📢 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.

@jeffpaul

Copy link
Copy Markdown
Member

@coderGtm looks like a merge conflict, then perhaps good for re-review on our end?

@coderGtm

Copy link
Copy Markdown
Contributor Author

@jeffpaul I am yet to add the e2e test and checking the validation and sanitization again. So once I do those and resolve the merge conflict, I'll manually request a re-review.

Thanks for checking it out.

@jeffpaul jeffpaul modified the milestones: 1.2.0, 1.3.0 Jul 13, 2026
@coderGtm

Copy link
Copy Markdown
Contributor Author

I have made the suggested improvements to this PR and it is ready for re-review.

cc: @jeffpaul @dkotter

@coderGtm
coderGtm requested a review from dkotter July 21, 2026 06:15
Comment thread includes/REST/Settings_IO_Controller.php Outdated
Comment thread routes/ai-home/hooks/use-settings-import-export.ts Outdated
@dkotter
dkotter requested a review from jeffpaul as a code owner July 24, 2026 16:43
@dkotter
dkotter merged commit 7d11901 into WordPress:develop Jul 24, 2026
24 checks passed
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.

Add import/export support for AI settings and provider configuration

3 participants