Skip to content

Add site-wide generation defaults for the suggestion features - #4492

Open
dabowman wants to merge 2 commits into
improve-ai-featuresfrom
site-wide-suggestion-defaults
Open

Add site-wide generation defaults for the suggestion features#4492
dabowman wants to merge 2 commits into
improve-ai-featuresfrom
site-wide-suggestion-defaults

Conversation

@dabowman

Copy link
Copy Markdown
Collaborator

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.

  • 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.
  • A new Parsely\Content_Helper\Suggestion_Defaults class 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.
  • The defaults are validated outside the Content Intelligence sanitizer, which coerces every scalar into a boolean and would otherwise discard them.
  • default_tone / default_persona (and default_length for excerpts) are added to the Parsely_Options_Content_Helper_Feature shape, the option defaults in Parsely, 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.

  • PHP is now their single source. Editor_Sidebar injects 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 small toMetadata() helper.
  • The custom entry stays in TypeScript: it is a UI affordance rather than part of the vocabulary, and it carries an icon PHP cannot express.
  • Nothing is lost in the move — ToneProp and PersonaProp were declared as keyof typeof PARSELY_* | string, which collapses to string, 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?

  • EndpointEditorSidebarSettingsTest gains a data-provider-driven test_excerpt_defaults_come_from_site_settings, covering Suggestion_Defaults::get_default_length / get_default_tone / get_default_persona and Endpoint_Editor_Sidebar_Settings::get_subvalues_specs — including the fallback paths for missing and out-of-range values.
  • The tree at this branch tip is byte-identical to what Redesign Excerpt Suggestions with core-native patterns #4489 carried at 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

dabowman and others added 2 commits August 10, 2026 10:55
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
@dabowman
dabowman requested a review from a team as a code owner August 13, 2026 16:52
@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review (4)
  • develop
  • add/.*
  • fix/.*
  • update/.*

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 7304fdc9-a5fe-4b4d-8748-dff85dbdf660

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant