Repository navigation
Core: Add experimentalReview feature flag and make the features type augmentable - #35379
Conversation
…re flags Extracts the inline `features` object type on `StorybookConfigRaw` into an exported `StorybookFeatures` interface. Addons can now declare their own feature flags via module augmentation of 'storybook/internal/types' instead of requiring users to @ts-expect-error unknown flags in main.ts. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The review feature (manager UI layer + server review channel) previously mounted unconditionally; the only gate lived in the external addon-mcp. Core now declares `features.experimentalReview` (default false) and gates both sides on it (plus `changeDetection`, mirroring the addon's availability check) via a shared isReviewFeatureEnabled helper. The internal Storybook enables the flag to keep its review workflow active. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
📝 WalkthroughWalkthroughAdds an ChangesExperimental review feature flag
Estimated code review effort: 2 (Simple) | ~12 minutes Sequence Diagram(s)sequenceDiagram
participant AppTsx as App.tsx
participant PreviewTsx as Preview.tsx
participant CommonPreset as common-preset.ts
participant Features as isReviewFeatureEnabled
AppTsx->>Features: isReviewFeatureEnabled(global.FEATURES)
Features-->>AppTsx: boolean
AppTsx->>AppTsx: render ReviewPersistentLayer or undefined
PreviewTsx->>Features: isReviewFeatureEnabled(global.FEATURES)
Features-->>PreviewTsx: boolean
PreviewTsx->>PreviewTsx: combine with route check for isReviewCollectionStory
CommonPreset->>Features: isReviewFeatureEnabled(resolved features)
Features-->>CommonPreset: boolean
CommonPreset->>CommonPreset: initReviewChannel(channel) only if enabled
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/types/modules/core-common.ts`:
- Around line 472-638: `StorybookFeatures` is missing the `babelRemoveBugfixes`
flag even though `common-preset.ts` still emits it, causing excess-property
checking on `StorybookConfigRaw['features']`. Add `babelRemoveBugfixes` to the
`StorybookFeatures` interface in `core-common.ts` with the appropriate boolean
type and default/temporary docs if needed, so the preset and config types stay
aligned.
🪄 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: fb842f32-3ae6-4029-81a2-ffa572aba2bd
📒 Files selected for processing (9)
code/.storybook/main.tscode/core/src/core-server/presets/common-preset.tscode/core/src/manager/App.tsxcode/core/src/manager/components/preview/Preview.tsxcode/core/src/shared/review/features.tscode/core/src/shared/review/index.tscode/core/src/types/modules/core-common.tsdocs/_snippets/main-config-features-experimental-review.mddocs/api/main-config/main-config-features.mdx
Package BenchmarksCommit: The following packages have significant changes to their size or dependencies:
|
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 188 | 188 | 0 |
| Self size | 79 KB | 79 KB | 🚨 +48 B 🚨 |
| Dependency size | 35.40 MB | 35.44 MB | 🚨 +35 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/angular
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 185 | 185 | 0 |
| Self size | 160 KB | 160 KB | 🎉 -54 B 🎉 |
| Dependency size | 30.62 MB | 30.65 MB | 🚨 +35 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/ember
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 187 | 187 | 0 |
| Self size | 15 KB | 15 KB | 0 B |
| Dependency size | 30.75 MB | 30.79 MB | 🚨 +35 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/nextjs
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 533 | 533 | 0 |
| Self size | 662 KB | 662 KB | 0 B |
| Dependency size | 62.12 MB | 62.16 MB | 🚨 +35 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/nextjs-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 93 | 93 | 0 |
| Self size | 1.39 MB | 1.39 MB | 0 B |
| Dependency size | 23.99 MB | 24.00 MB | 🚨 +13 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/react-native-web-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 122 | 122 | 0 |
| Self size | 30 KB | 30 KB | 🚨 +36 B 🚨 |
| Dependency size | 25.06 MB | 25.07 MB | 🚨 +13 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/react-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 83 | 83 | 0 |
| Self size | 36 KB | 36 KB | 0 B |
| Dependency size | 21.76 MB | 21.78 MB | 🚨 +13 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/react-webpack5
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 274 | 274 | 0 |
| Self size | 23 KB | 23 KB | 0 B |
| Dependency size | 47.90 MB | 47.94 MB | 🚨 +35 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/server-webpack5
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 200 | 200 | 0 |
| Self size | 16 KB | 16 KB | 🎉 -12 B 🎉 |
| Dependency size | 36.67 MB | 36.70 MB | 🚨 +35 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/tanstack-react
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 84 | 84 | 0 |
| Self size | 110 KB | 110 KB | 0 B |
| Dependency size | 21.80 MB | 21.81 MB | 🚨 +13 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/cli
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 204 | 204 | 0 |
| Self size | 821 KB | 821 KB | 0 B |
| Dependency size | 91.79 MB | 91.80 MB | 🚨 +14 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/codemod
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 197 | 197 | 0 |
| Self size | 32 KB | 32 KB | 0 B |
| Dependency size | 90.27 MB | 90.28 MB | 🚨 +14 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/preset-react-webpack
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 163 | 163 | 0 |
| Self size | 19 KB | 19 KB | 0 B |
| Dependency size | 32.38 MB | 32.41 MB | 🚨 +35 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/react
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 59 | 59 | 0 |
| Self size | 1.52 MB | 1.52 MB | 🎉 -18 B 🎉 |
| Dependency size | 12.43 MB | 12.45 MB | 🚨 +13 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
What I did
Two related changes to make the agentic review feature properly opt-in:
Extracted the inline
featurestype onStorybookConfigRawinto an exportedStorybookFeaturesinterface (code/core/src/types/modules/core-common.ts). Addons can now declare their own feature flags via TypeScript module augmentation instead of forcing users to@ts-expect-errorunknown flags inmain.ts:Verified against the production d.ts bundle: the interface survives the rollup un-renamed, augmentation merges, and a config using an augmented flag typechecks (and fails without the augmentation).
Declared
features.experimentalReviewin core (defaultfalse) and gated the review feature on it. The review feature (manager UI layer + server review channel) previously mounted unconditionally; the only gate lived in the external@storybook/addon-mcp. Core now gates both sides onexperimentalReview && changeDetection(mirroring the addon's availability check) via a sharedisReviewFeatureEnabledhelper:initReviewChannelincommon-preset.tsonly runs when enabledReviewPersistentLayer(App.tsx) andReviewToolbarHeader(Preview.tsx) only mount when enabled, read fromglobal.FEATURESThe internal Storybook (
code/.storybook/main.ts) enables the flag since it registers@storybook/addon-mcpand uses the review workflow. Docs entry added tomain-config-features.mdx.Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
Caution
This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!
cd code && yarn storybook:ui— the internal Storybook hasexperimentalReview: true, so the review workflow should behave exactly as before (push a review via addon-mcp'sdisplay-review; the review notification/summary appears).experimentalReview: truefromcode/.storybook/main.tsand restart — the review layer no longer mounts (no review notification/summary, review routes render as plain stories) and the server does not respond to review channel events.main.ts,features: { experimentalReview: true }typechecks without@ts-expect-error. Adding an unknown flag still errors, unless an addon augmentsStorybookFeatureswith it (see example above).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.🤖 Generated with Claude Code
Summary by CodeRabbit