use super::*;
#[derive(Clone)]
pub(crate) struct BashApprovalState {
pub(crate) request: crate::protection::bash::BashApprovalRequest,
pub(crate) response: crossbeam_channel::Sender<bool>,
}
impl std::fmt::Debug for BashApprovalState {
fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
formatter
.debug_struct("BashApprovalState")
.field("request", &"<redacted>")
.finish()
}
}
impl PartialEq for BashApprovalState {
fn eq(&self, other: &Self) -> bool {
self.request.command == other.request.command
&& self.request.score == other.request.score
&& self.request.confidence == other.request.confidence
}
}
impl Eq for BashApprovalState {}
impl MissionControlState {
pub(crate) fn open_bash_approval(
&mut self,
request: crate::protection::bash::BashApprovalRequest,
response: crossbeam_channel::Sender<bool>,
) {
self.modals.bash_approval = Some(BashApprovalState { request, response });
self.hide_autocomplete();
}
pub(crate) fn resolve_bash_approval(&mut self, allowed: bool) -> bool {
let Some(approval) = self.modals.bash_approval.take() else {
return false;
};
let _ = approval.response.try_send(allowed);
true
}
}