Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions code/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ const config = defineMain({
experimentalDocgenServer: process.env.STORYBOOK_EXPERIMENTAL_DOCGEN_SERVER === 'true',
experimentalReactComponentMeta: true,
changeDetection: true,
experimentalReview: true,
},
staticDirs: [{ from: './bench/bundle-analyzer', to: '/bundle-analyzer' }],
viteFinal: async (viteConfig: InlineConfig, { configType }: Options) => {
Expand Down
6 changes: 5 additions & 1 deletion code/core/src/core-server/presets/common-preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import { initCreateNewStoryChannel } from '../server-channel/create-new-story-ch
import { initFileSearchChannel } from '../server-channel/file-search-channel.ts';
import { initGhostStoriesChannel } from '../server-channel/ghost-stories-channel.ts';
import { initOpenInEditorChannel } from '../server-channel/open-in-editor-channel.ts';
import { isReviewFeatureEnabled } from '../../shared/review/features.ts';
import { initReviewChannel } from '../server-channel/review-channel.ts';
import { initTelemetryChannel } from '../server-channel/telemetry-channel.ts';
import { initializeChecklist } from '../utils/checklist.ts';
Expand Down Expand Up @@ -230,6 +231,7 @@ export const features: PresetProperty<'features'> = async (existing) => ({
componentsManifest: false,
controls: true,
disallowImplicitActionsInRenderV8: true,
experimentalReview: false,
highlight: true,
interactions: true,
legacyDecoratorFileOrder: false,
Expand Down Expand Up @@ -300,7 +302,9 @@ export const experimental_serverChannel = async (
initCreateNewStoryChannel(channel, options);
initGhostStoriesChannel(channel, options);
initOpenInEditorChannel(channel);
initReviewChannel(channel);
if (isReviewFeatureEnabled(await options.presets.apply('features'))) {
initReviewChannel(channel);
}
initTelemetryChannel(channel);

return channel;
Expand Down
7 changes: 6 additions & 1 deletion code/core/src/manager/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import type { Addon_PageType } from 'storybook/internal/types';
import { addons } from 'storybook/manager-api';
import { Global, createGlobal } from 'storybook/theming';

import { global } from '@storybook/global';

import { isReviewFeatureEnabled } from '../shared/review/features.ts';
import { ManagerErrorBoundary } from './components/error-boundary/ManagerErrorBoundary.tsx';
import { Layout } from './components/layout/Layout.tsx';
import { useLayout } from './components/layout/LayoutProvider.tsx';
Expand Down Expand Up @@ -80,7 +83,9 @@ export const App = ({ managerLayoutState, setManagerLayoutState, pages, hasTab }
hasTab={hasTab}
managerLayoutState={managerLayoutState}
setManagerLayoutState={setManagerLayoutState}
slotOverlay={<ReviewPersistentLayer />}
slotOverlay={
isReviewFeatureEnabled(global.FEATURES) ? <ReviewPersistentLayer /> : undefined
}
slotMain={<MainPreview />}
slotSidebar={<Sidebar onMenuClick={() => setMobileAboutOpen((state) => !state)} />}
slotPanel={<Panel />}
Expand Down
4 changes: 3 additions & 1 deletion code/core/src/manager/components/preview/Preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { Helmet } from 'react-helmet-async';
import { Consumer, addons, merge, types, type Combo } from 'storybook/manager-api';

import { useLandmark } from '../../hooks/useLandmark.ts';
import { isReviewFeatureEnabled } from '../../../shared/review/features.ts';
import { isReviewCollectionStoryRoute } from '../../../shared/review/routes.ts';
import { ReviewToolbarHeader } from '../review/components/ReviewToolbarHeader.tsx';
import { FramesRenderer } from './FramesRenderer.tsx';
Expand Down Expand Up @@ -93,7 +94,8 @@ const Preview = React.memo<PreviewProps>(function Preview(props) {
const shouldScale = viewMode === 'story';
const { showToolbar } = options;
const customisedShowToolbar = api.getShowToolbarWithCustomisations(showToolbar);
const isReviewCollectionStory = isReviewCollectionStoryRoute(path, queryParams);
const isReviewCollectionStory =
isReviewFeatureEnabled(global.FEATURES) && isReviewCollectionStoryRoute(path, queryParams);

const previousStoryId = useRef(storyId);

Expand Down
9 changes: 9 additions & 0 deletions code/core/src/shared/review/features.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type { StorybookFeatures } from '../../types/modules/core-common.ts';

/**
* Whether the agentic review feature is enabled. Review is opt-in via the
* `experimentalReview` feature flag and builds on the change-detection pipeline, so it needs both
* flags. Mirrors the availability check MCP tooling uses to register review tools.
*/
export const isReviewFeatureEnabled = (features: StorybookFeatures | undefined): boolean =>
!!features?.experimentalReview && !!features?.changeDetection;
1 change: 1 addition & 0 deletions code/core/src/shared/review/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export { REVIEW_EVENTS, REVIEW_NAMESPACE } from './events.ts';
export { isReviewFeatureEnabled } from './features.ts';
export type { ReviewPage, ReviewPageviewPayload } from './events.ts';
export type { ReviewCollection, ReviewState } from './review-state.ts';
export {
Expand Down
Loading
Loading