Skip to content

Conversation

@yash-builder
Copy link
Contributor

@yash-builder yash-builder commented Oct 6, 2025

Description

• Detect @Input() content switch (id differs from current)
• Re-initialise builderContextSignal.content & rootState
• Regenerate AB-test visibility script
This ensures repeaters/blocks re-render correctly after SSR refresh and route reuse, eliminating the need for custom RouteReuseStrategy hacks.

JIRA
https://builder-io.atlassian.net/browse/ENG-10194

Loom
https://www.loom.com/share/47d4f285da2a45f2bd1ff6cc82bdad4c?sid=16e0dad3-3104-4fbf-99fd-7f4b1378695a


Note

Detects content id changes and re-initializes builder context, root state, and AB-test visibility script.

  • Content runtime (packages/sdks/src/components/content/content.lite.tsx):
    • Add onUpdate watcher for props.content to detect id changes.
    • Re-initialize builderContextSignal.content via getContentInitialValue and builderContextSignal.value.rootState via getRootStateInitialValue.
    • Regenerate AB-test visibility script (state.scriptStr) using getUpdateVariantVisibilityScript with the new ids.
    • Import onUpdate to support the new watcher.

Written by Cursor Bugbot for commit bc31a8c. This will update automatically on new commits. Configure here.

@yash-builder yash-builder requested a review from samijaber October 6, 2025 13:10
@changeset-bot
Copy link

changeset-bot bot commented Oct 6, 2025

⚠️ No Changeset found

Latest commit: bc31a8c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@yash-builder yash-builder self-assigned this Oct 6, 2025
@yash-builder yash-builder requested a review from a team October 6, 2025 13:10
contentId: nextId,
});
}
}, [props.content]);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Stale State and Inconsistent Handling in Hook

The onUpdate hook's dependency array omits props.data and props.locale, which can lead to stale rootState. Additionally, testVariationId is handled inconsistently between initial setup and updates (non-null assertion vs. empty string fallback), potentially affecting AB-test functionality.

Fix in Cursor Fix in Web

const nextId = props.content?.id ?? (props.content as any)?._id;
const currentId = builderContextSignal.value.content?.id ?? (builderContextSignal.value.content as any)?._id;

if (nextId && nextId !== currentId) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Content Update Hook Fails with Missing IDs

The onUpdate hook's content update logic can lead to stale context. The nextId && nextId !== currentId condition prevents updates when props.content is cleared or lacks an ID. Additionally, currentId's _id fallback may not be preserved after initialization, causing unreliable comparisons and missed content changes.

Fix in Cursor Fix in Web

@nx-cloud
Copy link

nx-cloud bot commented Oct 6, 2025

🤖 Nx Cloud AI Fix Eligible

An automatically generated fix could have helped fix failing tasks for this run, but Self-healing CI is disabled for this workspace. Visit workspace settings to enable it and get automatic fixes in future runs.

To disable these notifications, a workspace admin can disable them in workspace settings.


View your CI Pipeline Execution ↗ for commit bc31a8c

Command Status Duration Result
nx test @snippet/angular-17 ❌ Failed 5m 44s View ↗
nx test @snippet/angular-17-ssr ❌ Failed 5m 26s View ↗
nx test @snippet/vue ❌ Failed 3m View ↗
nx test @snippet/svelte ❌ Failed 2m 47s View ↗
nx test @e2e/angular-17 ❌ Failed 2m 33s View ↗
nx test @snippet/react ❌ Failed 2m 18s View ↗
nx test @e2e/qwik-city ❌ Failed 2m 9s View ↗
nx test @snippet/qwik-city ❌ Failed 1m 30s View ↗
Additional runs (37) ❌ Failed ... View ↗

☁️ Nx Cloud last updated this comment at 2025-10-06 13:30:54 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant