🤖 refactor(stories): split Storybook helper monoliths into feature-scoped modules#3080
🤖 refactor(stories): split Storybook helper monoliths into feature-scoped modules#3080
Conversation
|
@codex review |
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…mports to feature modules
06a93e7 to
d62b1c5
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
https://github.com/coder/mux/blob/d62b1c5534f2e98f857601eb0d635c0d5b75ea82/src/browser/stories/mockFactory.ts#L1
Keep a compatibility shim for removed story helper imports
Removing src/browser/stories/mockFactory.ts (and storyHelpers.ts) without a compatibility re-export breaks internal guidance that still imports those paths, including docs/reference/storybook.mdx and the runtime-loaded built-in skill snapshot in src/node/services/agentSkills/builtInSkillContent.generated.ts. In practice, users/agents following those instructions now hit module-resolution failures when creating stories. Please either add temporary shim files that re-export from the new modules or update+regenerate the docs/skill content in the same change.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Summary
Split the monolithic
mockFactory.ts(~1134 LoC) andstoryHelpers.ts(~646 LoC) Storybook helper files into feature-scoped modules to reduce TurboSnap invalidation scope and improve Chromatic build efficiency.Background
Both files were imported by 20+ story files each, meaning any edit to an unrelated helper (e.g., adding a new tool factory) would invalidate every dependent story in Chromatic's TurboSnap. This broad dependency fan-out undermined
onlyChanged: trueeffectiveness — a single-line change inmockFactory.tscould trigger re-snapshots of 20+ stories.Implementation
New module structure
src/browser/stories/mocks/(frommockFactory.ts):workspaces.tsNOW,STABLE_TIMESTAMPmessages.tscreateUserMessage,createAssistantMessage, etc.tools.tscreate*Toolhelpers,withHookOutputchatHandlers.tsgit.tssrc/browser/stories/helpers/(fromstoryHelpers.ts):uiState.tsreviews.tscreateReviewdrafts.tschatSetup.tssetup*ChatStoryadaptersgit.tsMigration approach
TurboSnap impact
Previously, editing
mockFactory.tsinvalidated all 20 dependent stories. Now editingmocks/tools.tsonly invalidates the ~15 stories that use tool factories,helpers/reviews.tsonly invalidates ~3 review stories, etc.Validation
make typecheck✅make lint✅bun x storybook build --stats-json✅mockFactory.ts/storyHelpers.tsRisks
Low — pure structural refactoring with no logic changes. All exports preserved with identical signatures. The only risk is if external tooling hard-codes paths to the deleted files, but grep confirms no such references exist outside generated content strings.
Generated with
mux• Model:anthropic:claude-opus-4-6• Thinking:xhigh• Cost:$10.78