refactor(storybook): rebuild the unified host as a devframe hub - #139
Merged
Conversation
Each plugin's Storybook is now a first-class `type: 'launcher'` dock bound to a `ctx.commands` command, replacing the iframe docks + bespoke `storybook-hub:ensure` RPC. Hitting Start dispatches the command over `hub:commands:execute`, which spawns `storybook dev` through `ctx.terminals`, streams the boot output onto the launcher's digest, and returns the resolved URL the client iframes in place.
✅ Deploy Preview for devfra ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Replace the @devframes/storybook Storybook Composition shell with a devframe hub (built on @devframes/hub): each plugin's Storybook is a `type: 'launcher'` dock bound to a `ctx.commands` command that spawns `storybook dev` through `ctx.terminals` on demand, streams boot output to the launcher digest, and iframes the running instance in place. The live terminals plugin docks alongside so the spawned processes are watchable. Drop the now-redundant examples/storybook-hub example (its hub code lives in the storybook package now), and point `pnpm storybook` at the host hub rather than fanning out every plugin's storybook in parallel.
Projecting dock entries into the `devframe:docks` shared state runs them through Immer's `produce`, which deep-freezes the very objects the docks registry holds. The `register().update(patch)` handler then merged with an in-place `Object.assign`, throwing "Cannot assign to read only property" the first time a launcher (or any entry) was patched after the initial sync. Merge into a fresh object and swap it into the registry instead.
…gins in the hub Give the two plugins that lacked a Storybook their own Vue setup (`.storybook` config mirroring the existing plugins, plus presentational component stories with static fixtures), and dock every plugin's Storybook in the unified hub — data-inspector, og, and the pre-existing messages Storybook now join git/inspect/code-server/terminals/a11y as launcher docks.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Rebuilds the unified Storybook host (
@devframes/storybook) as a devframe hub (on@devframes/hub) instead of a Storybook Composition shell. The hub is the UI shell; each built-in plugin's Storybook is its owntype: 'launcher'dock that boots itsstorybook devprocess on demand, with the live terminals plugin docked alongside.ctx.commandscommand (storybook:launch:<id>) plus a launcher dock bound to it.hub:commands:executepath, which spawnsstorybook devthroughctx.terminals(a read-only hub terminal session), streams the tail of the boot output onto the launcher'sdigest, tracks it viaterminalSessionId, and returns the resolved URL.storybook-static/<id>served on one origin.The former Storybook Composition wiring (
.storybook/,refs, the HTML host shell,Introduction.stories.ts,@storybook/html-vite) is removed.Housekeeping
examples/storybook-hubexample — its hub code now lives in thestorybook/package (self-contained; no cross-dependency).pnpm storybookruns the host hub (pnpm -C storybook dev), which spawns each plugin's Storybook lazily, rather than fanning out every plugin'sstorybook devin parallel. Plugins keep their ownstorybookscripts for standalone use.turbo.json: swaps thestorybook-hub#buildtask for@devframes/storybook#build.cleanupUnusedCatalogsprunes the now-unused@storybook/html-vitecatalog entry.Why
The unified host now dogfoods devframe end to end — the hub's launcher primitive (bound command +
terminalSessionId+ livedigest) drives each Storybook instead of Storybook Composition.Verification
tsc --noEmit,eslint, andvite buildall pass for thestorybook/package.This PR was created with the help of an agent.
Follow-up fix
fix(hub): don't mutate frozen dock entries in register().update— surfaced while launching a Storybook: projecting a dock into thedevframe:docksshared state runs it through Immer'sproduce, which deep-freezes the object the registry holds, soregister().update(patch)'s in-placeObject.assignthrew "Cannot assign to read only property 'launcher'" on the first patch after sync. The handler now merges into a fresh object and swaps it in; added a regression test that freezes the stored view and patches it.