Skip to main content

InProcess

Struct InProcess 

Source
pub struct InProcess { /* private fields */ }
Expand description

The native in-process multiplexer backend.

Implementations§

Source§

impl InProcess

Source

pub fn new() -> Self

Source

pub fn set_spawn_env(&self, env: SpawnEnv)

Set the embedder’s typed env + cwd override, applied to every subsequent child PTY’s env AFTER the inherited + fallback env. mado calls this with its caps::EnvProjection pairs (+ the boot cwd) so vim in an embedded-tear window sees xterm-ghostty + truecolor + the vendored terminfo — identical to the local-PTY path. Idempotent; the last write wins.

Source

pub fn spawn_cwd(&self) -> Option<PathBuf>

The embedder’s current spawn cwd override (SpawnEnv.cwd), if any.

mado stamps this per-spawn (the focused pane’s cwd / boot cwd) before each new_session, so the daemon can read it at session- create time to learn which directory a session was opened in — the seed for praça’s project↔session binding (M1 “Remember”). None when no embedder cwd override is set (the bare-daemon path).

Source

pub fn set_socket_path(&self, path: PathBuf)

Record the UDS path the daemon bound to. Subsequent PTY spawns stamp TEAR_SOCKET=<path> on the child env. Called by tear-daemon::start* immediately after bind.

Source

pub fn socket_path(&self) -> Option<PathBuf>

Borrow the recorded socket path, if any.

Source

pub fn enable_pane_recording(&self, pane_id: PaneId) -> ControlResult<()>

Enable recording for pane_id. Idempotent — calling on an already-enabled pane resets the recording buffer (per PaneRecording::enable semantics). Reads the pane’s current size from the registry for the asciinema header.

Source

pub fn disable_pane_recording(&self, pane_id: PaneId) -> ControlResult<()>

Stop recording for pane_id. The captured buffer is retained until the next enable or kill_pane; the operator can still export after stopping.

Source

pub fn export_pane_recording(&self, pane_id: PaneId) -> ControlResult<String>

Export the pane’s captured recording as asciinema v2 .cast (JSON-lines). Returns an empty string when nothing has been captured yet (recording was never enabled or the pane has no events).

Source

pub fn pane_recording_status( &self, pane_id: PaneId, ) -> ControlResult<(bool, u32)>

(is_enabled, event_count) snapshot — driven by the pane-info / pane-record-status ergonomics.

Source

pub fn pane_blocks_list( &self, pane_id: PaneId, since_index: u64, limit: u32, ) -> ControlResult<Vec<Block>>

List captured blocks for a pane (oldest-first). Filters by since_index — pass 0 to get every retained block. The daemon currently caps at 10_000 blocks per pane (ring eviction). Returns NoSuchPane if the pane has no grid.

Source

pub fn pane_block_at(&self, pane_id: PaneId, index: u64) -> ControlResult<Block>

Fetch one block by per-pane index. Returns NoSuchPane if the pane is gone, or the InvalidArgument variant via Rejected when the block has been evicted / never existed.

Source

pub fn pane_blocks_status(&self, pane_id: PaneId) -> ControlResult<(u32, bool)>

(total_completed_blocks, current_in_progress) — useful for status displays. tear top reads this column.

Source

pub fn subscribe_pane_bytes( &self, pane: PaneId, ) -> ControlResult<Receiver<Vec<u8>>>

Register a byte-stream subscriber for the named pane. Returns the receiver end of an mpsc::channel; every PTY chunk that lands in this pane is sent on the corresponding sender. Drop the receiver to unsubscribe — the next send will error and the daemon prunes the dead sender.

Returns NoSuchPane if the pane has no PTY (never spawned or already killed).

If the pane’s child has already exited (remain-on-exit dead pane), the returned receiver is born already-disconnected: no live sender is registered, so the consumer can replay the pane’s final grid snapshot and then immediately observe end-of-stream (recv() -> Err) instead of blocking forever on a pane that will never emit again. The closed check and the sender push happen under the same lock, so a subscribe that races with the pane’s exit can’t leak a sender that never disconnects.

Source

pub fn with_registry<R>(&self, f: impl FnOnce(&Registry) -> R) -> R

Borrow the registry read-only — useful for callers that want to scan multiple entities atomically without locking per-call.

Source

pub fn pane_snapshot(&self, pane_id: PaneId) -> ControlResult<PaneSnapshot>

Return a serializable snapshot of the named pane’s rendered grid. Returns NoSuchPane if the pane never had a grid installed (which can only happen if it never had a PTY — every PTY-spawning code path also installs a grid).

Source

pub fn pane_cursor_keys_mode(&self, pane_id: PaneId) -> ControlResult<bool>

No-alloc DECCKM lookup — reads one bool off the live PaneGrid rather than building a full PaneSnapshot. Mado’s embedded-tear input loop hits this on every arrow keystroke; the snapshot path would clone the entire cell grid (~100KB per call on an 80×40 pane).

Source

pub fn reap_proven_dead_session(&self, proof: AllPanesExited) -> bool

Remove a session the caller has proven dead — every pane’s child process has exited.

This is the only way for a daemon to end a session on its own initiative, and AllPanesExited is the only ticket in. A rule keyed on “nobody is attached”, on an idle timer, or on the session’s tear_types::SessionSource cannot construct one — see crate::reap for the incident that motivated the narrowing.

Returns true if the session was removed. false means the proof went stale between witnessing and now (a new_window landed, or an explicit kill_session won the race) — the proof is re-taken under the write lock, so a resurrected session is never reaped.

Call with no registry guard held. Mint the proof from an owned TearSession (list_sessions() / get_session() both clone) or from a read() bound to its own let statement. Passing a proof witnessed inside a still-live read guard deadlocks on the write() below — parking_lot’s RwLock is not reentrant and this thread would be waiting for itself.

Source§

impl InProcess

Source

pub fn set_freio( &self, session: Option<SessionId>, engaged: bool, ) -> (Vec<(SessionId, Freio)>, Vec<PaneId>, Vec<PaneId>)

Engage or release the operator’s brake — see tear_types::freio.

session: None means every session; that is the one-gesture panic path. Returns, in order: every session’s state after the call, the panes actually braked, and — critically — the panes the brake could NOT reach because their provenance is unknown.

That third list is not diagnostics. An operator who pressed a panic button must be told what it did not stop, or they will believe everything halted.

at_unix is stamped HERE, from the daemon’s clock. No caller supplies it, so a backdated brake has no code path.

Source

pub fn freio_state(&self) -> Vec<(SessionId, Freio)>

Every session’s brake state.

Source§

impl InProcess

Provenance-aware spawn verbs.

Inherent rather than trait methods: MultiplexerControl is implemented by backends with no provenance model (the tmux backend), and widening the trait would force them to carry a concept they cannot honour. The trait verbs delegate here with Yurai::Unknown.

Source

pub fn new_session_yurai( &self, name: &str, shell: &str, args: &[String], source: SessionSource, size_cells: (u16, u16), yurai: Yurai, ) -> ControlResult<SessionId>

Spawn a session, recording WHO asked. See tear_types::yurai.

Source

pub fn new_window_yurai( &self, session: SessionId, name: &str, shell: &str, args: &[String], yurai: Yurai, ) -> ControlResult<WindowId>

Open a window, recording WHO asked.

Source

pub fn split_pane_yurai( &self, origin: PaneId, direction: Direction, shell: &str, args: &[String], yurai: Yurai, ) -> ControlResult<PaneId>

Split a pane, recording WHO asked.

The new pane inherits the provenance of the CONNECTION that asked for the split, not of the pane it split from: an operator splitting an agent’s pane gets their own pane, and the brake leaves it alone.

Trait Implementations§

Source§

impl Default for InProcess

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl MultiplexerControl for InProcess

Source§

fn pane_snapshot(&self, id: PaneId) -> ControlResult<PaneSnapshot>

Phase-2 override of the trait’s default pane_snapshot. Delegates to the inherent Self::pane_snapshot method, which reads the per-pane PaneGrid installed by Self::spawn_pty_for.

Source§

fn pane_cursor_keys_mode(&self, id: PaneId) -> ControlResult<bool>

Override the trait default with the no-alloc lookup — mado’s input loop calls this per keystroke, so the fast path matters here.

Source§

fn pane_resize_absolute( &self, id: PaneId, cols: u16, rows: u16, ) -> ControlResult<()>

Phase-3.1 override — resize the underlying PTY (fires SIGWINCH at the child) AND resize the per-pane PaneGrid so subsequent snapshots reflect the new geometry.

Source§

fn list_sessions(&self) -> ControlResult<Vec<TearSession>>

List every active session. Sorted by creation time (oldest first); the CLI’s tear list renders this directly.
Source§

fn get_session(&self, id: SessionId) -> ControlResult<TearSession>

Look up a single session by id.
Source§

fn get_window(&self, id: WindowId) -> ControlResult<(SessionId, TearWindow)>

Look up a single window. Returns the window + its parent session id (handy for rendering window paths like work:1).
Source§

fn get_pane(&self, id: PaneId) -> ControlResult<TearPane>

Look up a single pane.
Source§

fn new_session_with_source_and_size( &self, name: &str, shell: &str, args: &[String], source: SessionSource, size_cells: (u16, u16), ) -> ControlResult<SessionId>

Same as Self::new_session_with_source but the first pane is created at the given (cols, rows) size. The child shell’s TIOCGWINSZ returns these values on first query — TUI apps render at the correct grid from the very first prompt, no resize-flicker on attach. Read more
Source§

fn new_window( &self, session: SessionId, name: &str, shell: &str, args: &[String], ) -> ControlResult<WindowId>

Create a new window in a session, spawning shell as its first pane. args is that program’s argv[1..] — passed as a vector, never through a shell. &[] for a bare shell.
Source§

fn split_pane( &self, origin: PaneId, direction: Direction, shell: &str, args: &[String], ) -> ControlResult<PaneId>

Split a pane in the given direction. shell is the program spawned in the new pane and args is its argv[1..] — passed as a vector, never through a shell. &[] for a bare shell.
Source§

fn rename_session(&self, id: SessionId, new_name: &str) -> ControlResult<()>

Rename a session. Idempotent — renaming to the current name returns Ok(()) without side effects.
Source§

fn kill_session(&self, id: SessionId) -> ControlResult<()>

Kill a session and all its children.
Source§

fn kill_window(&self, id: WindowId) -> ControlResult<()>

Source§

fn select_window(&self, id: WindowId) -> ControlResult<()>

Source§

fn kill_pane(&self, id: PaneId) -> ControlResult<()>

Source§

fn select_pane(&self, id: PaneId) -> ControlResult<()>

Source§

fn resize_pane( &self, id: PaneId, direction: Direction, delta_cells: i16, ) -> ControlResult<()>

Resize a pane along one axis. delta_cells is signed — negative shrinks. tmux’s resize-pane -L/-R/-U/-D.
Source§

fn apply_layout(&self, window: WindowId, kind: LayoutKind) -> ControlResult<()>

Re-arrange a window’s existing panes into a named LayoutKind preset (tmux select-layout). The panes keep their PTYs and scrollback — only the window’s layout tree changes, then geometry reflows. LayoutKind::Custom (and an empty window) is a no-op: there is no canonical arrangement to impose, so the operator’s manual tree wins. Built on LayoutNode::from_kind.
Source§

fn send_keys(&self, id: PaneId, bytes: &[u8]) -> ControlResult<()>

Send keystrokes (already-bytes-encoded — caller resolved the chord) to a pane’s PTY.
Source§

fn pane_subscriber_count(&self, id: PaneId) -> ControlResult<u32>

How many byte-stream subscribers are currently attached to the named pane. Returns 0 if the pane has no subscribers (or doesn’t exist — wraps the typed NoSuchPane miss into a 0 count so the migration call site doesn’t have to distinguish “no subscribers” from “pane gone”).
Source§

fn set_input_policy(&self, id: PaneId, policy: InputPolicy) -> ControlResult<()>

Replace a pane’s typed crate::pane::InputPolicy. Default behavior is Free; setting Locked causes every subsequent send_keys for that pane to return ControlError::Rejected. Idempotent — same policy is a no-op.
Source§

fn capabilities(&self) -> DaemonIdentity

What this backend can actually do, and who it is. Read more
Source§

fn new_session( &self, name: &str, shell: &str, ) -> Result<SessionId, ControlError>

Create a new session. name is the operator-visible label; the returned SessionId is the stable handle. Defaults to SessionSource::Human — agent-driven consumers (mado MCP, automation) should call Self::new_session_with_source so tear list --source can audit provenance.
Source§

fn new_session_with_source( &self, name: &str, shell: &str, source: SessionSource, ) -> Result<SessionId, ControlError>

Create a session with a typed [SessionSource] tag. The daemon stores this on the TearSession so tear list can group by provenance and operators can audit agent-created sessions. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more