feat: Storybook hosting POC — SDK auto-upload#1290
Conversation
… run After a successful `percy storybook ./storybook-static` run completes its snapshot capture, the SDK now zips the directory and POSTs it to /api/v1/builds/:id/storybook_bundle on percy-api. Wired in src/storybook.js: - Only when args.serve is set (directory mode); URL mode has no on-disk bundle to upload. - After yield* takeStorybookSnapshots, yield* percy.yield.flush() drains the snapshot queue and resolves createBuild before reading percy.build.id (guard against the delayUploads: true race). - Best-effort: failure swallowed via uploadStorybookBundle's try/catch; the snapshot run remains the source of truth for build success. src/upload-bundle.js: - archiver streams the directory into a Buffer (form-data multipart needs the full body length, so we collect in memory; POC bundles are 30-80 MB). - axios.post (instead of percy.client.post — that's JSON-only) reusing percy.client.apiUrl + token. maxContentLength/Infinity for headroom. - log.info on 2xx; log.warn + return on any 4xx/5xx/network error. 7 jasmine specs cover happy path, 4xx, 5xx, network failure, and three gate conditions (missing buildId / directory / client config). New deps: archiver 7.0.1, form-data 4.0.5. axios 1.13.5 was already present. Plan: docs/plans/2026-04-24-001-feat-storybook-hosting-poc-plan.md (Unit 5)
Verified end-to-end (2026-04-28)After uploading a test fixture via curl to the new percy-api endpoint (PR #5806), the bundle is served from Click → new tab opens the hosted bundle: The SDK side (this PR) was unit-tested in isolation with axios stubbed (7/7 jasmine specs pass). For a full live SDK e2e, link the local Tracked at PER-7873. |
End-to-end with the SDK's own test storiesBuilt And on the percy-web review page: For the "live SDK" path (where this PR's actual code path runs end-to-end), |
|
This PR is stale because it has been open for more than 14 days with no activity. Remove stale label or comment or this will be closed in 14 days. |




Summary
POC: after a successful directory-mode `percy storybook ./storybook-static` run, zip the directory and POST it to percy-api's new bundle endpoint. Companion PR to the API + Web PRs.
Plan: `docs/plans/2026-04-24-001-feat-storybook-hosting-poc-plan.md` (status: completed)
Companion PRs
Changes
`f23199b` adds:
What this does NOT do
Testing
Post-Deploy Monitoring & Validation
`No additional operational monitoring required: this is opt-in by client SDK upgrade. Customers running an older @percy/storybook version do not get the upload. Productionization (Phase 2) adds Honeycomb instrumentation on upload latency + Sentry capture on swallowed failures above a threshold; that work has its own plan.`
🤖 Generated with Claude Code via Compound Engineering v2.54.0
Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com