refactor [NT-3230]: Use shared Preview Module in Web Preview Panel#314
Open
Felipe Mamud (fmamud) wants to merge 5 commits into
Open
refactor [NT-3230]: Use shared Preview Module in Web Preview Panel#314Felipe Mamud (fmamud) wants to merge 5 commits into
Felipe Mamud (fmamud) wants to merge 5 commits into
Conversation
Charles Hudson (phobetron)
left a comment
Collaborator
There was a problem hiding this comment.
Should we maybe migrate changes overrides to the Preview Support package, so we could similarly share that functionality with mobile (when we have someone who wants to make changes to mobile code 😅)?
Contributor
Author
done in 578c91b. Also, I've considered making those changes wiring into |
4e369bf to
01b9933
Compare
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
PreviewOverrideManagerfrom@contentful/optimization-core/preview-support, aligning the Web panel with the React Native SDK and iOS JSC bridge that already consume the same module.activateAudience/deactivateAudience, so audience-qualification snapshots and reset semantics match across platforms.setVariantOverride; the panel reset button routes throughresetAll; per-audienceDefaultclears viaresetAudienceOverride.applyChangeOverrides(inline-variable → Variable changes) stays in the panel package — the shared module doesn't model thechangessignal. It runs both as a state interceptor (on API refreshes) and synchronously fromonOverridesChanged(on user clicks), sosignals.changesandsignals.selectedOptimizationsalways update in lockstep.localStoragepersistence is preserved by subscribing toonOverridesChanged; overrides loaded from storage are hydrated into the manager on attach so first-render selections still reflect the prior session.Test plan
Validation:
pnpm typecheck— green across all packagespnpm lint— cleanpnpm --filter @contentful/optimization-web-preview-panel build— succeeds, all bundle sizes under budget (umd 35.7k/38.5k, mjs 24.2k/26.5k, cjs 25.0k/27.5k gzip)pnpm --filter @contentful/optimization-core test:unit—PreviewOverrideManagercoverage stays at 100%End-to-end (against the
web-sdkreference app + mock server):pnpm implementation:run -- web-sdk test:e2e(Playwrightpreview-panel.spec.ts)getFlag__ctfl_opt_preview_overrides__and__ctfl_opt_preview_defaults__json,number,plain-text) flip on Baseline/Variant 1 picks