-
Notifications
You must be signed in to change notification settings - Fork 809
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add/open ai useselect #28483
Add/open ai useselect #28483
Conversation
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available. Once your PR is ready for review, check one last time that all required checks (other than "Required review") appearing at the bottom of this PR are passing or skipped. Jetpack plugin:
|
Are you an Automattician? You can now test your Pull Request on WordPress.com. On your sandbox, run |
projects/plugins/jetpack/extensions/blocks/ai-paragraph/edit.js
Outdated
Show resolved
Hide resolved
projects/plugins/jetpack/extensions/blocks/ai-paragraph/edit.js
Outdated
Show resolved
Hide resolved
projects/plugins/jetpack/extensions/blocks/ai-paragraph/edit.js
Outdated
Show resolved
Hide resolved
This may be kind of relevant #28488 |
f5b43ca
to
e3977f2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. I added some comments that aren't necessarily blockers, but I would like others to look before I approved!
projects/plugins/jetpack/extensions/blocks/ai-paragraph/edit.js
Outdated
Show resolved
Hide resolved
projects/plugins/jetpack/extensions/blocks/ai-paragraph/edit.js
Outdated
Show resolved
Hide resolved
projects/plugins/jetpack/extensions/blocks/ai-paragraph/edit.js
Outdated
Show resolved
Hide resolved
const waitingState = completionFinished || loadingCompletion || loadingCategories; | ||
const nbCharactersNeeded = numberOfCharactersNeeded - content.length; | ||
if ( ! waitingState ) { | ||
if ( containsAiUntriggeredParapgraph( contentBefore ) ) { | ||
if ( ! errorMessage ) { | ||
setErrorMessage( | ||
/** translators: This will be an error message when multiple Open AI paragraph blocks are triggered on the same page. */ | ||
__( 'Waiting for the previous AI paragraph block to finish', 'jetpack' ) | ||
); | ||
} | ||
} else if ( | ||
content.length < numberOfCharactersNeeded && | ||
needsMoreCharacters !== nbCharactersNeeded | ||
) { | ||
setErrorMessage( | ||
sprintf( | ||
/** translators: First placeholder is a number of more characters we need */ | ||
__( | ||
'Please write a longer title or a few more words in the opening preceding the AI block. Our AI model needs %1$d more characters.', | ||
'jetpack' | ||
), | ||
nbCharactersNeeded | ||
) | ||
); | ||
setNeedsMoreCharacters( nbCharactersNeeded ); | ||
} else if ( needsMoreCharacters !== 0 && content.length >= numberOfCharactersNeeded ) { | ||
setErrorMessage( | ||
/** translators: This is to retry to complete the text */ | ||
__( 'Ready to retry', 'jetpack' ) | ||
); | ||
setShowRetry( true ); | ||
setNeedsMoreCharacters( 0 ); | ||
} else if ( needsMoreCharacters === 0 && ! showRetry ) { | ||
getSuggestionFromOpenAI(); | ||
} | ||
}, [ setAttributes, attributes ] ); // eslint-disable-line react-hooks/exhaustive-deps | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this all just go in a useEffect?
useEffect( () => {
if ( completionFinished || loadingCompletion || loadingCategories ) {
return;
}
// ...
}, [ completionFinished, loadingCompletion, loadingCategories ] );
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my other comment above about the logic of that if
not being correct...
projects/plugins/jetpack/extensions/blocks/ai-paragraph/edit.js
Outdated
Show resolved
Hide resolved
19b7ec9
Definitely. That will be in another PR, though. |
Yes, that should be another PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This tests well, I think I have enough of this PR :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merged master, resolved conflicts and accepting again
So do I... |
Fixes #28389
Proposed changes:
Does this pull request change what data or activity we track or use?
No
Testing instructions:
Sandbox a WPCOM site and push this to your favorite sandbox with