1142 connect content planner frontend with backend endpoints #23168
Conversation
…sending-the-2nd-request-to-ai-api
…api' into 1142-connect-content-planner-frontend-with-backend-endpoints-
There was a problem hiding this comment.
Pull request overview
Connects the AI Content Planner “content outline” flow end-to-end by wiring the frontend modal/state machine to the backend get_outline REST endpoint, and refactors the UI into hooks/blocks for better separation of concerns.
Changes:
- Refactors modal UI state to a Redux Toolkit slice and drives modal step transitions from async request lifecycle.
- Implements outline fetching + applying: new outline store, fetch hook, draggable structure hook, and apply-outline hook.
- Splits block registrations into dedicated block modules and updates metadata/intent UI components.
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/js/src/ai-content-planner/store/modal.js | Replaces hand-rolled reducer/actions with an RTK slice and adds featureModalStatus state driven by async actions. |
| packages/js/src/ai-content-planner/store/content-suggestions.js | Aligns suggestion shape/constants and updates suggestion transformation. |
| packages/js/src/ai-content-planner/store/content-outline.js | Adds outline slice, saga, and control to call the outline REST endpoint. |
| packages/js/src/ai-content-planner/initialize.js | Registers new blocks and initializes store state with the outline endpoint. |
| packages/js/src/ai-content-planner/hooks/use-fetch-content-outline.js | Adds hook to dispatch outline fetch using store/editor context. |
| packages/js/src/ai-content-planner/hooks/use-draggable-structure.js | Adds hook to manage reorderable outline structure in the modal. |
| packages/js/src/ai-content-planner/hooks/use-apply-outline.js | Adds hook to apply the outline: build blocks, apply meta, remove banner, close modal. |
| packages/js/src/ai-content-planner/hooks/index.js | Barrel export for hooks. |
| packages/js/src/ai-content-planner/helpers/get-progress-color.js | Extracts meta description progress bar color logic. |
| packages/js/src/ai-content-planner/helpers/build-blocks-from-outline.js | Updates block-building to use the new outline section schema. |
| packages/js/src/ai-content-planner/helpers/apply-post-meta-from-outline.js | Simplifies applying post + Yoast meta using provided category id. |
| packages/js/src/ai-content-planner/containers/feature-modal.js | Moves modal props derivation into withSelect and dispatch wiring into withDispatch. |
| packages/js/src/ai-content-planner/containers/content-planner-editor-item.js | Adds dispatch for setting the modal flow status before opening. |
| packages/js/src/ai-content-planner/containers/content-outline-modal.js | Adds container for the outline modal panel and navigation back to suggestions. |
| packages/js/src/ai-content-planner/constants.js | Adds shared constants/types (error default, meta description lengths, suggestion typedef). |
| packages/js/src/ai-content-planner/components/intent-callout.js | Extracts intent reasoning callout UI. |
| packages/js/src/ai-content-planner/components/intent-badge.js | Refactors intent badge rendering using UI library Badge + icons. |
| packages/js/src/ai-content-planner/components/feature-modal.js | Refactors orchestration logic to use hooks and store-driven flow status. |
| packages/js/src/ai-content-planner/components/content-suggestions-modal.js | Updates intent badge usage and Suggestion typedef import. |
| packages/js/src/ai-content-planner/components/content-planner-editor-item.js | Updates click behavior to set flow status and open modal. |
| packages/js/src/ai-content-planner/components/content-outline-modal.js | Refactors outline modal to use real async state + draggable structure hook and shared helpers. |
| packages/js/src/ai-content-planner/blocks/content-suggestion-block.js | Moves yoast-seo/content-suggestion block registration into its own module. |
| packages/js/src/ai-content-planner/blocks/banner-block.js | Updates banner block to open modal and fetch suggestions using new flow. |
Comments suppressed due to low confidence (1)
packages/js/src/ai-content-planner/components/feature-modal.js:136
handleOnApplyOutlineusessetStatus(andsetHasVisitedReplace) but they’re not listed in the dependency array. This can break the React Hooks exhaustive-deps linting and can capture stale props in edge cases. Include the missing dependencies (or refactor to avoid them).
const handleOnApplyOutline = useCallback( ( editedOutline ) => {
editedOutlineRef.current = editedOutline;
if ( isEmptyPost ) {
handleApplyOutline();
return;
}
setHasVisitedReplace( true );
setStatus( FEATURE_MODAL_STATUS.replaceContent );
}, [ isEmptyPost, handleApplyOutline ] );
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| isUpsell, | ||
| upsellLink, | ||
| onAddOutline = noop, | ||
| initialStatus = null, | ||
| resetBlocks, | ||
| getContentOutline, | ||
| status, | ||
| setStatus, | ||
| } ) => { |
There was a problem hiding this comment.
The status prop here represents the feature-flow status (FEATURE_MODAL_STATUS), which collides in naming with the status prop used by ContentSuggestionsModal / ContentOutlineModal for async loading (ASYNC_ACTION_STATUS). To avoid accidental prop overriding and blank panels, consider renaming this prop (e.g. flowStatus) and avoid passing it down to async-status components under the same name.
There was a problem hiding this comment.
lets keep it this way for now not to affect branches that are based on this branch.
…-the-2nd-request-to-ai-api' into 1142-connect-content-planner-frontend-with-backend-endpoints-
JorPV
left a comment
There was a problem hiding this comment.
CR 🚧 Some small findings ☝️ (see comments). I'd also consider adding unit tests for the new hooks (useApplyOutline, useDraggableStructure and useFetchContentOutline).
|
CR ✅ ACC ✅ |
Context
Summary
This PR can be summarized in the following changelog entry:
Relevant technical choices:
Test instructions
Test instructions for the acceptance test before the PR gets merged
This PR can be acceptance tested by following these steps:
Relevant test scenarios
Test instructions for QA when the code is in the RC
QA can test this PR by following these steps:
Impact check
This PR affects the following parts of the plugin, which may require extra testing:
Other environments
[shopify-seo], added test instructions for Shopify and attached theShopifylabel to this PR.[yoast-doc-extension], added test instructions for Yoast SEO for Google Docs and attached theGoogle Docs Add-onlabel to this PR.Documentation
Quality assurance
grunt build:imagesand commited the results, if my PR introduces new images or SVGs.Innovation
innovationlabel.Fixes Connect Content Planner frontend with backend endpoints - needed for zip