use crate::llm::actions::ActionDefinition;
use crate::tui::app::UiKey;
use crate::tui::hit::ModalAction;
#[derive(Debug, Clone)]
pub struct InterceptModel {
pub id: u64,
pub owner: UiKey,
pub protocol: String,
pub event_type: String,
pub description: String,
pub event_data: Option<serde_json::Value>,
pub vocabulary: Vec<ActionDefinition>,
pub error: Option<String>,
pub focused: usize,
}
impl InterceptModel {
pub fn buttons(&self) -> Vec<ModalAction> {
vec![
ModalAction::InterceptCompose,
ModalAction::InterceptSend,
ModalAction::InterceptDismiss,
]
}
pub fn focused_action(&self) -> Option<ModalAction> {
self.buttons().get(self.focused).copied()
}
pub fn cycle_focus(&mut self, backward: bool) {
let total = self.buttons().len();
self.focused = if backward {
(self.focused + total - 1) % total
} else {
(self.focused + 1) % total
};
}
}