-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
React: Change examples to stories in manifests and show correct examples and prop types #32908
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
View your CI Pipeline Execution ↗ for commit fcef900
☁️ Nx Cloud last updated this comment at |
📝 WalkthroughWalkthroughReplaces example-focused manifest fields and UI with story-focused fields and prop-type information: renames ComponentManifest.examples → stories, marks the componentManifest generator config experimental, adds parseReactDocgen/ParsedDocgen exports, and updates manifest generation, rendering, tests, types, and related CSS/UI to surface prop types and story errors. Changes
Sequence DiagramsequenceDiagram
participant Gen as Component Manifest Generator
participant Doc as React DocGen Parser
participant Render as Manifest Renderer (server)
participant UI as Manifest HTML/UI
Gen->>Doc: Provide reactDocgen for component
Doc-->>Gen: ParsedDocgen (prop types, descriptions)
Gen->>Render: Emit component manifest with `stories` and ParsedDocgen
Render->>UI: Render badges/panels (prop-type badge, properties panel, story errors)
UI-->>User: Display component entry (stories, props, story statuses)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
✨ Finishing touches
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🧰 Additional context used📓 Path-based instructions (4)**/*.{js,jsx,json,html,ts,tsx,mjs}📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
**/*.{ts,tsx,js,jsx,mjs}📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
code/**/*.{ts,tsx,js,jsx,mjs}📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
{code/**,scripts/**}/**/*.{ts,tsx,js,jsx,mjs}📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
🧠 Learnings (3)📓 Common learnings📚 Learning: 2025-10-13T13:33:14.659ZApplied to files:
📚 Learning: 2025-10-13T13:33:14.659ZApplied to files:
🧬 Code graph analysis (2)code/core/src/core-server/build-static.ts (2)
code/core/src/core-server/dev-server.ts (2)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
🔇 Additional comments (3)
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
code/core/src/core-server/manifest.ts (2)
774-801: New public API: ParsedDocgen type and parseReactDocgen function.These exports add new public API surface for parsing React DocGen data. The implementation correctly extracts prop information and delegates type serialization.
Note: As per the coding guidelines, functions exported from modules should be unit-tested. Consider adding tests for
parseReactDocgen.
803-870: Type serialization logic handles complex TypeScript structures.The
serializeTsTypehelper comprehensively handles unions, intersections, functions, objects, and generics. The recursive implementation with fallbacks torawvalues is appropriate for react-docgen type structures.While this is an internal helper, consider adding unit tests given its complexity, especially for edge cases like deeply nested generics or recursive type references.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
code/core/src/core-server/manifest.ts(16 hunks)code/core/src/types/modules/core-common.ts(2 hunks)code/renderers/react/src/componentManifest/generator.test.ts(5 hunks)code/renderers/react/src/componentManifest/generator.ts(6 hunks)
🧰 Additional context used
📓 Path-based instructions (7)
**/*.{js,jsx,json,html,ts,tsx,mjs}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.{js,jsx,json,html,ts,tsx,mjs}: Run Prettier formatting on changed files before committing
Run ESLint on changed files and fix all errors/warnings before committing (useyarn lint:js:cmd <file>)
Files:
code/core/src/types/modules/core-common.tscode/renderers/react/src/componentManifest/generator.tscode/renderers/react/src/componentManifest/generator.test.tscode/core/src/core-server/manifest.ts
**/*.{ts,tsx,js,jsx,mjs}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Export functions from modules when they need to be unit-tested
Files:
code/core/src/types/modules/core-common.tscode/renderers/react/src/componentManifest/generator.tscode/renderers/react/src/componentManifest/generator.test.tscode/core/src/core-server/manifest.ts
code/**/*.{ts,tsx,js,jsx,mjs}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
In application code, use Storybook loggers instead of
console.*(client code:storybook/internal/client-logger; server code:storybook/internal/node-logger)
Files:
code/core/src/types/modules/core-common.tscode/renderers/react/src/componentManifest/generator.tscode/renderers/react/src/componentManifest/generator.test.tscode/core/src/core-server/manifest.ts
{code/**,scripts/**}/**/*.{ts,tsx,js,jsx,mjs}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Do not use
console.log,console.warn, orconsole.errordirectly unless in isolated files where importing loggers would significantly increase bundle size
Files:
code/core/src/types/modules/core-common.tscode/renderers/react/src/componentManifest/generator.tscode/renderers/react/src/componentManifest/generator.test.tscode/core/src/core-server/manifest.ts
code/**/*.{test,spec}.{ts,tsx}
📄 CodeRabbit inference engine (.cursorrules)
code/**/*.{test,spec}.{ts,tsx}: Place all test files under the code/ directory
Name test files as *.test.ts, *.test.tsx, *.spec.ts, or *.spec.tsx
Files:
code/renderers/react/src/componentManifest/generator.test.ts
**/*.test.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/spy-mocking.mdc)
**/*.test.{ts,tsx,js,jsx}: Use vi.mock() with the spy: true option for all package and file mocks in Vitest tests
Place all mocks at the top of the test file before any test cases
Use vi.mocked() to type and access mocked functions
Implement mock behaviors in beforeEach blocks
Mock all required dependencies that the test subject uses
Mock implementations should be placed in beforeEach blocks
Each mock implementation should return a Promise for async functions
Mock implementations should match the expected return type of the original function
Use vi.mocked() to access and implement mock behaviors
Mock all required properties and methods that the test subject uses
Avoid direct function mocking without vi.mocked()
Avoid mock implementations outside of beforeEach blocks
Avoid mocking without the spy: true option
Avoid inline mock implementations within test cases
Avoid mocking only a subset of required dependencies
Mock at the highest level of abstraction needed
Keep mock implementations simple and focused
Use type-safe mocking with vi.mocked()
Document complex mock behaviors
Group related mocks together
Files:
code/renderers/react/src/componentManifest/generator.test.ts
**/*.@(test|spec).{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.@(test|spec).{ts,tsx,js,jsx}: Unit tests should import and execute the functions under test rather than only asserting on syntax patterns
Mock external dependencies in tests usingvi.mock()(e.g., filesystem, loggers)
Files:
code/renderers/react/src/componentManifest/generator.test.ts
🧠 Learnings (5)
📓 Common learnings
Learnt from: CR
Repo: storybookjs/storybook PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-13T13:33:14.659Z
Learning: Applies to test-storybooks/** : Maintain test Storybook configurations under `test-storybooks/` for E2E and visual testing scenarios
📚 Learning: 2025-10-13T13:33:14.659Z
Learnt from: CR
Repo: storybookjs/storybook PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-13T13:33:14.659Z
Learning: Applies to test-storybooks/** : Maintain test Storybook configurations under `test-storybooks/` for E2E and visual testing scenarios
Applied to files:
code/core/src/types/modules/core-common.tscode/renderers/react/src/componentManifest/generator.test.ts
📚 Learning: 2025-10-13T13:33:14.659Z
Learnt from: CR
Repo: storybookjs/storybook PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-13T13:33:14.659Z
Learning: Applies to code/.storybook/** : Place internal UI Storybook configuration in `code/.storybook/` and maintain it there
Applied to files:
code/core/src/types/modules/core-common.ts
📚 Learning: 2025-09-24T09:39:39.233Z
Learnt from: ndelangen
Repo: storybookjs/storybook PR: 32507
File: code/core/src/manager/globals/globals-module-info.ts:25-33
Timestamp: 2025-09-24T09:39:39.233Z
Learning: In Storybook, storybook/actions/decorator is a preview-only entrypoint and should not be included in manager globals configuration. The duplicatedKeys array in code/core/src/manager/globals/globals-module-info.ts is specifically for manager-side externalization, not preview entrypoints.
Applied to files:
code/core/src/types/modules/core-common.ts
📚 Learning: 2025-09-17T08:11:47.197Z
Learnt from: CR
Repo: storybookjs/storybook PR: 0
File: .cursor/rules/spy-mocking.mdc:0-0
Timestamp: 2025-09-17T08:11:47.197Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Document complex mock behaviors
Applied to files:
code/core/src/core-server/manifest.ts
🧬 Code graph analysis (2)
code/renderers/react/src/componentManifest/generator.ts (1)
code/core/src/csf-tools/CsfFile.ts (1)
stories(968-970)
code/core/src/core-server/manifest.ts (1)
code/frameworks/react-vite/src/plugins/react-docgen.ts (1)
reactDocgen(40-98)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: normal
🔇 Additional comments (12)
code/core/src/types/modules/core-common.ts (2)
355-355: Breaking change:examplesrenamed tostories.The field rename is consistent with the PR objectives to shift from example-based to story-based terminology. The type signature correctly includes the new error field structure.
384-384: Good practice marking the API as experimental.Prefixing with
experimental_appropriately signals that this API is unstable and may change in future releases.code/renderers/react/src/componentManifest/generator.ts (4)
41-56: LGTM: Stories array construction is correct.The mapping logic correctly transforms CSF stories into the manifest format, with appropriate error handling for code snippet generation failures.
58-64: Correct base object structure.The base manifest object properly includes the
storiesfield and satisfies the updatedComponentManifesttype.
66-87: Error handling preserves stories data.The error path correctly returns the manifest with stories included, maintaining data consistency even when component analysis fails.
90-141: Consistent stories field across all code paths.All return paths (success and error scenarios) correctly include the
storiesfield, ensuring the returned manifests consistently match the updated type definition.code/renderers/react/src/componentManifest/generator.test.ts (3)
300-318: Test snapshots correctly updated for stories structure.The snapshots accurately reflect the renamed field and new structure, with stories containing name, snippet, and optional error fields.
396-410: Header component snapshot properly structured.The stories array correctly captures the LoggedIn and LoggedOut stories with their respective snippets.
570-582: Error handling in stories correctly captured.The snapshot properly shows story-level errors with the expected error object structure containing name and message fields.
code/core/src/core-server/manifest.ts (3)
13-34: Metrics and UI updated to reflect prop type and story terminology.The totals calculation and pill rendering correctly shift from "component errors" to "prop type errors" and add new story-based metrics, aligning with the PR's objectives.
579-604: analyzeComponent correctly tracks prop type and story errors.The function properly computes statistics for both prop type errors and story-level errors, providing comprehensive component health metrics.
614-772: Card rendering extensively enhanced with prop types and stories panels.The refactored rendering logic adds comprehensive display of:
- Prop type information from React DocGen
- Story-level errors and successes
- Appropriate badges and toggles
The structure is consistent and aligns with the updated CSS.
Closes #
What I did
Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!
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.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