refactor: Pre-phase-6 review cleanup.
Some checks failed
CI / Lint (push) Has been cancelled
CI / Test (push) Has been cancelled

- Propagate serialization errors in output path
instead of unwrap_or_default() silently writing
blank lines (main.rs, handler.rs).
- Cap selection undo stack at 50 entries to bound
memory on heavy multi-select usage (menu.rs).
- Break TUI event loop on dead action channel
instead of silently dropping keypresses (lib.rs).
- Log dropped handler hook events when channel is
full (handler.rs).
- Reject menu and headless DSL tests that have no
assertions at compile time (codegen.rs).
- Document filter_text ownership design in TUI and
exec/handler error asymmetry in CompositeHandler.
This commit is contained in:
2026-03-14 15:26:31 -04:00
parent 8077469d19
commit cd1927fa9f
5 changed files with 57 additions and 12 deletions

View File

@@ -35,6 +35,10 @@ pub enum ActionOutcome {
NoOp,
}
/// Maximum number of undo snapshots to retain. Keeps memory
/// bounded when users toggle hundreds of selections.
const UNDO_STACK_LIMIT: usize = 50;
/// Tracks multi-select state: which items are selected (by
/// original index), with undo/redo support.
pub struct SelectionState {
@@ -57,6 +61,9 @@ impl SelectionState {
}
fn push_undo(&mut self) {
if self.undo_stack.len() >= UNDO_STACK_LIMIT {
self.undo_stack.remove(0);
}
self.undo_stack.push(self.selected.clone());
self.redo_stack.clear();
}