Add display-review tool for agentic review#230
Conversation
✅ Deploy Preview for storybook-mcp-self-host-example canceled.
|
🦋 Changeset detectedLatest commit: 7d424c1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
Bundle ReportChanges will decrease total bundle size by 3.58kB (-4.33%) ⬇️. This is within the configured threshold ✅ Detailed changes
ℹ️ *Bundle size includes cached data from a previous commit Affected Assets, Files, and Routes:view changes for bundle: @storybook/addon-mcp-esmAssets Changed:
Files in
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #230 +/- ##
==========================================
+ Coverage 77.77% 78.25% +0.48%
==========================================
Files 55 57 +2
Lines 1498 1550 +52
Branches 415 430 +15
==========================================
+ Hits 1165 1213 +48
Misses 202 202
- Partials 131 135 +4 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Pull request overview
Adds an agent-facing MCP tool (apply-review-state) to push a structured “curated review” payload into a running Storybook instance, cache it in-memory, and broadcast it to Storybook tabs so the paired @storybook/addon-review-changes manager page can render it. The tool is only registered when features.changeDetection is enabled, aligning it with the existing “changed stories” workflow.
Changes:
- Introduces
apply-review-stateMCP tool with Valibot validation + structured output containing areviewUrl. - Adds an in-memory review state store + Storybook channel event constants and a replay mechanism on tab refresh.
- Registers the tool under the existing
features.changeDetectiongate and adds a Changesets entry.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/addon-mcp/src/tools/tool-names.ts | Adds the apply-review-state tool name constant. |
| packages/addon-mcp/src/tools/apply-review-state.ts | Implements the new MCP tool (validation, caching, channel broadcast, URL return). |
| packages/addon-mcp/src/review-state-store.ts | Defines the canonical Valibot schema + module-scope cache for the review payload. |
| packages/addon-mcp/src/preset.ts | Replays cached review state to newly mounted/refreshed tabs via Storybook channel events. |
| packages/addon-mcp/src/mcp-handler.ts | Registers the tool when features.changeDetection is enabled. |
| packages/addon-mcp/src/constants.ts | Adds cross-addon channel event names + the manager route constant for the review page. |
| packages/addon-mcp/LOCAL_STORYBOOK_DEV.md | Adds local dev instructions for cross-repo iteration (currently marked “do not merge”). |
| .changeset/apply-review-state.md | Declares a minor release for @storybook/addon-mcp adding the tool. |
86ad2bc to
638a168
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 15 out of 18 changed files in this pull request and generated no new comments.
Files not reviewed (3)
- apps/internal-storybook/pnpm-lock.yaml: Language not supported
- eval/pnpm-lock.yaml: Language not supported
- packages/addon-mcp/pnpm-lock.yaml: Language not supported
23849ba to
a42bba0
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 15 out of 18 changed files in this pull request and generated 2 comments.
Files not reviewed (3)
- apps/internal-storybook/pnpm-lock.yaml: Language not supported
- eval/pnpm-lock.yaml: Language not supported
- packages/addon-mcp/pnpm-lock.yaml: Language not supported
96b12bf to
9327b89
Compare
The agent pushes a curated review (narrative, labelled clusters with optional semantic kind, changed files, diff hunks, optional per-story depth/chain) via this MCP tool. It validates with valibot, caches the state in memory, broadcasts it over the Storybook channel, and returns the review-page URL. Gated behind FEATURES.changeDetection. Pairs with the @storybook/addon-review-changes Storybook addon.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 16 out of 19 changed files in this pull request and generated no new comments.
Files not reviewed (3)
- apps/internal-storybook/pnpm-lock.yaml: Language not supported
- eval/pnpm-lock.yaml: Language not supported
- packages/addon-mcp/pnpm-lock.yaml: Language not supported
| /** Default MCP endpoint path. Kept in sync with `DEFAULT_MCP_ENDPOINT` in preset.ts. */ | ||
| const DEFAULT_ENDPOINT = '/mcp'; | ||
|
|
| // Hand the payload off to @storybook/addon-review | ||
| server.ctx.custom?.options?.channel?.emit(PUSH_REVIEW_EVENT, input); |
| let hasAddon = false; | ||
| try { | ||
| const mainConfig = await loadMainConfig({ configDir: options.configDir }); | ||
| hasAddon = getAddonNames(mainConfig).includes(REVIEW_ADDON_NAME); |
There was a problem hiding this comment.
Should we use feature detection rather than the presence of an addon? This will break if we decide to merge the addon into core.
There was a problem hiding this comment.
Sounds good, I’ll make the change!
| features?: { changeDetection?: boolean } | undefined; | ||
| } | ||
|
|
||
| export const getReviewStatus = async ( |
There was a problem hiding this comment.
Name is inconsistent with filename.
There was a problem hiding this comment.
I made it consistent with the “is-manifest-available” and getManifestStatus. If I change it I’d have to change both otherwise it’s not consistent across the codebase
|
|
||
| Anti-pattern: editing a theme token that only one component reads, then publishing a review with just that one component's story. The token change is visible on every page that renders the component — include those pages. | ||
|
|
||
| Always include the returned reviewUrl in your final user-facing response so the user can open it.`, |
There was a problem hiding this comment.
Would be good to add this clarification, so the agent has a notion of what happens when it submits multiple times:
This tool maintains a single active review state; each call replaces the previously published review.
The agent pushes a curated review (narrative, labeled clusters with
optional semantic kind, changed files, diff hunks, optional per-story
depth/chain) via this MCP tool. It validates with valibot, caches the
state in memory, broadcasts it over the Storybook channel, and returns
the review-page URL.
Gated behind FEATURES.changeDetection.
Pairs with the
@storybook/addon-reviewStorybook package.