Skip to content

feat: unify smartui-storybook into smartui-cli (built-in storybook command + TUI) - #527

Draft
chaitanyas-maker wants to merge 8 commits into
LambdaTest:stagefrom
chaitanyas-maker:feat/unify-storybook
Draft

feat: unify smartui-storybook into smartui-cli (built-in storybook command + TUI)#527
chaitanyas-maker wants to merge 8 commits into
LambdaTest:stagefrom
chaitanyas-maker:feat/unify-storybook

Conversation

@chaitanyas-maker

Copy link
Copy Markdown

Unify @lambdatest/smartui-storybook into @lambdatest/smartui-cli

Folds the standalone Storybook CLI into the main CLI as a built-in storybook command, plus a terminal UI. Draft — opened for review/discussion; not merge-ready (see Open Questions). Tested live end-to-end.

Why

Both packages declare bin.smartui, so they collide on PATH — installing @lambdatest/smartui-storybook silently clobbers @lambdatest/smartui-cli (and vice-versa), and users need two installs for one tool. The storybook package also re-implements auth, git, HTTP, polling, and constants the main CLI already owns. This PR makes one binary own the name and ships Storybook as a first-class command.

Approach — faithful relocation (not a rewrite)

Rather than re-plumb Storybook onto the CLI's createBuild/finalizeBuild lifecycle (which depends on an unverified backend question — see Open Questions), this vendors the proven, shipping @lambdatest/smartui-storybook v1.1.32 engine into the CLI under src/storybookVendor/, hitting the same /storybook/* endpoints it already uses in production. Behaviour is byte-identical to the standalone tool; only the collision and the double-install are removed. The "elegant" shared-lifecycle refactor is the documented follow-up once the backend routing is confirmed.

What changed

  • New command smartui storybook <url-or-dir> — URL and DIR modes, grammar identical to the standalone package.
  • New generator smartui config:create-storybook + a storybook block in the ajv ConfigSchema (and anyOf, since the top level is additionalProperties:false).
  • Vendored engine src/storybookVendor/** (12 .cjs modules), bundled by tsup. Vendored .js.cjs so esbuild bundles them as CommonJS under the CLI's "type":"module".
  • Terminal UI src/lib/tui.cjs — gradient banner + boxed launch/summary (dashboard link, screenshot/approval/change counts). Degrades gracefully without a TTY (CI-safe).
  • Deps: puppeteer, jsdom, archiver, form-data, cli-table3, proxy agents (engine); figlet, gradient-string, boxen, log-symbols, ora (TUI). pnpm-lock.yaml updated.

Testing (live)

  • DIR mode — fully working. 5-component / 17-story demo → baseline (0 changes) → one-line rebrand → 24 changed / 9 unchanged, real builds on the dashboard.
  • Core SDK regression — passes. Built from source (pnpm i → build → pack), wired to @lambdatest/playwright-driver (SDK stage), ran smartui exec -- node test.js → build finalized. The merge does not break the exec/web-capture flow.
  • URL mode — runs end-to-end after fixes below, but returns Total Screenshots: 0 from the backend /storybook/render DOM-upload path (both 17-story and 1-story). Points at the render endpoint, not the CLI glue — see Open Questions.

Fixes from review (thanks @sushobhit-lt)

  • dom.cjsdom/clone/element were implicit globals (strict-mode ReferenceError once bundled); declared with const.
  • storybook.cjs — guarded the URL-mode resolutions loop with a viewports fallback so smartui storybook <url> with no -c doesn't crash on the default config.
  • storybook.ts — merged root global flags via optsWithGlobals() so --config actually reaches the engine (local -c/--config collided with the global one).

Open questions for maintainers

  1. Backend endpoint ownership. URL-mode /storybook/render returns 0 screenshots here; and the shared-lifecycle refactor needs confirmation that the CLI's visualui/1.0 client can reach /storybook/*. Biggest unknown.
  2. Versioning / deprecation. Proposed 5.0.0 (MAJOR) + a deprecation shim on @lambdatest/smartui-storybook. Not done here.
  3. Tests + @ts-nocheck. Needs the project's test suite; src/commander/storybook.ts uses // @ts-nocheck (vendored .cjs import lacks types) — to be scoped down as follow-up.

Not included (deliberately)

Live publish, official version bump, deprecation shim, docs updates.

🤖 Generated with Claude Code

salmanlt and others added 8 commits May 16, 2026 01:38
docs: update README to TestMu AI branding
…command

Vendor the proven @lambdatest/smartui-storybook v1.1.32 engine into the single
smartui binary (faithful relocation hitting the same /storybook/* backend), add
config:create-storybook, and resolve the colliding-bin problem. One install, one
binary. Version 5.0.0-unified.1.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CwQRZwr64F9fLQAW4V1bWy
…ent, log-symbols)

Gradient figlet banner + launch config box + end-of-run summary box (dashboard
link, screenshot/approval/change counts) around the storybook command. Summary
deferred to process 'beforeExit' so it lands after the engine's polling. Verified
with a live baseline build (11 stories -> 33 screenshots) on SmartUI cloud.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CwQRZwr64F9fLQAW4V1bWy
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CwQRZwr64F9fLQAW4V1bWy
Two bugs that broke the URL-mode capture path (surfaced by live URL testing,
confirmed by @sushobhit-lt review on PR #1):

- storybook.ts: merge root global flags via optsWithGlobals() so `--config`
  actually reaches the engine (local -c/--config collided with the global one),
  letting validateConfig normalize viewports->resolutions.
- dom.cjs: declare `dom`/`clone`/`element` with const — they were implicit
  globals that throw ReferenceError once bundled into strict mode (same class
  as the earlier res/filename/githubURL fixes; these three were missed).
- storybook.cjs: guard the URL-mode resolutions loop with a viewports fallback
  so `smartui storybook <url>` with no -c flag doesn't crash on the default
  config (per review).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CwQRZwr64F9fLQAW4V1bWy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants