Skip to content

Port Pi extension UI, commands, and model settings to the RPC bridge - #2447

Closed
SawyerHood wants to merge 1 commit into
bb/garden-6-provider-extension-plumbingfrom
bb/garden-7-pi-extension-ui
Closed

SawyerHood wants to merge 1 commit into
bb/garden-6-provider-extension-plumbingfrom
bb/garden-7-pi-extension-ui

Conversation

@SawyerHood

@SawyerHood SawyerHood commented Aug 25, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

Pi extensions' ctx.ui calls (select/confirm/input/editor dialogs, notify, setStatus, setWidget, setTitle, setEditorText), extension-registered slash commands, and pi's enabledModels scope were invisible from bb after the bridge moved to pi --mode rpc.

What changed

  • Bridge (plugins/provider-pi/src/bridge): extension_ui_request lines become thread-scoped bb questions (answered back as extension_ui_response) or a bounded extension-state snapshot (statuses, widgets, title, editor text, notifications, 60 KiB cap); dialogs queue until the session is announced and are cancelled on stop; oversized editor prefills are refused; command/list from pi's get_commands; a /name input that is an extension command answers turn/start at once and ends the turn on pi's ack or the run the handler started (pi runs the handler before it answers the prompt, and the daemon's thread lane would otherwise deadlock the dialog answer behind turn/start).
  • Model scope: a port of pi's resolveModelScopeFromModels (globs, partial names, thinking suffixes), a locked, symlink-aware writer for ~/.pi/agent/settings.json, a settings-page editor, and bb pi models list|set|enable-all. docs/model-preferences-policy.md describes the policy.
  • App bundle (app.tsx): renders the state kinds beside the composer, applies editor text once per revision, and toasts notifications once per session with a dismiss X.
  • The fake pi (fake-pi-rpc.mjs) gained /ui, /ask, /ext [json] knobs; 24 test files / 141 tests in the plugin.

No wire change beyond the layer below. Prerequisite: #2446.

How you verified

turbo run typecheck; turbo run test --filter=bb-plugin-provider-pi; live QA of /ui-demo (every dialog kind + notifications) in the dev app, which found and fixed the extension-command deadlock.

Fixes: none (upstream stack split).

AGENT GENERATED

@fgrehm

fgrehm commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

<almost-meat-proxy>

Adding downstream weight here: I run bb + pi in a rootless container daily, and after fixing the Bun fd-4 issue (#3095), the next wall was this — I'm trying to run pi-landstrip for sandboxed tool execution, and its ctx.ui.select/confirm permission prompts get auto-cancelled by the bridge, making a sandbox-approval extension useless over bb 😅

Happy to QA this branch end to end (Bun pi + landstrip, stop/replace mid-dialog) before merge. I also built a narrower bridge-only stopgap (fgrehm/bb, fix/pi-extension-ui) — no core changes, works on today's protocol — not as an alternative, just evidence the bridge slice could ship independentl.

Is this close to merging? Not sure whether the blocker is review time or the protocol changes. If the latter, dialogs-first behind an opt-in would unblock landstrip-style extensions sooner.

</almost-meat-proxy>

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.

2 participants