fix: run section loaders for nested sections recursively#34
Open
JonasJesus42 wants to merge 1 commit intomainfrom
Open
fix: run section loaders for nested sections recursively#34JonasJesus42 wants to merge 1 commit intomainfrom
JonasJesus42 wants to merge 1 commit intomainfrom
Conversation
runSingleSectionLoader now walks resolved props after running a sections
own loader, detects nested sections ({ Component, props } shape from
normalizeNestedSections), and recursively runs their registered loaders.
This fixes wrapper sections like BackgroundWrapper whose children never
had their loaders invoked.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
1 issue found across 1 file
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/cms/sectionLoaders.ts">
<violation number="1" location="src/cms/sectionLoaders.ts:355">
P2: `enrichNestedSections` only inspects direct prop values and array items, but `normalizeNestedSections` in resolve.ts produces `{ Component, props }` at arbitrary depths inside plain objects. Nested sections inside non-section objects (e.g. `props.config.banner`) will silently skip loader enrichment. Consider adding an `else if (typeof value === 'object')` branch that recurses into plain objects.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| key: value.Component, | ||
| }; | ||
| promises.push({ key, promise: runSingleSectionLoader(nested, request) }); | ||
| } else if (Array.isArray(value)) { |
There was a problem hiding this comment.
P2: enrichNestedSections only inspects direct prop values and array items, but normalizeNestedSections in resolve.ts produces { Component, props } at arbitrary depths inside plain objects. Nested sections inside non-section objects (e.g. props.config.banner) will silently skip loader enrichment. Consider adding an else if (typeof value === 'object') branch that recurses into plain objects.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/cms/sectionLoaders.ts, line 355:
<comment>`enrichNestedSections` only inspects direct prop values and array items, but `normalizeNestedSections` in resolve.ts produces `{ Component, props }` at arbitrary depths inside plain objects. Nested sections inside non-section objects (e.g. `props.config.banner`) will silently skip loader enrichment. Consider adding an `else if (typeof value === 'object')` branch that recurses into plain objects.</comment>
<file context>
@@ -266,38 +266,127 @@ export async function runSectionLoaders(
+ key: value.Component,
+ };
+ promises.push({ key, promise: runSingleSectionLoader(nested, request) });
+ } else if (Array.isArray(value)) {
+ for (let i = 0; i < value.length; i++) {
+ const item = value[i];
</file context>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
runSingleSectionLoadernow recursively detects nested sections in resolved props ({ Component, props }shape fromnormalizeNestedSections) and runs their registered loadersBackgroundWrapperwhose child sections (e.g.CategoryBanner) never had their loaders invokedPromise.all; leaf sections with no nested children incur zero extra allocation (same reference returned)Test plan
BackgroundWrapper > CategoryBannerrenders the banner correctly without a site-level workaround🤖 Generated with Claude Code
Summary by cubic
Recursively run section loaders for nested sections found in resolved props to ensure child sections inside wrappers load their data and render correctly (e.g.,
BackgroundWrapper > CategoryBanner).runSingleSectionLoadernow walks props to detect normalized nested sections ({ Component, props }) and runs their loaders.Promise.all.Written for commit c84d57c. Summary will update on new commits.