You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a tracking issue for a project centered around creating a primitive that makes it easier to have state that is synced between some or all "environments".
β οΈ Problem
Storybook consists of multiple "environments" that tie the experience together:
The dev server
One or multiple places in the the manager UI (eg. an addon panel and toolbar dropdown)
The preview UI (ie. in stories)
The Channel API can be used to communicate between these environments, but it only solves the communication part, and leaves it up to the consumer to figure out how to keep state in sync between the environments, which is not straight forward. A few use cases that are harder to implement than they should be today are:
Sharing state between the dev server and the manager UI. The (experimental) Test addon does this a lot, sharing information between the Vitest instance on the server with the sidebar UI.
Sharing state between multiple "slots" in the manager UI, ie. an addon panel that shares information with a toolbar tool. This is hard today because the two components are registered separately without any possibility to instantiate a React context provider or similar way to share information.
Sharing state between the preview and the manager UI, ie. an addon panel that needs to show different information based on some logic it is injecting into stories.
The most immediate problem we're facing today is inconsistent state in the Test Module. It can quickly get out of sync if the dev server restarts, if the manager has stale state in session storage, or if other tabs changes the state of the server.
π Goals
The high-level goals of this project is to:
Construct a low-level primitive API that makes it easier to share state across multiple environments. It must be use-case agnostic, not focusing on any specific environments, eg. it shouldn't need to sync to the server, if the use case is only to sync between manager UI slots. It's still TBD whether or not that API will be a public, non-experimental at the end of the project or not, it might be beneficial to keep it internal/experimental for a period of time before we commit to stabilising it for public use.
Use the new API to revamp the state management in the testing addon, eliminating state inconsistencies where possible. There's a high chance this supersedes the current (experimental) testing module API, still TBD.
π Research
@JReinhold has done an initial POC on a "UniversalState" API, that can serve as an inspiration or starting point for discussions and initial implementation. The final API might not look like this at all, or it might be a slight modification of this, we'll see. π€· The POC is implemented in the jeppe/universal-state branch.
(note the following videos where originally intended for the Storybook Core team eyes only, so it might require contextual knowledge that you don't have)
Demonstration of UniversalState POC from the consumer perspectiveuniversal-state-1.mp4universal-state-2.mp4Demonstration of how the UniversalState POC is implementeduniversal-state-3.mp4
The @chromatic-com/storybook addon also has a concept of SharedState that is very similar to the UniversalState POC as it needs to solve the same underlying pain-points.
The base idea is currently to create a minimal, low-level abstraction on top of the existing Channel API that handles the syncing of the state - the Channel API already handled communication between the environments, but it doesn't handle anything regarding keeping state in sync.
Primitive API
The content you are editing has changed. Please copy your edits and refresh the page.
π§βπ€βπ§ Who: @JReinhold and @valentinpalkovic
This is a tracking issue for a project centered around creating a primitive that makes it easier to have state that is synced between some or all "environments".
Storybook consists of multiple "environments" that tie the experience together:
The Channel API can be used to communicate between these environments, but it only solves the communication part, and leaves it up to the consumer to figure out how to keep state in sync between the environments, which is not straight forward. A few use cases that are harder to implement than they should be today are:
The most immediate problem we're facing today is inconsistent state in the Test Module. It can quickly get out of sync if the dev server restarts, if the manager has stale state in session storage, or if other tabs changes the state of the server.
π Goals
The high-level goals of this project is to:
π Research
@JReinhold has done an initial POC on a "UniversalState" API, that can serve as an inspiration or starting point for discussions and initial implementation. The final API might not look like this at all, or it might be a slight modification of this, we'll see. π€· The POC is implemented in the
jeppe/universal-state
branch.(note the following videos where originally intended for the Storybook Core team eyes only, so it might require contextual knowledge that you don't have)
Demonstration of UniversalState POC from the consumer perspective
universal-state-1.mp4
universal-state-2.mp4
Demonstration of how the UniversalState POC is implemented
universal-state-3.mp4
The
@chromatic-com/storybook
addon also has a concept ofSharedState
that is very similar to the UniversalState POC as it needs to solve the same underlying pain-points.π© Milestones
The base idea is currently to create a minimal, low-level abstraction on top of the existing Channel API that handles the syncing of the state - the Channel API already handled communication between the environments, but it doesn't handle anything regarding keeping state in sync.
Primitive API
Tasks
Use API in testing addon
Tasks
The text was updated successfully, but these errors were encountered: