Terminal interface to find, download, and stream movies, TV shows, and live TV using local media players.
feat(tui): remap details back navigation and standardize modal escapes
Samir Hossains0068e143c982
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex e53ab9c..22b67f4 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -39,9 +39,16 @@- Optimized typed cache serialization in `src/cache.rs` using direct in-place encoding (`rmp_serde::encode::write`) into pre-seeded magic header buffers, eliminating intermediate vector allocations and duplicate memory copies.- Pre-allocated file buffer capacity from file metadata in `get_typed_cache` in `src/cache.rs`, eliminating repetitive vector reallocations during cache reads.### Changed+- **TUI & Ergonomics**:+ - Remapped `q` / `Q` on `Screen::Details` in `src/tui/app/keyboard.rs` from application exit to `Action::GoBack`, preserving active search results and returning to the home screen without unexpected process termination.+ - Standardized modal and popup dismissal across Settings, Providers, Browse Presets, Sources, Themes, Addons, and TV Config overlays to dismiss on both `Esc` and `q`.+ - Reordered episode list label formatting in `src/tui/screens/details.rs` to compute prefix and progress badge widths before truncating episode titles, strictly preventing list item text overflow and jagged multi-line wrapping.+ - Replaced ambiguous `" ... [i]"` plot synopsis truncation with an explicit `" ... [i: More]"` indicator in `src/tui/screens/details.rs`.+ - Optimized stream table column constraints for ultra-compact terminals (<65 columns) in `src/tui/screens/details.rs`, compacting `SIZE` to 7 characters and reclaiming columns for release title readability on mobile viewports.+ - Rendered cached IMDb rating badges across all visible search cards in `src/tui/screens/home.rs` by peeking `preview_cache`, enabling at-a-glance quality comparison across the grid without manual card-by-card selection.+ - Collapsed empty `[No Art]` poster placeholder columns when `image_supported` is false in `src/tui/screens/home.rs`, expanding search card text and metadata across the full available column width on non-graphical terminals.- **Documentation & Cross-Platform Terminal Compatibility**:- Documented native Windows Terminal Sixel image support requirements (`v1.22+` via Microsoft Store) in `docs/cross-platform.md` and `README.md`, clarifying that no third-party terminal or configuration is required on Windows.-## [0.1.24] - 2026-09-24### Addeddiff --git a/docs/controls.md b/docs/controls.mdindex b432e39..4c5d405 100644--- a/docs/controls.md+++ b/docs/controls.md@@ -43,7 +43,7 @@ All popups (Themes, Providers, Players, TV Manager, Addon Manager) share standar- **`↑` / `↓` / `k` / `j`**: Navigate choices.- **`Home` / `End`**: Jump to first / last item.- **`Enter`**: Confirm selection.-- **`Esc`**: Dismiss popup without applying changes.+- **`Esc` / `q`**: Dismiss popup without applying changes.- **TV & Addon Managers**:- `r`: Reload playlist sources or addon catalogs.- `d` / `Delete`: Remove selected source.@@ -61,7 +61,7 @@ All popups (Themes, Providers, Players, TV Manager, Addon Manager) share standar| **`f`** | Toggle favorite bookmark for current title || **`i`** | Open synopsis and plot overview dialog || **`r`** | Refresh stream list for current title or episode |-| **`Esc`** | Return to previous screen (Home or Search) |+| **`Esc` / `q`** | Return to previous screen (Home or Search) |## Synopsis & Overview Modal@@ -76,7 +76,7 @@ All popups (Themes, Providers, Players, TV Manager, Addon Manager) share standar- **`←` / `→` / `h` / `l`**: Adjust setting values or toggle options.- **`Enter` / `Space`**: Activate setting row (edit path, pick theme, run maintenance action).- **`d`** (on Download Folder): Reset custom download path back to `~/Downloads/MovieBox-TUI`.-- **`Esc`**: Close settings and persist changes.+- **`Esc` / `q`**: Close settings and persist changes.## Update Notification Modaldiff --git a/src/tui/app/keyboard.rs b/src/tui/app/keyboard.rsindex b9445f4..65fd8b0 100644--- a/src/tui/app/keyboard.rs+++ b/src/tui/app/keyboard.rs@@ -162,7 +162,7 @@ impl App {self.state.provider_list_state.select(None);self.cycle_provider();}- KeyCode::Esc => {+ KeyCode::Esc | KeyCode::Char('q') | KeyCode::Char('Q') => {self.state.show_provider_popup = false;self.state.provider_list_state.select(None);}@@ -236,7 +236,7 @@ impl App {};match key.code {- KeyCode::Esc => {+ KeyCode::Esc | KeyCode::Char('q') | KeyCode::Char('Q') => {self.state.show_browse_popup = false;self.state.browse_list_state.select(None);}@@ -301,7 +301,7 @@ impl App {}if self.state.player_picker_popup {match key.code {- KeyCode::Esc => {+ KeyCode::Esc | KeyCode::Char('q') | KeyCode::Char('Q') => {self.action_sender.send(Action::GoBack).ok();}KeyCode::Up | KeyCode::Char('k') => {@@ -351,7 +351,7 @@ impl App {if self.state.show_sources_popup {match key.code {- KeyCode::Esc => {+ KeyCode::Esc | KeyCode::Char('q') | KeyCode::Char('Q') => {self.state.show_sources_popup = false;}KeyCode::Up | KeyCode::Char('k') => {@@ -387,7 +387,7 @@ impl App {let total = crate::tui::theme::AVAILABLE_THEMES.len();let mut changed = false;match key.code {- KeyCode::Esc => {+ KeyCode::Esc | KeyCode::Char('q') | KeyCode::Char('Q') => {self.state.show_theme_popup = false;if let Some(orig) = self.state.original_theme_kind.take() {self.action_sender.send(Action::SelectTheme(orig)).ok();@@ -471,7 +471,7 @@ impl App {}match key.code {- KeyCode::Esc => {+ KeyCode::Esc | KeyCode::Char('q') | KeyCode::Char('Q') => {self.state.show_settings_popup = false;self.state.settings_download_dir_input = None;self.persist_config();@@ -717,7 +717,7 @@ impl App {return None;}match key.code {- KeyCode::Esc => {+ KeyCode::Esc | KeyCode::Char('q') | KeyCode::Char('Q') => {self.reset_transient_overlays();self.state.addon_manager_popup = false;}@@ -781,7 +781,7 @@ impl App {return None;}match key.code {- KeyCode::Esc => {+ KeyCode::Esc | KeyCode::Char('q') | KeyCode::Char('Q') => {self.reset_transient_overlays();self.state.tv_config_popup = false;}@@ -1154,7 +1154,7 @@ impl App {self.action_sender.send(Action::BackTabPane).ok();}}- KeyCode::Esc => {+ KeyCode::Esc | KeyCode::Char('q') | KeyCode::Char('Q') => {self.action_sender.send(Action::GoBack).ok();}KeyCode::Char(' ') | KeyCode::Char('p') | KeyCode::Char('P') => {@@ -1180,9 +1180,6 @@ impl App {}}}- KeyCode::Char('q') | KeyCode::Char('Q') => {- self.action_sender.send(Action::Quit).ok();- }KeyCode::Char('d') | KeyCode::Char('D') => {if !self.state.subtitle_popup&& !self.state.player_picker_popup@@ -1674,4 +1671,32 @@ mod tests {Some(Action::DownloadSeason)));}+ #[tokio::test]+ async fn test_details_q_triggers_go_back() {+ let mut app = App::new();+ app.state.active_screen = Screen::Details;+ app.state.details_pane = crate::tui::state::DetailsPane::Streams;+ app.handle_key(KeyEvent::new(KeyCode::Char('q'), KeyModifiers::empty()))+ .await;+ assert!(matches!(+ app.action_receiver.try_recv().ok(),+ Some(Action::GoBack)+ ));+ }++ #[tokio::test]+ async fn test_popups_dismiss_on_q() {+ let mut app = App::new();+ app.state.show_provider_popup = true;+ app.state.provider_list_state.select(Some(0));+ app.handle_key(KeyEvent::new(KeyCode::Char('q'), KeyModifiers::empty()))+ .await;+ assert!(!app.state.show_provider_popup);+ assert_eq!(app.state.provider_list_state.selected(), None);++ app.state.show_settings_popup = true;+ app.handle_key(KeyEvent::new(KeyCode::Char('q'), KeyModifiers::empty()))+ .await;+ assert!(!app.state.show_settings_popup);+ }}diff --git a/src/tui/screens/details.rs b/src/tui/screens/details.rsindex 271721a..1634ab2 100644--- a/src/tui/screens/details.rs+++ b/src/tui/screens/details.rs@@ -808,7 +808,7 @@ pub fn draw(frame: &mut Frame, area: Rect, state: &mut AppState, theme: &Theme)if wrapped_synopsis.len() > max_synopsis_lines {wrapped_synopsis.truncate(max_synopsis_lines);if let Some(last) = wrapped_synopsis.last_mut() {- let hint = " ... [i]";+ let hint = " ... [i: More]";let hint_w = crate::tui::text::width(hint);if crate::tui::text::width(last) + hint_w <= text_width {last.push_str(hint);@@ -1081,35 +1081,6 @@ pub fn draw(frame: &mut Frame, area: Rect, state: &mut AppState, theme: &Theme)&& !trim.eq_ignore_ascii_case(&format!("Episode {ep}"))&& !trim.eq_ignore_ascii_case(&format!("EP {ep}"))});- let ep_base = if let Some(t) = ep_title_opt {- let candidate = format!("Episode {ep:02} · {t}");- crate::tui::text::truncate_width(&candidate, ep_max_w).into_owned()- } else {- format!("Episode {ep:02}")- };- let item_style = if modal_active {- theme.muted- } else if is_selected && episodes_focused {- crate::tui::overlay::selection_style(theme, state.basic_terminal)- } else if is_selected {- theme.subtext1.add_modifier(Modifier::BOLD)- } else if let Some(hist) =- state- .history- .get_item(provider, subject_id, se_num, ep, Some(title))- {- if hist.completed {- theme.text_dim- } else if hist.is_in_progress() {- theme.accent- } else {- theme.text- }- } else if state.history.is_watched(provider, subject_id, se_num, ep) {- theme.text_dim- } else {- theme.text- };let sym = if let Some(hist) =state.history@@ -1140,6 +1111,38 @@ pub fn draw(frame: &mut Frame, area: Rect, state: &mut AppState, theme: &Theme)},).unwrap_or_default();+ let sym_w = crate::tui::text::width(sym);+ let prog_w = crate::tui::text::width(&progress_info);+ let title_budget = ep_max_w.saturating_sub(sym_w + prog_w).max(8);+ let ep_base = if let Some(t) = ep_title_opt {+ let candidate = format!("Episode {ep:02} · {t}");+ crate::tui::text::truncate_width(&candidate, title_budget).into_owned()+ } else {+ format!("Episode {ep:02}")+ };+ let item_style = if modal_active {+ theme.muted+ } else if is_selected && episodes_focused {+ crate::tui::overlay::selection_style(theme, state.basic_terminal)+ } else if is_selected {+ theme.subtext1.add_modifier(Modifier::BOLD)+ } else if let Some(hist) =+ state+ .history+ .get_item(provider, subject_id, se_num, ep, Some(title))+ {+ if hist.completed {+ theme.text_dim+ } else if hist.is_in_progress() {+ theme.accent+ } else {+ theme.text+ }+ } else if state.history.is_watched(provider, subject_id, se_num, ep) {+ theme.text_dim+ } else {+ theme.text+ };ListItem::new(format!("{sym}{ep_base}{progress_info}")).style(item_style)}).collect()@@ -1240,7 +1243,7 @@ pub fn draw(frame: &mut Frame, area: Rect, state: &mut AppState, theme: &Theme)use ratatui::widgets::{Cell, Row, Table};- let is_ultra_compact = streams_area.width < 58;+ let is_ultra_compact = streams_area.width < 65;let is_compact = streams_area.width < 85;let is_wide = streams_area.width >= 115;@@ -1255,7 +1258,7 @@ pub fn draw(frame: &mut Frame, area: Rect, state: &mut AppState, theme: &Theme)vec![Cell::from("RES"), Cell::from("SIZE"), Cell::from("RELEASE")],vec![Constraint::Length(8),- Constraint::Length(8),+ Constraint::Length(7),Constraint::Min(15),],)@@ -2713,6 +2716,95 @@ mod tests {assert!(!content.contains("· ·"));assert!(!content.contains("· EP"));}+ #[test]+ fn test_episode_list_progress_and_long_title_bounded() {+ let backend = ratatui::backend::TestBackend::new(80, 24);+ let mut terminal = ratatui::Terminal::new(backend).unwrap();+ let mut state = AppState {+ active_subject_id: Some("series_test".to_string()),+ selected_details: Some(MediaDetails {+ id: ProviderMediaId {+ provider: ProviderKind::MovieBox,+ value: "series_test".to_string(),+ },+ title: "Series Test".to_string(),+ media_type: MediaType::Series,+ year: Some("2024".to_string()),+ description: None,+ tagline: None,+ imdb_rating: None,+ director: None,+ stars: None,+ prints: None,+ audios: None,+ poster_url: None,+ duration: None,+ genres: vec![],+ seasons: vec![Season {+ number: 1,+ episodes: vec![Episode {+ season: 1,+ number: 1,+ title: Some(+ "Very Long Episode Title That Exceeds Normal Pane Width Substantially"+ .to_string(),+ ),+ overview: None,+ }],+ }],+ dubs: vec![],+ }),+ available_seasons: vec![Season {+ number: 1,+ episodes: vec![Episode {+ season: 1,+ number: 1,+ title: Some(+ "Very Long Episode Title That Exceeds Normal Pane Width Substantially"+ .to_string(),+ ),+ overview: None,+ }],+ }],+ available_episode_numbers: vec![vec![1]],+ details_pane: crate::tui::state::DetailsPane::Episodes,+ ..Default::default()+ };+ state.history.update_progress(+ crate::history::WatchHistoryItem {+ provider: "moviebox".to_string(),+ subject_id: "series_test".to_string(),+ title: "Series Test".to_string(),+ cover_url: None,+ stype: 2,+ release_year: "2024".to_string(),+ season: 1,+ episode: 1,+ timestamp: 1000,+ duration_seconds: Some(1200),+ progress_seconds: 600,+ completed: false,+ stream_filename: None,+ },+ 600,+ Some(1200),+ false,+ );+ let theme = Theme::mocha();+ terminal+ .draw(|frame| {+ draw(frame, frame.area(), &mut state, &theme);+ })+ .unwrap();+ let buffer = terminal.backend().buffer();+ let content = buffer+ .content()+ .iter()+ .map(|cell| cell.symbol())+ .collect::<String>();+ assert!(content.contains("Episode 01"));+ assert!(content.contains("50%"));+ }#[test]fn test_details_header_metadata_suppresses_empty_duration_and_double_middot() {diff --git a/src/tui/screens/home.rs b/src/tui/screens/home.rsindex ca78200..60db848 100644--- a/src/tui/screens/home.rs+++ b/src/tui/screens/home.rs@@ -1456,8 +1456,8 @@ pub fn draw(frame: &mut Frame, area: Rect, state: &mut AppState, theme: &Theme)} else {initial_metrics};- let target_width = if state.image_supported {- state+ let poster_width = if state.image_supported {+ let target_width = state.image_picker.as_ref().map(|picker| {@@ -1469,13 +1469,13 @@ pub fn draw(frame: &mut Frame, area: Rect, state: &mut AppState, theme: &Theme).unwrap_or(u16::MAX).max(6)})- .unwrap_or_else(|| state.poster_rows.saturating_mul(4).div_ceil(3).max(6))+ .unwrap_or_else(|| state.poster_rows.saturating_mul(4).div_ceil(3).max(6));+ target_width+ .min(metrics.col_width.saturating_sub(18).max(6))+ .max(6)} else {- state.poster_rows.saturating_mul(4).div_ceil(3).clamp(8, 12)+ 0};- let poster_width = target_width- .min(metrics.col_width.saturating_sub(18).max(6))- .max(6);state.last_result_metrics = Some(metrics);let row_height = metrics.row_height;frame.render_widget(list_block, results_area);@@ -1807,16 +1807,13 @@ pub fn draw(frame: &mut Frame, area: Rect, state: &mut AppState, theme: &Theme)let matching_meta = state.search_preview.as_ref()- .filter(|m| m.id.value == res.id && m.id.provider == res.provider);- if let Some(meta) = matching_meta {- if is_selected {- if let Some(r) = meta.imdb_rating.as_deref() {- let star = if state.basic_terminal { "* " } else { "★ " };- row2_spans.push(ratatui::text::Span::styled(star, theme.rating));- row2_spans.push(ratatui::text::Span::styled(r, theme.text));- row2_spans.push(ratatui::text::Span::styled(" ", theme.text_dim));- }- }+ .filter(|m| m.id.value == res.id && m.id.provider == res.provider)+ .or_else(|| state.preview_cache.peek(&res.id));+ if let Some(r) = matching_meta.and_then(|m| m.imdb_rating.as_deref()) {+ let star = if state.basic_terminal { "* " } else { "★ " };+ row2_spans.push(ratatui::text::Span::styled(star, theme.rating));+ row2_spans.push(ratatui::text::Span::styled(r, theme.text));+ row2_spans.push(ratatui::text::Span::styled(" ", theme.text_dim));}let has_year = res.release_year != "Unknown" && !res.release_year.is_empty();if has_year {@@ -3852,4 +3849,82 @@ mod tests {assert!(content.contains(&format!("v{}", env!("CARGO_PKG_VERSION"))));}++ #[test]+ fn test_search_card_cached_imdb_rating_rendered_on_unselected_card() {+ let backend = TestBackend::new(100, 30);+ let mut terminal = Terminal::new(backend).unwrap();+ let mut state = AppState {+ input_mode: InputMode::Normal,+ search_query: "Inception".into(),+ search_results: vec![+ crate::models::SearchResult {+ id: "item_0".into(),+ title: "First Movie".into(),+ stype: 1,+ release_year: "2010".into(),+ cover_url: None,+ season: 0,+ episode: 0,+ provider: crate::providers::models::ProviderKind::MovieBox,+ },+ crate::models::SearchResult {+ id: "item_1".into(),+ title: "Second Movie".into(),+ stype: 1,+ release_year: "2012".into(),+ cover_url: None,+ season: 0,+ episode: 0,+ provider: crate::providers::models::ProviderKind::MovieBox,+ },+ ],+ has_search_settled: true,+ basic_terminal: false,+ image_supported: false,+ ..Default::default()+ };+ state.search_list_state.select(Some(0));+ state.preview_cache.put(+ "item_1".to_string(),+ crate::providers::models::MediaDetails {+ id: crate::providers::models::ProviderMediaId {+ provider: crate::providers::models::ProviderKind::MovieBox,+ value: "item_1".to_string(),+ },+ title: "Second Movie".to_string(),+ media_type: crate::providers::models::MediaType::Movie,+ year: Some("2012".to_string()),+ description: None,+ tagline: None,+ imdb_rating: Some("8.8".to_string()),+ director: None,+ stars: None,+ prints: None,+ audios: None,+ poster_url: None,+ duration: None,+ genres: vec![],+ seasons: vec![],+ dubs: vec![],+ },+ );+ let theme = Theme::mocha();+ terminal+ .draw(|frame| {+ let area = Rect::new(0, 0, 100, 30);+ draw(frame, area, &mut state, &theme);+ })+ .unwrap();+ let buffer = terminal.backend().buffer();+ let mut rendered = String::new();+ for y in 0..30 {+ for x in 0..100 {+ rendered.push_str(buffer[(x, y)].symbol());+ }+ rendered.push('\n');+ }+ assert!(rendered.contains("8.8"));+ assert!(rendered.contains("★"));+ }}