Skip to main content

Crate purview_gpui

Crate purview_gpui 

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

ActionError
A tool error object.
BoundBridge
A bridge that is built and bound but not yet installed on an App, from HttpBridge::bind.
Bridge
Builder that installs a purview bridge onto a live gpui [App].
Field
A single key/value item inside a fields block.
HttpBridge
The Streamable HTTP half of Bridge, from Bridge::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). openedWindowIds is normally filled by the library; set it explicitly with Outcome::opened only when the auto tracking cannot see the open (e.g. a window opened from a spawned task).

Enums§

Block
One semantic block. The id is 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 notice block (§4.4).

Traits§

PurviewAppExt
Extension on gpui’s [App] (and thus any Context<V>, which derefs to it) to reach the bridge’s AppHandle — 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’s cx.listener.
on_entity_with
Like on_entity, but the action takes a typed parameter P (builds on on_ui(|p, cx|)). Declare the schema with ActionBuilder::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 Cx to 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::ActionHandle over gpui’s App.
PvActions
purview::Actions over gpui’s App.
PvApp
purview::AppHandle over gpui’s App.
PvBlock
purview::BlockHandle over gpui’s App.
PvBlockRef
purview::BlockRef over gpui’s App.
PvBlocks
purview::Blocks over gpui’s App.
PvFields
purview::FieldsHandle over gpui’s App.
PvList
purview::ListHandle over gpui’s App.
PvMedia
purview::MediaHandle over gpui’s App.
PvNotice
purview::NoticeHandle over gpui’s App.
PvTable
purview::TableHandle over gpui’s App.
PvText
purview::TextHandle over gpui’s App.
PvUi
purview::Ui over gpui’s App — the main-thread proxy an async handler captures to hop back with ui.run(|app| …).await.
PvWindow
purview::Window over gpui’s App (avoids the gpui::Window name clash).