Skip to content

fix(provider-pi): surface Pi extension dialogs as answerable bb interactions - #3228

Merged
SawyerHood merged 2 commits into
get-bb:mainfrom
fgrehm:fix/pi-extension-dialogs
Sep 8, 2026
Merged

SawyerHood merged 2 commits into
get-bb:mainfrom
fgrehm:fix/pi-extension-dialogs

Conversation

@fgrehm

@fgrehm fgrehm commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

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

image

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


Generated with "Omen Alpha" (Opencode Go) via BB / Pi

AGENT GENERATED

…actions

Pi extensions prompt users through ctx.ui.select/confirm/input/editor, which
in RPC mode emit an extension_ui_request line and block until the client
answers. bb's bridge answered every such request with {cancelled: true}, so
permission prompts from extensions like pi-landstrip were silently dismissed
(get-bb#1668).

Forward extension_ui_request dialogs as provider-pi/extension-ui pending
interactions rendered by the plugin's app component:

- rpc-child.ts forwards dialog requests to an optional handler; without one
  the old auto-cancel remains, so behavior is unchanged unless the bridge
  opts in.
- extension-ui-contract.ts validates dialog requests at the boundary (method
  enum, bounded title/options/message/placeholder/prefill, select requires
  non-empty options).
- extension-ui.ts forwards each dialog as a 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.
- app.tsx renders the four dialog shapes. The host passes plugin components
  the interaction's data object (not the stored {kind, title, data}
  wrapper), so the renderer parses the unwrapped payload directly.

Verified with bridge round-trip tests over the fake Pi harness (/ui
directive), rpc-child unit tests, jsdom renderer tests, and live
pi-landstrip permission prompts rendering and enforcing user answers.

Known gaps (better than the current always-cancelled behavior, candidates
for follow-ups): dialogs raised outside an active turn fail cancelled; a
dialog can outlive a Pi-side timeout since there is no withdrawal
notification; dialogs arriving before the session is announced are dropped;
fire-and-forget state is dropped.

Fixes: partial groundwork for get-bb#1668.

> AGENT GENERATED
@fgrehm
fgrehm force-pushed the fix/pi-extension-dialogs branch from 14a3e75 to 4bf45f6 Compare September 8, 2026 00:10
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.

2 participants