use tokio::sync::{mpsc, oneshot};
pub struct AskRequest {
pub prompt: String,
pub placeholder: Option<String>,
pub reply: oneshot::Sender<AskAnswer>,
}
#[derive(Clone, Debug, Default)]
pub struct AskAnswer {
pub answer: String,
pub cancelled: bool,
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum UiCommand {
ShowHelp,
ShowTools,
ManageMcp { arg: Option<String> },
ShowCwd,
SetStatusLayout { arg: Option<String> },
ClearTranscript,
RunShell { command: String },
Quit,
OpenModelOverlay { arg: Option<String> },
OpenEffortOverlay { arg: Option<String> },
SetExtensionStatus { ext: String, status: String },
}
pub trait HostUi: Send + Sync {
fn send(&self, command: UiCommand);
}
pub struct TuiHandle {
tx: mpsc::UnboundedSender<UiCommand>,
}
impl TuiHandle {
pub fn new(tx: mpsc::UnboundedSender<UiCommand>) -> Self {
Self { tx }
}
}
impl HostUi for TuiHandle {
fn send(&self, command: UiCommand) {
let _ = self.tx.send(command);
}
}