Skip to content

Add bulk "Generate AI Summary" action to the posts list table#650

Merged
dkotter merged 31 commits into
WordPress:developfrom
prasadkarmalkar:feat/bulk-posts-summary
Jul 13, 2026
Merged

Add bulk "Generate AI Summary" action to the posts list table#650
dkotter merged 31 commits into
WordPress:developfrom
prasadkarmalkar:feat/bulk-posts-summary

Conversation

@prasadkarmalkar

@prasadkarmalkar prasadkarmalkar commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

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:

  1. PHP (three new methods on Summarization experiment):

    • register_bulk_action() — appends "Generate AI Summary" to the bulk actions menu.
    • handle_bulk_action() — validates capabilities (edit_posts + per-post edit_post), then redirects back to edit.php with wpai_bulk_summary=1&wpai_post_ids=1,2,3 query 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).
  2. JavaScript (src/experiments/summarization/bulk.ts, new file):

    • On DOMContentLoaded, reads window.aiSummarizationBulkData and processes posts sequentially.
    • Checks provider availability; shows an admin notice error if no AI connector is configured.
    • For each post: calls 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 both content and meta.ai_generated_summary in a single apiFetch POST.
    • Displays a live-updating progress notice and a final success/failure summary.
    • Cleans up wpai_bulk_summary and wpai_post_ids from the URL via history.replaceState.
  3. Webpack (webpack.config.js): Adds experiments/summarization-bulk entry pointing to bulk.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.

  1. Go to Posts → All Posts (or Pages → All Pages).
  2. Select two or more posts using the checkboxes.
  3. Open the Bulk Actions dropdown — confirm "Generate AI Summary" is listed.
  4. Select "Generate AI Summary" and click Apply.
  5. The page reloads; a progress notice appears: "Generating summaries: 0 / N…"
  6. Wait for processing to complete — the notice updates to show success/failure counts.
  7. Open one of the processed posts in the block editor and confirm:
    • An AI Summary block group is prepended to the content.
    • The post meta ai_generated_summary is added
  8. Run the bulk action again on the same posts — confirm the old summary block is replaced, not duplicated.
  9. Repeat on the Pages list table to confirm post-type handling works.
  10. Negative test: Disable the summarization experiment in Settings → AI and confirm the bulk action is no longer listed.

Screenshots or screencast

Screen.Recording.2026-06-03.at.10.28.13.AM.mov

Changelog Entry

Added - Bulk "Generate AI Summary" action to the posts and pages list table, enabling AI summary generation for multiple posts at once without opening the block editor.

Open WordPress Playground Preview

@codecov

codecov Bot commented Jun 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.77419% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.17%. Comparing base (8303620) to head (a698941).

Files with missing lines Patch % Lines
...cludes/Experiments/Summarization/Summarization.php 98.18% 1 Missing ⚠️
includes/helpers.php 85.71% 1 Missing ⚠️
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     
Flag Coverage Δ
unit 77.17% <96.77%> (+0.11%) ⬆️

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.

@prasadkarmalkar prasadkarmalkar marked this pull request as ready for review June 17, 2026 12:52
@github-actions

github-actions Bot commented Jun 17, 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: prasadkarmalkar <prasadkarmalkar@git.wordpress.org>
Co-authored-by: dkotter <dkotter@git.wordpress.org>
Co-authored-by: jeffpaul <jeffpaul@git.wordpress.org>
Co-authored-by: coderGtm <gautam23@git.wordpress.org>
Co-authored-by: justin-jiajia <justinjiajia@git.wordpress.org>

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

@dkotter dkotter added this to the 1.1.0 milestone Jun 23, 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.

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

Comment thread includes/Experiments/Summarization/Summarization.php Outdated
Comment thread includes/Experiments/Summarization/Summarization.php Outdated
Comment thread includes/Experiments/Summarization/Summarization.php Outdated
Comment thread src/experiments/summarization/bulk.ts Outdated
@prasadkarmalkar prasadkarmalkar requested a review from dkotter June 24, 2026 14:30
@prasadkarmalkar

Copy link
Copy Markdown
Contributor Author

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.

Comment thread includes/Experiments/Summarization/Summarization.php Outdated
@prasadkarmalkar prasadkarmalkar requested a review from dkotter June 29, 2026 08:55
Comment thread src/experiments/summarization/bulk.ts Outdated
Comment thread src/experiments/summarization/bulk.ts Outdated
function removeExistingSummaryBlock( content: string ): string {
return content
.replace(
/<!-- wp:group \{[^}]*"aiGeneratedSummary":true[^}]*\} -->[\s\S]*?<!-- \/wp:group -->\n*/,

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.

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

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.

Updated to use the flow as per useSummaryGeneration.ts and added the common function findSummaryBlock inside utils.ts

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.

There is an issue with using parse existing content. Trying to find a solution as parse is giving an empty array .

@prasadkarmalkar prasadkarmalkar Jul 1, 2026

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.

Issue is fixed. as the parse()/createBlock() need block types registered first. Added a one-time registerCoreBlocks() call in bulk.ts

Comment thread includes/helpers.php Outdated
Comment thread includes/helpers.php Outdated
@dkotter dkotter modified the milestones: 1.1.0, 1.2.0 Jun 29, 2026
@prasadkarmalkar prasadkarmalkar requested a review from dkotter July 1, 2026 06:45

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

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?

@prasadkarmalkar prasadkarmalkar requested a review from a team July 2, 2026 06:33
@prasadkarmalkar prasadkarmalkar requested a review from dkotter July 2, 2026 06:59
@prasadkarmalkar

Copy link
Copy Markdown
Contributor Author

@dkotter , Fixed the issue it was due to different version of node while installing the dependency on my local.

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

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

@jeffpaul jeffpaul mentioned this pull request Jul 13, 2026
28 tasks
dkotter
dkotter previously approved these changes Jul 13, 2026
@dkotter dkotter merged commit be61fb4 into WordPress:develop Jul 13, 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 support for bulk summary generation

3 participants