Terminal interface to find, download, and stream movies, TV shows, and live TV using local media players.
fix(tui): streamline discover landing categories, fix description truncation, and add click navigation
Samir Hossainsc901dae7901b
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex cc44ebd..37e6495 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -15,6 +15,9 @@- Scoped `Ctrl+P` strictly to Streaming Mode for provider cycling, eliminating redundant `Ctrl+P` handling in TV and Addon modes.- Streamlined `/config` as a direct alias for `/settings`.+- **Discover Categories Landing Card UX**:+ - Streamlined `Discover & Quick Categories` card: elevated `/browse` command to a right-aligned header badge (`[ /browse ]`), eliminated redundant `/browse ·` row prefixes, and adapted category rows dynamically between Streaming and Addon modes.+ - Added direct mouse click navigation to discover categories, routing clicks to preset browse queries or the addon catalog menu.- **Command Dispatch & Cache Lookup Optimization**:- Unified `ParsedCommand` and `SlashCommand` into a single canonical enum, eliminating duplicate type definitions across command dispatch and testing.- Streamlined image disk cache lookups (`get_namespaced_image_cache`), eliminating 6-iteration fallback namespace scans across unrelated provider directories on cache misses.@@ -33,6 +36,9 @@- **Resilient Configuration & Accurate Metadata**:- Safeguarded user TV playlists (`tv_config.json`) and HTTP addons (`addons_config.json`): replaced destructive error-swallowing deletion with timestamped `.corrupt.{timestamp}` file rotation and sanitized logging on JSON parse failures.- Eliminated fabricated S01E01 fallback in addon metadata adapter, accurately reporting empty series episodes when an upstream catalog entry lacks episode records instead of injecting unplayable dummy data.+- **Discover Card Layout & Truncation**:+ - Fixed horizontal text clipping on discover card category descriptions by adjusting `margins_len` to account for visual pointer and margin cell budgets.+ - Suppressed discover card rendering while search suggestions dropdown is open, preventing visual overlap.- **Update Modal Input Isolation & Event Guards**:- Prevented keystroke hijacking: deferred blocking update modal presentation while the user is actively typing in the search bar (`InputMode::Editing`), ensuring keys (`u`, `o`, `Esc`) never trigger unintended update actions.- Added input lock during in-flight updates (`is_updating`), consuming all keyboard and mouse events to prevent mid-upgrade process termination or disk corruption.diff --git a/src/tui/app/mouse.rs b/src/tui/app/mouse.rsindex cd5e468..ee00c6e 100644--- a/src/tui/app/mouse.rs+++ b/src/tui/app/mouse.rs@@ -609,6 +609,51 @@ impl App {}return None;}+ } else if !self.state.is_tv_mode && area.height >= 26 {+ let suggestions_open = self.state.input_mode == InputMode::Editing+ && !self.state.search_suggestions.is_empty();+ if !suggestions_open {+ let discover_y = rows.rects[rows.favorites].y;+ let discover_height = 6;+ let discover_card_area = Rect {+ x: card_x,+ y: discover_y,+ width: card_width,+ height: discover_height,+ };++ if col >= discover_card_area.left()+ && col < discover_card_area.right()+ && row >= discover_card_area.top()+ && row < discover_card_area.bottom()+ {+ if self.state.is_addon_mode {+ self.action_sender.send(Action::ShowBrowseMenu).ok();+ } else {+ let rel_row = row - discover_card_area.top();+ match rel_row {+ 1 => self+ .action_sender+ .send(Action::SelectBrowse(BrowsePreset::Trending))+ .ok(),+ 2 => self+ .action_sender+ .send(Action::SelectBrowse(BrowsePreset::TopRatedAllTime))+ .ok(),+ 3 => self+ .action_sender+ .send(Action::SelectBrowse(BrowsePreset::TopRatedRecent))+ .ok(),+ 4 => self+ .action_sender+ .send(Action::SelectBrowse(BrowsePreset::MostWatched))+ .ok(),+ _ => self.action_sender.send(Action::ShowBrowseMenu).ok(),+ };+ }+ return None;+ }+ }}return None;diff --git a/src/tui/screens/home.rs b/src/tui/screens/home.rsindex 7809468..700008d 100644--- a/src/tui/screens/home.rs+++ b/src/tui/screens/home.rs@@ -655,12 +655,21 @@ pub(crate) fn render_discover_landing(return;}- let presets = [- ("Trending Movies", "/browse · Popular & In-Theaters"),- ("Top Rated Series", "/browse · Award-Winning TV"),- ("New Releases", "/browse · Latest 4K & HD Additions"),- ("Curated Catalogs", "/browse · Explore Genres"),- ];+ let presets = if state.is_addon_mode {+ [+ ("Top Movies", "Cinemeta Curated Catalog"),+ ("Top Series", "Popular & Episodic TV"),+ ("Addon Catalogs", "Installed Community Manifests"),+ ("Community Streams", "Multi-Source Aggregated Feeds"),+ ]+ } else {+ [+ ("Trending Now", "Popular & In-Theaters"),+ ("Top Rated Series", "Critically Acclaimed TV"),+ ("Latest Releases", "Recent 4K & HD Additions"),+ ("Most Watched", "Community Favorites"),+ ]+ };let card_width = search_deck_width(area, state, true);let row_count = presets.len() as u16;@@ -679,7 +688,14 @@ pub(crate) fn render_discover_landing(("─", "✦")};let block = Block::default()- .title(format!("{bar} {compass} Discover & Quick Categories "))+ .title(format!("{bar} {compass} Discover Categories "))+ .title(+ Line::from(vec![Span::styled(+ "[ /browse ] ",+ theme.accent.add_modifier(Modifier::BOLD),+ )])+ .alignment(Alignment::Right),+ ).title_style(theme.subtext1).borders(Borders::ALL).border_type(crate::tui::overlay::border_type(state.basic_terminal))@@ -699,7 +715,7 @@ pub(crate) fn render_discover_landing(let pointer = if state.basic_terminal { " - " } else { " · " };let tag_len = crate::tui::text::width(desc);let title_w = crate::tui::text::width(title);- let margins_len = 4;+ let margins_len = 6;let pad_len = (inner_area.width as usize).saturating_sub(margins_len + title_w + tag_len);let line = Line::from(vec![@@ -1410,10 +1426,16 @@ pub fn draw(frame: &mut Frame, area: Rect, state: &mut AppState, theme: &Theme));}search_bar_area = search_card_area;+ let suggestions_open =+ state.input_mode == InputMode::Editing && !state.search_suggestions.is_empty();if state.favorites_landing_visible() && !state.tv_config_popup {render_favorites_landing(frame, vertical_chunks[rows.favorites], state, theme);- } else if !state.is_tv_mode && !state.tv_config_popup && area.height >= 26 {+ } else if !state.is_tv_mode+ && !state.tv_config_popup+ && !suggestions_open+ && area.height >= 26+ {render_discover_landing(frame, vertical_chunks[rows.favorites], state, theme);}let bar_spans = home_bottom_bar_spans(state, theme, area.width, modal_active);@@ -2647,6 +2669,117 @@ mod tests {assert!(!rendered.contains("Secret Favorite Movie"));}+ #[test]+ fn test_landing_draw_hides_discover_when_suggestions_open() {+ let backend = TestBackend::new(90, 30);+ let mut terminal = Terminal::new(backend).unwrap();+ let mut state = AppState {+ input_mode: InputMode::Editing,+ streaming_enabled: true,+ search_suggestions: vec!["/help".to_string(), "Inception".to_string()],+ suggest_index: Some(0),+ ..Default::default()+ };+ state.favorites.items.clear();+ let theme = Theme::mocha();++ terminal+ .draw(|frame| {+ let area = Rect::new(0, 0, 90, 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..90 {+ rendered.push_str(buffer[(x, y)].symbol());+ }+ rendered.push('\n');+ }++ assert!(rendered.contains("help"));+ assert!(rendered.contains("Inception"));+ assert!(!rendered.contains("Discover Categories"));+ assert!(!rendered.contains("Trending Now"));+ }++ #[test]+ fn test_discover_landing_rendering_streaming_mode() {+ let backend = TestBackend::new(90, 30);+ let mut terminal = Terminal::new(backend).unwrap();+ let mut state = AppState {+ input_mode: InputMode::Normal,+ streaming_enabled: true,+ active_provider: crate::providers::models::ProviderKind::MovieBox,+ ..Default::default()+ };+ state.favorites.items.clear();+ let theme = Theme::mocha();++ terminal+ .draw(|frame| {+ let area = Rect::new(0, 0, 90, 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..90 {+ rendered.push_str(buffer[(x, y)].symbol());+ }+ rendered.push('\n');+ }++ assert!(rendered.contains("Discover Categories"));+ assert!(rendered.contains("[ /browse ]"));+ assert!(rendered.contains("Trending Now"));+ assert!(rendered.contains("Popular & In-Theaters"));+ assert!(!rendered.contains("/browse ·"));+ assert!(!rendered.contains("Top Movies"));+ }++ #[test]+ fn test_discover_landing_rendering_addon_mode() {+ let backend = TestBackend::new(90, 30);+ let mut terminal = Terminal::new(backend).unwrap();+ let mut state = AppState {+ input_mode: InputMode::Normal,+ is_addon_mode: true,+ addons_enabled: true,+ active_provider: crate::providers::models::ProviderKind::Addons,+ ..Default::default()+ };+ state.favorites.items.clear();+ let theme = Theme::mocha();++ terminal+ .draw(|frame| {+ let area = Rect::new(0, 0, 90, 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..90 {+ rendered.push_str(buffer[(x, y)].symbol());+ }+ rendered.push('\n');+ }++ assert!(rendered.contains("Discover Categories"));+ assert!(rendered.contains("[ /browse ]"));+ assert!(rendered.contains("Top Movies"));+ assert!(rendered.contains("Cinemeta Curated Catalog"));+ assert!(!rendered.contains("/browse ·"));+ assert!(!rendered.contains("Trending Now"));+ }+#[test]fn test_search_suggestions_bounds() {let area = Rect::new(0, 0, 80, 24);