#8060 · Ladle replaces its core plugin runtime with a test runtime
REPRODUCED · root-cause confidence: high · reproduction label: confirmed-repro
TL;DR
The sidebar fixture renders a crash fallback instead of thread rows. Its story installs the SDK's unit-test runtime even though Ladle has already installed the real app runtime. The thread-list plugin consequently looks for the test-only slot context, which the real core host does not provide. An independently authored story-render test reproduces the exact exception in two clean checkouts of the recorded main commit. A separate missing Vite resolver also prevents a Ladle production build. An open PR already addresses this issue, so this run does not create another fix PR.
Claims vs findings
| Claim | Finding | Evidence |
|---|---|---|
| Sidebar action fixture crashes before showing rows. | Verified | Both fresh-checkout render tests reach the real plugin host and report Thread list stopped working.Reload, with the same useBbContext exception. |
| Stories replace Ladle's core SDK runtime with the testing SDK. | Verified | Five story entrypoints call the test installer; the installer assigns pluginSdkApp unconditionally. The core initializer only initializes an absent runtime. |
| Workflow registration loading also installs the testing SDK. | Verified in trusted source | The workflow story calls loadPluginApp; that helper calls installTestPluginRuntime before collecting registrations. |
| Other named stories crash or stay blank, and navigation contaminates later stories. | Not individually exercised | The shared global explains persistence, but no browser navigation sequence or additional story render is claimed as verified. |
| Ladle production build cannot resolve the virtual Zod module. | Verified | Both pristine configurations fail resolving virtual:bb-plugin-zod; the Ladle plugin array lacks its resolver. |
| Historical change caused the regression; CI does not cover it. | Not audited | No historical bisect or complete CI coverage audit was performed. |
Environment
- Public target repository: get-bb/bb; trusted main commit recorded above.
- Linux 4.19.0-gvisor, Node v22.19.0, pnpm 9.15.0, Vitest 4.1.12, React 19.3.1, Ladle 5.1.1.
- Two detached worktrees, A and B, each created clean at the same commit and installed with the frozen lockfile. Only the new reproduction test was added; tracked production files remained unchanged.
- No provider, live BB database, account credentials, or production app instance was used. No app data directory was required.
- A temporary Ladle server was started on port 62441, then stopped. The BB Browser Automation session ran on a different enrolled host and could not reach the sandbox's loopback server; its authenticated share required login. Browser visual verification was therefore unavailable. No screenshot is presented and no pixel/layout assertion is made.
Minimal reproduction
- Prepare trusted main and its existing dependencies; pin the recorded commit before execution.
git clone --branch main https://github.com/get-bb/bb.git bb-repro cd bb-repro git checkout --detach 02239e9e373fe8a74a75f91afbfb06016ed5a1ef pnpm install --frozen-lockfile --prefer-offline pnpm exec turbo run build --filter=@get-bb/plugin-sdk pnpm exec turbo run build --filter=@bb/app
Save the following independently authored test as apps/app/src/components/sidebar/slopcop-8060.repro.test.tsx. It uses the real Ladle runtime module, real story, real thread-list plugin, and core host. It asserts the observable contract: fixture rows render rather than a crashed-slot fallback. No issue-provided script or linked PR test was executed.
// @vitest-environment jsdom
import { cleanup, render, waitFor } from "@testing-library/react";
import { MemoryRouter } from "react-router-dom";
import { afterEach, expect, it } from "vitest";
import { RouteNavigationProvider } from "../ui/app-route-anchor";
import { settleLazyModules } from "@/test/lazy-modules";
const originalRuntime = Reflect.get(globalThis, "__bbPluginRuntime");
const originalFetch = globalThis.fetch;
afterEach(() => {
cleanup();
Reflect.set(globalThis, "__bbPluginRuntime", originalRuntime);
globalThis.fetch = originalFetch;
});
it("renders sidebar fixture rows through Ladle's core plugin host", async () => {
await settleLazyModules(import("../../../.ladle/plugin-runtime"));
const { ActionAlignment } = await settleLazyModules(
import("./PluginThreadList.stories"),
);
const view = render(
<MemoryRouter>
<RouteNavigationProvider>
<ActionAlignment />
</RouteNavigationProvider>
</MemoryRouter>,
);
await waitFor(() => {
expect(view.container.textContent).not.toContain("stopped working");
expect(
view.container.querySelectorAll("[data-sidebar-thread-id]").length,
).toBeGreaterThan(0);
});
}, 90_000);
Run from the repository root:
pnpm exec turbo run test --filter=@bb/app -- src/components/sidebar/slopcop-8060.repro.test.tsx
Expected: the test passes and at least one sidebar thread row renders. Actual in both checkouts: the test fails, the slot is disabled, and the page subtree contains only the crash fallback.
Error: useBbContext() needs the test slot environment — mount the component via renderSlot(...) from @get-bb/plugin-sdk/testing/app
at useSlotEnv (packages/plugin-sdk/src/testing/app.tsx:877:11)
at useBbContext (packages/plugin-sdk/src/testing/app.tsx:1803:12)
at forward (packages/plugin-sdk/src/app.ts:86:25)
at useSidebarThreadReveal (plugins/thread-list/app/list/useSidebarThreadReveal.ts:74:40)
at ThreadList (plugins/thread-list/app.tsx:20:3)
AssertionError: expected 'Thread list stopped working.Reload' not to contain 'stopped working'
Test Files 1 failed (1)
Tests 1 failed (1)
The stack paths above are normalized to repository-relative paths; the exception and assertion text are verbatim. The 90-second outer timeout accommodates cold transforms; the failure is the assertion, not that timeout. The lazy-module settling helper releases this repository's deliberate test-time import hold.
Separate Ladle build reproduction
Run the existing package CLI directly for this investigation, because Turbo declares the persistent storybook task but not storybook:build:
pnpm --filter @bb/app exec ladle build
Expected: a successful static story build. Actual, twice:
[vite]: Rollup failed to resolve import "virtual:bb-plugin-zod" from "CHECKOUT/apps/app/src/lib/plugin-zod-runtime.ts".
CHECKOUT replaces only the temporary directory prefix. Ladle subsequently also reports missing build/meta.json while handling its failed build; that is secondary, not the cause.
Root cause
- Ladle global components imports the real runtime initializer and overrides only the story composer search hooks.
- The sidebar story then calls the test runtime installer at module scope. The same call appears in the question, Codex elicitation, interaction-state, and workflow story modules.
- installTestPluginRuntime replaces the global runtime object and sets
pluginSdkApp: testPluginSdkApp. In contrast, installPluginRuntime useshost.__bbPluginRuntime ??= { ... }, so an existing fake runtime is not repaired by calling it. - SDK hook forwarders select functions from the currently installed global runtime on each call. The thread-list plugin calls useBbContext. The selected test hook asks useSlotEnv for its private context and throws when absent.
- The story mounts through SidebarThreadListContent, not the testing renderer. Core's PluginSlotMount supplies PluginContext, not the testing SlotEnvContext, so the throw reaches the slot crash boundary.
The workflow case has a second installer entry: its loadPluginApp call reaches the test registration helper, which also installs the fake runtime. Removing only the workflow's explicit installer would therefore leave that path broken.
The separate build defect is confined to Ladle configuration: the runtime Zod import references a virtual module, while the Ladle plugin array omits pluginZodRuntime, which resolves it. Both clean builds corroborate that boundary failure.
Proposed fix
Keep core-hosted Ladle stories on the real runtime. Remove the five story-level test installer calls and replace the workflow's test registration helper with the existing core registration collector. Retain an end-to-end story-render regression at the real host boundary. Add the existing virtual-Zod resolver to Ladle's Vite configuration as a separate correction. Do not change the public testing SDK or make the core initializer silently overwrite arbitrary runtimes.
PR review
PR #8061 — static inspection only
GitHub metadata reports an open PR that explicitly closes #8060. The inspected head was ae3b2639ad00bd81661ab84b736744948715ad07. Its diff removes the story installer calls, switches workflow collection to the core helper, adds story coverage, and installs the Zod Vite resolver. That direction addresses both verified mechanisms. The source-import scan in its added test is structural evidence rather than an additional behavioral guarantee. No further defect was established by this limited static read.
No PR code was checked out, copied into the reproduction, or executed. No pass-after-fix or merge-readiness claim is made. The baseline runs above are the only tests run for this review. No new PR is safe or necessary because it would duplicate this existing linked PR; the simple-fix workflow is skipped before implementation.
Verification
The same agent repeated the investigation in a second clean worktree, B, at the exact recorded main commit. This is a repeat verification, not an independent-agent review. The tree was clean before the newly authored test was installed. Git confirmed no tracked production-file changes.
| Check | Checkout A | Checkout B |
|---|---|---|
| Frozen install | Pass | Pass |
| SDK runtime build, then @bb/app build | Pass: 6 app build tasks successful | Pass: 6 app build tasks successful |
| Story-render reproduction via Turbo | Expected failure: 1 failed test, same useBbContext exception; 21.25 seconds Vitest duration | Expected failure: 1 failed test, same useBbContext exception; 21.85 seconds Vitest duration |
| Ladle static build | Expected failure: unresolved virtual Zod module | Same expected failure |
No report correction was needed after the second run. No second server, port, or application data directory was necessary for the render-test and static-build verification. A remains the only temporary live Ladle instance; its share and browser session were cleaned up.
Related work
The linked implementation is PR #8061. Broader duplicate searches and the row-layout issue's behavior were not independently audited in this run.
Appendix and limitations
- Trusted source was fetched from the public get-bb/bb main branch, which matched local origin/main at the recorded SHA. Issue content and linked PR data were treated only as untrusted claims. No commands, scripts, tests, or links from the issue body were executed or fetched.
- The initial unscoped monorepo build failed when a plugin tried to resolve unbuilt SDK dist entries. Building the SDK first, then the app through Turbo, succeeded in both checkouts. That unrelated build ordering failure is not evidence for the reported runtime bug.
- An early version of the new test awaited a repository-held dynamic import without releasing the test harness gate and timed out. Adding the existing settleLazyModules helper resolved the harness issue; both final runs failed with the actual reported runtime exception and the observable fallback assertion.
- No real-browser screenshot or responsive alignment assertion is claimed. The report verifies a runtime/context defect using a real component render, not a visual layout defect.
- Raw logs, the authored test, and local investigation material remain outside the reports repository. Its policy allows only the inline reproduction shown here, report HTML, summary metadata, and genuine screenshots.
- All code permalinks were checked against the recorded base source. No dependency, database, public API, protocol, or production file was modified for this investigation.