Terminal interface to find, download, and stream movies, TV shows, and live TV using local media players.
fix(tui): clear unsubmitted command and query drafts on escape key
Samir Hossainsf2a91b919bff
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex d300473..dce604c 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -4,7 +4,7 @@### Added- **Comprehensive QA & Regression Test Architecture**:- - Introduced a 69-test automated suite covering critical algorithmic boundaries, end-to-end user journeys, active player session lifecycle & duplicate launch protection, dynamic slash command autocomplete (`/download-dir reset`), error handling, addon manifest validation, mouse interactions, modal dismissals, TUI rendering across terminal size matrices, state reconciliation, crypto HMAC signing, download chunk arithmetic, and URL/stem security.+ - Introduced a 71-test automated suite covering critical algorithmic boundaries, end-to-end user journeys, active player session lifecycle & duplicate launch protection, dynamic slash command autocomplete (`/download-dir reset`), search/command draft cancellation via `Esc`, error handling, addon manifest validation, mouse interactions, modal dismissals, TUI rendering across terminal size matrices, state reconciliation, crypto HMAC signing, download chunk arithmetic, and URL/stem security.- Added structured integration tests in `tests/` (`error_handling.rs`, `tui_acceptance.rs`, `history_reconciliation.rs`, `cache_lifecycle.rs`, `player_integration.rs`, `m3u_integration.rs`, `addons_manifest.rs`, `download_integration.rs`, `url_security.rs`) and test fixtures (`tests/fixtures/`).- Added [`docs/testing.md`](docs/testing.md) detailing test architecture, command references, and manual QA procedures.- **Playback Tracking & Watch History Progress**:diff --git a/docs/known-issues.md b/docs/known-issues.mdindex 6afe546..670d342 100644--- a/docs/known-issues.md+++ b/docs/known-issues.md@@ -26,6 +26,6 @@ Tracked here so future work and issue reports reference the same facts.## Verification-- Automated testing is enforced via `cargo test --locked` covering 69 unit and integration tests across 10 test suites (see [`docs/testing.md`](testing.md)).+- Automated testing is enforced via `cargo test --locked` covering 71 unit and integration tests across 10 test suites (see [`docs/testing.md`](testing.md)).- Static correctness is enforced by strict compiler type checking, the lint gate (`cargo clippy --all-targets --all-features -- -D warnings`), formatting (`cargo fmt --check`), dependency vulnerability scanning (`cargo audit`), and packaging verification (`cargo package --locked`).- Runtime and platform-specific behavior (terminal resize, focus handling, external player launch, and Termux chooser) are verified through the release checklist in [`release-checklist.md`](release-checklist.md).diff --git a/src/tui/app/keyboard.rs b/src/tui/app/keyboard.rsindex 640aa23..4941fd6 100644--- a/src/tui/app/keyboard.rs+++ b/src/tui/app/keyboard.rs@@ -195,6 +195,11 @@ impl App {self.state.input_mode = InputMode::Normal;self.state.suggest_index = None;self.state.search_suggestions.clear();+ if self.state.search_query.starts_with('/')+ || self.state.search_results.is_empty()+ {+ self.state.search_query.clear();+ }self.state.set_status(String::new(), 150);}KeyCode::Enter => {diff --git a/tests/tui_acceptance.rs b/tests/tui_acceptance.rsindex d9a9c23..6000145 100644--- a/tests/tui_acceptance.rs+++ b/tests/tui_acceptance.rs@@ -167,3 +167,42 @@ async fn test_download_dir_reset_user_journey() {assert_eq!(notif.title, "Download Directory");assert!(notif.message.contains("Reset to default"));}++#[tokio::test]+async fn test_esc_key_cancels_slash_command_and_clears_search_bar() {+ let mut app = App::new();+ app.state_mut().update_available = None;+ app.state_mut().show_theme_popup = false;+ app.state_mut().show_browse_popup = false;+ app.state_mut().input_mode = InputMode::Editing;+ app.state_mut().search_query = "/download-dir".to_string();++ let esc_key = crossterm::event::KeyEvent::new(+ crossterm::event::KeyCode::Esc,+ crossterm::event::KeyModifiers::empty(),+ );+ app.handle_action(Action::Key(esc_key)).await;++ assert_eq!(app.state().input_mode, InputMode::Normal);+ assert_eq!(app.state().search_query, "");+}++#[tokio::test]+async fn test_esc_key_cancels_unsubmitted_search_query() {+ let mut app = App::new();+ app.state_mut().update_available = None;+ app.state_mut().show_theme_popup = false;+ app.state_mut().show_browse_popup = false;+ app.state_mut().input_mode = InputMode::Editing;+ app.state_mut().search_query = "batman".to_string();+ assert!(app.state().search_results.is_empty());++ let esc_key = crossterm::event::KeyEvent::new(+ crossterm::event::KeyCode::Esc,+ crossterm::event::KeyModifiers::empty(),+ );+ app.handle_action(Action::Key(esc_key)).await;++ assert_eq!(app.state().input_mode, InputMode::Normal);+ assert_eq!(app.state().search_query, "");+}