← reports

#8060 · Ladle replaces its core plugin runtime with a test runtime

BugHighEffort: Mediumui · pluginsIssue

November 23, 2026 · trusted origin/main 02239e9e373fe8a74a75f91afbfb06016ed5a1ef

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

ClaimFindingEvidence
Sidebar action fixture crashes before showing rows.VerifiedBoth 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.VerifiedFive 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 sourceThe 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 exercisedThe 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.VerifiedBoth 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 auditedNo historical bisect or complete CI coverage audit was performed.

Environment

Minimal reproduction

  1. 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

  1. Ladle global components imports the real runtime initializer and overrides only the story composer search hooks.
  2. 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.
  3. installTestPluginRuntime replaces the global runtime object and sets pluginSdkApp: testPluginSdkApp. In contrast, installPluginRuntime uses host.__bbPluginRuntime ??= { ... }, so an existing fake runtime is not repaired by calling it.
  4. 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.
  5. 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.

CheckCheckout ACheckout B
Frozen installPassPass
SDK runtime build, then @bb/app buildPass: 6 app build tasks successfulPass: 6 app build tasks successful
Story-render reproduction via TurboExpected failure: 1 failed test, same useBbContext exception; 21.25 seconds Vitest durationExpected failure: 1 failed test, same useBbContext exception; 21.85 seconds Vitest duration
Ladle static buildExpected failure: unresolved virtual Zod moduleSame 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

Agent-generated reproduction report · 2026-11-23