Skip to content

Utilize the new client-side Abilities API#364

Open
dkotter wants to merge 22 commits intoWordPress:developfrom
dkotter:update/client-ability-execution
Open

Utilize the new client-side Abilities API#364
dkotter wants to merge 22 commits intoWordPress:developfrom
dkotter:update/client-ability-execution

Conversation

@dkotter
Copy link
Copy Markdown
Collaborator

@dkotter dkotter commented Apr 2, 2026

What?

Closes #346

Ensure we properly use the new client-side Abilities API and ensure we fix all errors with existing Abilities

Why?

We currently have a helper method that attempted to use the client-side Abilities API, falling back to making direct API requests if it wasn't available. This was based on the older client-side API and so needed updating with the new version that is shipping with WordPress 7.0 (see post).

In doing this, ran into a number of issues that prevented things from working properly. These issues were silently ignored when using direct API requests but the validation the client-side API uses is more strict and thus surfaced these errors. All of those have been fixed up here.

How?

  • Update our runAbility helper function to use the new client-side Abilities API
  • Remove the use of sanitize_callback from all of our Ability schemas as this isn't supported by the Abilities API, just the REST API
  • Ensure we have proper sanitization ourselves due to the removal of the above
  • Ensure the @wordpress/core-abilities script module is loaded anytime an Ability needs it
  • Fix an issue where block content was sometimes being returned as an object instead of a string, causing errors with the client-side Abilities API
  • Fix some new eslint errors that surfaced after updating dependencies

Use of AI Tools

Used Cursor running GPT-5.3 Codex to figure out how to properly load the @wordpress/core-abilities script module based on our current setup. Also used it to investigate what schema options are supported and verify sanitize_callback was not. All other work done by me

Testing Instructions

  1. Pull this PR down and run npm i && npm run build
  2. For each Experiment that utilizes AI (everything besides the Abilities Explorer), turn those on one-by-one
  3. Test the Experiment you turned on, ensuring you have the browser console open. The Experiment should function the same as it always has and you shouldn't see any errors or messages in the console. Importantly, shouldn't see [AI] Client ability execution unavailable. Falling back to REST.
  4. Continuing testing each Experiment ensuring they all still work as expected
Open WordPress Playground Preview

dkotter added 15 commits April 1, 2026 16:58
…put schema and ensure we have our own sanitization
… schema and ensure we have our own sanitization
…input schema and ensure we have our own sanitization
… input schema and ensure we have our own sanitization
…tion input schema and ensure we have our own sanitization
…put schema and ensure we have our own sanitization
…schema and ensure we have our own sanitization
…nstead of a string. Add a console error message when making a request using the client-side Abilities API for easier debugging
@dkotter dkotter added this to the 0.7.0 milestone Apr 2, 2026
@dkotter dkotter self-assigned this Apr 2, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 2, 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: jorgefilipecosta <jorgefilipecosta@git.wordpress.org>
Co-authored-by: gziolo <gziolo@git.wordpress.org>
Co-authored-by: ocean90 <ocean90@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
Copy Markdown

codecov bot commented Apr 2, 2026

Codecov Report

❌ Patch coverage is 86.30137% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.59%. Comparing base (86b224d) to head (e99ea97).

Files with missing lines Patch % Lines
includes/Abilities/Image/Generate_Image.php 57.14% 3 Missing ⚠️
.../Content_Classification/Content_Classification.php 0.00% 1 Missing ⚠️
...eriments/Excerpt_Generation/Excerpt_Generation.php 0.00% 1 Missing ⚠️
.../Experiments/Image_Generation/Image_Generation.php 0.00% 1 Missing ⚠️
.../Experiments/Meta_Description/Meta_Description.php 0.00% 1 Missing ⚠️
includes/Experiments/Review_Notes/Review_Notes.php 0.00% 1 Missing ⚠️
...cludes/Experiments/Summarization/Summarization.php 0.00% 1 Missing ⚠️
.../Experiments/Title_Generation/Title_Generation.php 0.00% 1 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             develop     #364      +/-   ##
=============================================
- Coverage      65.75%   65.59%   -0.16%     
- Complexity       763      771       +8     
=============================================
  Files             53       53              
  Lines           3863     3851      -12     
=============================================
- Hits            2540     2526      -14     
- Misses          1323     1325       +2     
Flag Coverage Δ
unit 65.59% <86.30%> (-0.16%) ⬇️

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.

jeffpaul
jeffpaul previously approved these changes Apr 6, 2026
@jeffpaul
Copy link
Copy Markdown
Member

jeffpaul commented Apr 6, 2026

Holding on merge here as its unclear from #346 (comment) whether we should proceed with this PR or await a change in Gutenberg/core that we may then need to adjust for in the AI plugin.

@jeffpaul jeffpaul modified the milestones: 0.7.0, 0.8.0 Apr 8, 2026
@dkotter
Copy link
Copy Markdown
Collaborator Author

dkotter commented Apr 9, 2026

Making a note for myself that this PR needs updated to account for the newly merged Abilities, namely Content Classification and Meta Descriptions

Edit: Now updated in b3846a1 and e99ea97. If additional Abilities get merged prior to this PR being merged, will update again

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.

Executing summarization ability with @wordpress/abilities in WordPress 7.0 doesn't work due to invalid schema

2 participants