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-tattle-tests, mnml-db-postgres, …) 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.

Modules§

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.