Skip to content

fix(storybook): export writeModeFor from the plugins shim, widen the shim check - #661

Merged
crs48 merged 1 commit into
mainfrom
claude/epic-chaum-775141
Jul 30, 2026
Merged

fix(storybook): export writeModeFor from the plugins shim, widen the shim check#661
crs48 merged 1 commit into
mainfrom
claude/epic-chaum-775141

Conversation

@crs48

@crs48 crs48 commented Jul 30, 2026

Copy link
Copy Markdown
Owner

What broke

The capture job in .github/workflows/visual-capture.yml has failed its Build Storybook step on every PR since #656. Pre-existing on main (verified at bcec607b1), unrelated to the PR that surfaced it (#658).

"writeModeFor" is not exported by ".storybook/shims/xnet-plugins-browser.ts",
  imported by "packages/workbench/src/views/ai-chat-write-tools.ts".

.storybook/workspace-aliases.ts:29 aliases @xnetjs/plugins to the browser shim, and 0394 phase-2 (#656) added a writeModeFor import the shim never got a matching export for.

Why the gate didn't catch it

pnpm check:storybook-shim stayed green the whole time — "873 modules walked, 114 shim exports".

Its walker only knew the aliases parsed out of workspace-aliases.ts. @xnetjs/workbench has 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 — adds writeModeFor / WriteMode, matching packages/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:

  • aliases first (Vite applies them first), then the package's own exports/main;
  • dist entries map back to the source they're built from, so the walk doesn't stop at an artifact that may not be present;
  • an @xnetjs/* specifier it cannot resolve is now a hard failure, not a silent drop — the graph can't quietly shrink again;
  • seeds .storybook/preview.tsx and manager.tsx, which the build compiles too.

Coverage: 873 → 1177 modules walked. That turned up a second real breakAgentAuditRecorder in views/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

Check Result
pnpm build:stories (the capture job's exact command, after turbo run build --filter='./packages/*') Storybook build completed successfully
pnpm check:storybook-shim ✅ 1177 modules walked, 128 shim exports
Regression proof — remove writeModeFor from the shim again ✅ now fails with · writeModeFor (…/ai-chat-write-tools.ts); the old walker passed
Pre-push full suite ✅ 11331 passed, 4 skipped

Labelled skip-changelog: dev tooling, nothing a user notices.

🤖 Generated with Claude Code

…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>
@crs48 crs48 added the skip-changelog Exclude this PR from the changelog label Jul 30, 2026
@crs48
crs48 temporarily deployed to pr-661 July 30, 2026 17:53 — with GitHub Actions Inactive
@github-actions

Copy link
Copy Markdown
Contributor

🖼️ UI changes in this PR

No UI changes detected in this PR.

github-actions Bot added a commit that referenced this pull request Jul 30, 2026
github-actions Bot added a commit that referenced this pull request Jul 30, 2026
@github-actions

github-actions Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Preview removed for PR #661.

@crs48
crs48 merged commit 8bf5d6c into main Jul 30, 2026
15 of 16 checks passed
@crs48
crs48 deleted the claude/epic-chaum-775141 branch July 30, 2026 18:02
github-actions Bot added a commit that referenced this pull request Jul 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-changelog Exclude this PR from the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant