Repository navigation
Revision Change Summary: Add experiment to summarize changes between revisions - #1159
Conversation
…revisions Adds an opt-in experiment and the `ai/revision-change-summary` ability that explain in plain language what changed in the title, content and excerpt between two revisions of a post. The summary is read-only and is available on the visual revisions screen in the block editor and on the classic revisions screen. See WordPress#1133.
|
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. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #1159 +/- ##
=============================================
+ Coverage 83.74% 84.15% +0.41%
- Complexity 3388 3508 +120
=============================================
Files 136 139 +3
Lines 13062 13464 +402
=============================================
+ Hits 10939 11331 +392
- Misses 2123 2133 +10
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:
|
|
Hi @jeffpaul, friendly ping on this one. CI is green and it is ready for your review whenever you have time. Thank you! |
Check read_post on both revisions, refuse posts with revisions turned off, escape the diff in the prompt, drop the excerpt and the JSON format text, return HTTP 400 for invalid revisions, split HTML without line breaks, and keep the start of a long changed line when cutting the diff.
Show a Change summary panel in the Revision tab instead of a header button and custom sidebar. Generate one summary at a time, hide the button once a summary is shown, keep the state when the sidebar closes, move focus to the summary, and use a full-width box on the classic screen.
|
Thanks for the review, @dkotter! All points are addressed in 0d29f7b and ce2d97b. While testing I also fixed a few edge cases:
The PR description and screenshots are updated too. |
…sain/ai into add/revision-change-summary
- Explain the marker for unchanged lines in the system instruction, and use "(unchanged lines left out)" without a prefix, so it can't be mistaken for a paragraph that is only "...". - Ask for a summary only for one or two changes, and an overview plus a list for three or more. - Remove list items that repeat the summary or each other, and drop lists with fewer than three distinct items.
…n visual revisions The visual revisions screen now checks for the oldest revision up front and shows the same message as the classic screen, instead of failing only after the button is clicked. The button stays disabled while the check runs.
…st text Smaller models sometimes followed instructions written in the post text, or answered non-English posts in English. Repeat the task after the changes, show how to describe an instruction in the content, and make the language rule clearer.
|
Thanks for testing again, @dkotter! All three points are addressed in 82b1d44 and 07a291f. Same feedback twice: the prompt gave the summary and the list the same job, so models repeated the summary as bullet points. Fixed in two ways:
I tested it live with Gemini 3.6 Flash, Gemini 3.1 Flash Lite and Llama 3.1 8B (Ollama) on 10 kinds of edits: typo fix, title only, two changes, full rewrite, removed section, long post with changes at both ends, a "..." paragraph, Spanish content, and more. The exact repeats you saw are gone on all three. The overview sentence can still name the same areas at a high level (for example "Updated the opening details and added pricing"), with the details in the list. While testing, I also found two older prompt weaknesses with smaller models, so I added small fixes in a separate commit, 44d569f. Happy to move it to its own PR if you prefer:
|
…sain/ai into add/revision-change-summary

What?
Closes #1133
Adds a new opt-in experiment, Revision Change Summary. It explains in plain language what changed between two revisions of a post, on the revisions screens. The summary is read-only. Nothing in the post or its revisions is changed or saved.
Why?
The revisions screen shows an exact comparison, which is slow to read on long posts. Editors, clients and reviewers often only need to know "what is different?". As discussed in #1133, the summary lives in the revisions screen and focuses on content. Title changes are included too, since they come from the same diff. The excerpt is left out, because the revisions screens don't show it. Meta and taxonomy changes are left for a follow-up issue.
How?
Ability
ai/revision-change-summarypost_id,revision_id, optionalfrom_revision_id. Withoutfrom_revision_id, the revision saved just before is used (same order as core's visual revisions, autosaves included).{ summary, changes[], truncated, from_revision_id, revision_id }. A short summary plus up to 10 changes, as proposed in the issue.edit_poston the parent post (same as core's revisions REST endpoint andrevision.php), andread_poston both revisions. The post type must be in REST and support revisions, and revisions must be turned on for the post (revisions_disabledotherwise). Both IDs must be revisions of that post (invalid_revision, HTTP 400, otherwise).Text_Diff. Blocks and shortcodes are never rendered. Only changed lines, with one line of context, are sent to the model. Angle brackets are escaped before the diff is wrapped in<changes>.wpai_revision_change_summary_max_diff_length, minimum 1,000), on a line boundary when one is close, and the result is flagged as partial.as_json_response), is treated as untrusted and is sanitized. The system instruction tells the model to treat the revision text as data only. The prompt can be customized with the standardwpai_revision_change_summary_*filters.UI
revision.php: a Change summary panel below the revision slider. It works in "Compare any two revisions" mode too. Sites with meta boxes always get this screen, because core setsdisableVisualRevisions, so supporting it means the feature works there as well.speak(), keyboard accessible (focus moves to the summary when it's ready), all strings translatable. Results are rendered as text only.Points I'd like feedback on
PluginDocumentSettingPanelor any other slot. So the panel is added right after core's revision summary section in the sidebar (the same approach Slug Generation uses for the permalink panel), and the selected revision is read from the "Open classic revisions screen" link in that section, becausegetCurrentRevisionId()is private. If core changes that markup, the panel is simply not shown and nothing breaks.Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5.5
Used for: implementation plan, code, tests and docs, the review follow-up, plus review passes on the diff. I directed the work, checked the design against the discussion in #1133 and the review, tested it on my site, and take responsibility for the result.
Testing Instructions
wp-admin/revision.php?revision=<ID>) and click Summarize changes. Try Compare any two revisions.add_filter( 'wp_revisions_to_keep', '__return_zero' );): the panel isn't shown, and the ability returnsrevisions_disabled.insufficient_capabilities.Automated:
npm run test:php(tests intests/Integration/Includes/Abilities/Revision_Change_SummaryTest.phpandtests/Integration/Includes/Experiments/Revision_Change_Summary/), andnpm run test:e2e -- tests/e2e/specs/experiments/revision-change-summary.spec.js.Screenshots or screencast
Visual revisions screen and classic revisions screen:
Changelog Entry