Skip to content

Expose the question form host through the SDK and the registry - #4181

Merged
SawyerHood merged 1 commit into
bb/forkable-03-plugins-without-ui-depsfrom
bb/forkable-04-question-form-host
Sep 23, 2026
Merged

SawyerHood merged 1 commit into
bb/forkable-03-plugins-without-ui-depsfrom
bb/forkable-04-question-form-host

Conversation

@SawyerHood

@SawyerHood SawyerHood commented Sep 23, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

Fourth PR in the forkable built-ins stack; it builds on #4180. A pending-interaction form shows bb's answer shortcuts (question.select.1 and on, which users can remap) next to its options, and chooses an option when the person presses one. The host owns those bindings through a React context in @bb/shared-ui.

The built-in Ask User Question and pi plugins reach that context by importing @bb/shared-ui/question-form-host, which bb plugin build swaps for the host's module. A copy of either plugin can't import that package, and the component registry has no question form to give it. Both plugins' PRs later in the stack need this, so it lands on its own first.

What changed

  • SDK 0.5.22: experimental_useQuestionFormHost() in @get-bb/plugin-sdk/app returns { shortcuts, registerChoiceHandler }.
    • The app backs it with the existing ThreadQuestionFormHost context.
    • renderSlot returns an empty host.
    • Documented in docs/api_to_audit.md, the Plugin Guide's in-thread forms surface, and the plugin authoring references.
  • Registry: gains question-form, with question-form-state and question-form-host. question-form-host is a plugin flavor that re-exports the SDK hook, the same way the registry's icon draws from the host.
  • shared-ui: question-form.tsx imports its siblings relatively so it can become a registry item.
  • plugin-build: routes shared-ui's own relative ./question-form-host import to the host's module, as it already does for ./icon. Built-in bundles keep a single context.

No wire changes. It adds a new experimental SDK member, listed in docs/api_to_audit.md.

How you verified

  • plugin-build: new tests check that shared-ui's relative ./question-form-host resolves to the host runtime slot and a plugin's own file doesn't. They also check that a bundle never carries a second context.
  • SDK facade: a new test covers the hook's empty test-harness host.
  • Bundle identity: ask-user-question and provider-pi app.js were built before and after this PR. A token diff shows only the SDK facade's export list gaining the new name, and both bundles reference the host's questionFormHost slot as before.
  • Turbo: pnpm exec turbo run build build:types typecheck test for the plugin SDK, plugin-build, plugin-registry, plugin-api-map, shared-ui, ask-user-question, provider-pi, and bb-guide; @bb/app typecheck; the app's user-question, pending-interaction, and plugin lib tests.
  • SDK version guards: both pass.

🤖 Generated with Claude Code

AGENT GENERATED

@SawyerHood
SawyerHood added this pull request to stack #4182 September 23, 2026 16:34
@SawyerHood
SawyerHood force-pushed the bb/forkable-04-question-form-host branch from abefa0f to 10db268 Compare September 23, 2026 16:36
@SawyerHood
SawyerHood force-pushed the bb/forkable-04-question-form-host branch from 10db268 to 16855a5 Compare September 23, 2026 16:47
@SawyerHood
SawyerHood force-pushed the bb/forkable-04-question-form-host branch from 16855a5 to b0f39af Compare September 23, 2026 17:50
@SawyerHood
SawyerHood force-pushed the bb/forkable-04-question-form-host branch from b0f39af to f1f7163 Compare September 23, 2026 20:40
@SawyerHood
SawyerHood marked this pull request as ready for review September 23, 2026 21:07
@SawyerHood
SawyerHood removed this pull request from stack #4182 September 23, 2026 21:40
@SawyerHood
SawyerHood added this pull request to stack #4220 September 23, 2026 21:41
A pending-interaction form shows bb's answer shortcuts next to its
options and chooses an option when the person presses one. The host owns
those bindings through a React context in @bb/shared-ui, and the built-in
Ask User Question and pi plugins reached it by importing
`@bb/shared-ui/question-form-host`, which `bb plugin build` swaps for the
host's module. A copy of either plugin cannot import that package, and
the registry had no question form to give it.

- `experimental_useQuestionFormHost()` in `@get-bb/plugin-sdk/app`
  returns the host's shortcuts and `registerChoiceHandler`; the app backs
  it with the existing context, and the test harness returns an empty
  host. Documented in docs/api_to_audit.md, the Plugin Guide's in-thread
  forms surface, and the authoring references. SDK 0.5.22.
- The registry gains `question-form` (with `question-form-state` and
  `question-form-host`). Its `question-form-host` is a plugin flavor that
  re-exports the SDK hook, the way the registry's `icon` draws from the
  host.
- shared-ui's question-form imports its siblings relatively so it can
  become a registry item. `bb plugin build` now routes shared-ui's own
  relative `./question-form-host` import to the host's module, as it
  already does for `./icon`, so the built-in bundles keep one context.
  Their app.js differs from before only in the SDK facade's export list.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@SawyerHood
SawyerHood force-pushed the bb/forkable-04-question-form-host branch from f1f7163 to 1efab3f Compare September 23, 2026 22:10
@SawyerHood
SawyerHood merged commit b9e16d3 into main Sep 23, 2026
18 checks passed
@SawyerHood
SawyerHood deleted the bb/forkable-04-question-form-host branch September 23, 2026 22:13
SawyerHood added a commit that referenced this pull request Sep 23, 2026
## Human comments

## What was wrong

Fifth PR in the forkable built-ins stack; it builds on #4181.
`plugins/navigation` replaces bb's whole sidebar navigation region,
which makes it the cleanest fork after the sidebar thread list (#4140).
A copy of its directory still couldn't build on its own:

- It imported ten `@bb/shared-ui` components and helpers. All ten have
registry items.
- Its vitest config imported the repository's `vitest.shared.ts`.
- A copy installed without npm's peer resolution lacked
`@testing-library/dom` and `@types/react-dom`.

## What changed

- **Registry imports:** the plugin follows thread-list's conventions and
imports UI through the registry alias (`@/components/ui/button`,
`@/lib/utils`, …).
- **tsconfig:** maps `@/*` onto `packages/shared-ui/src` and
`@/components/ui/icon` onto the registry's host-backed icon.
`customConditions: ["source"]` is gone. `app.test.tsx` is now
typechecked.
- **vitest config:** `defineConfig` with tsconfig paths.
- **Tooling:** the package gets a lint script, and turbo gives its
typecheck and test tasks the registry flavors as inputs and the SDK
build as a test dependency.
- **App test fixture:**
`apps/app/src/test/fixtures/navigation-plugin.ts` imported the plugin's
`app.tsx` by a literal path. That pulled the plugin into `@bb/app`'s
typecheck, where `@/` means the app's own source. The fixture now loads
the module by a resolved path and checks the export, as the sidebar
bench already does for thread-list.

## How you verified

- `pnpm exec turbo run typecheck test lint
--filter=bb-plugin-navigation`, `@bb/app` typecheck, and the three app
test files that load the plugin: `NavigationPlugin`,
`SidebarNavigationRegion`, `plugin-slot-mounts`. `@bb/plugin-api-map`
tests pass; it anchors `Navigation.tsx`.
- `pnpm check:plugin-forks plugins/navigation`: install, typecheck,
test, and `bb plugin build` pass in a copy.
- **Bundle identity:** `app.css` and `server.js` are byte-identical
before and after. An unminified `app.js` differs only in module order
and names. The plugin's own icons now render through the SDK's
`experimental_Icon`, which the host binds to the same `Icon` component
that the old `@bb/shared-ui/icon` shim provided.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

> AGENT GENERATED
SawyerHood added a commit that referenced this pull request Sep 23, 2026
## Human comments

## What was wrong

Fourteenth PR in the forkable built-ins stack; it builds on #4196.
ask-user-question and secrets render bb's in-thread forms (the
`pendingInteraction` slot). A copy of either couldn't build on its own:

- Both imported `@bb/shared-ui` and `@bb/plugin-interaction-contracts`,
a workspace package holding their payload and response schemas.
- ask-user-question rendered shared-ui's question form, which reaches
the host's answer shortcuts through a module only `bb plugin build` can
swap.
- Their tsconfigs mapped the SDK onto its bundled `.d.ts` files, and
their vitest configs used `vitest.shared.ts`.

## What changed

- **Contracts:** each plugin owns its contract (`src/contracts.ts`,
`src/secret-request.ts`) with its half of the old tests. Nothing else
imported `@bb/plugin-interaction-contracts`, so it is deleted.
- **UI:** components come through the registry alias. ask-user-question
uses the registry's `question-form`, whose `question-form-host` flavor
calls `experimental_useQuestionFormHost` (#4181), so its
`engines.bbPluginSdk` is `>=0.5.22`. The built-in bundle still takes the
question form host from the app's runtime, so it keeps bb's answer
shortcuts and a single React context.
- **Config:**
- The SDK path entries are gone; the package's `types` condition already
points tsc at the same files.
- ask-user-question's tsconfig maps only `@/*` and the icon flavor. It
never imports `question-form-host` itself, so it doesn't map it.
  - `app.test.tsx` and the vitest configs join the tsconfig `include`.
- Each plugin declares its test peers and gets a lint script and turbo
entries.
- **Stories:** ask-user-question's Ladle story rendered through app
source, so it moves into `apps/app` beside the other pending-interaction
stories, with `origin="plugin"` replacing a stale prop. Both stories
load their plugin through `import.meta.glob`
(`apps/app/.ladle/plugin-app-module.ts`), which keeps the plugins' `@/`
imports out of `@bb/app`'s type program.
- **Docs:** `docs/forkable-plugins.md` records both rules: a listed
plugin maps nothing onto `@get-bb/plugin-sdk`, and Ladle stories load a
listed plugin with `import.meta.glob`.

## How you verified

- `pnpm exec turbo run typecheck test lint` for both plugins.
- `pnpm check:plugin-forks` passes for both. In a kept copy, `app.js`
calls `experimental_useQuestionFormHost` and never calls
`createContext`.
- `@bb/app` typecheck and tests, `@bb/scripts`,
`bb-plugin-plugin-api-docs`, and the server's built-in plugin tests.
- Both Ladle stories render in the dev server with no console errors.
- **Bundle identity:** `app.css` is byte-identical. `app.js` differs
only in module paths and in dropping the other plugin's schemas, which
the shared package's index had pulled into both bundles. Both bundles
take the question form host from `runtime.questionFormHost`.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

> AGENT GENERATED

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
SawyerHood added a commit that referenced this pull request Sep 23, 2026
## Human comments

## What was wrong

Second agent-provider PR in the forkable built-ins stack; it builds on
#4200. `plugins/provider-pi` couldn't be copied out:

- **App imports:** it imported `Button`, `cn`, and the question form
host from `@bb/shared-ui`.
- **Workspace test imports:** the delta translation test imported the
assembler and `ThreadEvent` from workspace packages.
- **Recordings:** the recorded-conformance test replays recordings
committed under `packages/provider-bridge-protocol`.
- **Lint:** 51 code comments.

## What changed

- **App imports:** they go through the registry alias. The question form
host comes from the registry flavor over
`experimental_useQuestionFormHost` (#4181), so `engines.bbPluginSdk`
rises to `>=0.5.22`. The SDK path entries are gone from the tsconfig.
- **Test imports:** tests use `experimental_createDeltaAssembler` and
`ThreadEvent` from `@get-bb/plugin-sdk/provider-bridge/testing`.
- **Recorded conformance:** the test moves to `@bb/provider-parity`, and
`docs/provider-bridge-protocol.md` says pi's replay lives there.
`@bb/provider-parity#test` now takes `packages/plugin-sdk/src/**` and
`packages/plugin-sdk/package.json` as inputs, because the replayed
bridges load SDK sources.
- **Config and lint:** `defineConfig`, declared peers, and turbo
entries; the 51 comments are removed, and the README keeps what the fake
pi's header and the Bun test explained.
- **App test:** the test that checks pi's answer shortcuts loads the
plugin by path under the app's own plugin runtime, because the SDK test
runtime backs the question form host with an empty host.
- **CI:** the Plugin Fork Check job installs Bun, as the packages test
shard does, because a copy runs pi's Bun runtime regression, which
requires Bun in CI.

## How you verified

- `pnpm exec turbo run typecheck test lint
--filter=bb-plugin-provider-pi`; a Bun-only case is skipped without Bun.
- `pnpm check:plugin-forks plugins/provider-pi` passes in a copy.
- `@bb/provider-parity`, including the moved recorded conformance and
the pi parity replays; `apps/app/src/components/plugin` tests; and the
server's first-party provider plugin tests.
- **Turbo input:** without the new inputs, `turbo --dry=json` reported
the same `@bb/provider-parity#test` hash after a change to an SDK
source; with them, the hash changes.
- **Bundle identity:** `app.css` is byte-identical. An unminified
`app.js` differs only in the question-form-host source (the runtime shim
became the SDK facade's hook, the same host context) and formatting.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

> AGENT GENERATED

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant