Add site-wide generation defaults for the suggestion features - #4492
Open
dabowman wants to merge 2 commits into
Open
Add site-wide generation defaults for the suggestion features#4492dabowman wants to merge 2 commits into
dabowman wants to merge 2 commits into
Conversation
Title Suggestions and Excerpt Suggestions each start from a tone and a persona, and Excerpt Suggestions also from a desired length. Those starting points were hardcoded, so a site had no way to express its own editorial voice. Each feature now exposes its defaults in the Content Intelligence section of the settings page, and the Editor Sidebar settings endpoint resolves its defaults from them. They apply to users who have not yet chosen their own values in the editor. The new Suggestion_Defaults class holds the tones, the personas, the length bounds, and a validator for each setting, so that a missing or invalid stored value falls back to the shipped default. Installations that predate these settings therefore need no migration. The defaults are validated outside the Content Intelligence sanitizer, which coerces every scalar into a boolean and would otherwise discard them. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MXxy3dkvUCyMxsBQNMJbaq
The tone and persona lists existed in both PHP and TypeScript, as the settings page is rendered by PHP and cannot read a TypeScript constant. Keeping two copies of the same vocabulary in step is not something the build or the tests would have caught. PHP is now their single source. The Editor Sidebar injects them alongside the values it already passes to the bundle, and the selectors build their maps from that, adding only the custom entry. That entry stays in TypeScript, as it is a UI affordance rather than part of the vocabulary, and it carries an icon that PHP cannot express. Nothing is lost in the move: ToneProp and PersonaProp are declared as `keyof typeof PARSELY_* | string`, which collapses to `string`, so the literal types were never checking anything. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MXxy3dkvUCyMxsBQNMJbaq
Contributor
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review (4)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Split out of #4489 so that PR stays scoped to the Excerpt Suggestions panel redesign. Stacked on
improve-ai-features— merge #4489 first.Two commits that give a site an editorial voice of its own, and give that vocabulary a single owner.
Site-wide generation defaults (
608004f7)Title Suggestions and Excerpt Suggestions each start from a tone and a persona, and Excerpt Suggestions also from a desired length. Those starting points were hardcoded, so a site had no way to express its own editorial voice.
Parsely\Content_Helper\Suggestion_Defaultsclass holds the tones, the personas, the length bounds (50–300, default 160), and a validator per setting. A missing or out-of-range stored value falls back to the shipped default, so installations that predate these settings need no migration.default_tone/default_persona(anddefault_lengthfor excerpts) are added to theParsely_Options_Content_Helper_Featureshape, the option defaults inParsely, and the permissions defaults.PHP as the single source for tones and personas (
a01e9f66)The tone and persona lists existed in both PHP and TypeScript, because the settings page is rendered by PHP and cannot read a TypeScript constant. Keeping two copies of the same vocabulary in step is not something the build or the tests would have caught.
Editor_Sidebarinjects them alongside the values it already passes to the bundle (window.wpParselyContentHelperTones/…Personas), and the tone/persona selectors build their maps from that via a smalltoMetadata()helper.TonePropandPersonaPropwere declared askeyof typeof PARSELY_* | string, which collapses tostring, so the literal types were never checking anything.Motivation and context
#4489 made tone, persona, and length into real persisted settings per user. This makes them configurable per site, so an editorial team can set the voice once instead of each author rediscovering it. Consolidating the vocabulary in PHP is what makes that possible: the settings page and the editor now offer the same choices without restating them.
How has this been tested?
EndpointEditorSidebarSettingsTestgains a data-provider-driventest_excerpt_defaults_come_from_site_settings, coveringSuggestion_Defaults::get_default_length/get_default_tone/get_default_personaandEndpoint_Editor_Sidebar_Settings::get_subvalues_specs— including the fallback paths for missing and out-of-range values.a01e9f66, so the manual wp-env verification and lint/build runs reported there apply unchanged; this PR is a pure branch split with no code edits.Screenshots
🤖 Generated with Claude Code