Skip to content

Excerpt Generation: Keep the generate buttons on the WordPress 7.2 inspector - #1244

Merged
dkotter merged 11 commits into
developfrom
fix/excerpt-generation-wp-7-2-inspector
Nov 2, 2026
Merged

dkotter merged 11 commits into
developfrom
fix/excerpt-generation-wp-7-2-inspector

Conversation

@jorgefilipecosta

@jorgefilipecosta jorgefilipecosta commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

Alternative to #1139, following the suggestion of @oandregal there to override the core excerpt field instead of adding a panel.

WordPress 7.2 renders the post summary of the inspector from the registered entity fields, so the excerpt panel slot and the DOM injection used by the excerpt generation experiment never render anything. This PR keeps the current UI on both inspectors. On 7.2+, wp_update_entity_fields() hands the render and Edit parts of core's excerpt field to a new @ai/excerpt-field script module (packages/excerpt-field) that reuses the existing components: the inline icon in the summary and the generate button in the popover. Before 7.2 nothing changes, unless Gutenberg (24.3+) brings the Entity Fields API: the legacy registration is skipped when the API exists.

The e2e test now accepts both inspectors, so it catches the next breakage. The showPlaceholderIfEmpty filter is a no-op until WordPress/gutenberg#85842 lands.

Use of AI Tools

AI assistance: Yes
Tool(s):
Model(s):
Used for: implementation, tests and docs; reviewed and tested by me.

Testing Instructions

Run npm run build (the module is built by wp-build; a watch that was already running does not pick the new package up).
On WordPress 7.2 beta and on 7.1, enable the Excerpt Generation experiment and open a post with at least 250 characters.
Verify the Excerpt row shows the generate icon at its end, also while the excerpt is empty.
Open the excerpt popover ("Edit Excerpt" on 7.2, "Add an excerpt" on 7.1) and verify the "Generate excerpt" button is there.
On 7.2, close it and click the excerpt text itself: the popover opens too, as it does for core's summary.
Generate from both buttons and verify the summary and the textarea update.
Open a post with less than 250 characters and verify the buttons are disabled and the popover shows the notice.
npm run test:e2e -- excerpt-generation and vendor/bin/phpunit tests/Integration/Includes/Experiments/Excerpt_Generation pass on 7.1.4 and 7.2-beta3.

Screenshots

On WordPress 7.2 develop shows no generate button at all. With this PR:

WordPress 7.1.4 (legacy panel, unchanged) WordPress 7.2-beta3 (entity field)
Empty excerpt
Empty excerpt, popover
Generated excerpt
Generated excerpt, popover
Content too short
Content too short, popover

Changelog Entry

Fixed - Excerpt Generation: the generate excerpt buttons show again in the WordPress 7.2 post inspector.

Open WordPress Playground Preview

…spector

WordPress 7.2 renders the excerpt of the editor inspector from the
registered entity field instead of the excerpt panel, so the plugin's
`__experimentalPluginPostExcerpt` slot and DOM injection no longer reach
it. On 7.2+, hand the field's `render` and `Edit` parts to a new
`@ai/excerpt-field` script module (packages/excerpt-field) reusing the
existing components: the summary keeps the inline generate button next to
the excerpt or its placeholder, and the popover keeps the textarea with the
generate button and the too-short notice. Before 7.2 the legacy
registration is unchanged, gated by the new `entityFieldsApi` flag.
@github-actions

Copy link
Copy Markdown

✅ WordPress Plugin Check Report

✅ Status: Passed

📊 Report

All checks passed! No errors or warnings found.


🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check

@codecov

codecov Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 21.42857% with 33 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.04%. Comparing base (a82d0f3) to head (f8a7f1f).
⚠️ Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
...eriments/Excerpt_Generation/Excerpt_Generation.php 21.42% 33 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             develop    #1244      +/-   ##
=============================================
- Coverage      85.20%   85.04%   -0.16%     
- Complexity      4714     4722       +8     
=============================================
  Files            182      182              
  Lines          17509    17548      +39     
=============================================
+ Hits           14918    14924       +6     
- Misses          2591     2624      +33     
Flag Coverage Δ
unit 85.04% <21.42%> (-0.16%) ⬇️

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.

Core lifts a field summary holding a link or button above the panel's
edit button, whose hit area is stretched over the whole row, so the
inline generate button also kept clicks on the excerpt text from opening
the popover, unlike core's excerpt summary. Lift only the button instead,
and cover the click in the e2e test.
…e it can run

CI measures the coverage on the latest WordPress release, which has no
Entity Fields API before 7.2, so the block handing the excerpt field to
the script module never runs there and Codecov reports it uncovered.
Exclude that block from the measurement (the trunk job runs its test),
and test the parts running on every version: the early return while the
experiment is disabled and the view config patch keeping the summary.
@jorgefilipecosta
jorgefilipecosta marked this pull request as ready for review October 29, 2026 17:12
@jorgefilipecosta
jorgefilipecosta requested a review from a team October 29, 2026 17:12
@github-actions

github-actions Bot commented Oct 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.

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

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


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

@jorgefilipecosta

Copy link
Copy Markdown
Member Author

cc: @oandregal, @ntsekouras

) : (
field.placeholder && (
<Text className="ai-excerpt-field__placeholder">
{ field.placeholder }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good for this particular field because it's only displayed in the inspector and not in DataViews. If it were, this would result in rendering the placeholder in the DataViews layouts (table, etc.). It doesn't impact this PR, but it's something I ran into while working in WordPress/gutenberg#85842 (comment) and so I thought I'd bring it up.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to know 👍 the field only renders in the inspector for now.

@oandregal

Copy link
Copy Markdown
Member

This is what I meant in my comment and I'm glad it's working well.

I've glossed over the AI specific bits, but it looks good to me.

The `wp_entity_fields_api_init` action only fires with the Entity Fields
API, from core or from Gutenberg on older versions, so the callback no
longer checks for it. Gutenberg brings the API to WordPress 7.0 without
`wp_get_entity_view_config_hook_name()`, which is WordPress 7.1, so the
view configuration filter is hooked by the hook's name instead of
through the helper, and the PHPStan ignore for the helper goes.
@dkotter dkotter added this to the 1.6.0 milestone Nov 2, 2026
dkotter
dkotter previously approved these changes Nov 2, 2026
@dkotter
dkotter merged commit c1d7f61 into develop Nov 2, 2026
33 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.

3 participants