Skip to content

Conversation

@JReinhold
Copy link
Contributor

@JReinhold JReinhold commented Oct 1, 2025

What I did

Made subtype optional, defaulting to 'story' on index inputs. This doesn't change what is actually in the index, only what indexers are required to specify.

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

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

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 pull request has been released as version 0.0.0-pr-32602-sha-16d7f80f. Try it out in a new sandbox by running npx [email protected] sandbox or in an existing project with npx [email protected] upgrade.

More information
Published version 0.0.0-pr-32602-sha-16d7f80f
Triggered by @JReinhold
Repository storybookjs/storybook
Branch jeppe/optional-subtype
Commit 16d7f80f
Datetime Thu Oct 2 19:24:10 UTC 2025 (1759433050)
Workflow run 18203399574

To request a new release of this pull request, mention the @storybookjs/core team.

core team members can create a new canary release here or locally with gh workflow run --repo storybookjs/storybook publish.yml --field pr=32602

Summary by CodeRabbit

  • New Features

    • Indexing now accepts entries without a subtype; unspecified subtype defaults to "story".
    • Index entries may include optional component path and export name metadata.
  • Bug Fixes

    • Improved handling and classification for entries with the "test" subtype.
  • Documentation

    • Indexer docs updated to describe the optional experimental subtype field, its default, and examples.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 1, 2025

📝 Walkthrough

Walkthrough

Story index handling was adjusted: StoryIndexInput.subtype became optional, StoryIndexGenerator computes an effective subtype (defaulting to 'story'), casts indexer output to StoryIndexInput[], defers setting parent/exportName/componentPath onto entries, and a renderer preset stopped emitting subtype for story entries. Types and docs updated.

Changes

Cohort / File(s) Summary
Core: Story index generator
code/core/src/core-server/utils/StoryIndexGenerator.ts
Cast indexer.createIndex result to StoryIndexInput[]; compute local subtype = input.subtype ?? 'story'; use subtype when building entries; defer post-assignments of parent, parentName, and exportName; maintain entry structure otherwise.
Types: indexer input & entry
code/core/src/types/modules/indexer.ts
Make StoryIndexInput.subtype optional (`subtype?: 'story'
Docs: API indexers
docs/api/main-config/main-config-indexers.mdx
Document `subtype?: 'story'
Renderers: preset output
code/renderers/server/src/preset.ts
Remove emitting subtype: 'story' from indexer entries produced by the experimental indexer preset; other fields unchanged.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Indexer as Indexer (produces IndexInput)
  participant SIG as StoryIndexGenerator
  participant Output as Story Index

  Note over Indexer: Emits IndexInput with optional `subtype` and other fields
  Indexer->>SIG: IndexInput { type, subtype?, componentPath?, exportName?, ... }

  rect rgba(200,230,210,0.25)
    Note over SIG: Normalize and construct entry
    SIG->>SIG: cast inputs to StoryIndexInput[]
    SIG->>SIG: subtype := input.subtype ?? 'story'
    SIG->>SIG: build entry using subtype and other fields
    SIG->>SIG: if subtype === 'test' then assign parent/parentName
    SIG->>SIG: if input.exportName then assign exportName
  end

  SIG->>Output: emit StoryIndexEntry (with optional componentPath/exportName/subtype for tests)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly and accurately describes the primary change of making the subtype property optional on index input objects within the core module, matching both the raw code updates and the PR objectives. It is clear and specific without extraneous information.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between db59962 and 06a15c4.

📒 Files selected for processing (3)
  • code/core/src/core-server/utils/StoryIndexGenerator.ts (4 hunks)
  • code/core/src/types/modules/indexer.ts (2 hunks)
  • code/renderers/server/src/preset.ts (0 hunks)
💤 Files with no reviewable changes (1)
  • code/renderers/server/src/preset.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • code/core/src/core-server/utils/StoryIndexGenerator.ts
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Adhere to ESLint and Prettier rules across all JS/TS source files

Files:

  • code/core/src/types/modules/indexer.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Fix type errors and prefer precise typings instead of using any or suppressions, consistent with strict mode

Files:

  • code/core/src/types/modules/indexer.ts
⏰ 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)
  • GitHub Check: normal
  • GitHub Check: Core Unit Tests, windows-latest
🔇 Additional comments (2)
code/core/src/types/modules/indexer.ts (2)

139-139: LGTM: Optional subtype input defaults to 'story' at runtime.

StoryIndexGenerator applies input.subtype ?? 'story' and no direct unguarded input.subtype accesses remain, preserving type safety.


77-78: No action needed: exportName on input and entry is the same field carried through—no ambiguity in usage or purpose.


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

@JReinhold JReinhold requested a review from ghengeveld October 1, 2025 14:02
@JReinhold JReinhold self-assigned this Oct 1, 2025
@JReinhold JReinhold added maintenance User-facing maintenance tasks core ci:normal labels Oct 1, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
docs/api/main-config/main-config-indexers.mdx (1)

499-499: Remove trailing blank line.

This appears to be an unintentional whitespace change.

Apply this diff:

-
 </details>
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 764c7c2 and f265de0.

📒 Files selected for processing (3)
  • code/core/src/core-server/utils/StoryIndexGenerator.ts (2 hunks)
  • code/core/src/types/modules/indexer.ts (1 hunks)
  • docs/api/main-config/main-config-indexers.mdx (3 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Adhere to ESLint and Prettier rules across all JS/TS source files

Files:

  • code/core/src/types/modules/indexer.ts
  • code/core/src/core-server/utils/StoryIndexGenerator.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Fix type errors and prefer precise typings instead of using any or suppressions, consistent with strict mode

Files:

  • code/core/src/types/modules/indexer.ts
  • code/core/src/core-server/utils/StoryIndexGenerator.ts
⏰ 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). (3)
  • GitHub Check: Danger JS
  • GitHub Check: normal
  • GitHub Check: Core Unit Tests, windows-latest
🔇 Additional comments (2)
code/core/src/core-server/utils/StoryIndexGenerator.ts (1)

442-462: LGTM! Clean implementation of optional subtype with sensible defaults.

The logic correctly:

  • Defaults to 'story' when input.type !== 'story'
  • Falls back to 'story' when input.subtype is undefined
  • Uses the computed subtype consistently throughout the entry construction

The conditional at line 457 properly uses the computed subtype value instead of the raw input.subtype.

code/core/src/types/modules/indexer.ts (1)

137-137: LGTM! Type definition correctly reflects optional nature.

The optional marker correctly aligns with the PR objective and the default handling logic in StoryIndexGenerator.ts.

@nx-cloud
Copy link

nx-cloud bot commented Oct 1, 2025

View your CI Pipeline Execution ↗ for commit 06a15c4

Command Status Duration Result
nx run-many -t build --parallel=3 ✅ Succeeded 52s View ↗

☁️ Nx Cloud last updated this comment at 2025-10-03 08:31:39 UTC

JReinhold and others added 2 commits October 1, 2025 16:16
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link
Contributor

@kylegach kylegach left a comment

Choose a reason for hiding this comment

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

Thanks for updating the API reference. I made some suggested changes that need to be addressed prior to merging.

@storybook-bot
Copy link
Contributor

Failed to publish canary version of this pull request, triggered by @JReinhold. See the failed workflow run at: https://github.com/storybookjs/storybook/actions/runs/18203285428

@JReinhold JReinhold merged commit 2dbb592 into next Oct 3, 2025
56 of 58 checks passed
@JReinhold JReinhold deleted the jeppe/optional-subtype branch October 3, 2025 09:34
@github-actions github-actions bot mentioned this pull request Oct 3, 2025
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:normal core maintenance User-facing maintenance tasks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants