use super::super::*;
pub(super) struct InteractiveTerminalGuard {
tx: Option<mpsc::Sender<Event>>,
}
impl InteractiveTerminalGuard {
pub(super) async fn engage(tx: mpsc::Sender<Event>, interactive: bool) -> Self {
if !interactive {
return Self { tx: None };
}
let _ = tx.send(Event::PauseEvents).await;
Self { tx: Some(tx) }
}
}
impl Drop for InteractiveTerminalGuard {
fn drop(&mut self) {
if let Some(tx) = self.tx.take()
&& let Err(err) = tx.try_send(Event::ResumeEvents)
{
tracing::warn!(
target: "engine.tool_execution",
?err,
"InteractiveTerminalGuard: try_send(ResumeEvents) failed; \
terminal may stay in paused state until the next \
pause/resume cycle"
);
}
}
}