Repository navigation
CLI: Update AI setup instructions to msw-storybook-addon v3 - #35512
Conversation
f23f705 to
2557210
Compare
The setup prompts taught the v2 API, which crashes at module load under
v3: `initialize` no longer exists and `mswLoader` moved to the
`msw-storybook-addon/csf3` subpath.
- register the addon via `storybook add msw-storybook-addon@3` so it
lands in the main config (and the install command is pinned to the
major the snippets teach, so they cannot drift apart)
- CSF3 previews: `loaders: [mswLoader()]` from `/csf3`, handlers wired
in `beforeEach({ msw })` instead of the deprecated `parameters.msw`
- CSF factories previews (`hasCsfFactoryPreview`): `addonMsw()` in
`definePreview({ addons })`
- handlers file example is a flat array now that it is spread into
`msw.use(...)`
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
`storybook add` syncs third-party addons into `definePreview` as namespace imports, which the factories types reject — a single such entry collapses the whole preview's inference to `never` (#35571). When the project uses CSF factories, the msw setup step now tells the agent to remove the injected `mswStorybookAddon` entry and register `addonMsw()` instead.
2557210 to
9200c8d
Compare
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (4)
📝 WalkthroughWalkthroughMSW setup prompts now install ChangesMSW v3 setup prompts
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant StorybookPreview
participant mswLoader
participant beforeEach
participant MSWHandlers
StorybookPreview->>mswLoader: load mswLoader()
StorybookPreview->>beforeEach: invoke async beforeEach({ msw })
beforeEach->>MSWHandlers: msw.use(...mswHandlers)
Possibly related PRs
✨ Finishing Touches📝 Generate docstrings
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@code/core/src/cli/ai/setup-prompts/pattern-copy-play.ts`:
- Line 147: Update the preview import snippets to include the generated
handler-file extension, using .ts for TypeScript output and .js for JavaScript
output. Apply this to both imports in pattern-copy-play.ts (lines 147-147 and
164-164) and all three imports in partials/examples.ts (lines 19-19, 48-48, and
79-79), preserving the existing generated-output language distinction.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 950d56b7-03cf-472b-9d99-f45aefe6eb7c
📒 Files selected for processing (7)
code/core/src/cli/ai/setup-prompts/monorepo-optimized-tests-relaxed-limits-no-story-deletion.tscode/core/src/cli/ai/setup-prompts/monorepo.tscode/core/src/cli/ai/setup-prompts/optimized-tests.tscode/core/src/cli/ai/setup-prompts/partials/examples.tscode/core/src/cli/ai/setup-prompts/partials/steps.tscode/core/src/cli/ai/setup-prompts/pattern-copy-play.tscode/core/src/cli/ai/setup-prompts/relaxed-limits.ts
…sw-v3 CLI: Update AI setup instructions to msw-storybook-addon v3 (cherry picked from commit 95efa3d)
LogDetails |
What I did
The
storybook ai setupprompts teach the msw-storybook-addon v2 API. Under the upcoming v3 (mswjs/msw-storybook-addon#193), that preview snippet crashes at module load:initializeno longer exists, andmswLoadermoved to themsw-storybook-addon/csf3subpath. Since the install step is unpinned, the moment v3 becomeslatest, every fresh setup run would produce instructions that make agents scaffold broken previews.Changes, across all prompt variants (the shipping
pattern-copy-playdefault plus the other variants via the shared partials):storybook add msw-storybook-addon@3so it also lands in themain.*addonsfield. Pinning the major means the snippets and the installed API can't drift apart.loaders: [mswLoader()]imported frommsw-storybook-addon/csf3, with handlers wired inbeforeEach({ msw })instead of the deprecatedparameters.msw(merged into the existingbeforeEachthe example already had).hasCsfFactoryPreviewand wire viaaddonMsw()indefinePreview({ addons }).msw-handlersexample exports a flat array now that it's spread intomsw.use(...).storybook addmay inject amswStorybookAddonnamespace entry intodefinePreview.addonsand instructs removing it in favor ofaddonMsw()— a single namespace entry collapses the whole preview's type inference tonever(CSF factories codemod injects incompatible addon namespaces into definePreview, collapsing all preview types to never #35571).How to test
npx @hipster/sb-utils uninstall --yesSummary by CodeRabbit
New Features
definePreview,mswHandlers, and session provider wiring.Bug Fixes
definePreviewinjection and mismatched initialization style.