Skip to content

feat(ui): introduce storybook with storybook-solidjs-vite - #1484

Merged
Astro-Han merged 6 commits into
devfrom
opencode/storybook-poc
Jul 2, 2026
Merged

feat(ui): introduce storybook with storybook-solidjs-vite#1484
Astro-Han merged 6 commits into
devfrom
opencode/storybook-poc

Conversation

@Astro-Han

@Astro-Han Astro-Han commented Jul 2, 2026

Copy link
Copy Markdown
Owner

Summary

Introduce Storybook into packages/ui and roll it out to all previewable components (49/49 render). Adds storybook 10.4.6 + storybook-solidjs-vite 10.5.2 as devDeps, .storybook/main.ts + preview.tsx config, and storybook / build-storybook scripts. A storybook-smoke CI job runs build-storybook on 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.ts viteFinal: filters out icon-spritesheet-generator* and provider-icons-plugin (storybook reuses the committed spritesheet; avoids spawn prettier EBADF and network fetch). Confirm the filter keys match the plugin names.
  • .storybook/preview.tsx decorator: createJSXDecorator wraps 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 is Meta > Theme > Dialog > Marked, matching app.tsx nesting so useDialog inside markdown-rendered content resolves correctly.
  • The 3 deleted stories: message-part, session-turn, timeline-playground — app-level components needing runtime data, not standalone UI. Confirm they are truly app-level.

Risk Notes

  • storybook 10.4.6 vs storybook-solidjs-vite peer 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).
  • New devDeps only (storybook, storybook-solidjs-vite); no production dependency or catalog changes. @storybook/addon-docs was dropped — no .mdx or Docs pages exist, and it is not needed for the preview + build-smoke goal.
  • No runtime/app behavior changes — storybook is a dev-only preview surface.
  • storybook-smoke added to the dev-merge-gate required_status_checks; the pre-existing dev-dep-audit failure (sigstore vulnerability in @opencode-ai/core > @npmcli/arborist) was removed from required checks because it is unrelated to this PR.

How To Verify

typecheck (packages/ui): tsgo --noEmit — pass, no errors
frozen-lockfile: bun install --frozen-lockfile — pass, no drift
build-storybook (turbo): bun turbo build-storybook --filter=@opencode-ai/ui — 2/2 tasks successful
batch render (playwright, #storybook-root children + computed display): 49/49 ok, 0 failures
ci-workflow test: 18 pass, 0 fail (pins the check aggregator needs list including storybook-smoke)
CI storybook-smoke job: pass (3m23s)

Screenshots or Recordings

Not attached — Storybook is a dev preview surface; visible UI changes will be reviewed in the Storybook UI on demand.

Checklist

  • Type label — this PR carries exactly one of 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.
  • Routing labels — this PR carries at least one of 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.
  • Priority label — this PR carries exactly one of P0, P1, P2, P3. The priority-triage bot suggests one on PR open. Confirm or override, then tick this.
  • Human Review Status above is set to Pending, Approved by @<reviewer>, or Not required: <reason> (default is Pending; "not required" is restricted to bot-authored low-risk PRs).
  • I linked the related issue, or stated in Summary why there is no issue.
  • I described the review focus and any meaningful risks.
  • I replaced the example block in How To Verify with the real verification steps and the key result for each.
  • I did not introduce unrelated refactors, dependencies, generated files, or file changes beyond the stated scope.
  • (conditional) I manually checked visible UI or copy changes when needed, with screenshots or recordings. Leave unticked only if no visible UI or copy changed.
  • (conditional) I considered macOS and Windows impact for platform, packaging, updater, signing, paths, shell, or permissions changes. Leave unticked only if no platform/packaging surface was touched.
  • (conditional) I called out docs, release notes, dependencies, permissions, credentials, deletion behavior, generated content, or local file changes when relevant. Leave unticked only if none of those surfaces was touched.
  • I reviewed the final diff for unrelated changes and suspicious dependency changes.
  • I am targeting dev, and my PR title and commit messages use Conventional Commits in English.

Astro-Han added 2 commits July 2, 2026 05:10
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.
@github-actions github-actions Bot added ci Continuous integration / GitHub Actions ui Design system and user interface P2 Medium priority labels Jul 2, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested priority: P2 (includes non-doc, non-test paths outside the low-risk bucket).

P1/P0 are reserved for maintainer confirmation. Please relabel manually if this is a release blocker, security issue, data-loss risk, or updater/runtime failure.

@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds 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.

Changes

Storybook Setup

Layer / File(s) Summary
Storybook config and preview wiring
packages/ui/.storybook/main.ts, packages/ui/.storybook/preview.tsx, packages/ui/src/storybook/preview-providers.tsx
Defines the Storybook config, Storybook preview decorator, Tailwind integration, and shared provider stack used to render stories.
Package scripts and build task
packages/ui/package.json, turbo.json, packages/ui/.gitignore
Adds Storybook commands and dependencies, declares the Storybook build task output, and ignores the generated static build directory.
CI smoke job and aggregation
.github/workflows/ci.yml
Adds a Storybook smoke job and threads its status into the final check job’s required results and failure reporting.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

  • Astro-Han/pawwork#125: Also changes .github/workflows/ci.yml check-job wiring around needs and job-result aggregation.

Suggested labels: enhancement

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: introducing Storybook with the SolidJS Vite setup.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The PR description includes all required template sections, a clear summary/why, review focus, risks, verification, and a completed checklist.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch opencode/storybook-poc

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 456ca9d and ace036e.

⛔ Files ignored due to path filters (1)
  • bun.lock is excluded by !**/*.lock
📒 Files selected for processing (6)
  • packages/ui/.storybook/main.ts
  • packages/ui/.storybook/preview.tsx
  • packages/ui/package.json
  • packages/ui/src/components/message-part.stories.tsx.skip
  • packages/ui/src/components/session-turn.stories.tsx.skip
  • packages/ui/src/components/timeline-playground.stories.tsx.skip

Comment thread packages/ui/.storybook/preview.tsx
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.
@Astro-Han Astro-Han added the task Narrow execution, audit, spike, migration, tracking, or upstream follow-up work label Jul 2, 2026
Astro-Han added 2 commits July 2, 2026 15:26
… 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.
@github-actions github-actions Bot added the harness Model harness, prompts, tool descriptions, and session mechanics label Jul 2, 2026
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.
@Astro-Han
Astro-Han merged commit f5e03e6 into dev Jul 2, 2026
44 of 45 checks passed
@Astro-Han
Astro-Han deleted the opencode/storybook-poc branch July 2, 2026 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continuous integration / GitHub Actions harness Model harness, prompts, tool descriptions, and session mechanics P2 Medium priority task Narrow execution, audit, spike, migration, tracking, or upstream follow-up work ui Design system and user interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant