fix(storybook): export writeModeFor from the plugins shim, widen the shim check - #661
Merged
Conversation
…shim check The visual-capture `capture` job has failed its Build Storybook step on every PR since #656: `views/ai-chat-write-tools.ts` imports `writeModeFor` from `@xnetjs/plugins`, and the storybook browser shim never got a matching export. `pnpm check:storybook-shim` stayed green through all of it. Its walker only knew the aliases in `.storybook/workspace-aliases.ts`, and `@xnetjs/workbench` has no entry there, so it dropped the specifier and never reached the importing module — while rollup resolved it through the workspace link and failed. A gate that cannot fail on a real breakage teaches everyone to ignore red. The walker now resolves `@xnetjs/*` the way the build does: aliases first, then the package's own `exports`/`main`, mapping `dist` entries back to the source they are built from. A specifier it cannot resolve is a hard failure rather than a silent drop, so the graph cannot quietly shrink again. It also seeds the preview and manager entries, not just stories. Coverage goes from 873 to 1177 modules, which turned up a second real break (`AgentAuditRecorder`, also a value import) plus ten type-only names the shim should mirror. Verified with `pnpm build:stories`, the same command the capture job runs. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Signed-off-by: xNet Test <test@xnet.dev>
Contributor
🖼️ UI changes in this PRNo UI changes detected in this PR. |
Contributor
|
Preview removed for PR #661. |
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.
What broke
The
capturejob in.github/workflows/visual-capture.ymlhas failed its Build Storybook step on every PR since #656. Pre-existing onmain(verified atbcec607b1), unrelated to the PR that surfaced it (#658)..storybook/workspace-aliases.ts:29aliases@xnetjs/pluginsto the browser shim, and 0394 phase-2 (#656) added awriteModeForimport the shim never got a matching export for.Why the gate didn't catch it
pnpm check:storybook-shimstayed green the whole time — "873 modules walked, 114 shim exports".Its walker only knew the aliases parsed out of
workspace-aliases.ts.@xnetjs/workbenchhas no entry there, so the walker silently dropped the specifier and never reached the importing module — while rollup resolved it through the workspace link and kept bundling. Everything past that point went unchecked.Per AGENTS.md: "A gate that cannot go green teaches everyone to ignore red." The inverse is worse — a gate that cannot go red on a live breakage.
What changed
.storybook/shims/xnet-plugins-browser.ts— addswriteModeFor/WriteMode, matchingpackages/plugins/src/ai/connectors/types.ts:101, plus the names the widened walk turned up.scripts/check-storybook-shim.mjs— resolves@xnetjs/*the way the build does rather than only via aliases:exports/main;distentries map back to the source they're built from, so the walk doesn't stop at an artifact that may not be present;@xnetjs/*specifier it cannot resolve is now a hard failure, not a silent drop — the graph can't quietly shrink again;.storybook/preview.tsxandmanager.tsx, which the build compiles too.Coverage: 873 → 1177 modules walked. That turned up a second real break —
AgentAuditRecorderinviews/ai-chat-ceremony.ts:32, also a value import — plus ten type-only names the shim should mirror anyway.On "walk the full module graph instead"
Rejected as framed. The story graph was nearly the whole build graph; the defect was that the resolver was weaker than Vite's, not that the seed set was too small. Matching resolution (plus the two extra entry seeds) closes the class without needing to run rollup to find out.
Verification
pnpm build:stories(the capture job's exact command, afterturbo run build --filter='./packages/*')Storybook build completed successfullypnpm check:storybook-shimwriteModeForfrom the shim again· writeModeFor (…/ai-chat-write-tools.ts); the old walker passedLabelled
skip-changelog: dev tooling, nothing a user notices.🤖 Generated with Claude Code