Skip to content

Core: Add experimentalReview feature flag and make the features type augmentable - #35379

Merged
ghengeveld merged 2 commits into
nextfrom
yann/augmentable-features-type
Jul 7, 2026
Merged

ghengeveld merged 2 commits into
nextfrom
yann/augmentable-features-type

Conversation

@yannbf

@yannbf yannbf commented Jul 6, 2026 •

Copy link
Copy Markdown
Member

What I did

Two related changes to make the agentic review feature properly opt-in:

  1. Extracted the inline features type on StorybookConfigRaw into an exported StorybookFeatures interface (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-error unknown flags in main.ts:

    declare module 'storybook/internal/types' {
      interface StorybookFeatures {
        myAddonFeature?: boolean;
      }
    }

    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).

  2. Declared features.experimentalReview in core (default false) 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 on experimentalReview && changeDetection (mirroring the addon's availability check) via a shared isReviewFeatureEnabled helper:

    • server: initReviewChannel in common-preset.ts only runs when enabled
    • manager: ReviewPersistentLayer (App.tsx) and ReviewToolbarHeader (Preview.tsx) only mount when enabled, read from global.FEATURES

    The internal Storybook (code/.storybook/main.ts) enables the flag since it registers @storybook/addon-mcp and uses the review workflow. Docs entry added to main-config-features.mdx.

Checklist for Contributors

Testing

The changes in this PR are covered in the following automated tests:

  • stories
  • unit tests
  • integration tests
  • end-to-end tests

Manual testing

Caution

This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!

  1. cd code && yarn storybook:ui — the internal Storybook has experimentalReview: true, so the review workflow should behave exactly as before (push a review via addon-mcp's display-review; the review notification/summary appears).
  2. Remove experimentalReview: true from code/.storybook/main.ts and 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.
  3. Type check: in a sandbox main.ts, features: { experimentalReview: true } typechecks without @ts-expect-error. Adding an unknown flag still errors, unless an addon augments StorybookFeatures with it (see example above).

Documentation

  • Add or update documentation reflecting your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Checklist for Maintainers

  • When this PR is ready for testing, make sure to add ci:normal, ci:merged or ci:daily GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found in code/lib/cli-storybook/src/sandbox-templates.ts

  • Declare whether manual QA will be needed for this PR during the next release, through qa:needed or qa:skip

  • Make 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

  • New Features
    • Added an opt-in review feature setting to Storybook configuration.
    • Review-related UI and server behavior now only appear when the feature is enabled.
  • Documentation
    • Added setup examples showing how to turn on the new review feature in different configuration styles.
    • Updated configuration docs to include the new option and its requirements.

yannbf and others added 2 commits July 6, 2026 16:16
…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>
@yannbf yannbf added bug ci:normal Run our default set of CI jobs (choose this for most PRs). qa:skip Pull Requests that do not need any QA. (e.g. documentation) labels Jul 6, 2026
@yannbf yannbf self-assigned this Jul 6, 2026
@yannbf
yannbf marked this pull request as ready for review July 6, 2026 16:14
@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds an experimentalReview feature flag and isReviewFeatureEnabled helper that gates review-related server channel initialization and manager UI rendering (ReviewPersistentLayer, review collection story detection). Introduces a StorybookFeatures type, enables the flag in internal Storybook config, and adds documentation and example snippets.

Changes

Experimental review feature flag

Layer / File(s) Summary
StorybookFeatures type and isReviewFeatureEnabled utility
code/core/src/types/modules/core-common.ts, code/core/src/shared/review/features.ts, code/core/src/shared/review/index.ts
Adds exported StorybookFeatures interface consolidating feature flags and isReviewFeatureEnabled, which checks experimentalReview and changeDetection flags; re-exported from the review module.
Server-side review channel gating
code/core/src/core-server/presets/common-preset.ts
Adds experimentalReview: false default to the features preset and conditionally initializes the review server channel using isReviewFeatureEnabled.
Manager UI review flag gating
code/core/src/manager/App.tsx, code/core/src/manager/components/preview/Preview.tsx
Conditionally renders ReviewPersistentLayer via slotOverlay and gates isReviewCollectionStory based on isReviewFeatureEnabled(global.FEATURES).
Documentation and Storybook config for experimentalReview
code/.storybook/main.ts, docs/api/main-config/main-config-features.mdx, docs/_snippets/main-config-features-experimental-review.md
Enables experimentalReview in internal Storybook config, documents the new option, and adds example configuration snippets.

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
Loading

Possibly related PRs

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between fac05a5 and 423e2f2.

📒 Files selected for processing (9)
  • code/.storybook/main.ts
  • code/core/src/core-server/presets/common-preset.ts
  • code/core/src/manager/App.tsx
  • code/core/src/manager/components/preview/Preview.tsx
  • code/core/src/shared/review/features.ts
  • code/core/src/shared/review/index.ts
  • code/core/src/types/modules/core-common.ts
  • docs/_snippets/main-config-features-experimental-review.md
  • docs/api/main-config/main-config-features.mdx

Comment thread code/core/src/types/modules/core-common.ts
@storybook-app-bot

Copy link
Copy Markdown
Contributor

Package Benchmarks

Commit: 423e2f2, ran on 6 July 2026 at 16:23:37 UTC

The following packages have significant changes to their size or dependencies:

@storybook/builder-webpack5

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

@ghengeveld
ghengeveld merged commit e72753b into next Jul 7, 2026
158 of 165 checks passed
@ghengeveld
ghengeveld deleted the yann/augmentable-features-type branch July 7, 2026 09:06
@github-actions github-actions Bot mentioned this pull request Jul 7, 2026
2 tasks done
This was referenced Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug ci:normal Run our default set of CI jobs (choose this for most PRs). qa:skip Pull Requests that do not need any QA. (e.g. documentation)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants