Skip to content

Core: Improve path handling in arg types data extraction#33536

Merged
yannbf merged 1 commit into
nextfrom
yann/fix-ghost-stories-flow
Jan 14, 2026
Merged

Core: Improve path handling in arg types data extraction#33536
yannbf merged 1 commit into
nextfrom
yann/fix-ghost-stories-flow

Conversation

@yannbf
Copy link
Copy Markdown
Member

@yannbf yannbf commented Jan 14, 2026

Closes #

What I did

The argtypes data extraction is called from multiple places, both the Storybook UI and Vitest plugin. Through the UI, the paths are not absolute, and through the Vitest plugin they are. So this fix makes sure to normalize the path if needed.

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

Caution

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-33536-sha-9c4b46d4. Try it out in a new sandbox by running npx storybook@0.0.0-pr-33536-sha-9c4b46d4 sandbox or in an existing project with npx storybook@0.0.0-pr-33536-sha-9c4b46d4 upgrade.

More information
Published version 0.0.0-pr-33536-sha-9c4b46d4
Triggered by @yannbf
Repository storybookjs/storybook
Branch yann/fix-ghost-stories-flow
Commit 9c4b46d4
Datetime Wed Jan 14 14:04:48 UTC 2026 (1768399488)
Workflow run 20996918012

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=33536

Summary by CodeRabbit

  • Bug Fixes
    • Fixed an issue where absolute component file paths were being incorrectly prefixed with the project root, preventing proper path resolution.

✏️ Tip: You can customize this high-level summary in your review settings.

@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented Jan 14, 2026

View your CI Pipeline Execution ↗ for commit 9c4b46d

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

☁️ Nx Cloud last updated this comment at 2026-01-14 14:14:40 UTC

@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented Jan 14, 2026

View your CI Pipeline Execution ↗ for commit 9c4b46d


☁️ Nx Cloud last updated this comment at 2026-01-14 14:04:49 UTC

@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented Jan 14, 2026

View your CI Pipeline Execution ↗ for commit 9c4b46d

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

☁️ Nx Cloud last updated this comment at 2026-01-14 14:14:40 UTC

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 14, 2026

📝 Walkthrough

Walkthrough

Modifies the React preset's path resolution logic to conditionally check if a component file path is absolute before prepending the project root, preventing double-prefixing of already absolute paths.

Changes

Cohort / File(s) Summary
Path resolution fix
code/renderers/react/src/preset.ts
Added absolute path check in internal_getArgTypesData: imports both default and named exports from the path module; now conditionally resolves componentFilePath only if it's relative, avoiding path double-prefixing for absolute paths.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • storybookjs/storybook#32893: Adjusts path-resolution logic in presets to handle component file path absoluteness, similar to this PR's introduction of conditional path checks.
✨ Finishing touches
  • 📝 Generate docstrings


📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2840142 and 9c4b46d.

📒 Files selected for processing (1)
  • code/renderers/react/src/preset.ts
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{js,jsx,ts,tsx,json,md,html,css,scss}

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

Format code using Prettier with yarn prettier --write <file>

Files:

  • code/renderers/react/src/preset.ts
**/*.{js,jsx,json,html,ts,tsx,mjs}

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

Run ESLint checks using yarn lint:js:cmd <file> or the full command cross-env NODE_ENV=production eslint --cache --cache-location=../.cache/eslint --ext .js,.jsx,.json,.html,.ts,.tsx,.mjs --report-unused-disable-directives to fix linting errors before committing

Files:

  • code/renderers/react/src/preset.ts
**/*.{ts,tsx}

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

Enable TypeScript strict mode across all packages

Files:

  • code/renderers/react/src/preset.ts
**/*.{ts,tsx,js,jsx}

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

**/*.{ts,tsx,js,jsx}: Export functions from modules if they need to be tested
Do not use console.log, console.warn, or console.error directly unless in isolated files where importing loggers would significantly increase bundle size

Files:

  • code/renderers/react/src/preset.ts
🧠 Learnings (2)
📚 Learning: 2025-10-01T15:24:01.060Z
Learnt from: Sidnioulz
Repo: storybookjs/storybook PR: 32594
File: code/core/src/components/components/Popover/WithPopover.tsx:7-9
Timestamp: 2025-10-01T15:24:01.060Z
Learning: In the Storybook repository, "react-aria-components/patched-dist/*" (e.g., "react-aria-components/patched-dist/Dialog", "react-aria-components/patched-dist/Popover", "react-aria-components/patched-dist/Tooltip") are valid import paths created by a patch applied to the react-aria-components package. These imports should not be flagged as broken or invalid until a maintainer explicitly states they are no longer acceptable.

Applied to files:

  • code/renderers/react/src/preset.ts
📚 Learning: 2025-12-22T22:03:40.123Z
Learnt from: CR
Repo: storybookjs/storybook PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-22T22:03:40.123Z
Learning: Applies to code/{core,lib,addons,builders,frameworks,presets}/**/*.{ts,tsx,js,jsx} : Use `logger` from `storybook/internal/node-logger` for server-side logging in Node.js code

Applied to files:

  • code/renderers/react/src/preset.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). (6)
  • GitHub Check: normal
  • GitHub Check: Core Unit Tests, windows-latest
  • GitHub Check: nx
  • GitHub Check: nx
  • GitHub Check: nx
  • GitHub Check: nx
🔇 Additional comments (2)
code/renderers/react/src/preset.ts (2)

1-1: LGTM!

The combined default and named import pattern is appropriate here since both path.isAbsolute() and join() are used in the file.


86-91: LGTM!

The conditional path resolution correctly handles both contexts:

  • Storybook UI provides relative paths → joined with project root
  • Vitest plugin provides absolute paths → used directly

The use of path.isAbsolute() is the idiomatic way to handle this cross-platform.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


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

@yannbf yannbf changed the title Core: improve path handling in arg types data extraction Core: Improve path handling in arg types data extraction Jan 14, 2026
@yannbf yannbf merged commit b3cfc15 into next Jan 14, 2026
77 of 78 checks passed
@yannbf yannbf deleted the yann/fix-ghost-stories-flow branch January 14, 2026 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants