(&mut self, key: KeyEvent)
| 1615 | } |
| 1616 | |
| 1617 | fn handle_draft_key(&mut self, key: KeyEvent) { |
| 1618 | // Approve-all confirmation modal intercepts all keys when open. |
| 1619 | if self.approve_all_confirm_open { |
| 1620 | match key.code { |
| 1621 | KeyCode::Char('y') | KeyCode::Enter => { |
| 1622 | self.pending_draft_approve_all = true; |
| 1623 | self.approve_all_confirm_open = false; |
| 1624 | // Don't clear chunks here — the event loop takes them |
| 1625 | // via std::mem::take when it processes the flag. |
| 1626 | } |
| 1627 | KeyCode::Esc | KeyCode::Char('n') => { |
| 1628 | self.approve_all_confirm_open = false; |
| 1629 | self.approve_all_confirm_chunks.clear(); |
| 1630 | } |
| 1631 | _ => {} |
| 1632 | } |
| 1633 | return; |
| 1634 | } |
| 1635 | |
| 1636 | // Detail popup intercepts most keys when open. |
| 1637 | if self.draft_detail_open { |
| 1638 | match key.code { |
| 1639 | KeyCode::Esc | KeyCode::Enter => { |
| 1640 | self.draft_detail_open = false; |
| 1641 | } |
| 1642 | // Allow approve/reject toggle from within the popup. |
| 1643 | KeyCode::Char('a') => { |
| 1644 | if self.sandbox_policy_is_global { |
| 1645 | self.status_text = |
| 1646 | "Cannot approve rules while a global policy is active".to_string(); |
| 1647 | } else { |
| 1648 | let abs = self.draft_scroll + self.draft_selected; |
| 1649 | if abs < self.draft_chunks.len() { |
| 1650 | let st = self.draft_chunks[abs].status.as_str(); |
| 1651 | if st == "pending" || st == "rejected" { |
| 1652 | self.pending_draft_approve = true; |
| 1653 | self.draft_detail_open = false; |
| 1654 | } |
| 1655 | } |
| 1656 | } |
| 1657 | } |
| 1658 | KeyCode::Char('x') => { |
| 1659 | if self.sandbox_policy_is_global { |
| 1660 | self.status_text = |
| 1661 | "Cannot modify rules while a global policy is active".to_string(); |
| 1662 | } else { |
| 1663 | let abs = self.draft_scroll + self.draft_selected; |
| 1664 | if abs < self.draft_chunks.len() { |
| 1665 | let st = self.draft_chunks[abs].status.as_str(); |
| 1666 | if st == "pending" || st == "approved" { |
| 1667 | self.pending_draft_reject = true; |
| 1668 | self.draft_detail_open = false; |
| 1669 | } |
| 1670 | } |
| 1671 | } |
| 1672 | } |
| 1673 | _ => {} |
| 1674 | } |
no test coverage detected