Skip to content

Remove unused ai service class - #905

Open
theaminulai wants to merge 9 commits into
WordPress:developfrom
theaminulai:Remove-unused-AI_Service-class
Open

Remove unused ai service class#905
theaminulai wants to merge 9 commits into
WordPress:developfrom
theaminulai:Remove-unused-AI_Service-class

Conversation

@theaminulai

@theaminulai theaminulai commented Jul 29, 2026

Copy link
Copy Markdown
Member

What?

See #233

Removes the unused AI_Service layer (includes/Services/AI_Service.php), its test file, and the get_ai_service() helper.

Why?

AI_Service was introduced in #101 (0.2.1) as a proposed centralized layer for AI provider access, and #233 tracked refactoring the experiments to use it. A follow-up PR (#898) that wired several abilities through AI_Service was closed, since per [@jeffpaul's comment](#233 (comment)) and @dkotter's review on #898, the layer isn't used anywhere, hasn't been adopted by newer experiment PRs, and doesn't provide value over calling wp_ai_client_prompt() directly. Rather than carry the dead code forward, this PR removes it.

How?

  • Deleted includes/Services/AI_Service.php (the create_textgen_prompt() wrapper and singleton).
  • Deleted tests/Integration/Includes/Services/AI_ServiceTest.php.
  • Removed the get_ai_service() helper and its use WordPress\AI\Services\AI_Service; import from includes/helpers.php. The ai_experiments_service_initialized action referenced only in the deleted test was never fired anywhere (do_action() for it doesn't exist in the codebase), so no hook needs replacing.
  • Updated docs/ARCHITECTURE_OVERVIEW.md and docs/experiments/multi-provider-support.md to drop references to AI_Service (the includes/Services/ folder still exists for Guidelines.php).
  • Added a changelog entry under Unreleased; left the historical 0.2.1 entry describing the original introduction untouched.
  • Confirmed via a codebase-wide search that no ability, experiment, or feature calls AI_Service::get_instance() or get_ai_service() — all AI calls already go through wp_ai_client_prompt() directly, so this is a pure removal with no functional change.

Testing Instructions

  1. Confirm nothing else references the removed class or helper:
    • Search the codebase for AI_Service and get_ai_service — no matches should remain outside historical CHANGELOG entries.
  2. Run the PHPUnit integration suite to confirm no test depends on the removed class:
    • composer test
  3. Spot-check that Excerpt Generation, Title Generation, Content Summarization, Alt Text Generation, and Image Generation still work end-to-end with a connected provider (they were unaffected by this change, but worth a smoke test).
Open WordPress Playground Preview

AI_Service was introduced in WordPress#101 (0.2.1) as a proposed centralized
layer for AI provider access. It was never adopted by any experiment
or ability, and a follow-up PR (WordPress#898) to wire it in was closed as not
wanted. Removing the dead code rather than carrying it forward.

Refs WordPress#233
Companion removal to the AI_Service class deletion. No other test
depends on this file.

Refs WordPress#233
Drops the get_ai_service() function and its AI_Service use-import.
No longer needed now that AI_Service itself is gone; experiments and
abilities call wp_ai_client_prompt() directly.

Refs WordPress#233
The Services/ folder description referenced AI_Service; updated to
reflect that it now only contains Guidelines.

Refs WordPress#233
Drops the includes/Services/AI_Service.php entry from the Related
Files list since the file no longer exists.

Refs WordPress#233
Documents the removal under Unreleased. The historical 0.2.1 entry
describing AI_Service's original introduction is left untouched.

Refs WordPress#233
@theaminulai
theaminulai requested a review from a team July 29, 2026 03:48
@theaminulai
theaminulai requested a review from jeffpaul as a code owner July 29, 2026 03:48
@github-actions

github-actions Bot commented Jul 29, 2026

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: theaminulai <theaminuldev@git.wordpress.org>
Co-authored-by: dkotter <dkotter@git.wordpress.org>

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

@codecov

codecov Bot commented Jul 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.44%. Comparing base (7e92a70) to head (d1440a5).

Additional details and impacted files
@@            Coverage Diff             @@
##             develop     #905   +/-   ##
==========================================
  Coverage      80.43%   80.44%           
- Complexity      2565     2566    +1     
==========================================
  Files            110      110           
  Lines          10448    10451    +3     
==========================================
+ Hits            8404     8407    +3     
  Misses          2044     2044           
Flag Coverage Δ
unit 80.44% <100.00%> (+<0.01%) ⬆️

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.

@dkotter dkotter added this to the 1.3.0 milestone Jul 29, 2026

@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.

@theaminulai Thanks for the PR! In thinking about it a bit more, since the class is public and the helper function is also public, better to deprecate those and remove later than just remove entirely. Otherwise anyone that is relying on those will hit fatal errors.

I've pushed changes to handle that deprecation process but let me know if all of that looks good to you. In addition, would be great to get the PR title and description updated since we're not removing anything in this release, just deprecating

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.

2 participants