Repository navigation
Cli: Install MCP when upgrade is ran by agent - #35215
Conversation
|
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 (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a new ChangesaddonMcp automigration fix
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes ✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 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/lib/cli-storybook/src/automigrate/fixes/addon-mcp.test.ts`:
- Line 10: The `vi.mock()` calls for mocking the add module and another module
are missing the required `spy: true` option. Update both `vi.mock()`
declarations to include the `spy: true` option in their configuration objects to
ensure the original implementation is preserved for unmocked exports, as per the
Vitest mocking guidelines. Find the mock declarations around lines 10 and 13
where the add module is being mocked and apply the same `spy: true`
configuration to both calls.
- Around line 38-82: The mock implementations for detectAgent are currently set
inline within each test case in the check phase describe block. Move the
detectAgent.mockReturnValue() calls from inside each test (in "returns null when
no AI agent is detected", "returns isInstalled: false when an agent is detected
and addon-mcp is missing", "returns isInstalled: true when addon-mcp is already
configured", and "detects addon-mcp when configured as an object") into
appropriate beforeEach blocks. Create separate beforeEach blocks before each
test or group tests by their shared mock behavior, so that mock setups are
declared before the test runs rather than inline within the test case.
- Around line 1-14: The test file is missing mocks for dependencies that the
addonMcp module uses. You need to add vi.mock() calls for the modules that
export getAddonNames and logger, following the same pattern as the existing
vi.hoisted() mock for detectAgent. Once the mocks are declared, implement the
mock behaviors in the beforeEach hook using vi.fn() to create spy functions for
getAddonNames and logger. This ensures that when addonMcp accesses these
dependencies during testing, it receives controlled mock implementations rather
than the actual modules.
🪄 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: 17b54268-80f9-469b-9391-7cc98b833e23
📒 Files selected for processing (3)
code/lib/cli-storybook/src/automigrate/fixes/addon-mcp.test.tscode/lib/cli-storybook/src/automigrate/fixes/addon-mcp.tscode/lib/cli-storybook/src/automigrate/fixes/index.ts
Follow .cursor/rules/spy-mocking.mdc: use vi.mock(..., { spy: true }) for all
deps the subject touches (add, common, node-logger, telemetry), and move mock
behaviors into beforeEach blocks grouped by scenario.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Package BenchmarksCommit: The following packages have significant changes to their size or dependencies:
|
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 72 | 72 | 0 |
| Self size | 21.12 MB | 21.08 MB | 🎉 -47 KB 🎉 |
| Dependency size | 36.42 MB | 36.42 MB | 0 B |
| Bundle Size Analyzer | Link | Link |
@storybook/cli
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 204 | 204 | 0 |
| Self size | 820 KB | 804 KB | 🎉 -16 KB 🎉 |
| Dependency size | 91.48 MB | 91.42 MB | 🎉 -56 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/codemod
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 197 | 197 | 0 |
| Self size | 32 KB | 32 KB | 🚨 +36 B 🚨 |
| Dependency size | 89.96 MB | 89.91 MB | 🎉 -47 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
create-storybook
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 73 | 73 | 0 |
| Self size | 1.09 MB | 1.08 MB | 🎉 -10 KB 🎉 |
| Dependency size | 57.55 MB | 57.50 MB | 🎉 -47 KB 🎉 |
| Bundle Size Analyzer | node | node |
Closes #
What I did
This PR add addon-mcp upgrade/installation when upgrade command is run through AI.
Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
verify upgrade command from AI correctly installs addon-mcp or update it
Tested with Claude OK.
Caution
This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!
Documentation
MIGRATION.MD
Checklist for Maintainers
When this PR is ready for testing, make sure to add
ci:normal,ci:mergedorci:dailyGH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found incode/lib/cli-storybook/src/sandbox-templates.tsDeclare whether manual QA will be needed for this PR during the next release, through
qa:neededorqa:skipMake sure this PR contains one of the labels below:
Available labels
bug: Internal changes that fixes incorrect behavior.maintenance: User-facing maintenance tasks.dependencies: Upgrading (sometimes downgrading) dependencies.build: Internal-facing build tooling & test updates. Will not show up in release changelog.cleanup: Minor cleanup style change. Will not show up in release changelog.documentation: Documentation only changes. Will not show up in release changelog.feature request: Introducing a new feature.BREAKING CHANGE: Changes that break compatibility in some way with current major version.other: Changes that don't fit in the above categories.🦋 Canary release
This pull request has been released as version
0.0.0-pr-35215-sha-cf433ce6. Try it out in a new sandbox by runningnpx storybook@0.0.0-pr-35215-sha-cf433ce6 sandboxor in an existing project withnpx storybook@0.0.0-pr-35215-sha-cf433ce6 upgrade.More information
0.0.0-pr-35215-sha-cf433ce6feat/addon-mcp-agent-upgradecf433ce61781796548)To request a new release of this pull request, mention the
@storybookjs/coreteam.core team members can create a new canary release here or locally with
gh workflow run --repo storybookjs/storybook publish.yml --field pr=35215Summary by CodeRabbit
New Features
@storybook/addon-mcp) is present when an AI-powered agent is detected, installing or refreshing it as needed.Tests