Skip to content

Manifests: Use correct story name#33709

Merged
kasperpeulen merged 5 commits into
nextfrom
jeppe/use-correct-story-name-in-manifests
Feb 4, 2026
Merged

Manifests: Use correct story name#33709
kasperpeulen merged 5 commits into
nextfrom
jeppe/use-correct-story-name-in-manifests

Conversation

@JReinhold
Copy link
Copy Markdown
Contributor

@JReinhold JReinhold commented Jan 29, 2026

Closes #

What I did

Fixed a bug where a story's name in the manifest would always be its export name, and not its actual human-readable name, either from the custom name property, or using auto-naming that adds spaces.

This aligns the manifest with the same logic used in normalizeStory.ts and StoryIndexGenerator.

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

No manual testing needed - the unit tests verify that story names are correctly converted (e.g., LoggedInLogged In).

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

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

🦋 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/core team 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

  • Refactor

    • Improved story resolution and manifest structure so story names and IDs are surfaced more reliably; story display names render with proper spacing.
    • Component manifests now include richer prop and per-story entries for clearer story organization.
  • Tests

    • Updated and added tests to cover story extraction and JSDoc description/summary parsing, plus updated fixtures for new story formats.

@JReinhold JReinhold self-assigned this Jan 29, 2026
@JReinhold JReinhold added bug ci:normal manifest Component manifest generation labels Jan 29, 2026
@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented Jan 29, 2026

View your CI Pipeline Execution ↗ for commit a765607

Command Status Duration Result
nx run-many -t compile,check,knip,test,pretty-d... ✅ Succeeded 8m 46s View ↗

☁️ Nx Cloud last updated this comment at 2026-02-04 08:33:47 UTC

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 29, 2026

📝 Walkthrough

Walkthrough

Story extraction in the React component manifest was changed to iterate using story export keys and story objects; name resolution now prefers runtime story.name with fallback to storyNameFromExport(export). Code-snippet lookup and error payloads now use the export key and include story id/name; tests updated accordingly.

Changes

Cohort / File(s) Summary
Component Manifest Generator
code/renderers/react/src/componentManifest/generator.ts
Switched story iteration to [storyExport, story] pairs; import storyNameFromExport; resolve display name as story.name ?? storyNameFromExport(storyExport); use storyExport when calling getCodeSnippet and when locating JSDoc statements; include id and resolved name in returned story objects and error payloads.
Generator Tests / Snapshots
code/renderers/react/src/componentManifest/generator.test.ts
Updated snapshots and tests to expect per-story id fields, new nested stories structure, story display-name resolution changes (runtime name vs export fallback), and added test for JSDoc description/summary extraction for a Primary story.

Sequence Diagram(s)

mermaid
sequenceDiagram
autonumber
participant Generator as Generator (componentManifest)
participant CSF as CSF module
participant Snippet as getCodeSnippet
participant Output as Manifest

Generator->>CSF: iterate stories as [storyExport, story]
CSF-->>Generator: provide story object, _storyStatements[storyExport]
Generator->>Generator: resolve name = story.name ?? storyNameFromExport(storyExport)
Generator->>Snippet: request code snippet with (csf, storyExport, componentName)
Snippet-->>Generator: return code snippet or error
Generator->>Output: emit story entry with id, name, snippet, and JSDoc-derived description/summary

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

✨ Finishing touches
  • 📝 Generate docstrings

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

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes the story names displayed in component manifests to use properly formatted names (e.g., "Logged In" instead of "LoggedIn").

Changes:

  • Modified manifest generator to use story.name (which is already properly formatted from the runtime index) with a fallback to storyNameFromExport(storyExport) for backward compatibility
  • Updated test expectations to reflect the corrected story name formatting

Reviewed changes

Copilot reviewed 1 out of 2 changed files in this pull request and generated no comments.

File Description
code/renderers/react/src/componentManifest/generator.ts Updated to use story.name instead of the raw export name, with proper fallback logic
code/renderers/react/src/componentManifest/generator.test.ts Updated test snapshots to expect properly formatted story names

Copy link
Copy Markdown
Member

@kasperpeulen kasperpeulen left a comment

Choose a reason for hiding this comment

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

LGTM! Good catch - this should have used storyNameFromExport from the start.

Minor optional nit: the id and name computation is duplicated in both try/catch branches. Could extract it before the try block, but not a blocker.

@kasperpeulen
Copy link
Copy Markdown
Member

To add some context: this is the same logic used in normalizeStory.ts and StoryIndexGenerator. The manifest was the only place not using this pattern.

@kasperpeulen kasperpeulen merged commit 4884b33 into next Feb 4, 2026
124 of 125 checks passed
@kasperpeulen kasperpeulen deleted the jeppe/use-correct-story-name-in-manifests branch February 4, 2026 09:31
@github-actions github-actions Bot mentioned this pull request Feb 4, 2026
8 tasks
@valentinpalkovic valentinpalkovic added the patch:yes Bugfix & documentation PR that need to be picked to main branch label Feb 23, 2026
@github-actions github-actions Bot mentioned this pull request Feb 23, 2026
7 tasks
valentinpalkovic pushed a commit that referenced this pull request Feb 23, 2026
…me-in-manifests

Manifests: Use correct story name
(cherry picked from commit 4884b33)
@github-actions github-actions Bot added the patch:done Patch/release PRs already cherry-picked to main/release branch label Feb 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug ci:normal manifest Component manifest generation patch:done Patch/release PRs already cherry-picked to main/release branch patch:yes Bugfix & documentation PR that need to be picked to main branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants