CLI: Stop running dev automatically on init#34526
Conversation
|
View your CI Pipeline Execution ↗ for commit 22a5bc1
☁️ Nx Cloud last updated this comment at |
|
View your CI Pipeline Execution ↗ for commit 91c0d05
☁️ Nx Cloud last updated this comment at |
There was a problem hiding this comment.
Pull request overview
This PR changes the init/create-storybook flow to stop launching the dev server by default and adjusts the AI-assisted setup experience (especially in agent mode) by moving compatibility checks into a central service and changing what guidance is shown at the end.
Changes:
- Make
--no-devthe effective default by settingoptions.devtofalseunless explicitly provided. - Add
FeatureCompatibilityService.supportsAIPrepareFeature()and thread AI/test compatibility booleans intoUserPreferencesCommandinstead of doing checks inside the command. - Update finalization messaging to (a) avoid auto-running
sb ai prepareand (b) show AI “next step” instructions viaFinalizationCommand.
Reviewed changes
Copilot reviewed 7 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| code/lib/create-storybook/src/services/FeatureCompatibilityService.ts | Adds centralized AI prepare compatibility check helper. |
| code/lib/create-storybook/src/services/FeatureCompatibilityService.test.ts | Unit tests for supportsAIPrepareFeature(). |
| code/lib/create-storybook/src/initiate.ts | Uses centralized feature-support checks; stops auto-running AI prepare; changes when dev server is launched. |
| code/lib/create-storybook/src/commands/UserPreferencesCommand.ts | Accepts precomputed compatibility booleans; adjusts AI prompt copy. |
| code/lib/create-storybook/src/commands/UserPreferencesCommand.test.ts | Updates tests for new options plumbing and helper export. |
| code/lib/create-storybook/src/commands/FinalizationCommand.ts | Adds agent/AI-instructions flags and updates end-of-flow messaging. |
| code/lib/create-storybook/src/commands/FinalizationCommand.test.ts | Adds coverage for new agent/AI-instructions behaviors. |
| code/lib/create-storybook/src/bin/run.ts | Changes default dev behavior to false. |
| code/lib/cli-storybook/src/bin/run.ts | Updates init --dev/--no-dev option descriptions to reflect new default behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughRemoved CI-based defaulting for CLI Changes
Sequence Diagram(s)sequenceDiagram
participant Initiate as initiate()
participant FCS as FeatureCompatibilityService
participant UPC as executeUserPreferences / UserPreferencesCommand
participant FC as executeFinalization / FinalizationCommand
participant Dev as DevServer
Initiate->>FCS: checkFeatureSupport(framework, builder, renderer)
FCS-->>Initiate: {isTestFeatureAvailable, isAiPrepareAvailable}
Initiate->>UPC: executeUserPreferences({isTestFeatureAvailable, isAiPrepareAvailable})
UPC-->>Initiate: {selectedFeatures, newUser}
Initiate->>FC: executeFinalization({agent, isAiPrepareAvailable, showAiInstructions, storybookCommand})
FC-->>Initiate: finalization complete
alt shouldRunDev && !agent
Initiate->>Dev: start dev server (if options.dev set)
Dev-->>Initiate: dev server started
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
✨ Finishing Touches📝 Generate docstrings
Comment |
Package BenchmarksCommit: The following packages have significant changes to their size or dependencies:
|
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 184 | 184 | 0 |
| Self size | 818 KB | 806 KB | 🎉 -12 KB 🎉 |
| Dependency size | 68.41 MB | 68.17 MB | 🎉 -248 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
create-storybook
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 51 | 51 | 0 |
| Self size | 1.30 MB | 1.05 MB | 🎉 -246 KB 🎉 |
| Dependency size | 37.08 MB | 37.08 MB | 🎉 -2 KB 🎉 |
| Bundle Size Analyzer | node | node |
eslint-plugin-storybook
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 20 | 20 | 0 |
| Self size | 131 KB | 131 KB | 0 B |
| Dependency size | 3.44 MB | 3.00 MB | 🎉 -446 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
code/lib/create-storybook/src/commands/FinalizationCommand.test.ts (1)
21-203: Consider replacing positional booleans with a tiny test factory for readability.
new FinalizationCommand(undefined, true, false, true)is easy to misread across many tests. A local helper with named options would make intent clearer and reduce setup mistakes.Refactor sketch
+const makeCommand = ({ + logfile, + agent = false, + isAiPrepareAvailable = false, + showAiInstructions = false, +}: { + logfile?: string; + agent?: boolean; + isAiPrepareAvailable?: boolean; + showAiInstructions?: boolean; +} = {}) => + new FinalizationCommand(logfile, agent, isAiPrepareAvailable, showAiInstructions); - -command = new FinalizationCommand(undefined, false, false, false); +command = makeCommand(); -const bothCommand = new FinalizationCommand(undefined, true, true, true); +const bothCommand = makeCommand({ agent: true, isAiPrepareAvailable: true, showAiInstructions: true });🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@code/lib/create-storybook/src/commands/FinalizationCommand.test.ts` around lines 21 - 203, Tests use hard-to-read positional booleans when instantiating FinalizationCommand (e.g., new FinalizationCommand(undefined, true, false, true)); create a small test factory like makeFinalizationCommand({ agent?, showAiInstructions?, aiPrepareSupported? }) that returns new FinalizationCommand(undefined, agent, showAiInstructions, aiPrepareSupported) and replace all direct constructor calls in FinalizationCommand.test.ts with calls to the factory (use named options for each test), keeping existing mocks and assertions unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@code/lib/create-storybook/src/commands/FinalizationCommand.test.ts`:
- Around line 114-246: Tests in FinalizationCommand.test.ts repeatedly call
vi.mocked(find.up).mockReturnValue(...) inside individual it blocks; move these
inline mock implementations into the file's beforeEach so test setup is
centralized and follows the guideline. Update the beforeEach to set
vi.mocked(find.up).mockReturnValue(...) to the common default, and for tests
that need a different return override, either reset and re-mock inside that test
(using vi.mocked(find.up).mockReturnValueOnce(...)) or use per-test helper
functions; ensure references to FinalizationCommand and executeFinalization
tests still work after centralizing the mock.
---
Nitpick comments:
In `@code/lib/create-storybook/src/commands/FinalizationCommand.test.ts`:
- Around line 21-203: Tests use hard-to-read positional booleans when
instantiating FinalizationCommand (e.g., new FinalizationCommand(undefined,
true, false, true)); create a small test factory like makeFinalizationCommand({
agent?, showAiInstructions?, aiPrepareSupported? }) that returns new
FinalizationCommand(undefined, agent, showAiInstructions, aiPrepareSupported)
and replace all direct constructor calls in FinalizationCommand.test.ts with
calls to the factory (use named options for each test), keeping existing mocks
and assertions unchanged.
🪄 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: f8c7d583-de33-43b6-b838-09c3fb4a980c
📒 Files selected for processing (1)
code/lib/create-storybook/src/commands/FinalizationCommand.test.ts
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@code/lib/create-storybook/src/commands/UserPreferencesCommand.ts`:
- Around line 221-236: The promptAiSetup method currently auto-enables AI when
skipPrompt is true and emits telemetry even when no prompt was shown; change the
skipPrompt branch to default useAi to false (do not opt-in by default) and move
the telemetryService.trackAiPromptNudge call so it only runs after an explicit
user confirmation (i.e., when skipPrompt is false and useAi is true). Update
references in promptAiSetup and ensure telemetryService.trackAiPromptNudge({
skipPrompt }) is only invoked after an interactive confirmation to avoid
recording an ai-prompt-nudge for non-interactive runs.
🪄 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: d72964f4-70ec-41f5-a79b-aa905bd819a7
📒 Files selected for processing (5)
code/core/src/telemetry/types.tscode/lib/create-storybook/src/commands/UserPreferencesCommand.test.tscode/lib/create-storybook/src/commands/UserPreferencesCommand.tscode/lib/create-storybook/src/services/TelemetryService.test.tscode/lib/create-storybook/src/services/TelemetryService.ts
✅ Files skipped from review due to trivial changes (2)
- code/core/src/telemetry/types.ts
- code/lib/create-storybook/src/services/TelemetryService.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- code/lib/create-storybook/src/commands/UserPreferencesCommand.test.ts
yannbf
left a comment
There was a problem hiding this comment.
LGTM apart from minor comments
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
code/lib/create-storybook/src/commands/UserPreferencesCommand.test.ts (1)
75-80:⚠️ Potential issue | 🟡 MinorMake the telemetry mocks match the async service contract.
executeUserPreferences()constructs a freshUserPreferencesCommand, so it can still hit thevi.mocked(TelemetryService).mockImplementation(...)object at lines 75–80. That mock still omitstrackAiPromptNudge, and all telemetry methods are modeled as plainvi.fn()s even though productionawaits them. Adding the missing method and usingmockResolvedValue(undefined)keeps the helper path aligned with the real service contract.Suggested fix
vi.mocked(TelemetryService).mockImplementation(function () { return { - trackNewUserCheck: vi.fn(), - trackInstallType: vi.fn(), + trackNewUserCheck: vi.fn().mockResolvedValue(undefined), + trackInstallType: vi.fn().mockResolvedValue(undefined), + trackAiPromptNudge: vi.fn().mockResolvedValue(undefined), }; }); @@ const mockTelemetryService = { - trackNewUserCheck: vi.fn(), - trackInstallType: vi.fn(), - trackAiPromptNudge: vi.fn(), + trackNewUserCheck: vi.fn().mockResolvedValue(undefined), + trackInstallType: vi.fn().mockResolvedValue(undefined), + trackAiPromptNudge: vi.fn().mockResolvedValue(undefined), }; @@ (yesCommand as unknown as CommandWithPrivates).telemetryService = { - trackNewUserCheck: vi.fn(), - trackInstallType: vi.fn(), - trackAiPromptNudge: vi.fn(), + trackNewUserCheck: vi.fn().mockResolvedValue(undefined), + trackInstallType: vi.fn().mockResolvedValue(undefined), + trackAiPromptNudge: vi.fn().mockResolvedValue(undefined), };Per coding guidelines, "Mock all required properties and methods that the test subject uses in Vitest tests" and "Each mock implementation should return a Promise for async functions in Vitest tests".
Also applies to: 93–97, 287–290
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@code/lib/create-storybook/src/commands/UserPreferencesCommand.test.ts` around lines 75 - 80, The telemetry mock implementation for TelemetryService used by executeUserPreferences()/UserPreferencesCommand is missing the trackAiPromptNudge method and treats all telemetry methods as synchronous vi.fn()s; update the vi.mocked(TelemetryService).mockImplementation to include trackAiPromptNudge and replace plain vi.fn() for trackNewUserCheck, trackInstallType (and other telemetry methods at the other mock sites) with mockResolvedValue(undefined) so the mock matches the async service contract the code awaits.
🧹 Nitpick comments (1)
code/lib/create-storybook/src/commands/UserPreferencesCommand.ts (1)
31-38: TrimUserPreferencesOptionsto the inputs this command still consumes.After moving capability detection to
code/lib/create-storybook/src/initiate.ts,framework,builder, andrendererare no longer read here. Keeping them required widensexecuteUserPreferences()unnecessarily and is why the updated tests still have to invent values for them. Consider narrowing this contract toprojectType,isTestFeatureAvailable, andisAiPrepareAvailable(andskipPrompttoo, if nothing else still uses it).Also applies to: 238-245
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@code/lib/create-storybook/src/commands/UserPreferencesCommand.ts` around lines 31 - 38, Update the UserPreferencesOptions interface and its usages to only include the fields this command actually consumes: keep projectType, isTestFeatureAvailable, isAiPrepareAvailable, and skipPrompt (if used), and remove framework, builder, and renderer; adjust the signature of executeUserPreferences (and any call sites that construct UserPreferencesOptions) to accept the trimmed interface and remove any test/setup code that invents framework/builder/renderer values, and ensure imports/types referencing SupportedFramework, SupportedBuilder, and SupportedRenderer are removed from this file if no longer used.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@code/lib/create-storybook/src/commands/UserPreferencesCommand.test.ts`:
- Around line 75-80: The telemetry mock implementation for TelemetryService used
by executeUserPreferences()/UserPreferencesCommand is missing the
trackAiPromptNudge method and treats all telemetry methods as synchronous
vi.fn()s; update the vi.mocked(TelemetryService).mockImplementation to include
trackAiPromptNudge and replace plain vi.fn() for trackNewUserCheck,
trackInstallType (and other telemetry methods at the other mock sites) with
mockResolvedValue(undefined) so the mock matches the async service contract the
code awaits.
---
Nitpick comments:
In `@code/lib/create-storybook/src/commands/UserPreferencesCommand.ts`:
- Around line 31-38: Update the UserPreferencesOptions interface and its usages
to only include the fields this command actually consumes: keep projectType,
isTestFeatureAvailable, isAiPrepareAvailable, and skipPrompt (if used), and
remove framework, builder, and renderer; adjust the signature of
executeUserPreferences (and any call sites that construct
UserPreferencesOptions) to accept the trimmed interface and remove any
test/setup code that invents framework/builder/renderer values, and ensure
imports/types referencing SupportedFramework, SupportedBuilder, and
SupportedRenderer are removed from this file if no longer used.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 57106b33-47cd-4b39-abf5-f4e42bdcd288
📒 Files selected for processing (5)
code/lib/create-storybook/src/commands/FinalizationCommand.test.tscode/lib/create-storybook/src/commands/FinalizationCommand.tscode/lib/create-storybook/src/commands/UserPreferencesCommand.test.tscode/lib/create-storybook/src/commands/UserPreferencesCommand.tscode/lib/create-storybook/src/initiate.ts
✅ Files skipped from review due to trivial changes (1)
- code/lib/create-storybook/src/initiate.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- code/lib/create-storybook/src/commands/FinalizationCommand.ts
What I did
--no-devthe new default: no more dev serversb ai prepareas a followupsb ai preparein agent mode (please challenge this!)ai preparepreconditions to the feature compatibility serviceChecklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
node ./path-to-storybook/code/lib/create-storybook/dist/bin/index.jsnode ./path-to-storybook/code/lib/create-storybook/dist/bin/index.js --devDocumentation
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.tsMake 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 PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the
@storybookjs/coreteam here.core team members can create a canary release here or locally with
gh workflow run --repo storybookjs/storybook publish.yml --field pr=<PR_NUMBER>Summary by CodeRabbit
New Features
Bug Fixes
Improvements
Tests