Repository navigation
Port Pi extension UI, commands, and model settings to the RPC bridge - #2447
SawyerHood wants to merge 1 commit into
Conversation
|
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 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 ( 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.
|
…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]>
|
Human comments
What was wrong
Pi extensions'
ctx.uicalls (select/confirm/input/editor dialogs, notify, setStatus, setWidget, setTitle, setEditorText), extension-registered slash commands, and pi'senabledModelsscope were invisible from bb after the bridge moved topi --mode rpc.What changed
plugins/provider-pi/src/bridge):extension_ui_requestlines become thread-scoped bb questions (answered back asextension_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/listfrom pi'sget_commands; a/nameinput that is an extension command answersturn/startat 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 behindturn/start).resolveModelScopeFromModels(globs, partial names, thinking suffixes), a locked, symlink-aware writer for~/.pi/agent/settings.json, a settings-page editor, andbb pi models list|set|enable-all.docs/model-preferences-policy.mddescribes the policy.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.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).