Skip to content

Carry provider extension UI through the bridge, daemon, server, and app - #2446

Closed
SawyerHood wants to merge 1 commit into
bb/garden-5-thread-reloadfrom
bb/garden-6-provider-extension-plumbing
Closed

SawyerHood wants to merge 1 commit into
bb/garden-5-thread-reloadfrom
bb/garden-6-provider-extension-plumbing

Conversation

@SawyerHood

@SawyerHood SawyerHood commented Aug 25, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

A provider plugin's extensions (pi's ctx.ui) had no generic path into bb: no thread-scoped questions outside a turn, no way to cancel them, no persisted per-thread extension state with app-rendered actions, no bridge-listed slash commands, and no plugin-to-bridge RPC.

What changed (no Pi code in this layer)

  • Bridge protocol: interaction/request may carry turnId: null + experimental_scope: "thread"; interaction/cancel notification; command/list; provider/custom; extension/action (packages/provider-bridge-protocol, packages/agent-runtime).
  • User questions: experimental_responseMode: "verbatim", experimental_placeholder, experimental_prefill, answers with experimental_verbatimText; USER_QUESTION_MAX_OPTIONS 4 → 100 (packages/domain/src/pending-interactions.ts). App and mobile question forms honor verbatim mode.
  • Daemon: host.list_commands merges the bridge's command/list (with diagnostics); provider.custom_call; thread.extension-state.action; per-interaction abort registry.
  • Server: persists extension.state snapshots (thread/extensionState/updated, superseded-event pruning), exposes extensionStates on the timeline, POST …/extension-state/action; bb.providers.experimental_client / experimental_modelsChanged (per-host model cache invalidation); PluginSettingsSectionProps.experimental_hostId.
  • App: app.slots.experimental_providerExtensionState renders a provider's state kinds above/below the composer.
  • Wire change: HOST_DAEMON_PROTOCOL_VERSION 171 → 172. docs/provider-bridge-protocol.md and docs/api_to_audit.md updated.

Prerequisite: #2445 (shares the protocol header and routes/threads/actions.ts).

Known gaps, deliberate: dialogs are thread-scoped even mid-turn; cancel is thread-wide; no runtime-level test for interaction/cancel wiring.

How you verified

turbo run typecheck; turbo run test for @bb/agent-runtime, @bb/provider-bridge-protocol, @bb/host-daemon, @bb/server (interactions, extension-state action, project commands, model cache), @bb/app, @bb/mobile, @bb/db, @bb/domain, @bb/thread-view, @get-bb/plugin-sdk, bb-plugin-provider-codex, @bb/host-daemon-contract.

Fixes: none (upstream stack split).

AGENT GENERATED

SawyerHood added a commit that referenced this pull request Sep 8, 2026
…actions (#3228)

## Human comments

yet another PR for making the pi provider more polished here. I’ve been
running this and my other PRs on my local install of bb and been working
fine

<img width="1170" height="2205" alt="image"
src="https://github.com/user-attachments/assets/d300ebf0-23ef-4cb0-9e0d-83832f61537a"
/>


## What was wrong

Pi extensions prompt the user through `ctx.ui.select`, `ctx.ui.confirm`,
`ctx.ui.input`, and `ctx.ui.editor`. In RPC mode these emit an
`extension_ui_request` line on stdout and block until an
`extension_ui_response` arrives on stdin (see `docs/rpc.md`, "Extension
UI Protocol"). bb's provider-pi bridge answered every such request with
`{cancelled: true}`, so any extension that raises a permission prompt
had it silently dismissed —
[pi-landstrip](https://github.com/landstrip/landstrip) sandbox-approval
prompts were unusable over bb. Investigation and reproduction trail:
#1668.

## What changed

- `plugins/provider-pi/src/bridge/rpc-child.ts` forwards
`extension_ui_request` dialogs to an optional handler; with no handler
the old auto-cancel remains, so behavior is unchanged unless the bridge
opts in.
- `plugins/provider-pi/src/extension-ui-contract.ts` validates dialog
requests at the boundary: method enum, bounded
title/options/message/placeholder/prefill, `select` requires a non-empty
options list.
- `plugins/provider-pi/src/bridge/extension-ui.ts` forwards each dialog
as a `provider-pi/extension-ui` pending interaction and maps resolutions
back (`value` for select/input/editor, `confirmed` for confirm,
`cancelled` on error, unknown value, or session close). Request ids use
a `pi-ui-N` string space so they cannot collide with numeric
item/tool/call ids. Pending dialogs are cancelled on thread stop,
session replace, and discard. Fire-and-forget methods (`notify`,
`setStatus`, `setWidget`, `setTitle`, `set_editor_text`) are dropped.
- Helper sessions such as fork helpers retain automatic dialog
cancellation when no UI handler is installed. Select responses are
checked against the originally offered options before reaching Pi.
- `plugins/provider-pi/app.tsx` renders the four dialog shapes in the
plugin pending-interaction slot. The host passes plugin components the
interaction's data object rather than the stored `{kind, title, data}`
wrapper, so the renderer parses the unwrapped payload directly.

No protocol or wire changes: no `HOST_DAEMON_PROTOCOL_VERSION` bump, no
new grammar, no new plugin API surface — this reuses the existing
`interaction/request` plugin-extension payload kind and
pending-interaction slot.

This is deliberately the minimal bridge-only subset of #2446/#2447 (both
still open): thread-scoped requests outside an active turn, withdrawal
notifications, and queued-before-announcement dialogs are left as
follow-ups — and the behavior is strictly better than the current
always-cancelled path.

## How you verified

- `pnpm exec turbo run test --filter=bb-plugin-provider-pi` (26 files,
143 tests) and `turbo run typecheck --filter=bb-plugin-provider-pi` —
clean.
- Both review regressions were reproduced before the fixes: helper
startup timed out waiting for a dialog response, and an unoffered select
string reached Pi. Both now pass; `pnpm exec turbo run test typecheck
--filter=bb-plugin-provider-pi` passed with 26 test files and 143 tests.
The working-tree and commit-range secret scan was clean.
- New bridge round-trip tests over the fake Pi harness (`/ui` directive
in `fake-pi-rpc.mjs`), rpc-child handler unit tests, and jsdom renderer
tests covering select/confirm/input/editor and the host-unwrapped
payload shape.
- Live: pi-landstrip read/write permission prompts render the full
option list over bb, and user answers propagate back and drive the
sandbox decision (e.g. "Keep blocked" denies the underlying write).

Fixes: partial groundwork for #1668


---

<sub><em>Generated with "Omen Alpha" (Opencode Go) via BB /
Pi</em></sub>

> AGENT GENERATED

---------

Co-authored-by: Sawyer Hood <[email protected]>
@SawyerHood

Copy link
Copy Markdown
Collaborator Author

This is an automated message. We have closed this pull request because it has been open for more than two weeks.

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