-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
base: next
Are you sure you want to change the base?
Core: New Status Store #30764
Conversation
…n the state hasn't changed
View your CI Pipeline Execution ↗ for commit 87c4b2a.
☁️ Nx Cloud last updated this comment at |
@@ -101,7 +101,7 @@ const config = defineMain({ | |||
'@storybook/addon-designs', | |||
'@storybook/addon-test', | |||
'@storybook/addon-a11y', | |||
'@chromatic-com/storybook', |
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.
temporary, until VTA has been updated with the new Status API
export const componentTestStatusStore = experimental_getStatusStore(STATUS_TYPE_ID_COMPONENT_TEST); | ||
export const a11yStatusStore = experimental_getStatusStore(STATUS_TYPE_ID_A11Y); |
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.
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( |
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.
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' }, |
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.
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' |
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.
this is a temporary workaround, until we fix UniversalStore leader/follower determination on a holistic level.
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.
47 file(s) reviewed, 27 comment(s)
Edit PR Review Bot Settings | Greptile
code/core/src/shared/universal-store/use-universal-store-manager.ts
Outdated
Show resolved
Hide resolved
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>
… into jeppe/status-store
Package BenchmarksCommit: The following packages have significant changes to their size or dependencies:
|
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 |
Closes #
What I did
Replaced the existing status API (
experimental_updateStatus
et.al.) with a new one, based on astatusStore
- 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:
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:merged
orci:daily
GH 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.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.
code/core/src/shared/status-store
with comprehensive test coverage and type safety for managing component statusesexperimental_useStatusStore
hook instead of direct API callsAPI_StatusValue
,API_StatusObject
) in favor of newStatusByTypeId
andStatusValue
enumStatusTypeIdMismatchError
for type validation across environments