Terminal interface to find, download, and stream movies, TV shows, and live TV using local media players.
refactor(tui): streamline addon manager modal and fix input wrapping
Samir Hossains9a6f48926311
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex dca3b18..75bf1ea 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -3,10 +3,27 @@## [Unreleased]### Fixed+- **Single-Line Input Windowing & Overflow Prevention**:+ - Fixed text overflow in `render_single_line_input` (`src/tui/widgets/input.rs`) where appending ellipsis (`...`) without sufficient budget caused line length to exceed modal width and trigger word wrapping onto a second line.+ - Reserved 3 columns for trailing ellipsis when characters remain past the cursor and removed `Wrap` on single-line input widgets, keeping prompt symbols and text strictly single-line across all cursor movements.+- **Addons Manager Search Bar Anchor & Overlay Isolation**:+ - Anchored Addons Manager popup directly in place of the landing search bar using unified `home_search_y` geometry in `src/tui/overlay.rs`.+ - Gated the landing search bar, search suggestions, provider pill popup, and discovery decks in `src/tui/screens/home.rs` during active Addon Manager sessions, preventing background search bar leakage.- **MovieBox Deprecation Notice Stream Filtering**:- Filtered deprecation notice video URLs (`macdn.aoneroom.com/other/`, notice video hash `b164fbfb4347792950bdfbfb563d39d9`) from community resource releases in `src/providers/moviebox/adapt.rs`.- Prevented 21-second upgrade announcement video placeholders from leaking into stream selection as playable releases when episodes lack official DASH streams.-+### Changed+- **Minimalist Addon Manager Modal Redesign & Balanced Geometry**:+ - Streamlined Addon Manager popup into a content-fitted modal matching the provider popup design language, eliminating empty right-side letterboxing and arbitrary vertical blank gaps.+ - Replaced noisy capability bracket badges (`[Core]`, `[Meta]`, `[Streams]`, `[Catalog]`), button bracket wrappers (`[ Add Manifest URL ]`), and arbitrary gap rows with continuous list rhythm, clean checkmarks (`✓`) for active addons, symmetric 2-cell horizontal padding, and full-width background highlight bars (`highlight_symbol("")`).+ - Aligned mouse click hitboxes and keyboard navigation with simplified two-variant row indexing (`Addon(usize)` and `AddUrl`).+- **Contextual `/config` Command Separation & Slash Command Cleanup**:+ - Promoted `/config` to a dedicated slash command rather than an alias for `/settings`.+ - Restricted `/config` suggestion visibility to contexts where a configuration modal exists: TV mode (playlist manager) and Addons provider (manifest manager).+ - Added a contextual guidance notification when `/config` is entered while MovieBox or 4KHDHub is active, prompting users to use `/settings` for preferences or switch to Addons (`Ctrl+P`/`^P`) to configure addons.+ - Restored missing `/browse` description in `SlashCommand::description_for` to display proper annotations in search suggestions.+ - Added contextual `/config` command row to in-app help overlay (`?`) under TV Mode and Addons provider.+ - Pruned redundant and confusing slash command aliases (`/pref`, `/preferences`, `/options`, and `/fav`), establishing `/settings` and `/favorites` as single canonical commands while retaining universal terminal conventions (`/?` for `/help`, `/q`/`/quit` for `/exit`).### Refactored- **Streamlined MovieBox Episode Stream Resolution**:- Replaced speculative parallel `get_resources` and secondary `fetch_resource_page` fallbacks in `providers/moviebox/mod.rs` with direct `play-info/v2` resolution.diff --git a/docs/addons-mode.md b/docs/addons-mode.mdindex 7a57cbf..a18156f 100644--- a/docs/addons-mode.md+++ b/docs/addons-mode.md@@ -19,15 +19,16 @@ Stremio Addons are integrated directly into standard Streaming Mode as a first-c- `Ctrl+P`: Cycle providers in Streaming Mode to select **Addons**.- `/config`: Open the **Addon Manager** directly when the active provider is `Addons`.+- `Tab` or click `[Addons]`: Open the **Addon Manager** popup directly from the search bar.- `Ctrl+S`: Return smoothly to **MovieBox** provider.- `/browse`: Browse curated addon catalogs (`Top Movies`, `Top Series`, `Top Rated Movies`, `Top Rated Series`).-## Addon Manager-- Interactive modal listing installed addons with capability badges (`[Core]`, `[Meta]`, `[Streams]`, `[Catalog]`).-- `[x] / [ ]`: Toggle addon enabled/disabled state (`Enter` or `Space`). Core provider remains locked.-- `[ Add Manifest URL ]`: Install any public HTTP addon manifest by URL.-- `[d]` or `[Delete]`: Remove the selected addon (protected for core addons).+## Addon Manager+- Interactive modal anchored in place of the landing search bar, displaying installed addons and activation state.+- `✓` / blank indent: Toggle addon enabled/disabled state (`Enter` or `Space`). Core provider remains protected with instant notice.+- `+ Add manifest URL`: Install any public HTTP addon manifest by URL.+- `d` or `Delete`: Remove the selected addon (protected for core metadata provider).## PersistenceInstalled addons are atomically saved to `addons_config.json` inside the application config directory (`~/Library/Application Support/moviebox-tui/` on macOS, `~/.config/moviebox-tui/` on Linux, `%APPDATA%\moviebox-tui\` on Windows). If `addons_config.json` encounters corrupt data on disk, it is preserved and rotated to `addons_config.json.corrupt.{timestamp}` before initializing fallback defaults, preventing silent data loss.diff --git a/docs/controls.md b/docs/controls.mdindex ef677a7..f4e85a7 100644--- a/docs/controls.md+++ b/docs/controls.md@@ -122,7 +122,8 @@ Type these commands directly into the search bar:| Command | Applicable Mode | Action || :--- | :--- | :--- |-| `/settings` | All | Open interactive Settings & Preferences Hub (aliases `/config` [opens Addon Manager in Addons provider or TV playlist manager in TV mode], `/pref`, `/preferences`, `/options`) |+| `/settings` | All | Open interactive Settings & Preferences Hub |+| `/config` | Contextual | Open playlist manager in TV mode, or Addon Manager in Addons provider (prompts `/settings` on MovieBox/4KHDHub) || `/browse` | Streaming | Browse curated views (Trending, Popular) or Addon catalogs (Top Movies, Top Series) || `/history` | Streaming | View watch history with latest progress || `/favorites` | Streaming | View all starred titles |diff --git a/src/tui/app/mod.rs b/src/tui/app/mod.rsindex 61f9b86..9cc75bd 100644--- a/src/tui/app/mod.rs+++ b/src/tui/app/mod.rs@@ -396,7 +396,6 @@ impl App {AddonManagerRow::AddUrl => {self.action_sender.send(Action::AddonInputToggle(true)).ok();}- AddonManagerRow::Header(_) => {}}}}diff --git a/src/tui/app/mouse.rs b/src/tui/app/mouse.rsindex 132ca63..beab307 100644--- a/src/tui/app/mouse.rs+++ b/src/tui/app/mouse.rs@@ -469,21 +469,19 @@ impl App {let popup = crate::tui::overlay::addon_manager_layout(area,addons_count,+ self.state.max_addon_name_width(),self.state.addon_input_active,);if popup.contains(ratatui::layout::Position::new(col, row)) {if !self.state.addon_input_active {- let list_start_y = popup.y + 1;- let button_y = list_start_y + addons_count as u16 + 1;- if row > list_start_y && row < button_y {- let clicked_addon_idx = (row - list_start_y - 1) as usize;- if clicked_addon_idx < addons_count {- self.state.addon_manager_selected = clicked_addon_idx + 1;+ let items_start_y = popup.y + 1;+ let total_items = addons_count + 1;+ if row >= items_start_y && row < items_start_y + total_items as u16 {+ let clicked_idx = (row - items_start_y) as usize;+ if clicked_idx < total_items {+ self.state.addon_manager_selected = clicked_idx;self.addon_manager_activate();}- } else if row == button_y {- self.state.addon_manager_selected = addons_count + 1;- self.addon_manager_activate();}}} else {diff --git a/src/tui/app/search.rs b/src/tui/app/search.rsindex b414e3f..2983c93 100644--- a/src/tui/app/search.rs+++ b/src/tui/app/search.rs@@ -120,20 +120,28 @@ impl App {Some(true)}crate::tui::commands::SlashCommand::Settings => {- if trimmed.eq_ignore_ascii_case("/config") {- if self.state.is_tv_mode {- self.action_sender.send(Action::ShowTvConfig).ok();- return Some(true);- } else if self.state.active_provider- == crate::providers::models::ProviderKind::Addons- {- self.action_sender.send(Action::ShowAddonManager).ok();- return Some(true);- }- }self.action_sender.send(Action::ToggleSettingsPopup).ok();Some(true)}+ crate::tui::commands::SlashCommand::Config => {+ if self.state.is_tv_mode {+ self.action_sender.send(Action::ShowTvConfig).ok();+ } else if self.state.active_provider+ == crate::providers::models::ProviderKind::Addons+ {+ self.action_sender.send(Action::ShowAddonManager).ok();+ } else {+ let ctrl_p = crate::tui::text::CTRL_P_STR;+ self.state.notify(+ NotificationKind::Info,+ "Configuration",+ format!(+ "Use /settings for preferences, or switch to Addons ({ctrl_p}) to configure addons."+ ),+ );+ }+ Some(true)+ }crate::tui::commands::SlashCommand::Clear => {self.state.clear_search_state();self.state.set_status_default("Search cleared.");@@ -731,3 +739,47 @@ impl App {});}}++#[cfg(test)]+mod tests {+ use super::*;++ #[test]+ fn test_handle_search_command_config_in_streaming_mode_shows_guidance() {+ let mut app = App::new();+ app.state.active_provider = ProviderKind::MovieBox;+ app.state.is_tv_mode = false;++ let handled = app.handle_search_command("/config", "/config");+ assert_eq!(handled, Some(true));+ assert!(!app.state.show_settings_popup);+ assert!(!app.state.addon_manager_popup);+ assert!(!app.state.tv_config_popup);+ assert_eq!(app.state.notifications.len(), 1);+ assert_eq!(app.state.notifications[0].title, "Configuration");+ assert!(app.state.notifications[0].message.contains("/settings"));+ }++ #[test]+ fn test_handle_search_command_config_in_addons_mode_opens_addon_manager() {+ let mut app = App::new();+ app.state.active_provider = ProviderKind::Addons;+ app.state.is_tv_mode = false;++ let handled = app.handle_search_command("/config", "/config");+ assert_eq!(handled, Some(true));+ assert!(!app.state.show_settings_popup);+ assert!(app.state.notifications.is_empty());+ }++ #[test]+ fn test_handle_search_command_config_in_tv_mode_opens_tv_config() {+ let mut app = App::new();+ app.state.is_tv_mode = true;++ let handled = app.handle_search_command("/config", "/config");+ assert_eq!(handled, Some(true));+ assert!(!app.state.show_settings_popup);+ assert!(app.state.notifications.is_empty());+ }+}diff --git a/src/tui/commands.rs b/src/tui/commands.rsindex c3a3f70..9994497 100644--- a/src/tui/commands.rs+++ b/src/tui/commands.rs@@ -3,6 +3,7 @@ use crate::tui::state::AppState;#[derive(Debug, Clone, Copy, PartialEq, Eq)]pub enum SlashCommand {Settings,+ Config,Browse,History,Favorites,@@ -13,8 +14,9 @@ pub enum SlashCommand {}impl SlashCommand {- pub const ALL: [Self; 8] = [+ pub const ALL: [Self; 9] = [Self::Settings,+ Self::Config,Self::Browse,Self::History,Self::Favorites,@@ -23,10 +25,10 @@ impl SlashCommand {Self::List,Self::Exit,];-pub fn name(self) -> &'static str {match self {Self::Settings => "/settings",+ Self::Config => "/config",Self::Browse => "/browse",Self::History => "/history",Self::Favorites => "/favorites",@@ -36,10 +38,18 @@ impl SlashCommand {Self::Exit => "/exit",}}-- pub fn description(self, _state: &AppState) -> &'static str {+ pub fn description(self, state: &AppState) -> &'static str {match self {Self::Settings => "Interactive preferences, content modes & configuration",+ Self::Config => {+ if state.is_tv_mode {+ "Manage TV playlist sources"+ } else if state.active_provider == crate::providers::models::ProviderKind::Addons {+ "Manage Stremio addon manifests"+ } else {+ "Configure TV playlists or Addons"+ }+ }Self::Browse => "Curated, rated & most-watched views",Self::History => "Watch history",Self::Favorites => "Starred titles",@@ -53,13 +63,16 @@ impl SlashCommand {pub fn is_available(self, state: &AppState) -> bool {match self {Self::Settings => true,+ Self::Config => {+ state.is_tv_mode+ || state.active_provider == crate::providers::models::ProviderKind::Addons+ }Self::Browse | Self::History => state.streaming_enabled && !state.is_tv_mode,Self::Favorites => state.favorites_available(),Self::List => state.tv_enabled && state.is_tv_mode,Self::Clear | Self::Help | Self::Exit => true,}}-pub fn suggest(state: &AppState, query: &str) -> Vec<String> {let lower = query.to_ascii_lowercase();let mut results = Vec::new();@@ -84,24 +97,14 @@ impl SlashCommand {return None;};- if trimmed == "/pref"- || trimmed == "/preferences"- || trimmed == "/options"- || trimmed == "/config"- {- return Some(Self::Settings.description(state));- }- if trimmed == "/?" {- return Some(Self::Help.description(state));- }-match trimmed {"/settings" => Some(Self::Settings.description(state)),+ "/config" => Some(Self::Config.description(state)),"/browse" => Some(Self::Browse.description(state)),"/history" => Some(Self::History.description(state)),"/favorites" => Some(Self::Favorites.description(state)),"/clear" => Some(Self::Clear.description(state)),- "/help" => Some(Self::Help.description(state)),+ "/help" | "/?" => Some(Self::Help.description(state)),"/list" => Some(Self::List.description(state)),"/exit" | "/quit" | "/q" => Some(Self::Exit.description(state)),_ => None,@@ -118,7 +121,8 @@ impl SlashCommand {let command_name = parts.next()?;match command_name.to_ascii_lowercase().as_str() {- "/settings" | "/config" | "/pref" | "/preferences" | "/options" => Some(Self::Settings),+ "/settings" => Some(Self::Settings),+ "/config" => Some(Self::Config),"/browse" => Some(Self::Browse),"/history" => Some(Self::History),"/favorites" => Some(Self::Favorites),@@ -158,6 +162,23 @@ mod tests {let c_sug = SlashCommand::suggest(&state, "/c");assert_eq!(c_sug, vec!["/clear".to_string()]);+ let tv_state = AppState {+ is_tv_mode: true,+ tv_enabled: true,+ ..Default::default()+ };+ let tv_c_sug = SlashCommand::suggest(&tv_state, "/c");+ assert_eq!(tv_c_sug, vec!["/config".to_string(), "/clear".to_string()]);++ let addons_state = AppState {+ active_provider: crate::providers::models::ProviderKind::Addons,+ ..Default::default()+ };+ let addons_c_sug = SlashCommand::suggest(&addons_state, "/c");+ assert_eq!(+ addons_c_sug,+ vec!["/config".to_string(), "/clear".to_string()]+ );let t_sug = SlashCommand::suggest(&state, "/t");assert!(t_sug.is_empty());let p_sug = SlashCommand::suggest(&state, "/p");@@ -198,7 +219,7 @@ mod tests {#[test]fn test_core_commands_and_aliases_parse() {let state = AppState::default();- assert_eq!(SlashCommand::ALL.len(), 8);+ assert_eq!(SlashCommand::ALL.len(), 9);assert_eq!(SlashCommand::parse("/exit"), Some(SlashCommand::Exit));assert_eq!(SlashCommand::parse("/quit"), Some(SlashCommand::Exit));assert_eq!(SlashCommand::parse("/q"), Some(SlashCommand::Exit));@@ -218,20 +239,19 @@ mod tests {SlashCommand::parse("/settings"),Some(SlashCommand::Settings));- assert_eq!(SlashCommand::parse("/config"), Some(SlashCommand::Settings));- assert_eq!(SlashCommand::parse("/pref"), Some(SlashCommand::Settings));- assert_eq!(- SlashCommand::parse("/preferences"),- Some(SlashCommand::Settings)- );- assert_eq!(- SlashCommand::parse("/options"),- Some(SlashCommand::Settings)- );-+ assert_eq!(SlashCommand::parse("/config"), Some(SlashCommand::Config));+ assert_eq!(SlashCommand::Config.name(), "/config");+ assert_eq!(SlashCommand::parse("/pref"), None);+ assert_eq!(SlashCommand::parse("/preferences"), None);+ assert_eq!(SlashCommand::parse("/options"), None);assert_eq!(SlashCommand::parse("/list"), Some(SlashCommand::List));assert_eq!(SlashCommand::parse("/browse"), Some(SlashCommand::Browse));assert_eq!(SlashCommand::parse("/history"), Some(SlashCommand::History));+ assert_eq!(+ SlashCommand::parse("/favorites"),+ Some(SlashCommand::Favorites)+ );+ assert_eq!(SlashCommand::parse("/fav"), None);assert_eq!(SlashCommand::parse("/theme"), None);assert_eq!(SlashCommand::parse("/themes"), None);assert_eq!(SlashCommand::parse("/toggle-tv"), None);@@ -259,16 +279,37 @@ mod tests {);assert_eq!(SlashCommand::description_for("/config", &state),- Some("Interactive preferences, content modes & configuration")+ Some("Configure TV playlists or Addons"));+ let tv_state = AppState {+ is_tv_mode: true,+ tv_enabled: true,+ ..Default::default()+ };assert_eq!(- SlashCommand::description_for("/pref", &state),- Some("Interactive preferences, content modes & configuration")+ SlashCommand::description_for("/config", &tv_state),+ Some("Manage TV playlist sources")+ );+ let addons_state = AppState {+ active_provider: crate::providers::models::ProviderKind::Addons,+ ..Default::default()+ };+ assert_eq!(+ SlashCommand::description_for("/config", &addons_state),+ Some("Manage Stremio addon manifests"));+ assert_eq!(SlashCommand::description_for("/pref", &state), None);+ assert_eq!(SlashCommand::description_for("/preferences", &state), None);+ assert_eq!(SlashCommand::description_for("/options", &state), None);assert_eq!(SlashCommand::description_for("/?", &state),Some("Open interactive keybinding help menu"));+ assert_eq!(+ SlashCommand::description_for("/browse", &state),+ Some("Curated, rated & most-watched views")+ );+ assert_eq!(SlashCommand::description_for("/fav", &state), None);assert_eq!(SlashCommand::description_for("/download-dir", &state), None);assert_eq!(SlashCommand::description_for("/toggle-tv", &state), None);assert_eq!(SlashCommand::description_for("/theme", &state), None);diff --git a/src/tui/overlay.rs b/src/tui/overlay.rsindex 7d22376..bf673c0 100644--- a/src/tui/overlay.rs+++ b/src/tui/overlay.rs@@ -45,6 +45,18 @@ pub fn picker_layout()}+pub(crate) fn home_search_y(area: Rect) -> u16 {+ if area.height >= 24 {+ if area.width < 76 {+ area.y + 7+ } else {+ area.y + 11+ }+ } else {+ area.y + 5+ }+}+pub fn tv_config_layout(area: Rect,longest_source_width: usize,@@ -54,29 +66,56 @@ pub fn tv_config_layout(let content_width = longest_source_width.max(48).max(crate::tui::text::width("[ Add URL ] [ Add file ] [ Reload ] [ Done ]",));+ let min_width = 44u16.min(area.width.saturating_sub(2));let popup_width = 68u16.max(content_width.saturating_add(6) as u16)- .min(area.width.saturating_sub(4));+ .min(area.width.saturating_sub(2))+ .max(min_width);let popup_height = if input_active {5u16} else {- total_rows.min(10).saturating_add(4) as u16+ (total_rows.min(10) as u16)+ .saturating_add(4)+ .min(area.height.saturating_sub(2))};- centered(area, popup_width, popup_height, 36, 74)+ let available_width = area.width.saturating_sub(2).max(1);+ let width = popup_width.min(available_width);+ let x = area.x + area.width.saturating_sub(width) / 2;+ let search_y = home_search_y(area);+ let y = search_y.min(area.bottom().saturating_sub(popup_height));+ Rect::new(x, y, width, popup_height)}-pub fn addon_manager_layout(area: Rect, addons_count: usize, input_active: bool) -> Rect {- let popup_width = 76u16.min(area.width.saturating_sub(4)).max(56);- let popup_height = if input_active {- 5u16+pub fn addon_manager_layout(+ area: Rect,+ addons_count: usize,+ max_name_len: usize,+ input_active: bool,+) -> Rect {+ let (popup_width, popup_height) = if input_active {+ let w = 48u16.min(area.width.saturating_sub(2)).max(28);+ (w, 5u16)} else {- (addons_count as u16)- .saturating_add(4)- .min(area.height.saturating_sub(4))- .max(5)+ let longest_line = (max_name_len as u16).saturating_add(6).max(22);+ let w = longest_line+ .saturating_add(2)+ .min(area.width.saturating_sub(2))+ .max(24);+ let total_items = (addons_count as u16).saturating_add(1);+ let h = total_items+ .saturating_add(2)+ .min(area.height.saturating_sub(2))+ .max(3);+ (w, h)};- centered(area, popup_width, popup_height, 36, 80)+ let available_width = area.width.saturating_sub(2).max(1);+ let width = popup_width.min(available_width);+ let x = area.x + area.width.saturating_sub(width) / 2;+ let search_y = home_search_y(area);+ let y = search_y.min(area.bottom().saturating_sub(popup_height));+ Rect::new(x, y, width, popup_height)}+pub fn settings_modal_layout(area: Rect, category: crate::tui::state::SettingsCategory) -> Rect {let min_width = 44u16.min(area.width.saturating_sub(2));let popup_width = 68u16.min(area.width.saturating_sub(2)).max(min_width);@@ -85,11 +124,7 @@ pub fn settings_modal_layout(area: Rect, category: crate::tui::state::SettingsCalet available_width = area.width.saturating_sub(2).max(1);let width = popup_width.min(available_width);let x = area.x + area.width.saturating_sub(width) / 2;- let search_y = if area.height >= 24 {- area.y + 2 + 6 + 1 + 2- } else {- area.y + 1 + 2 + 1 + 1- };+ let search_y = home_search_y(area);let y = search_y.min(area.bottom().saturating_sub(popup_height));Rect::new(x, y, width, popup_height)}@@ -100,11 +135,7 @@ pub fn help_modal_layout(area: Rect, desired_width: u16, desired_height: u16) ->let width = desired_width.clamp(46, 120).min(available_width);let height = desired_height.min(available_height).max(1);let x = area.x + area.width.saturating_sub(width) / 2;- let search_y = if area.height >= 24 {- area.y + 2 + 6 + 1 + 2- } else {- area.y + 1 + 2 + 1 + 1- };+ let search_y = home_search_y(area);let y = search_y.min(area.bottom().saturating_sub(height));Rect::new(x, y, width, height)}@@ -1057,4 +1088,30 @@ mod tests {assert_eq!(rects.len(), 1);assert!(rects[0].1.height >= 5);}+ #[test]+ fn test_addon_manager_layout_anchors_at_search_bar_position() {+ let standard_area = Rect::new(0, 0, 80, 24);+ let layout = addon_manager_layout(standard_area, 2, 10, false);+ assert_eq!(layout.y, 11);+ assert_eq!(layout.height, 5);+ assert_eq!(layout.width, 24);+ assert_eq!(layout.x, 28);++ let compact_area = Rect::new(0, 0, 70, 24);+ let compact_layout = addon_manager_layout(compact_area, 1, 8, false);+ assert_eq!(compact_layout.y, 7);+ assert_eq!(compact_layout.height, 4);+ assert_eq!(compact_layout.width, 24);+ assert_eq!(compact_layout.x, 23);++ let short_area = Rect::new(0, 0, 80, 20);+ let short_layout = addon_manager_layout(short_area, 1, 8, false);+ assert_eq!(short_layout.y, 5);++ let input_layout = addon_manager_layout(standard_area, 2, 10, true);+ assert_eq!(input_layout.height, 5);+ assert_eq!(input_layout.y, 11);+ assert_eq!(input_layout.width, 48);+ assert_eq!(input_layout.x, 16);+ }}diff --git a/src/tui/screens/help.rs b/src/tui/screens/help.rsindex 2e46010..4d4ec44 100644--- a/src/tui/screens/help.rs+++ b/src/tui/screens/help.rs@@ -84,8 +84,10 @@ pub fn build_help_columns(right.push(help_section_header("Commands & Shortcuts", theme));right.push(help_row("/settings", "Preferences & maintenance", theme));if state.is_tv_mode {+ right.push(help_row("/config", "Manage TV playlist sources", theme));right.push(help_row("/list", "Browse all TV channels", theme));} else if state.active_provider == crate::providers::models::ProviderKind::Addons {+ right.push(help_row("/config", "Manage Stremio addon manifests", theme));right.push(help_row("/browse", "Browse addon catalogs", theme));} else {right.push(help_row("/browse", "Browse curated genres", theme));@@ -210,6 +212,35 @@ mod tests {assert!(right_text.contains("/settings"));assert!(right_text.contains("/exit"));}+ #[test]+ fn test_build_help_columns_contextual_config() {+ let tv_state = AppState {+ is_tv_mode: true,+ ..Default::default()+ };+ let theme = Theme::mocha();+ let (_, tv_right) = build_help_columns(&tv_state, &theme);+ let tv_text = tv_right+ .iter()+ .map(Line::to_string)+ .collect::<Vec<_>>()+ .join("\n");+ assert!(tv_text.contains("/config"));+ assert!(tv_text.contains("Manage TV playlist sources"));++ let addons_state = AppState {+ active_provider: crate::providers::models::ProviderKind::Addons,+ ..Default::default()+ };+ let (_, addons_right) = build_help_columns(&addons_state, &theme);+ let addons_text = addons_right+ .iter()+ .map(Line::to_string)+ .collect::<Vec<_>>()+ .join("\n");+ assert!(addons_text.contains("/config"));+ assert!(addons_text.contains("Manage Stremio addon manifests"));+ }#[test]fn test_help_modal_renders_two_columns_without_panic() {diff --git a/src/tui/screens/home.rs b/src/tui/screens/home.rsindex da435b5..16581be 100644--- a/src/tui/screens/home.rs+++ b/src/tui/screens/home.rs@@ -223,9 +223,7 @@ fn render_search_state(format!("No items found for {}", catalog.label)} else if state.search_query.trim().eq_ignore_ascii_case("/history") {"No watch history found".to_string()- } else if state.search_query.trim().eq_ignore_ascii_case("/favorites")- || state.search_query.trim().eq_ignore_ascii_case("/fav")- {+ } else if state.search_query.trim().eq_ignore_ascii_case("/favorites") {"No favorites saved yet".to_string()} else if !state.search_query.trim().is_empty() {format!("No results for “{query}” on {provider_label}")@@ -241,8 +239,7 @@ fn render_search_state(let is_compact_btn = area.width < 56;let sep = if is_compact_btn { " " } else { " " };let is_history_or_fav = state.search_query.trim().eq_ignore_ascii_case("/history")- || state.search_query.trim().eq_ignore_ascii_case("/favorites")- || state.search_query.trim().eq_ignore_ascii_case("/fav");+ || state.search_query.trim().eq_ignore_ascii_case("/favorites");let pills = if is_history_or_fav {vec![]} else if state.is_tv_mode {@@ -1381,6 +1378,7 @@ pub fn draw(frame: &mut Frame, area: Rect, state: &mut AppState, theme: &Theme)};if !state.tv_config_popup+ && !state.addon_manager_popup&& !update_active&& !state.show_settings_popup&& !state.show_help@@ -1393,12 +1391,14 @@ pub fn draw(frame: &mut Frame, area: Rect, state: &mut AppState, theme: &Theme)if state.landing_deck_visible()&& !state.tv_config_popup+ && !state.addon_manager_popup&& !update_active&& !state.show_settings_popup{render_landing_deck(frame, vertical_chunks[rows.favorites], state, theme);} else if !state.is_tv_mode&& !state.tv_config_popup+ && !state.addon_manager_popup&& !suggestions_open&& !update_active&& !state.show_settings_popup@@ -1902,10 +1902,16 @@ pub fn draw(frame: &mut Frame, area: Rect, state: &mut AppState, theme: &Theme)}}- if !state.tv_config_popup && !state.show_settings_popup && !state.show_help {+ if !state.tv_config_popup+ && !state.addon_manager_popup+ && !state.show_settings_popup+ && !state.show_help+ {render_search_suggestions(frame, area, search_bar_area, state, theme, view);}- render_provider_popup(frame, area, search_bar_area, state, theme);+ if !state.addon_manager_popup {+ render_provider_popup(frame, area, search_bar_area, state, theme);+ }if state.tv_config_popup {let rows = state.tv_manager_rows();let total_rows = rows.len();@@ -2014,16 +2020,18 @@ pub fn draw(frame: &mut Frame, area: Rect, state: &mut AppState, theme: &Theme)}if state.addon_manager_popup {- let addons_count = state.installed_addons.len();- let total_rows = state.addon_manager_rows().len();- let popup_area =- crate::tui::overlay::addon_manager_layout(area, addons_count, state.addon_input_active);- let title = format!(- "Addons Manager · {}/{}",- state.addon_manager_selected.saturating_add(1),- total_rows.max(1)+ let popup_area = crate::tui::overlay::addon_manager_layout(+ area,+ state.installed_addons.len(),+ state.max_addon_name_width(),+ state.addon_input_active,);- let inner_area = crate::tui::widgets::ModalFrame::new(&title, theme, state.basic_terminal)+ let title = if state.addon_input_active {+ "Add Addon Manifest"+ } else {+ "Addons"+ };+ let inner_area = crate::tui::widgets::ModalFrame::new(title, theme, state.basic_terminal).render(frame, popup_area, area);if state.addon_input_active {@@ -2036,96 +2044,72 @@ pub fn draw(frame: &mut Frame, area: Rect, state: &mut AppState, theme: &Theme)state.basic_terminal,);} else {- let sections = ratatui::layout::Layout::vertical([- ratatui::layout::Constraint::Min(1),- ratatui::layout::Constraint::Length(1),- ratatui::layout::Constraint::Length(2),- ])- .split(inner_area);-- let is_add_selected = state.addon_manager_selected == state.installed_addons.len() + 1;-- let mut items = vec![ratatui::widgets::ListItem::new(ratatui::text::Line::from(- vec![- ratatui::text::Span::raw(" "),- ratatui::text::Span::styled("Installed Addons", theme.muted),- ],- ))];+ let mut items = Vec::with_capacity(state.installed_addons.len() + 1);for (idx, a) in state.installed_addons.iter().enumerate() {- let row_idx = idx + 1;- let is_selected = state.addon_manager_selected == row_idx;- let prefix = ratatui::text::Span::raw(" ");- let check = if a.enabled {- ratatui::text::Span::styled("[x] ", theme.success)+ let is_selected = state.addon_manager_selected == idx;+ let (prefix, prefix_style) = if a.enabled {+ if state.basic_terminal {+ (+ "* ",+ theme.success.add_modifier(ratatui::style::Modifier::BOLD),+ )+ } else {+ (+ "✓ ",+ theme.success.add_modifier(ratatui::style::Modifier::BOLD),+ )+ }} else {- ratatui::text::Span::styled("[ ] ", theme.text_dim)+ (" ", theme.text_dim)};- let mut badges = Vec::new();- let mut badges_w = 0;- if a.is_core() {- let label = "[Core] ";- badges_w += crate::tui::text::width(label);- badges.push(ratatui::text::Span::styled(label, theme.lavender));- }- if a.provides_meta {- let label = "[Meta] ";- badges_w += crate::tui::text::width(label);- badges.push(ratatui::text::Span::styled(label, theme.sapphire));- }- if a.provides_stream {- let label = "[Streams] ";- badges_w += crate::tui::text::width(label);- badges.push(ratatui::text::Span::styled(label, theme.rating));- }- if a.provides_catalog {- let label = "[Catalog]";- badges_w += crate::tui::text::width(label);- badges.push(ratatui::text::Span::styled(label, theme.teal));- }- let prefix_w = 2;- let check_w = 4;- let name_budget = (inner_area.width as usize)- .saturating_sub(prefix_w + check_w + badges_w + 2)- .max(8);- let addon_label = format!("{} v{} ", a.name, a.version.as_deref().unwrap_or("1.0"));- let name = ratatui::text::Span::styled(- crate::tui::text::truncate_width(&addon_label, name_budget).into_owned(),- if is_selected {- theme.text.add_modifier(ratatui::style::Modifier::BOLD)- } else {- theme.text- },- );- let mut spans = vec![ratatui::text::Span::raw(" "), prefix, check, name];- spans.extend(badges);- let item = ratatui::widgets::ListItem::new(ratatui::text::Line::from(spans));- let item = if is_selected {- item.style(crate::tui::overlay::selection_style(- theme,- state.basic_terminal,- ))+ let name_style = if is_selected {+ theme.text.add_modifier(ratatui::style::Modifier::BOLD)+ } else if a.enabled {+ theme.text} else {- item+ theme.text_dim};+ let name_budget = (inner_area.width as usize).saturating_sub(6).max(8);+ let truncated_name = crate::tui::text::truncate_width(&a.name, name_budget);+ let item = ratatui::widgets::ListItem::new(ratatui::text::Line::from(vec![+ ratatui::text::Span::raw(" "),+ ratatui::text::Span::styled(prefix, prefix_style),+ ratatui::text::Span::styled(truncated_name.into_owned(), name_style),+ ratatui::text::Span::raw(" "),+ ]));items.push(item);}- let list = ratatui::widgets::List::new(items);- frame.render_widget(list, sections[0]);-- let add_button = if is_add_selected {- ratatui::text::Span::styled(- " [ Add Manifest URL ]",- crate::tui::overlay::selection_style(theme, state.basic_terminal),- )+ let is_add_selected = state.addon_manager_selected == state.installed_addons.len();+ let add_style = if is_add_selected {+ theme.text.add_modifier(ratatui::style::Modifier::BOLD)} else {- ratatui::text::Span::styled(" [ Add Manifest URL ]", theme.sapphire)+ theme.sapphire};+ let add_prefix_style = if is_add_selected {+ theme.text.add_modifier(ratatui::style::Modifier::BOLD)+ } else {+ theme.sapphire+ };+ let add_item = ratatui::widgets::ListItem::new(ratatui::text::Line::from(vec![+ ratatui::text::Span::raw(" "),+ ratatui::text::Span::styled("+ ", add_prefix_style),+ ratatui::text::Span::styled("Add manifest URL", add_style),+ ratatui::text::Span::raw(" "),+ ]));+ items.push(add_item);++ let list = ratatui::widgets::List::new(items)+ .highlight_style(crate::tui::overlay::selection_style(+ theme,+ state.basic_terminal,+ ))+ .highlight_symbol("");- let button_line =- ratatui::text::Line::from(vec![ratatui::text::Span::raw(" "), add_button]);- frame.render_widget(ratatui::widgets::Paragraph::new(button_line), sections[1]);+ let mut list_state = ratatui::widgets::ListState::default();+ list_state.select(Some(state.addon_manager_selected));+ frame.render_stateful_widget(list, inner_area, &mut list_state);}}@@ -2194,12 +2178,9 @@ fn suggestion_source_badge<'a>(("[HISTORY]", theme.sapphire)} else if suggestion.eq_ignore_ascii_case("/favorites") {("[FAVORITES]", theme.rating)- } else if suggestion.eq_ignore_ascii_case("/settings")- || suggestion.eq_ignore_ascii_case("/config")- || suggestion.eq_ignore_ascii_case("/preferences")- || suggestion.eq_ignore_ascii_case("/pref")- || suggestion.eq_ignore_ascii_case("/options")- {+ } else if suggestion.eq_ignore_ascii_case("/config") {+ ("[CONFIG]", theme.lavender)+ } else if suggestion.eq_ignore_ascii_case("/settings") {("[SETTINGS]", theme.teal)} else {("[CMD]", theme.teal)@@ -2971,6 +2952,85 @@ mod tests {assert!(!rendered.contains('●'));assert!(!rendered.contains('○'));}+ #[test]+ fn test_render_home_addon_manager_popup_replaces_search_bar() {+ let backend = TestBackend::new(80, 24);+ let mut terminal = Terminal::new(backend).unwrap();+ let mut state = AppState {+ addon_manager_popup: true,+ active_provider: crate::providers::models::ProviderKind::Addons,+ installed_addons: vec![+ crate::providers::addons::models::InstalledAddon {+ manifest_url: "https://x1".into(),+ name: "Cinemeta".into(),+ version: Some("1.0".into()),+ description: None,+ enabled: true,+ provides_catalog: true,+ provides_meta: true,+ provides_stream: false,+ id_prefixes: vec![],+ types: vec![],+ },+ crate::providers::addons::models::InstalledAddon {+ manifest_url: "https://x2".into(),+ name: "CircleFTP Bridge".into(),+ version: Some("1.0".into()),+ description: None,+ enabled: false,+ provides_catalog: false,+ provides_meta: true,+ provides_stream: false,+ id_prefixes: vec![],+ types: vec![],+ },+ crate::providers::addons::models::InstalledAddon {+ manifest_url: "https://x3".into(),+ name: "HdHub".into(),+ version: Some("1.0".into()),+ description: None,+ enabled: true,+ provides_catalog: false,+ provides_meta: true,+ provides_stream: false,+ id_prefixes: vec![],+ types: vec![],+ },+ ],+ addon_manager_selected: 2,+ basic_terminal: false,+ ..Default::default()+ };+ let theme = Theme::mocha();+ terminal+ .draw(|frame| {+ let area = Rect::new(0, 0, 80, 24);+ draw(frame, area, &mut state, &theme);+ })+ .unwrap();++ let mut rendered = String::new();+ for y in 0..24 {+ for x in 0..80 {+ let cell = terminal.backend().buffer().cell((x, y)).unwrap();+ rendered.push_str(cell.symbol());+ }+ rendered.push('\n');+ }+ assert!(rendered.contains("Addons"));+ assert!(rendered.contains("+ Add manifest URL"));+ assert!(!rendered.contains("[Core]"));+ assert!(!rendered.contains("[Meta]"));+ assert!(!rendered.contains('●'));+ assert!(!rendered.contains('○'));+ assert!(!rendered.contains('▌'));+ assert!(!rendered.contains("Search via addons"));++ let line_11: String = (0..80)+ .map(|x| terminal.backend().buffer().cell((x, 11)).unwrap().symbol())+ .collect();+ assert!(line_11.contains("Addons"));+ }#[test]fn test_search_deck_width_stability() {diff --git a/src/tui/state.rs b/src/tui/state.rsindex 96755ff..25caef0 100644--- a/src/tui/state.rs+++ b/src/tui/state.rs@@ -1151,7 +1151,6 @@ pub enum TvManagerRow {#[derive(Debug, Clone, Copy, PartialEq, Eq)]pub enum AddonManagerRow {- Header(&'static str),Addon(usize),AddUrl,}@@ -1264,7 +1263,7 @@ impl AppState {}pub fn addon_manager_rows(&self) -> Vec<AddonManagerRow> {- let mut rows = vec![AddonManagerRow::Header("Installed Addons")];+ let mut rows = Vec::with_capacity(self.installed_addons.len() + 1);for index in 0..self.installed_addons.len() {rows.push(AddonManagerRow::Addon(index));}@@ -1273,31 +1272,34 @@ impl AppState {}pub fn step_addon_manager_selected(&mut self, step: isize) {- let rows = self.addon_manager_rows();- self.addon_manager_selected =- step_header_aware_list(self.addon_manager_selected, rows.len(), step, |idx| {- matches!(rows.get(idx), Some(AddonManagerRow::Header(_)))- });+ let total = self.addon_manager_rows().len();+ if total == 0 {+ self.addon_manager_selected = 0;+ return;+ }+ if step > 0 {+ self.addon_manager_selected = (self.addon_manager_selected + step as usize) % total;+ } else {+ let s = (-step) as usize % total;+ self.addon_manager_selected = (self.addon_manager_selected + total - s) % total;+ }}pub fn first_addon_manager_selected(&mut self) {- let rows = self.addon_manager_rows();- if let Some(idx) = rows- .iter()- .position(|r| !matches!(r, AddonManagerRow::Header(_)))- {- self.addon_manager_selected = idx;- }+ self.addon_manager_selected = 0;}pub fn last_addon_manager_selected(&mut self) {- let rows = self.addon_manager_rows();- if let Some(idx) = rows+ let total = self.addon_manager_rows().len();+ self.addon_manager_selected = total.saturating_sub(1);+ }++ pub fn max_addon_name_width(&self) -> usize {+ self.installed_addons.iter()- .rposition(|r| !matches!(r, AddonManagerRow::Header(_)))- {- self.addon_manager_selected = idx;- }+ .map(|a| crate::tui::text::width(&a.name))+ .max()+ .unwrap_or(0)}pub fn open_overview_modal(&mut self, title: String, content: String) {self.overview_modal_title = title;diff --git a/src/tui/widgets/input.rs b/src/tui/widgets/input.rsindex 0949048..32dbfe7 100644--- a/src/tui/widgets/input.rs+++ b/src/tui/widgets/input.rs@@ -3,7 +3,7 @@ use ratatui::{layout::Rect,style::Modifier,text::{Line, Span},- widgets::{Paragraph, Wrap},+ widgets::Paragraph,};use crate::tui::{text::TextInputBuffer, theme::Theme};@@ -31,7 +31,12 @@ pub fn render_single_line_input(};let cursor_w = crate::tui::text::width(cursor_grapheme).max(1);- let max_before_w = available_width.saturating_sub(cursor_w);+ let after_reserve = if cursor.saturating_add(1) < segments.len() {+ 3+ } else {+ 0+ };+ let max_before_w = available_width.saturating_sub(cursor_w + after_reserve);let mut start = cursor;let mut current_before_w = 0;while start > 0 {@@ -75,21 +80,25 @@ pub fn render_single_line_input(}let after_cursor = if end < segments.len() {- let budget = remaining_after_w.saturating_sub(3);- let mut adj_end = cursor.saturating_add(1).min(segments.len());- let mut adj_w = 0;- while adj_end < segments.len() {- let gw = crate::tui::text::width(segments[adj_end]);- if adj_w + gw > budget {- break;+ if remaining_after_w >= 3 {+ let budget = remaining_after_w.saturating_sub(3);+ let mut adj_end = cursor.saturating_add(1).min(segments.len());+ let mut adj_w = 0;+ while adj_end < segments.len() {+ let gw = crate::tui::text::width(segments[adj_end]);+ if adj_w + gw > budget {+ break;+ }+ adj_w += gw;+ adj_end += 1;}- adj_w += gw;- adj_end += 1;+ format!(+ "{}...",+ segments[cursor.saturating_add(1).min(segments.len())..adj_end].concat()+ )+ } else {+ segments[cursor.saturating_add(1).min(segments.len())..end].concat()}- format!(- "{}...",- segments[cursor.saturating_add(1).min(segments.len())..adj_end].concat()- )} else {segments[cursor.saturating_add(1).min(segments.len())..end].concat()};@@ -103,7 +112,7 @@ pub fn render_single_line_input(]),];- frame.render_widget(Paragraph::new(lines).wrap(Wrap { trim: false }), area);+ frame.render_widget(Paragraph::new(lines), area);}#[cfg(test)]@@ -180,11 +189,65 @@ mod tests {let buffer =TextInputBuffer::from_str("https://very-long-domain-name.example.com/stream.m3u8");let theme = Theme::default();-terminal.draw(|f| {render_single_line_input(f, Rect::new(0, 0, 20, 3), "URL:", &buffer, &theme, false);}).unwrap();}++ #[test]+ fn test_render_single_line_input_cursor_movement_no_line_overflow() {+ let backend = TestBackend::new(46, 5);+ let mut terminal = Terminal::new(backend).unwrap();+ let long_str = "a".repeat(80);+ let theme = Theme::default();++ for cursor_pos in 0..=80 {+ let mut buffer = TextInputBuffer::from_str(&long_str);+ for _ in 0..80 {+ buffer.move_left();+ }+ for _ in 0..cursor_pos {+ buffer.move_right();+ }+ terminal+ .draw(|f| {+ render_single_line_input(+ f,+ Rect::new(0, 0, 46, 3),+ "Enter Addon Manifest URL:",+ &buffer,+ &theme,+ false,+ );+ })+ .unwrap();++ let line_0: String = (0..46)+ .map(|x| terminal.backend().buffer().cell((x, 0)).unwrap().symbol())+ .collect();+ let line_1: String = (0..46)+ .map(|x| terminal.backend().buffer().cell((x, 1)).unwrap().symbol())+ .collect();+ let line_2: String = (0..46)+ .map(|x| terminal.backend().buffer().cell((x, 2)).unwrap().symbol())+ .collect();++ assert!(line_0.contains("Enter Addon Manifest URL:"));+ assert!(+ line_1.contains('❯'),+ "line 1 must contain prompt symbol at cursor {cursor_pos}: {line_1}"+ );+ assert!(+ line_1.contains('a') || line_1.contains('.'),+ "line 1 must contain input text at cursor {cursor_pos}: {line_1}"+ );+ assert_eq!(+ line_2.trim(),+ "",+ "line 2 must be empty and not wrapped at cursor {cursor_pos}: {line_2}"+ );+ }+ }}