purview_gpui/lib.rs
1//! Ergonomic glue for embedding a [`purview`] MCP bridge in a [`gpui`] app.
2//!
3//! `purview` is framework-agnostic: to bind it to gpui a host must wire up a
4//! `Send` channel, a poster closure, the background server, a main-thread drain
5//! loop, and keep the server handle alive for the app's lifetime. This crate
6//! collapses all of that into one call:
7//!
8//! ```ignore
9//! use gpui::Application;
10//! use purview_gpui::Bridge;
11//!
12//! Application::new().run(|cx| {
13//! let app = Bridge::new()
14//! .instructions_append("A single-window counter.")
15//! .http()
16//! .bind("127.0.0.1:8931")
17//! .expect("bind the MCP port")
18//! .install(cx);
19//! // `app` is a `purview::AppHandle<App>`; declare windows/actions as usual.
20//! let _ = app;
21//! });
22//! ```
23//!
24//! It also provides [`on_entity`] / [`on_entity_with`] (drive a gpui `Entity`
25//! from an action with no per-action boilerplate), a [`PurviewAppExt`]
26//! extension (`cx.purview()` to reach the [`AppHandle`](purview::AppHandle)
27//! from any view), and `Pv*` type aliases fixing `Cx = gpui::App`.
28//!
29//! # gpui version alignment
30//!
31//! This crate depends on `gpui = "0.2.2"`. Every crate in the graph must agree
32//! on that version, or two incompatible gpui copies land in it and the `App`
33//! types will not unify (the errors are cryptic). Installing the bridge once
34//! per `App` is required.
35
36#![warn(missing_docs)]
37
38mod aliases;
39mod ext;
40mod handler;
41mod install;
42
43pub use aliases::*;
44pub use ext::PurviewAppExt;
45pub use handler::{on_entity, on_entity_with};
46pub use install::{BoundBridge, Bridge, HttpBridge};