Skip to content

Re-generates the llms.txt file immediately when there's any change in the selection of the pages to be included#22439

Merged
thijsoo merged 6 commits intotrunkfrom
668-nice-to-have-regenerate-the-file-immediately-when-any-sub-setting-is-changed
Jul 24, 2025
Merged

Re-generates the llms.txt file immediately when there's any change in the selection of the pages to be included#22439
thijsoo merged 6 commits intotrunkfrom
668-nice-to-have-regenerate-the-file-immediately-when-any-sub-setting-is-changed

Conversation

@leonidasmi
Copy link
Copy Markdown
Contributor

@leonidasmi leonidasmi commented Jul 16, 2025

Note

Even though the PR currently does what's expected, it has not been thoroughly tested or finalized by its author. Consider that, if it's to be resumed.

Context

Summary

This PR can be summarized in the following changelog entry:

  • Re-generates the llms.txt file immediately when there's any change in the selection of the pages to be included.

Relevant technical choices:

About the way we detect changes in the llms.txt settings:

  • We're going to check the following sub-settings of the wpseo_llmstxt option with a watcher and trigger a re-generation of the file when there's a change in either:
    • llms_txt_selection_mode
    • about_us_page
    • contact_page
    • terms_page
    • privacy_policy_page
    • shop_page
    • other_included_pages
  • the other_included_pages one is an array with maximum 100 elements. this means that with every save of the wpseo_llmstxt option, there's going to be a comparison of two arrays with 100 elements each. the current technical conclusion is that we can live with that
  • an alternative approach was considered (mostly to avoid comparing two arrays of 100 elements each, every time we save the wpseo_llmstxt option), but was rejected. Adding it here for completeness sake
    • have a hidden field in the llms.txt where we would save a timestamp every time an option in that settings page was changed
    • that timestamp would refer to a new sub-setting of the wpseo_llmstxt option, so that would be updated every time a llms.txt setting was changed
    • the watcher would then have to only compare that timestamp instead of all the sub-settings above, so a much faster comparison
  • reasons the first approach was picked:
    • much cleaner
    • the overhead of comparing two 100-element arrays was deemed insignificant, both because of the size and because it would be triggered only when the wpseo_llmstxt option is specifically saved

Test instructions

Test instructions for the acceptance test before the PR gets merged

This PR can be acceptance tested by following these steps:

  • Have the llms.txt feature enabled
  • Change anything in the llms.txt setting page and confirm that the file was immediately regenerated with the new settings
    • that includes changes in the llms.txt page selection setting (auto/manual) and changes in any of the pages dropdown below, so please test all
    • for the content pages specifically, check both adding a page, removing a page, or replacing a page with a different page
  • Delete the llms.txt file
  • Save any setting outside the llms.txt settings page and confirm that the file didnt get re-generated
  • Change any llms.txt setting but before saving disable the feature
  • Confirm that the file didnt get re-generated

Relevant test scenarios

  • Changes should be tested with the browser console open
  • Changes should be tested on different posts/pages/taxonomies/custom post types/custom taxonomies
  • Changes should be tested on different editors (Default Block/Gutenberg/Classic/Elementor/other)
  • Changes should be tested on different browsers
  • Changes should be tested on multisite

Test instructions for QA when the code is in the RC

  • QA should use the same steps as above.

Impact check

This PR affects the following parts of the plugin, which may require extra testing:

UI changes

  • This PR changes the UI in the plugin. I have added the 'UI change' label to this PR.

Other environments

  • This PR also affects Shopify. I have added a changelog entry starting with [shopify-seo], added test instructions for Shopify and attached the Shopify label to this PR.

Documentation

  • I have written documentation for this change. For example, comments in the Relevant technical choices, comments in the code, documentation on Confluence / shared Google Drive / Yoast developer portal, or other.

Quality assurance

  • I have tested this code to the best of my abilities.
  • During testing, I had activated all plugins that Yoast SEO provides integrations for.
  • I have added unit tests to verify the code works as intended.
  • If any part of the code is behind a feature flag, my test instructions also cover cases where the feature flag is switched off.
  • I have written this PR in accordance with my team's definition of done.
  • I have checked that the base branch is correctly set.

Innovation

  • No innovation project is applicable for this PR.
  • This PR falls under an innovation project. I have attached the innovation label.
  • I have added my hours to the WBSO document.

Fixes #

@leonidasmi leonidasmi added the changelog: enhancement Needs to be included in the 'Enhancements' category in the changelog label Jul 16, 2025
@leonidasmi leonidasmi changed the title Watch if any llms.txt subsetting has changed and generate the file ag… Re-generates the llms.txt file immediately when there's any change in the selection of the pages to be included Jul 16, 2025
@coveralls
Copy link
Copy Markdown

coveralls commented Jul 22, 2025

Pull Request Test Coverage Report for Build 1333cd57a9ff7792e731aee40a8012114f3ad85a

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 11 of 11 (100.0%) changed or added relevant lines in 1 file are covered.
  • 22 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.08%) to 52.211%

Files with Coverage Reduction New Missed Lines %
src/ai-generator/user-interface/get-usage-route.php 22 0.0%
Totals Coverage Status
Change from base Build 691c5ee44b19c46833b5b63c850b2c2cbcdb4d3a: 0.08%
Covered Lines: 30507
Relevant Lines: 59138

💛 - Coveralls

@thijsoo thijsoo marked this pull request as ready for review July 23, 2025 06:52
@thijsoo thijsoo added this to the 25.7 milestone Jul 24, 2025
Copy link
Copy Markdown
Contributor

@thijsoo thijsoo left a comment

Choose a reason for hiding this comment

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

CR + ACC 👍

@thijsoo thijsoo merged commit a439952 into trunk Jul 24, 2025
27 checks passed
@thijsoo thijsoo deleted the 668-nice-to-have-regenerate-the-file-immediately-when-any-sub-setting-is-changed branch July 24, 2025 11:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog: enhancement Needs to be included in the 'Enhancements' category in the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants