Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
a69dc87
Update content resize to use wordCountType for word count based on ch…
hbhalodia May 19, 2026
ec4f0cc
Merge branch 'develop' into fix/issue-578
hbhalodia May 21, 2026
923446f
Standardize wordCount across the experiments and added filter to add …
hbhalodia May 21, 2026
53ade0f
Update text based on users locale and use exact min content length data
hbhalodia May 21, 2026
72f53df
Fix phpcs errors
hbhalodia May 21, 2026
3e0143c
Fix e2e tests for content summarization
hbhalodia May 21, 2026
eec8f23
Merge branch 'develop' into fix/issue-578
hbhalodia Jun 9, 2026
abd5181
Address feedbacks
hbhalodia Jun 9, 2026
e8f7162
Add the editorial notes for checking min content availability
hbhalodia Jun 9, 2026
78cce60
Add test for the editorial notes
hbhalodia Jun 9, 2026
cd7b56e
Add the test case for content classification
hbhalodia Jun 9, 2026
99e3747
Add test for content resizing
hbhalodia Jun 9, 2026
afdeeb6
Add test for the summarization
hbhalodia Jun 9, 2026
56af1c8
Remove $_GLOBALS as not needed
hbhalodia Jun 9, 2026
9b509c3
Add e2e test for resizing and classification
hbhalodia Jun 9, 2026
24591c2
Add support for min length for title generation
hbhalodia Jun 9, 2026
a437194
Add unit test for title generation min length
hbhalodia Jun 9, 2026
318d26d
Add e2e test for the title generation
hbhalodia Jun 9, 2026
db74b03
Fix test cases
hbhalodia Jun 9, 2026
da02fab
Add the support for min content length for excerpt generation
hbhalodia Jun 9, 2026
8c5d6c6
Add test cases for excerpt generation with e2e tests
hbhalodia Jun 9, 2026
acff5c0
Add the min content length for the meta description
hbhalodia Jun 9, 2026
d3b5046
Add unit test case for meta and excerpt generation
hbhalodia Jun 9, 2026
6463548
Update all experiments to use default for 100 content length for both…
hbhalodia Jun 9, 2026
4ae4fba
Merge branch 'develop' into fix/issue-578
dkotter Jun 17, 2026
82c7ecc
Ensure we use Editorial Notes instead of Review Notes
dkotter Jun 17, 2026
6774350
Reduce our minimum content from 100 to 50 so it's not quite such a la…
dkotter Jun 17, 2026
56ea5fc
Set minimum content size for content resizing to just 5, as we purpos…
dkotter Jun 17, 2026
f6d165d
Ensure all Features output the same type of message when content is t…
dkotter Jun 17, 2026
b28cec9
Refactor a bit to remove duplicate code
dkotter Jun 17, 2026
0dfa55a
Reduce Editorial Notes min content length down so we can run it on in…
dkotter Jun 17, 2026
58d3f86
More test fixes
dkotter Jun 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Update content resize to use wordCountType for word count based on ch…
…aracters and words
  • Loading branch information
hbhalodia committed May 19, 2026
commit a69dc8740a49bea0bf6c78bd9d304b8cf0316af3
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import {
import { useSelect, useDispatch } from '@wordpress/data';
import { store as blockEditorStore } from '@wordpress/block-editor';
import { useState, useCallback, useMemo } from '@wordpress/element';
import { __, _n, sprintf } from '@wordpress/i18n';
import { __, _n, _x, sprintf } from '@wordpress/i18n';
import { store as noticesStore } from '@wordpress/notices';
import { store as editorStore } from '@wordpress/editor';
import { count } from '@wordpress/wordcount';
import { count as wordCount, type Strategy } from '@wordpress/wordcount';

/**
* Internal dependencies
Expand All @@ -30,7 +30,7 @@ import { ICON_SHORTEN, ICON_EXPAND, ICON_REPHRASE } from '../icons';
import { ensureProvider } from '../../../utils/provider-status';
import AIIcon from '../../../../routes/ai-home/ai-icon';

const SHORTEN_MIN_WORDS = 5;
const SHORTEN_MIN_WORDS_CHARACTERS = 5;
const NOTICE_ID = 'ai_content_resizing_error';

/**
Expand Down Expand Up @@ -73,16 +73,36 @@ export default function ContentResizingToolbar( {
const blockEditorDispatch = useDispatch( blockEditorStore ) as any;
const noticesDispatch = useDispatch( noticesStore ) as any;

/**
* translators: If your word count is based on single characters (e.g. East Asian characters),
* enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.
* Do not translate into your own language.
*
* Uses the default (core) text domain so the word count type stays consistent
* with WordPress core's behavior.
*
* See - https://github.com/WordPress/ai/pull/577#discussion_r3265155502
*/
// eslint-disable-next-line @wordpress/i18n-text-domain
const wordCountType = _x(
'words',
'Word count type. Do not translate!'
) as Strategy;

const handleAction = useCallback(
async ( action: ContentResizingAction ) => {
if ( ! ensureProvider( NOTICE_ID ) ) {
return;
}

if ( action === 'shorten' ) {
const wordCount = count( blockContent, 'words', {} );
const hasEnoughWords = wordCount(
blockContent,
wordCountType,
{}
);
// We need at least 5 words to shorten the content.
if ( wordCount < SHORTEN_MIN_WORDS ) {
if ( hasEnoughWords < SHORTEN_MIN_WORDS_CHARACTERS ) {
noticesDispatch.createErrorNotice(
__( 'Text is too short to shorten further.', 'ai' ),
{
Expand Down Expand Up @@ -125,7 +145,7 @@ export default function ContentResizingToolbar( {
setIsLoading( false );
}
},
[ blockContent, noticesDispatch, postId ]
[ blockContent, noticesDispatch, postId, wordCountType ]
);

const handleAccept = useCallback( () => {
Expand Down Expand Up @@ -159,8 +179,8 @@ export default function ContentResizingToolbar( {
}

const delta =
count( suggestedContent, 'words', {} ) -
count( blockContent, 'words', {} );
wordCount( suggestedContent, wordCountType, {} ) -
wordCount( blockContent, wordCountType, {} );

if ( delta === 0 ) {
return {
Expand Down Expand Up @@ -201,7 +221,7 @@ export default function ContentResizingToolbar( {
magnitude
),
};
}, [ blockContent, suggestedContent ] );
}, [ blockContent, suggestedContent, wordCountType ] );

const controls: Array< {
title: string;
Expand Down
Loading