Skip to main content

Crate mnml_bridge

Crate mnml_bridge 

Source
Expand description

§mnml-bridge — Mount protocol for mnml sibling tools

Bridge / Mount is the integration layer that lets sibling tools (mnml-db-postgres, mnml-forge-bitbucket, …) render their UI as a first-class pane inside mnml — owning the activity-bar icon, the rail content, and the editor body — instead of running as a plain Pty pane.

§The four tiers

  1. Env vars — every Pty mnml spawns sees MNML_WORKSPACE, MNML_THEME, and MNML_IPC_DIR. Zero protocol; just read on startup. (Available today for any sibling.)
  2. JSONL sibling → host — sibling writes JSONL commands to $MNML_IPC_DIR/command; mnml ingests them. toast, open-pty, open (file), more coming. One-way.
  3. mnml-bridge SDK — this crate. Typed Rust API around tiers 1 + 2, plus the Mount protocol below.
  4. Mount — sibling connects to a Unix-socket-per-mount, streams cell+style frames back, receives input events. Owns rail + body areas of an activity-bar section.

§Wire shape

Length-prefixed JSON. Every message is a Frame or Input. The 4-byte little-endian length precedes the JSON body so framing is trivial (no streaming JSON parser needed).

Host → Sibling:

  • MountHello { cols, rows } first
  • Resize { cols, rows } on terminal resize
  • Input { event } on every routed key / mouse event

Sibling → Host:

  • Frame { cells: Vec<Vec<Cell>> } whenever the sibling has a new screen state. Cell-perfect; the host stamps these into its own ratatui frame.

V1 keeps it simple: full frames, no diffing. A ~24x80 panel is ~2 KB of JSON; serialization cost is negligible vs ratatui’s own draw cycle.

Re-exports§

pub use install::ChipSpec;
pub use install::CommandSpec;
pub use install::ContextMenuEntry;
pub use install::IntegrationSpec;
pub use install::MenuBarEntry;
pub use install::NotificationsSpec;
pub use install::OsNotifyPolicy;
pub use install::Requires;
pub use install::SettingsPage;
pub use install::StatuslineSpec;
pub use install::install_integration;
pub use install::integration_manifest_path;
pub use install::list_installed_integrations;
pub use install::uninstall_integration;
pub use ipc::NotifyOpts;
pub use ipc::ProgressStatus;
pub use ipc::SegmentSide;
pub use ipc::ToastLevel;
pub use ipc::notify;
pub use ipc::progress_end;
pub use ipc::progress_start;
pub use ipc::progress_update;
pub use ipc::register_command;
pub use ipc::set_activity_badge;
pub use ipc::statusline_clear_segment;
pub use ipc::statusline_set_segment;
pub use ipc::toast;
pub use ipc::toast_dismiss;
pub use ipc::toast_error;
pub use ipc::toast_info;
pub use ipc::toast_persistent;
pub use ipc::toast_warn;

Modules§

install
Integration manifest install helpers — sibling-authored self-registration for the rail chip, palette commands, chord bindings, context menu additions, menu-bar entries, statusline segments, settings pages, and OS notification policy. Writes a single TOML file per integration:
ipc
Tier-2 IPC helpers — write JSONL commands to the host.
modifier
Bitflags for Cell::modifiers. Mirrors ratatui’s Modifier constants so a sibling can reuse its existing styling.

Structs§

Cell
A single terminal cell — one grapheme + style. Mirrors ratatui’s buffer::Cell shape but with serde derived.
Geometry
Sent by the host once on connection, then on every terminal resize.

Enums§

HostMessage
Host → sibling messages.
InputEvent
Routed input event from the host. Key / mouse events that happened inside the mount’s area are forwarded as-is.
RgbOrIndex
Either a true-color RGB triple or a 256-color palette index.
SiblingMessage
Sibling → host messages.

Functions§

read_message
Read a length-prefixed JSON message from a stream.
write_message
Write a length-prefixed JSON message to a stream.