Repository navigation
Conversation
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
|
Contributor
|
📦 Package Size: 8060 KB Bundled dependencies compared with PR base ae4f6f7. Bundled dependency changesVersions from emitted source maps; external dependencies are not included. CLI / Node API
GitHub Action
|
…hanges With TurboSnap, a change to any file the preview reaches recaptures every story. When a stats file exists, doctor now builds the TurboSnap manifest and reports how many project and package files preview reaches, the imports that bring in the most (and what only they bring in), and how many recent commits changed a project file behind it. Without a stats file it says how to make one. The check is read-only: it warns at most and offers no fix. Amp-Thread-ID: https://ampcode.com/threads/T-01a1d7b7-69d0-75bd-a184-7440f6a67cef
codykaup
force-pushed
the
codykaup/doctor-preview-reach
branch
from
November 22, 2026 16:24
3112d78 to
6b2c7f8
Compare
…ith stats when doctor needs them The preview check now lists the most-changed files one per line with their commit counts, instead of packing them into one sentence. When TurboSnap is on and Chromatic builds Storybook itself but there is no stats file, doctor offers to run the same build command a TurboSnap build would, then shows the preview check. In a terminal it asks first; --yes builds without asking; without a terminal and without --yes it doesn't build, and says to run doctor --yes. Amp-Thread-ID: https://ampcode.com/threads/T-01a1d7b7-69d0-75bd-a184-7440f6a67cef
This branch has not been deployed
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.
Shows in
chromatic doctorwhat the Storybook preview reaches and how often those files change. With TurboSnap, a change to any file the preview reaches recaptures every story, so this tells people how big that is and which import causes it. When TurboSnap is on but there's no stats file yet,doctorcan build Storybook with stats first and then run the check. It sits on theinitPR below it in the stack.📸 Screenshots
--yes: builds, then checks--yesBoth are a React Vite project with TurboSnap on, whose
.storybook/preview.tsximports a barrelsrc/index.ts, with 8 commits spread over 200 days. In a terminal without--yes,doctorasks "Build Storybook with stats to check what preview imports?" before building.📋 What changed
bin-src/setup/previewReach.tsbuildManifest, and reports what preview reaches, by import, and how often it changed in gitbin-src/setup/checks.ts,report.tsinfostatus with a●mark thatsummarizedoesn't count; wrapped-list items are indentedbin-src/doctor.tsbin-src/setup/checks.tsbuild: the command and the stats file it writesbin-src/setup/init.tsinit's closing check lists only warnings and failures, so the info line doesn't show there💡 Why
doctorruns on the user's machine, not in CI, so it has the full git history to say how often those files actually change.🛠️ How it works
attribution.previewSubtreefrombuildManifest, for the preview files in the config directorygit log --since=90.daysover those files. Skipped in a shallow clone. Packages change through the lockfile, so they aren't counteddependencieschromatic trace -s <stats file> <file>, which already prints the chainStatus: a warning when a commit changed a file behind preview, otherwise a pass. It never fails
doctorand never offers a fix.No stats file: an info line. It reads
<storybookBuildDir or storybook-static>/preview-stats.json.Building the stats file: when TurboSnap is on (
onlyChanged) and Chromatic builds Storybook itself (nostorybookBuildDir),doctorcan run the same command a TurboSnap build runs, from the main command'ssetBuildCommand, intostorybook-static. Then it prints the preview check.doctorruns--yes, in a terminal or CI--yesnpx chromatic doctor --yesbuild-storybook.log, says so, and keeps the info line.doctorstill exits 0Without TurboSnap, or with a prebuilt Storybook, the info line says how to build one, as before.
Skipped for Playwright, Cypress and Vitest projects, which have no preview of their own.
⚖️ Trade-offs & decisions
doctorotherwise never starts one: a Storybook build can take minutes, and CI shouldn't start one unasked.--yesnow means "answer yes to everything", so it also builds when--fixisn't set.storybook-static, wheredoctorlooks for the stats file, so the next run is instant and thechromatic trace -shint points at a file that exists. A Chromatic build uses a temp folder instead.initdoesn't build. Its closing check only shows warnings and failures, so the info line never shows there.🧪 Verification
node dist/bin.cjs doctorin the project in the first screenshotsrc/index.tsis the top import, with all 10 project files only through it, flagged "like a barrel"doctorafterbuild-storybook --stats-jsondoctorin a monorepo package with no builddoctoratb99f796ein the barrel projectsrc/theme/tokens.ts: 3 commits,src/utils/date.ts: 2 commits,src/utils/currency.ts: 1 commit--yesin CICI=1 doctor --yesafter deleting the stats filestorybook-static/preview-stats.json, then printed the preview check. No spinner frames in the logdoctorin tmux, answered Yes, then again answering NoCI=1 doctorwithout the stats fileCI=1 doctor --yeswith a build script given an unknown flagonlyChangedguardstorybookBuildDir👀 Reviewer notes
previewReachChecksat the bottom ofbin-src/setup/previewReach.ts, thenbuildStatsinbin-src/doctor.ts.📦 Published PR as canary version:
18.15.2--canary.1731.45055248418.0✨ Test out this PR locally via:
npm install chromatic@18.15.2--canary.1731.45055248418.0 # or yarn add chromatic@18.15.2--canary.1731.45055248418.0