Skip to content

Content Guidelines AI: update injection selectors for latest Gutenberg#49155

Draft
aagam-shah wants to merge 1 commit into
add/content-guidelines-plugin-extensibilityfrom
update/content-guidelines-ai-gutenberg-selectors
Draft

Content Guidelines AI: update injection selectors for latest Gutenberg#49155
aagam-shah wants to merge 1 commit into
add/content-guidelines-plugin-extensibilityfrom
update/content-guidelines-ai-gutenberg-selectors

Conversation

@aagam-shah
Copy link
Copy Markdown
Contributor

@aagam-shah aagam-shah commented May 26, 2026

Proposed changes

Stacked on top of #47959.

The Gutenberg Guidelines page markup changed in ways that silently broke the Content Guidelines AI UI injection — the JS bundle loads (HTTP 200, no console error) but zero components render, because every DOM anchor the injector looks for no longer exists:

  • content-guidelines__* classes were renamed to guidelines__* (Gutenberg #77223).
  • The accordion was refactored to CollapsibleCard (Gutenberg #77903), which emits hashed CSS-module class names and removed the per-section element id.
  • The wp-admin Page header (#77088) moved to CSS modules; it also renders no header-actions slot because the Guidelines page passes no actions to <Page>.

This PR updates _inc/content-guidelines-ai/lib/inject.js to anchor on stable selectors:

  • Per-section badge / actions / generate-button key off the new data-slug attribute on .guidelines__list-item, then use semantic anchors within the section (form, the type="submit" button's HStack, the form's top VStack).
  • Banner / upgrade notice use the renamed .guidelines__list.
  • Header "Suggest all" button moves to the top of .guidelines__content (above the list), since there is no header-actions slot to target.
  • Block-guideline modal selectors are unchanged (those classes were not renamed).

Dependency

Requires the Gutenberg-side hook: WordPress/gutenberg#78676 (data-slug on the guideline list items). Until that ships in the bundled Gutenberg, the per-section injections will no-op.

Testing instructions

  1. Build the plugin and apply the Gutenberg branch from Guidelines: Add data-slug attribute to settings list items WordPress/gutenberg#78676 (or patch the attribute in).
  2. Enable the gutenberg-guidelines experiment.
  3. Visit wp-admin/options-general.php?page=guidelines-wp-admin&enable_ai_generation=true.
  4. Confirm the AI UI now renders: the "Suggest all" button above the list, per-section badges/actions/generate buttons, and the block-guideline modal buttons.

Verification done

  • Validated all 15 injection anchors resolve against the live Guidelines DOM (with the data-slug attribute simulated), and a marker-insertion test placed every component at the correct spot.
  • Full in-browser render of the built bundle was not reproducible locally due to an unrelated workspace build-env issue (@automattic/jetpack-ai-client / jetpack-components build artifacts); CI/sandbox builds it normally.

@github-actions
Copy link
Copy Markdown
Contributor

Are you an Automattician? The PR will need to be tested on WordPress.com. This comment will be updated with testing instructions as soon the build is complete.

@github-actions github-actions Bot added [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Status] In Progress labels May 26, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 26, 2026

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add testing instructions.
  • 🔴 Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


🔴 Action required: We would recommend that you add a section to the PR description to specify whether this PR includes any changes to data or privacy, like so:

## Does this pull request change what data or activity we track or use?

My PR adds *x* and *y*.

Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!


Jetpack plugin:

The Jetpack plugin has different release cadences depending on the platform:

  • WordPress.com Simple releases happen as soon as you deploy your changes after merging this PR (PCYsg-Jjm-p2).
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly:
    • Scheduled release: June 2, 2026
    • Code freeze: June 1, 2026

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

@github-actions github-actions Bot added the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label May 26, 2026
@aagam-shah aagam-shah force-pushed the update/content-guidelines-ai-gutenberg-selectors branch from 188a245 to 002503e Compare May 26, 2026 10:31
The Gutenberg Guidelines page markup changed in two ways that broke the
AI UI injection (silently — the bundle loaded with no console error but
nothing rendered):

- content-guidelines__* classes were renamed to guidelines__*.
- The accordion was refactored to CollapsibleCard (hashed CSS-module
  classes) and the per-section element id was removed.

Update lib/inject.js to anchor on stable selectors:
- Per-section badge/actions/button now key off the new `data-slug`
  attribute on `.guidelines__list-item`, plus semantic anchors (form,
  submit button) within each section.
- Banner / upgrade notice use the renamed `.guidelines__list`.
- The header "Suggest all" button moves to the top of
  `.guidelines__content` (the wp-admin Page header renders no actions
  slot since the page passes no `actions`).

The block-guideline modal selectors are unchanged.

Depends on the Gutenberg `data-slug` hook.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@aagam-shah aagam-shah force-pushed the update/content-guidelines-ai-gutenberg-selectors branch from 002503e to 190a217 Compare May 26, 2026 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Status] In Progress [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant