Skip to content

Fix[Experiments]: Adopt character based count to gate features#802

Merged
dkotter merged 13 commits into
WordPress:developfrom
yogeshbhutkar:fix-767/ai-features-button-disabled
Jun 30, 2026
Merged

Fix[Experiments]: Adopt character based count to gate features#802
dkotter merged 13 commits into
WordPress:developfrom
yogeshbhutkar:fix-767/ai-features-button-disabled

Conversation

@yogeshbhutkar

@yogeshbhutkar yogeshbhutkar commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

What, Why, and How?

Closes #767

This PR standardizes AI feature content-length checks on character counts excluding spaces, instead of switching between words and characters based on locale.

This fixes cases where AI feature buttons stay disabled for sufficient CJK or similar non-space-delimited content when the site or user locale uses word-based counting. It also keeps minContentLength consistent by making the unit deterministic across users and languages.

The character thresholds are based on the previous word thresholds, using 5 characters as an approximate average word length. So a previous limit of 15 words now becomes 75 (15*5) characters. This keeps the limits calculated and proportional, rather than choosing new values arbitrarily.

Use of AI Tools

AI assistance: Yes
Tool(s): Codex
Model(s): GPT-5.5
Used for: Code reviews

Testing Instructions

  1. Create a new post.
  2. Confirm gated AI features show the minimum length message using character count.
  3. Keep the site/editor locale set to English.
  4. Add Japanese content to the post.
  5. Confirm the gate is removed once the content reaches the required character length.
  6. Use Content Resizing and confirm the changeset shows character counts correctly instead of “no change”.
  7. Confirm the Shorten action works with sufficient Japanese content in an English locale.

Screenshots

Before After
before-01 after-01
before-02 after-02
before-03 after-03

Changelog Entry

Changed - Use character-based count to gate AI Experiments.

Open WordPress Playground Preview
@codecov

codecov Bot commented Jun 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.51%. Comparing base (8da94a9) to head (cc285a8).

Additional details and impacted files
@@              Coverage Diff              @@
##             develop     #802      +/-   ##
=============================================
+ Coverage      76.48%   76.51%   +0.03%     
  Complexity      1869     1869              
=============================================
  Files             89       89              
  Lines           7990     7996       +6     
=============================================
+ Hits            6111     6118       +7     
+ Misses          1879     1878       -1     
Flag Coverage Δ
unit 76.51% <100.00%> (+0.03%) ⬆️

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

☔ View full report in Codecov by Harness.
📢 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.
@yogeshbhutkar yogeshbhutkar changed the title Fix[Experiments]: Adopt a character based count (WIP) Jun 29, 2026
@yogeshbhutkar yogeshbhutkar changed the title Fix[Experiments]: Adopt character based count Jun 29, 2026
@yogeshbhutkar yogeshbhutkar marked this pull request as ready for review June 29, 2026 08:44
@github-actions

github-actions Bot commented Jun 29, 2026

Copy link
Copy Markdown

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.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @hasanmehmood.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Unlinked contributors: hasanmehmood.

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

@jeffpaul jeffpaul added this to the 1.1.0 milestone Jun 29, 2026
@jeffpaul jeffpaul mentioned this pull request Jun 29, 2026
32 tasks
Comment thread includes/Abilities/Content_Resizing/Content_Resizing.php Outdated
Comment thread src/experiments/excerpt-generation/components/useExcerptGeneration.ts Outdated
Comment thread includes/helpers.php
- Each word is assumed to have 5 characters on average. For example, 15 words becomes 75 characters.
- Adopts character based counting mechanism.
- Updates Integration tests.
- Updates E2E tests.
- Fixes static analysis errors.
- Also unifies JS and PHP constants for `minContentLength`
- Fixes static analysis
- Also fixes wording in e2e tests.
- Updates docs.
- Updates tests.
- Updates comments.
@yogeshbhutkar yogeshbhutkar force-pushed the fix-767/ai-features-button-disabled branch from ad4c1bc to cc285a8 Compare June 30, 2026 11:03
@yogeshbhutkar yogeshbhutkar requested a review from dkotter June 30, 2026 12:05
@dkotter dkotter merged commit dacf74e into WordPress:develop Jun 30, 2026
24 checks passed
@jeffpaul

Copy link
Copy Markdown
Member

@hasanmehmood if you can connect your GitHub and WordPress.org accounts, then I can more formally credit you in the release post there and grant you the AI Contributor badge.

@yogeshbhutkar yogeshbhutkar deleted the fix-767/ai-features-button-disabled branch July 1, 2026 04:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants