pub struct UiDialogMailbox { /* private fields */ }Expand description
Thread-safe mailbox connecting plugin runtime actions to an interactive host (normally the TUI). It deliberately carries only JSON and primitives, so the extension crate remains independent of the UI crate.
Implementations§
Source§impl UiDialogMailbox
impl UiDialogMailbox
pub fn new() -> Self
Sourcepub fn detach(&self)
pub fn detach(&self)
Detach the consumer and cancel every outstanding request. This prevents a TUI restart/reload from leaving plugin polls blocked forever.
pub fn is_attached(&self) -> bool
Sourcepub fn take_pending(&self) -> Option<UiDialogRequest>
pub fn take_pending(&self) -> Option<UiDialogRequest>
Remove and return the next request for presentation by the TUI.
Cancelled/answered requests are skipped; duplicate open calls never
enqueue the same request id twice.
pub fn pending_len(&self) -> usize
Sourcepub fn is_pending(&self, request_id: &str) -> bool
pub fn is_pending(&self, request_id: &str) -> bool
Inspect lifecycle without consuming the answer reserved for a plugin.
Sourcepub fn respond(&self, request_id: &str, answer: Value) -> Result<(), String>
pub fn respond(&self, request_id: &str, answer: Value) -> Result<(), String>
Supply an answer for a request. Repeating the same operation is idempotent; answering a cancelled/unknown request is an explicit error.
Sourcepub fn cancel(&self, request_id: &str) -> Result<(), String>
pub fn cancel(&self, request_id: &str) -> Result<(), String>
Mark one request cancelled. The terminal state remains visible to the
plugin’s next poll, then is reclaimed by that poll.
Sourcepub fn cancel_all(&self)
pub fn cancel_all(&self)
Cancel all requests currently known to the mailbox.
Sourcepub fn cancel_tool_call(&self, tool_call_id: &str)
pub fn cancel_tool_call(&self, tool_call_id: &str)
Cancel approval requests belonging to one tool without disturbing questions from concurrent tool calls.