Skip to content
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

Core: New Status Store #30764

Open
wants to merge 43 commits into
base: next
Choose a base branch
from
Open

Core: New Status Store #30764

wants to merge 43 commits into from

Conversation

JReinhold
Copy link
Contributor

@JReinhold JReinhold commented Mar 6, 2025

Closes #

What I did

Replaced the existing status API (experimental_updateStatus et.al.) with a new one, based on a statusStore - that is backed by a Universal Store.

End-user functionality should stay the same, except now statuses are persisted on the server too instead of in browser sesison storage, so they sync between different tabs, they are kept when you close the tab, but they are cleared when you restart the dev server.

Not going to explain the new status API just yet, as it's still considered mainly an internal/experimental thing.

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 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 canary-release-pr.yml --field pr=<PR_NUMBER>

Greptile Summary

This PR introduces a new Status Store system for centralized status management across Storybook's server, manager, and preview environments, replacing the existing experimental status API with a more robust implementation.

  • Added code/core/src/shared/status-store with comprehensive test coverage and type safety for managing component statuses
  • Updated A11y and Test addons to use new experimental_useStatusStore hook instead of direct API calls
  • Removed old status-related types (API_StatusValue, API_StatusObject) in favor of new StatusByTypeId and StatusValue enum
  • Modified sidebar components to use new status store for error/warning counts and status filtering
  • Added proper error handling with new StatusTypeIdMismatchError for type validation across environments

Copy link

nx-cloud bot commented Mar 6, 2025

View your CI Pipeline Execution ↗ for commit 87c4b2a.

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

☁️ Nx Cloud last updated this comment at 2025-03-11 20:42:29 UTC

@@ -101,7 +101,7 @@ const config = defineMain({
'@storybook/addon-designs',
'@storybook/addon-test',
'@storybook/addon-a11y',
'@chromatic-com/storybook',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

temporary, until VTA has been updated with the new Status API

Comment on lines +18 to +19
export const componentTestStatusStore = experimental_getStatusStore(STATUS_TYPE_ID_COMPONENT_TEST);
export const a11yStatusStore = experimental_getStatusStore(STATUS_TYPE_ID_A11Y);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because addon-test both handles CT statuses and a11y statuses, we get a status store slice for each of the two type ids, that operates independently of each other.

)
);
})();
componentTestStatusStore.set(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

from an addon's perspective, this change is the main difference between the old and the new API.

@@ -67,7 +67,10 @@ const bootTestRunner = async (channel: Channel) => {

const startChildProcess = () =>
new Promise<void>((resolve, reject) => {
child = execaNode(vitestModulePath);
child = execaNode(vitestModulePath, {
env: { VITEST: 'true', TEST: 'true', NODE_ENV: process.env.NODE_ENV ?? 'test' },
Copy link
Contributor Author

Choose a reason for hiding this comment

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

these were already set at runtime in the vitest module, but setting them immediately here means that they will be set before anything else.


const statusStore = createStatusStore({
universalStatusStore:
process.env.VITEST !== 'true'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is a temporary workaround, until we fix UniversalStore leader/follower determination on a holistic level.

@JReinhold JReinhold added maintenance User-facing maintenance tasks core addon: test and removed ci: do not merge labels Mar 10, 2025
@JReinhold JReinhold self-assigned this Mar 10, 2025
@JReinhold JReinhold requested a review from yannbf March 10, 2025 14:02
@JReinhold JReinhold marked this pull request as ready for review March 10, 2025 14:02
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

47 file(s) reviewed, 27 comment(s)
Edit PR Review Bot Settings | Greptile

JReinhold and others added 6 commits March 10, 2025 16:08
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@JReinhold JReinhold requested a review from ghengeveld March 11, 2025 14:22
@storybook-pr-benchmarking
Copy link

storybook-pr-benchmarking bot commented Mar 11, 2025

Package Benchmarks

Commit: 87c4b2a, ran on 11 March 2025 at 20:46:57 UTC

The following packages have significant changes to their size or dependencies:

storybook

Before After Difference
Dependency count 98 98 0
Self size 21.54 MB 21.59 MB 🚨 +52 KB 🚨
Dependency size 21.69 MB 21.69 MB 🚨 +145 B 🚨
Bundle Size Analyzer Link Link

@storybook/nextjs

Before After Difference
Dependency count 540 539 🎉 -1 🎉
Self size 219 KB 219 KB 0 B
Dependency size 58.82 MB 58.62 MB 🎉 -203 KB 🎉
Bundle Size Analyzer Link Link

sb

Before After Difference
Dependency count 99 99 0
Self size 1 KB 1 KB 0 B
Dependency size 43.24 MB 43.29 MB 🚨 +52 KB 🚨
Bundle Size Analyzer Link Link

@storybook/cli

Before After Difference
Dependency count 388 388 0
Self size 284 KB 284 KB 0 B
Dependency size 93.38 MB 93.44 MB 🚨 +61 KB 🚨
Bundle Size Analyzer Link Link

@storybook/codemod

Before After Difference
Dependency count 309 309 0
Self size 614 KB 614 KB 0 B
Dependency size 74.99 MB 75.05 MB 🚨 +57 KB 🚨
Bundle Size Analyzer Link Link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants