Skip to content

When getting content for a post, ensure we're always getting the most recent version#367

Merged
dkotter merged 6 commits intoWordPress:developfrom
dkotter:fix/edited-content
Apr 6, 2026
Merged

When getting content for a post, ensure we're always getting the most recent version#367
dkotter merged 6 commits intoWordPress:developfrom
dkotter:fix/edited-content

Conversation

@dkotter
Copy link
Copy Markdown
Collaborator

@dkotter dkotter commented Apr 2, 2026

What?

When content about a post is needed when an experiment is triggered, ensure we always grab the most recent version.

Why?

There was a bug report around the Title Generation Experiment and how they added some post content that was about one topic and then changed that content to be about a completely different topic. When generating titles, the titles reflected the first content, not the second.

The issue here is we grab the content from the editor at page load so if the content is changed and the page isn't refreshed, we have the old version of the content stored. Instead we should pull the content fresh each time title generation is triggered.

I audited all of our other Experiments and found similar problems with Excerpt Generation and Featured Image Generation (in particular, generating the image prompt). All of those are fixed now. All other Experiments were working correctly.

How?

  • Grab the post content from the editor when title generation is triggered instead of when the component is loaded
  • Switch to using the useSelect hook to get the post content and excerpt when Excerpt Generation is triggered to ensure we always have the freshest data
  • For the context we send to our Image Prompt Generation Ability, switch away from using our get-post-details Ability and instead directly grab the post title and post type. This ensures we always have the most up-to-date title instead of the latest version stored in the database

Use of AI Tools

None

Testing Instructions

  1. Checkout this PR and run npm i && npm run build
  2. Turn on Title Generation, Excerpt Generation and Image Generation
  3. Create a new post and add a title and some content
  4. Ensure all three of those Experiments work
  5. Modify the title and content significantly. Don't save or reload
  6. Run all three Experiments again and ensure they still work
Open WordPress Playground Preview

dkotter added 3 commits April 2, 2026 16:47
…riggered so we are working with the latest version of the content
… triggered so we are working with the latest version of the content
…erating a featured image, grab that context directly from the post so we know we're getting the most recent version of the title
@dkotter dkotter added this to the 0.7.0 milestone Apr 2, 2026
@dkotter dkotter self-assigned this Apr 2, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 2, 2026

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

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

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 58.09%. Comparing base (7d20bba) to head (a15dd32).
⚠️ Report is 88 commits behind head on develop.

Additional details and impacted files
@@            Coverage Diff             @@
##             develop     #367   +/-   ##
==========================================
  Coverage      58.09%   58.09%           
  Complexity       630      630           
==========================================
  Files             46       46           
  Lines           3193     3193           
==========================================
  Hits            1855     1855           
  Misses          1338     1338           
Flag Coverage Δ
unit 58.09% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 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.

@dkotter dkotter merged commit 0b343a4 into WordPress:develop Apr 6, 2026
18 checks passed
@dkotter dkotter deleted the fix/edited-content branch April 6, 2026 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

2 participants