Skip to content

Ladle: plugin stories crash with "needs the test slot environment" because they install the fake SDK runtime #8060

Description

@lanjak

Summary

The Ladle story sidebar/Thread list/Action alignment does not render on main. The thread-list plugin crashes with useBbContext() needs the test slot environment, so no thread rows show. The check script apps/app/.ladle/tests/sidebar-actions.mjs needs this story, so it cannot run. Four other stories have the same cause, and two of them also crash.

Versions and environment

  • bb from source at main 02239e9.
  • Arch Linux (CachyOS), Node v26.13.1, pnpm 9.15.0.
  • Chromium (/usr/bin/chromium) through playwright-core 1.58.2.

Steps to reproduce

  1. pnpm install
  2. pnpm exec turbo run @bb/templates#generate:templates @bb/plugin-build#generate build:types --filter=@bb/templates --filter=@bb/plugin-build --filter=@get-bb/plugin-sdk
  3. cd apps/app && npx ladle serve --port 61287
  4. Open http://127.0.0.1:61287/?story=sidebar--thread-list--action-alignment&mode=preview.
  5. Run apps/app/.ladle/tests/sidebar-actions.mjs with a browser.getPage("main") that returns that page (dev-browser, or a small Playwright harness).

Expected vs actual

Expected: the story shows six thread rows, and the script prints PASS: parent and leaf actions align at 220, 288 and 360px; disclosure precedes quick actions and overflow.

Actual: the page shows Thread list stopped working. Reload. The browser console shows:

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)
    at useBbContext (packages/plugin-sdk/src/testing/app.tsx)
    at forward (packages/plugin-sdk/src/app.ts)
    at useSidebarThreadReveal (plugins/thread-list/app/list/useSidebarThreadReveal.ts)
    at ThreadList (plugins/thread-list/app.tsx)

The script stops with:

page.waitForSelector: Timeout 30000ms exceeded.
  - waiting for locator('[data-sidebar-thread-id="thr_actions_leaf_short"]') to be visible

Other stories with the same cause, on the same server:

Story Result on main
sidebar--thread-list--inbox-read-status Same useBbContext() crash
plugins--codex-mcp-elicitation--computer-use useBbNavigate() needs the test slot environment, "The plugin form crashed"
plugins--workflows--workflow-panel--panel-states useBbNavigate() needs the test slot environment in the Loaded panel
plugins--codex-mcp-elicitation--form, thread--pending-interaction--additional-states--overview, --plugin-form-settled Blank page after 4 s, no error

Evidence

Observed cause:

  1. The story calls installTestPluginRuntime() at module load: PluginThreadList.stories.tsx#L31.
  2. That function replaces globalThis.__bbPluginRuntime.pluginSdkApp with the fake test SDK: testing/app.tsx#L2209-L2216. The fake useBbContext() throws unless renderSlot(...) mounts the component: testing/app.tsx#L874-L882.
  3. The story mounts the plugin through the real core host (SidebarThreadListContent), not through renderSlot. The plugin calls useBbContext() in useSidebarThreadReveal.ts#L74.
  4. Ladle's global provider already installs core's real runtime through apps/app/.ladle/plugin-runtime.ts. installPluginRuntime() uses ??= (plugin-frontend.ts#L235), so the fake SDK stays in place whichever module loads first.

Change that exposed it: before #6942 (e005c1a), Ladle aliased @get-bb/plugin-sdk/app to a static shim, .ladle/plugin-sdk-app.ts. Thus the global runtime had no effect on plugins, and installTestPluginRuntime() in a story did nothing. #6942 removed the alias. Since then, plugins read the global runtime through the SDK forwarders, and the call in the story gives them the fake SDK. The same call is in AskUserQuestionPlugin.stories.tsx, CodexMcpElicitation.stories.tsx, InteractionStates.stories.tsx and .ladle/workflows.stories.tsx (through loadPluginApp, which calls installTestPluginRuntime()).

Because Ladle changes stories without a page reload, one of these stories also gives the fake SDK to every story that opens after it in the same tab.

CI: no workflow in .github/workflows/ runs ladle serve, ladle build or the scripts in apps/app/.ladle/tests/. turbo.json has a storybook task, but no CI job calls it. CI does not catch this.

Related, separate cause: npx ladle build in apps/app also fails on main with Rollup failed to resolve import "virtual:bb-plugin-zod" from "apps/app/src/lib/plugin-zod-runtime.ts". .ladle/vite.config.ts does not include pluginZodRuntime(), which #6959 added to the app and Vitest configs.

Found while testing #8053, bb thread thr_kpwmyxvrr7. Investigation thread: thr_76u78zfygh.

What you ruled out

Suggested priority and effort

Low priority, small effort. The defect stops Ladle stories and the layout check scripts. The app works. The workaround is to render rows in a unit test, as described in the #8053 notes.

AGENT GENERATED

Activity

  1. added theissue type on Nov 23, 2026
  2. added
    ui
    plugins
    confirmed-repro
    on Nov 23, 2026
  3. bb-slop-cop commented on Nov 23, 2026

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    • Classification: Bug · High priority · Medium effort; ui, plugins.
    • Verdict: REPRODUCED · high root-cause confidence. Reproduction and root-cause report.
    • Root cause: Core-hosted Ladle stories replace the real plugin SDK with its testing runtime, whose hooks require an absent test slot context. Ladle also omits the virtual-Zod resolver.
    • Evidence: A newly authored real-story render test reproduces the exception and crash fallback in two clean trusted-main checkouts; both Ladle builds also fail resolving the virtual module. Browser visual verification was unavailable.
    • Reproduction label: confirmed-repro.
    • No new PR: Open PR #8061 already closes this issue; a duplicate fix was skipped. Its code was not executed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-repropluginsui

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions