Skip to content

Refactor ai organization#23031

Merged
thijsoo merged 3 commits intotrunkfrom
refactor-ai-organization
Mar 12, 2026
Merged

Refactor ai organization#23031
thijsoo merged 3 commits intotrunkfrom
refactor-ai-organization

Conversation

@pls78
Copy link
Copy Markdown
Member

@pls78 pls78 commented Feb 25, 2026

Context

  • We want to tidy up the AI-related code.

Summary

This PR can be summarized in the following changelog entry:

  • Re-organizes AI-related code by collecting all modules into an ai parent directory and consequently losing the AI_ namespace/class prefix

Relevant technical choices:

  • All the AI-related modules dropped the AI_ prefix and are now under an ai parent directory.
  • The old code structure has been kept beside the new one to keep supporting older version of Yoast SEO Premium
  • Tests covering the duplicated code (i.e. the code in the old directory structure) has been kept for the sake of code coverage.

Test instructions

Test instructions for the acceptance test before the PR gets merged

This PR can be acceptance tested by following these steps:

  • Smoke test the Free AI features
  • Make sure you perform tests under the following circumstances and confirm that AI tools work as intended:
    • Only Free Activated (this PR)
    • Free and Premium up-to-date (this PR and corresponding Premium PR)
    • This PR and an older version of Premium

Relevant test scenarios

  • Changes should be tested with the browser console open
  • Changes should be tested on different posts/pages/taxonomies/custom post types/custom taxonomies
  • Changes should be tested on different editors (Default Block/Gutenberg/Classic/Elementor/other)
  • Changes should be tested on different browsers
  • Changes should be tested on multisite

Test instructions for QA when the code is in the RC

  • QA should use the same steps as above.

Impact check

This PR affects the following parts of the plugin, which may require extra testing:

  • N/A

Other environments

  • This PR also affects Shopify. I have added a changelog entry starting with [shopify-seo], added test instructions for Shopify and attached the Shopify label to this PR.
  • This PR also affects Yoast SEO for Google Docs. I have added a changelog entry starting with [yoast-doc-extension], added test instructions for Yoast SEO for Google Docs and attached the Google Docs Add-on label to this PR.

Documentation

  • I have written documentation for this change. For example, comments in the Relevant technical choices, comments in the code, documentation on Confluence / shared Google Drive / Yoast developer portal, or other.

Quality assurance

  • I have tested this code to the best of my abilities.
  • During testing, I had activated all plugins that Yoast SEO provides integrations for.
  • I have added adapted unit tests to verify the code works as intended.
  • If any part of the code is behind a feature flag, my test instructions also cover cases where the feature flag is switched off.
  • I have written this PR in accordance with my team's definition of done.
  • I have checked that the base branch is correctly set.
  • I have run grunt build:images and commited the results, if my PR introduces new images or SVGs.

Innovation

  • No innovation project is applicable for this PR.
  • This PR falls under an innovation project. I have attached the innovation label.
  • I have added my hours to the WBSO document.

Fixes https://github.com/Yoast/reserved-tasks/issues/632

Original ones are kept for the sake of code coverage
@pls78 pls78 added the changelog: non-user-facing Needs to be included in the 'Non-userfacing' category in the changelog label Feb 25, 2026
@pls78 pls78 marked this pull request as ready for review March 2, 2026 09:43
@coveralls
Copy link
Copy Markdown

coveralls commented Mar 2, 2026

Pull Request Test Coverage Report for Build ef2afb7ec132ebfd9ef01d989a8e4d86f626598a

Details

  • 718 of 759 (94.6%) changed or added relevant lines in 38 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall first build on refactor-ai-organization at 49.871%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/ai/http-request/domain/exceptions/wp-request-exception.php 0 2 0.0%
src/ai/http-request/domain/exceptions/payment-required-exception.php 0 5 0.0%
src/ai/http-request/domain/exceptions/remote-request-exception.php 0 5 0.0%
src/ai/http-request/domain/request.php 0 13 0.0%
src/ai/http-request/domain/response.php 0 16 0.0%
Totals Coverage Status
Change from base Build ccc9ca3c35e350c3a2c5b2d9266ff2f924a477fd: 49.9%
Covered Lines: 19083
Relevant Lines: 38265

💛 - Coveralls

Copy link
Copy Markdown
Contributor

@thijsoo thijsoo left a comment

Choose a reason for hiding this comment

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

The code looks well moved. But like we discussed I would like to investigate if we can make the BC easier by aliassing the current structure with either class_alias or maybe some DI magic.

@pls78 pls78 force-pushed the refactor-ai-organization branch from 747267f to 25ffa8e Compare March 9, 2026 14:19
@pls78
Copy link
Copy Markdown
Member Author

pls78 commented Mar 9, 2026

The code looks well moved. But like we discussed I would like to investigate if we can make the BC easier by aliassing the current structure with either class_alias or maybe some DI magic.

I tried using class_alias but as they are not injected, Premium would still refer the old namespaces. So I tried adding an autoloader that would run first and maps old namespaces to new ones, but the result has been the same. 🤷‍♂️
I vote for leaving the old code beside the new one for a couple of versions and then remove it.

Copy link
Copy Markdown
Contributor

@thijsoo thijsoo left a comment

Choose a reason for hiding this comment

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

CR + ACC 👍

@thijsoo thijsoo added this to the 27.3 milestone Mar 12, 2026
@thijsoo thijsoo merged commit 3b129c2 into trunk Mar 12, 2026
50 checks passed
@thijsoo thijsoo deleted the refactor-ai-organization branch March 12, 2026 11:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog: non-user-facing Needs to be included in the 'Non-userfacing' category in the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants