Expand description
Ergonomic glue for embedding a purview MCP bridge in a [gpui] app.
purview is framework-agnostic: to bind it to gpui a host must wire up a
Send channel, a poster closure, the background server, a main-thread drain
loop, and keep the server handle alive for the app’s lifetime. This crate
collapses all of that into one call:
use gpui::Application;
use purview_gpui::Bridge;
Application::new().run(|cx| {
let app = Bridge::new()
.instructions_append("A single-window counter.")
.http()
.bind("127.0.0.1:8931")
.expect("bind the MCP port")
.install(cx);
// `app` is a `purview::AppHandle<App>`; declare windows/actions as usual.
let _ = app;
});It also provides on_entity / on_entity_with (drive a gpui Entity
from an action with no per-action boilerplate), a PurviewAppExt
extension (cx.purview() to reach the AppHandle
from any view), and Pv* type aliases fixing Cx = gpui::App.
§gpui version alignment
This crate depends on gpui = "0.2.2". Every crate in the graph must agree
on that version, or two incompatible gpui copies land in it and the App
types will not unify (the errors are cryptic). Installing the bridge once
per App is required.
Structs§
- Action
Error - A tool error object.
- Bound
Bridge - A bridge that is built and bound but not yet installed on an
App, fromHttpBridge::bind. - Bridge
- Builder that installs a purview bridge onto a live gpui [
App]. - Field
- A single key/value item inside a
fieldsblock. - Http
Bridge - The Streamable HTTP half of
Bridge, fromBridge::http. - NoArgs
- Placeholder parameter type for actions with no parameters: deserializes from
any JSON (including
{}/ absent) and ignores the content. - Outcome
- Action success result (§5.4).
openedWindowIdsis normally filled by the library; set it explicitly withOutcome::openedonly when the auto tracking cannot see the open (e.g. a window opened from a spawned task).
Enums§
- Block
- One semantic block. The
idis assigned by the library (constructors leave it empty; it is filled in when the block is inserted into a window). - Severity
- Severity level of a
noticeblock (§4.4).
Traits§
- Purview
AppExt - Extension on gpui’s [
App] (and thus anyContext<V>, which derefs to it) to reach the bridge’sAppHandle— e.g.cx.purview().open("Detail")to open another projected window from inside a view or handler.
Functions§
- on_
entity - Build a parameterless action that mutates a gpui [
Entity] on the main thread, exactly like a button’scx.listener. - on_
entity_ with - Like
on_entity, but the action takes a typed parameterP(builds onon_ui(|p, cx|)). Declare the schema withActionBuilder::params. - on_ui
- Wrap a synchronous closure to run on the UI main thread. Use it for pure-UI
actions. The closure may take the params (
|p|), the host context&mut Cxto reach real widgets (e.g. gpui’s&mut App), both (|p, cx|), or neither (||); the|cx|and||forms are for parameterless actions.
Type Aliases§
- PvAction
purview::ActionHandleover gpui’sApp.- PvActions
purview::Actionsover gpui’sApp.- PvApp
purview::AppHandleover gpui’sApp.- PvBlock
purview::BlockHandleover gpui’sApp.- PvBlock
Ref purview::BlockRefover gpui’sApp.- PvBlocks
purview::Blocksover gpui’sApp.- PvFields
purview::FieldsHandleover gpui’sApp.- PvList
purview::ListHandleover gpui’sApp.- PvMedia
purview::MediaHandleover gpui’sApp.- PvNotice
purview::NoticeHandleover gpui’sApp.- PvTable
purview::TableHandleover gpui’sApp.- PvText
purview::TextHandleover gpui’sApp.- PvUi
purview::Uiover gpui’sApp— the main-thread proxy anasynchandler captures to hop back withui.run(|app| …).await.- PvWindow
purview::Windowover gpui’sApp(avoids thegpui::Windowname clash).