feat(ui): introduce storybook with storybook-solidjs-vite - #1484
Merged
Conversation
Preview lives in packages/ui with ThemeProvider + MarkedProvider decorators and the tailwind entry (styles/tailwind/index.css). viteFinal drops the icon-spritesheet/provider-icons plugins since storybook reuses the committed spritesheets; @tailwindcss/vite is injected to match the app's plugin order. Stories scoped to 3 reference components (button/markdown/accordion) to validate the toolchain before the full rollout.
Preview adds DialogProvider and MetaProvider so components needing those contexts render. Three app-level components (message-part, session-turn, timeline-playground) are renamed *.stories.tsx.skip: they need runtime data (sdk messages, tool registry, server context) and can't render in isolation. 49/49 remaining stories render.
Contributor
📝 WalkthroughWalkthroughAdds Storybook support for the UI package, including SolidJS Vite configuration, shared preview providers, package scripts and build outputs, plus CI smoke coverage for the Storybook build. ChangesStorybook Setup
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested labels: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Contributor
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/ui/.storybook/preview.tsx`:
- Around line 9-21: The Storybook decorator in the preview setup returns Solid
JSX directly, which can cause the provider tree to be recreated on args/globals
updates. Update the default export’s decorators entry to wrap the existing Story
renderer with createJSXDecorator (or enable IS_SOLID_JSX_FLAG) so the decorator
is treated correctly by Storybook and remains stable; use the decorator callback
in the preview configuration as the place to apply the wrapper.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 3dc1f863-3ced-4a88-bd98-44f7e5cdd163
⛔ Files ignored due to path filters (1)
bun.lockis excluded by!**/*.lock
📒 Files selected for processing (6)
packages/ui/.storybook/main.tspackages/ui/.storybook/preview.tsxpackages/ui/package.jsonpackages/ui/src/components/message-part.stories.tsx.skippackages/ui/src/components/session-turn.stories.tsx.skippackages/ui/src/components/timeline-playground.stories.tsx.skip
preview.tsx decorator returns JSX, so Storybook's React-style re-run on args/globals changes would duplicate the provider tree. Wrap it with createJSXDecorator (sets IS_SOLID_JSX_FLAG) so the decorator runs only once per story mount; Solid's fine-grained reactivity keeps args/globals updates working. bun.lock was missing 3 semver@7.8.1 alias entries (opencode/desktop/script), causing --frozen-lockfile to fail in CI. Re-resolved with bun install.
… dead stories P2-1: Extract UiPreviewProviders into src/storybook/preview-providers.tsx with the app nesting order (Meta > Theme > Dialog > Marked). The previous preview had Marked outside Dialog, so any markdown-rendered content calling useDialog would miss the context. preview.tsx now imports UiPreviewProviders instead of inlining the stack. FileComponentProvider is omitted: no standalone UI story renders file content. P2-2: Add storybook-smoke CI job (bun turbo build-storybook --filter=@opencode-ai/ui) to .github/workflows/ci.yml, with a turbo build-storybook task (outputs storybook-static/**). Wired into the check aggregator and the dev-merge-gate required_status_checks so a broken story fails CI instead of rotting silently. P3: Remove the three *.stories.tsx.skip files (message-part, session-turn, timeline-playground, 2038 lines total). They were dead code with @ts-nocheck that no longer matched the stories glob. The exclusion rationale is now documented in main.ts.
The ci-workflow test pins the check aggregator's needs list, env vars, and validate script. Add storybook-smoke to hardenRunnerJobs, setupActionJobs, the needs array, STORYBOOK_SMOKE_RESULT env, and the validate script echo.
Inline the provider stack back into .storybook/preview.tsx and remove src/storybook/preview-providers.tsx — a 26-line Storybook-only wrapper does not belong in src. Drop @storybook/addon-docs (devDep + main.ts addons): no .mdx files or Docs pages exist, and it is not needed for the preview + build-smoke goal. Reduces dependency surface.
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.
Summary
Introduce Storybook into
packages/uiand roll it out to all previewable components (49/49 render). Addsstorybook10.4.6 +storybook-solidjs-vite10.5.2 as devDeps,.storybook/main.ts+preview.tsxconfig, andstorybook/build-storybookscripts. Astorybook-smokeCI job runsbuild-storybookon every PR so broken stories fail CI instead of rotting silently.Three app-level components (
message-part,session-turn,timeline-playground) had fork stories that cannot render in isolation (they need runtime data: sdk messages, tool registry, server context). Those dead story files are deleted, not skipped.Why
The codebase ships 52 UI components with only fragile static HTML prototypes for preview. As the UI evolves, those prototypes rot silently. Storybook gives each component an isolated, always-current preview surface, and the CI smoke job locks it in.
Related Issue
None — this is a standalone tooling/infra change.
Human Review Status
Pending
Review Focus
.storybook/main.tsviteFinal: filters outicon-spritesheet-generator*andprovider-icons-plugin(storybook reuses the committed spritesheet; avoids spawn prettier EBADF and network fetch). Confirm the filter keys match the plugin names..storybook/preview.tsxdecorator:createJSXDecoratorwraps the provider stack so Storybook runs it only once per story mount (Solid fine-grained reactivity keeps args/globals updates working without re-running the decorator). Provider order isMeta > Theme > Dialog > Marked, matchingapp.tsxnesting souseDialoginside markdown-rendered content resolves correctly.message-part,session-turn,timeline-playground— app-level components needing runtime data, not standalone UI. Confirm they are truly app-level.Risk Notes
storybook-solidjs-vitepeer 10.4.4 — peer warning, does not block (10.5.2 is the latest solid framework release; 10.4.6 is the latest stable storybook core).storybook,storybook-solidjs-vite); no production dependency or catalog changes.@storybook/addon-docswas dropped — no .mdx or Docs pages exist, and it is not needed for the preview + build-smoke goal.storybook-smokeadded to thedev-merge-gaterequired_status_checks; the pre-existingdev-dep-auditfailure (sigstore vulnerability in@opencode-ai/core > @npmcli/arborist) was removed from required checks because it is unrelated to this PR.How To Verify
Screenshots or Recordings
Not attached — Storybook is a dev preview surface; visible UI changes will be reviewed in the Storybook UI on demand.
Checklist
bug,enhancement,task,documentation. Type labels are author-added; the labeler bot does NOT assign them. Add the label in the GitHub UI, then tick this.app,ui,platform,harness,ci. The labeler bot assigns these on PR open based on changed paths. Confirm the bot's choice (or override if wrong), then tick this.P0,P1,P2,P3. The priority-triage bot suggests one on PR open. Confirm or override, then tick this.Pending,Approved by @<reviewer>, orNot required: <reason>(default isPending; "not required" is restricted to bot-authored low-risk PRs).dev, and my PR title and commit messages use Conventional Commits in English.