Add bulk "Generate AI Summary" action to the posts list table#650
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #650 +/- ##
=============================================
+ Coverage 77.05% 77.17% +0.11%
- Complexity 2233 2252 +19
=============================================
Files 103 103
Lines 9216 9273 +57
=============================================
+ Hits 7101 7156 +55
- Misses 2115 2117 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
dkotter
left a comment
There was a problem hiding this comment.
Overall this looks good, left a few minor comments. In addition to those, we should look to get tests added here to cover these changes. Maybe some unit tests though likely won't provide much value but definitely want E2E tests to cover these changes
|
Hi @dkotter , I have updated the above requested changes and also added e2e and integration test cases (Took reference from other test cases). Let me know if this is fine or need any changes. |
…ai into feat/bulk-posts-summary
…edit.php action to register the bulk edit filters
| function removeExistingSummaryBlock( content: string ): string { | ||
| return content | ||
| .replace( | ||
| /<!-- wp:group \{[^}]*"aiGeneratedSummary":true[^}]*\} -->[\s\S]*?<!-- \/wp:group -->\n*/, |
There was a problem hiding this comment.
Seems like this regex could likely break, if for instance the attribute order changes. This is another place that would be great to standardize this in useSummaryGeneration.ts so we parse this block out the same in all contexts (if possible). Right now we have code in that file that parses content into blocks and then loops through all blocks to look at the block name and attributes that we may be able to use here
There was a problem hiding this comment.
Updated to use the flow as per useSummaryGeneration.ts and added the common function findSummaryBlock inside utils.ts
There was a problem hiding this comment.
There is an issue with using parse existing content. Trying to find a solution as parse is giving an empty array .
There was a problem hiding this comment.
Issue is fixed. as the parse()/createBlock() need block types registered first. Added a one-time registerCoreBlocks() call in bulk.ts
…rmalkar/ai into feat/bulk-posts-summary
dkotter
left a comment
There was a problem hiding this comment.
Changes look good here but looks like the addition of the @wordpress/block-library is breaking most of our automated checks. Looks like it's pulling in a newer version of React maybe?
|
@dkotter , Fixed the issue it was due to different version of node while installing the dependency on my local. |
…ai into feat/bulk-posts-summary
dkotter
left a comment
There was a problem hiding this comment.
Tested and is working well.
I think the last thing here is we recently added minimum content length requirements for most of our features and that doesn't seem to apply here for bulk generation. I would suggest we implement that for bulk generation to match individual generation
What?
Closes #614
Why?
AI summary generation is only available from within the block editor for a single post at a time. This PR adds a bulk workflow that lets users generate summaries for multiple posts in a single action directly from the list table.
How?
References from the existing Alt Text Generation bulk action pattern:
PHP (three new methods on
Summarizationexperiment):register_bulk_action()— appends"Generate AI Summary"to the bulk actions menu.handle_bulk_action()— validates capabilities (edit_posts+ per-postedit_post), then redirects back toedit.phpwithwpai_bulk_summary=1&wpai_post_ids=1,2,3query args.maybe_enqueue_bulk_assets()— detects the redirect on page reload, sanitizes post IDs, resolves the correct REST base from the current post type (so pages and custom post types work), and enqueues the bulk script with localized data (window.aiSummarizationBulkData).JavaScript (
src/experiments/summarization/bulk.ts, new file):DOMContentLoaded, readswindow.aiSummarizationBulkDataand processes posts sequentially.runAbility('ai/summarization', { context: postId })(the ability fetches post content from the DB itself), fetches raw block content via the REST API, strips any pre-existing summary block, prepends the new one, and saves bothcontentandmeta.ai_generated_summaryin a singleapiFetchPOST.wpai_bulk_summaryandwpai_post_idsfrom the URL viahistory.replaceState.Webpack (
webpack.config.js): Addsexperiments/summarization-bulkentry pointing tobulk.ts.Use of AI Tools
AI assistance: Yes
Tool(s): GitHub Copilot
Model(s): Claude Sonnet 4.6
Used for: Initial code skeleton. Final implementation reviewed and edited by me.
Testing Instructions
Prerequisites: An AI connector must be configured in Settings → Connectors.
ai_generated_summaryis addedScreenshots or screencast
Screen.Recording.2026-06-03.at.10.28.13.AM.mov
Changelog Entry