fix: preserve experiment settings when ai is globally disabled#353
fix: preserve experiment settings when ai is globally disabled#353turtlepod wants to merge 1 commit intoWordPress:developfrom
Conversation
|
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. |
There was a problem hiding this comment.
Pull request overview
Fixes a settings persistence bug where per-experiment enable/disable options were being reset when “AI is globally disabled” and the settings form was submitted, ensuring that re-enabling AI restores the prior experiment toggle state.
Changes:
- Update settings page rendering to always submit per-experiment values even when AI is globally disabled (via hidden inputs).
- Add an e2e regression test covering disable → enable roundtrip while preserving a specific experiment toggle.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
includes/Settings/Settings_Page.php |
Preserves per-experiment option values by submitting hidden fields when global AI is disabled and omitting the checkbox name to prevent overwrites. |
tests/e2e/specs/admin/settings.spec.js |
Adds an e2e test asserting an experiment remains enabled after toggling global AI off and back on. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #353 +/- ##
=============================================
- Coverage 57.85% 57.66% -0.19%
- Complexity 615 618 +3
=============================================
Files 46 46
Lines 3165 3175 +10
=============================================
Hits 1831 1831
- Misses 1334 1344 +10
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
dkotter
left a comment
There was a problem hiding this comment.
Overall this looks good to me though noting this entire settings page will likely change in the next release coming out of #340. I think worth holding this PR until that is merged and then likely will need changes here to still support this (or the issue may go away once that PR is merged)
What?
Closes #352
Ensures per-experiment enable/disable settings are not cleared when the site admin uses Disable AI and saves, so Enable AI restores the same feature toggles as before.
Why?
With AI globally off, experiment checkboxes are disabled. Disabled fields are not submitted with the form.
options.phpstill updates every option registered for the settings page; when a key is missing fromPOST, the saved value becomes empty/null, which wiped eachwpai_feature_{id}_enabledoption. After re-enabling AI, every experiment appeared off until configured again.How?
0plus the checkbox (1) so unchecked experiments still save as off.name(still disabled, sameidfor the label) so only the hidden value is submitted and options stay intact.Adds an e2e test: enable Title Generation, toggle global AI off then on, assert the Title Generation checkbox remains checked.
Use of AI Tools
Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast
n/a