Skip to content

Terminal interface to find, download, and stream movies, TV shows, and live TV using local media players.

refactor(tui): trigger downloads directly and prune confirmation dialog

Samir Hossainse49cf2dbdb72
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 04cd0de..0006d70 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -83,11 +83,20 @@
- **Documentation Overhaul & Clarity Streamlining**:
- Overhauled all user and technical guides in `docs/` (`players.md`, `controls.md`, `tv-mode.md`, `config.md`, `addons-mode.md`, `providers.md`, `cross-platform.md`, `cache.md`, `downloads.md`), cutting redundant tables, eliminating dense run-on text walls, and standardizing on direct, beginner-accessible explanations.
- Added complete environment variable documentation for `MOVIEBOX_LOG`, `MOVIEBOX_IMAGE_PROTOCOL`, `MOVIEBOX_CELL_SIZE`, and `NO_COLOR` in `docs/config.md`.
+ - Documented missing Details screen pane navigation, stream download triggers, synopsis overlay controls, `/settings` interactive modal keybindings, in-app update prompt shortcuts, and `Ctrl+P` provider cycling in `docs/controls.md`.
+ - Corrected theme catalog count to 9 themes and clarified `/settings` invocation without invalid single-key shortcuts in `docs/config.md`.
+ - Clarified non-toggle mode switching semantics (`Ctrl+T` to TV mode, `Ctrl+S` to Streaming mode) in `docs/tv-mode.md`.
+- **Instant Stream and Season Download Triggering**:
+ - Streamlined download initiation by starting stream and season downloads immediately upon pressing `d` (or clicking `[d] Download`) on the details screen, bypassing the intermediate confirmation popup.
- **Automated Test Architecture Hardening**:
- Replaced thread-shared `cargo test` execution with process-isolated `cargo nextest run` across testing rules in `.omp/AGENTS.md`.
- Added hermetic local loopback server download tests in `src/download.rs` verifying custom authentication headers (`X-Auth-Token`, `User-Agent`, `Referer`), byte streaming, and progress callbacks.
- Added deterministic CLI argument and header verification tests in `src/player.rs` for `mpv` and `VLC`.
- Pruned tautological assertions and dead code (`step_header_aware_list`).
+### Removed
+- **Download Confirmation Modal & Transient Dialog States**:
+ - Removed `PromptDownloadEpisode`, `ConfirmDownloadEpisode`, `PromptDownloadSeason`, and `ConfirmDownloadSeason` in favor of direct `DownloadEpisode` and `DownloadSeason` actions.
+ - Pruned transient modal state flags (`show_episode_download_confirm`, `show_season_download_confirm`, `episode_download_confirm_yes_selected`, `season_download_confirm_yes_selected`) and confirmation render helpers (`confirmation`, `download_confirm_layout`, `download_confirm_action_row`).
## [0.1.23] - 2026-09-21
### Fixed
diff --git a/docs/config.md b/docs/config.md
index 0809b19..0dc331f 100644
--- a/docs/config.md
+++ b/docs/config.md
@@ -4,11 +4,11 @@ MovieBox-TUI stores its settings in `config.json` inside your platform configura
## Interactive Settings Hub (`/settings`)
-Enter `/settings` or press `s` on the Home screen to configure options interactively:
+Enter `/settings` in the search bar or click `[ ⚙ Settings ]` on the Home screen to configure options interactively:
- **General**: Toggle automatic update checks, select default media player (`mpv`, `VLC`, `IINA`, `Android`), and customize download directory.
-- **Content Modes**: Toggle Streaming Mode, enable or disable specific streaming providers (MovieBox, 4KHDHub, CircleFTP, DhakaFlix), and toggle Live TV Mode.
-- **Appearance**: Select among 6 color themes with live preview.
+- **Content Modes**: Toggle Streaming Mode, enable or disable specific streaming providers (MovieBox, 4KHDHub, Dramachi, CircleFTP, DhakaFlix), and toggle Live TV Mode.
+- **Appearance**: Select among 9 color themes (Mocha, Latte, Macchiato, Frappe, Nord, TokyoNight, Dracula, Gruvbox, RosePine) with live preview.
- **Maintenance**: Check for updates, re-test local BDIX network connectivity, clear disk cache, clear watch history, and open the GitHub repository.
## Configuration File Paths
diff --git a/docs/controls.md b/docs/controls.md
index 68bfa27..b432e39 100644
--- a/docs/controls.md
+++ b/docs/controls.md
@@ -11,15 +11,18 @@ Press `?` anywhere inside the application to open the interactive help dialog.
| **`Home` / `End` / `g` / `G`** | Jump to start / end of lists or text inputs |
| **`PageUp` / `PageDown`** | Scroll lists by one page height |
| **`Enter`** | Play, open, or confirm selected item |
-| **`Space` / `P`** | Direct resume playback from Home Continue Watching or `/history` |
+| **`Space` / `P`** | Direct resume playback from Home Continue Watching, `/history`, or play stream |
| **`Esc`** | Dismiss dialogs, close popups, or cancel search query |
| **`Tab` / `Shift+Tab`** | Cycle landing tabs (Resume / Favorites), switch Details panes, or auto-complete |
-| **`d` / `Delete`** | Delete selected entry in `/history`, playlist manager, or addon manager |
+| **`d`** | Download selected stream/season (Details) or delete entry (`/history`, managers) |
+| **`f`** | Toggle favorite on highlighted card or active media title |
+| **`r`** | Refresh search results (Home), reload playlists (TV), or refresh streams (Details) |
| **`c`** | Clear active search query and return to landing (Normal mode) |
| **`x` / `X`** | Cancel active download |
+| **`Ctrl+P`** | Cycle active streaming provider |
| **`Ctrl+S`** | Switch to **Streaming Mode** |
| **`Ctrl+T`** | Switch to **TV Mode** |
-| **`?`** | Open help overlay |
+| **`?`** | Open interactive help overlay |
| **`Ctrl+C` / `q`** | Quit application |
## Text Editing (Search & Dialog Prompts)
@@ -35,20 +38,53 @@ Press `?` anywhere inside the application to open the interactive help dialog.
## Dialog & Modal Controls
-All popups (Themes, Providers, Players, TV Manager, Addon Manager, Download Confirmation) share standard navigation:
+All popups (Themes, Providers, Players, TV Manager, Addon Manager) share standard navigation:
- **`↑` / `↓` / `k` / `j`**: Navigate choices.
- **`Home` / `End`**: Jump to first / last item.
- **`Enter`**: Confirm selection.
- **`Esc`**: Dismiss popup without applying changes.
-- **Download Confirmation**:
- - `y` / `Y`: Confirm download immediately.
- - `n` / `N`: Cancel download immediately.
- - `Left` / `Right` / `Tab`: Toggle between `[ Download ]` and `[ Cancel ]`.
- **TV & Addon Managers**:
- `r`: Reload playlist sources or addon catalogs.
- `d` / `Delete`: Remove selected source.
+
+## Details Screen Controls
+
+| Key | Action |
+| :--- | :--- |
+| **`Tab` / `Shift+Tab`** | Switch active pane (Languages, Seasons, Episodes, Streams) |
+| **`←` / `→` / `h` / `l`** | Switch pane horizontally (Languages ↔ Seasons/Episodes ↔ Streams) |
+| **`↑` / `↓` / `k` / `j`** | Navigate items in active pane |
+| **`Enter` / `Space` / `p`** | Play selected stream, expand season episodes, or select language |
+| **`d`** | Start downloading selected stream (or entire season if Seasons pane active) |
+| **`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) |
+
+## Synopsis & Overview Modal
+
+- **`↑` / `↓` / `k` / `j`**: Scroll synopsis text line-by-line.
+- **`PageUp` / `PageDown`**: Scroll synopsis text 5 lines.
+- **`Esc` / `q` / `i` / `Enter`**: Dismiss synopsis dialog.
+
+## Settings Hub (`/settings`)
+
+- **`Tab` / `Shift+Tab`**: Switch category tabs (General, Content Modes, Appearance, Maintenance).
+- **`↑` / `↓` / `k` / `j`**: Navigate setting rows.
+- **`←` / `→` / `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.
+
+## Update Notification Modal
+
+- **`u`**: Update immediately (Direct installation).
+- **`b`**: Copy Homebrew update command to clipboard.
+- **`s`**: Copy Scoop update command to clipboard.
+- **`o`**: Open GitHub release notes in default browser.
+- **`Esc`**: Dismiss update prompt.
## Slash Commands
Type `/` in the search bar on the Home screen to trigger slash commands:
diff --git a/docs/downloads.md b/docs/downloads.md
index e764d9f..206aa14 100644
--- a/docs/downloads.md
+++ b/docs/downloads.md
@@ -23,7 +23,7 @@ Upon completion, temporary sidecars are verified and renamed atomically to the t
## Download Controls
-- Press **`d`** on any stream in the Details screen to open the download confirmation dialog.
+- Press **`d`** on any stream in the Details screen to start downloading immediately.
- Press **`x`** or **`X`** during an active download to cancel or pause the transfer. Partial `.part` data is preserved on disk for resumption.
- Downloads run cooperatively in the background, allowing you to browse or search without interrupting transfers.
diff --git a/docs/tv-mode.md b/docs/tv-mode.md
index 06dc131..4bab147 100644
--- a/docs/tv-mode.md
+++ b/docs/tv-mode.md
@@ -4,7 +4,7 @@ TV mode streams live television channels from M3U playlists. Playlists can be lo
## Entering TV Mode
-- Press **`Ctrl+T`** to toggle between Streaming and TV mode.
+- Press **`Ctrl+T`** to switch to TV mode (and **`Ctrl+S`** to switch back to Streaming mode).
- If no playlists are loaded on entry, the playlist manager opens automatically.
- Type in the search bar to filter channels by name or group; press `Enter` to play.
diff --git a/src/tui/action.rs b/src/tui/action.rs
index c3c4845..a88dbef 100644
--- a/src/tui/action.rs
+++ b/src/tui/action.rs
@@ -86,10 +86,8 @@ pub enum Action {
DownloadPaused(String),
ClearDownload,
CancelDownload,
- PromptDownloadEpisode,
- ConfirmDownloadEpisode,
- PromptDownloadSeason,
- ConfirmDownloadSeason,
+ DownloadEpisode,
+ DownloadSeason,
ProcessDownloadQueue,
FetchDetails(String, bool),
DetailsSuccess(
diff --git a/src/tui/app/download.rs b/src/tui/app/download.rs
index c9b2b93..a0dc64b 100644
--- a/src/tui/app/download.rs
+++ b/src/tui/app/download.rs
@@ -625,14 +625,7 @@ impl App {
self.start_resilient_download(subtitle_url, link, headers);
return None;
}
- Action::PromptDownloadEpisode => {
- self.state.show_episode_download_confirm = true;
- self.state.episode_download_confirm_yes_selected = false;
- }
-
- Action::ConfirmDownloadEpisode => {
- self.state.show_episode_download_confirm = false;
-
+ Action::DownloadEpisode => {
let subject_id = self.state.active_subject_id.clone().unwrap_or_default();
let resource_id = self.get_selected_resource_id();
@@ -673,14 +666,7 @@ impl App {
self.action_sender.send(Action::DownloadStream(None)).ok();
}
}
-
- Action::PromptDownloadSeason => {
- self.state.show_season_download_confirm = true;
- self.state.season_download_confirm_yes_selected = false;
- }
-
- Action::ConfirmDownloadSeason => {
- self.state.show_season_download_confirm = false;
+ Action::DownloadSeason => {
self.state.season_subtitle_preference = None;
let season_num = self.state.selected_season;
@@ -1104,7 +1090,7 @@ mod tests {
}];
app.state.resource_list_state.select(Some(0));
- app.handle_download(Action::ConfirmDownloadEpisode).await;
+ app.handle_download(Action::DownloadEpisode).await;
let notif = app.state.notifications.back().expect("notification posted");
assert_eq!(notif.kind, NotificationKind::Info);
diff --git a/src/tui/app/keyboard.rs b/src/tui/app/keyboard.rs
index 482fa52..90c8041 100644
--- a/src/tui/app/keyboard.rs
+++ b/src/tui/app/keyboard.rs
@@ -1139,13 +1139,7 @@ impl App {
}
match key.code {
KeyCode::Tab => {
- if self.state.show_season_download_confirm {
- self.state.season_download_confirm_yes_selected =
- !self.state.season_download_confirm_yes_selected;
- } else if self.state.show_episode_download_confirm {
- self.state.episode_download_confirm_yes_selected =
- !self.state.episode_download_confirm_yes_selected;
- } else if !self.state.subtitle_popup
+ if !self.state.subtitle_popup
&& !self.state.player_picker_popup
&& !self.state.is_download_subtitle_popup
{
@@ -1153,52 +1147,20 @@ impl App {
}
}
KeyCode::BackTab => {
- if self.state.show_season_download_confirm {
- self.state.season_download_confirm_yes_selected =
- !self.state.season_download_confirm_yes_selected;
- } else if self.state.show_episode_download_confirm {
- self.state.episode_download_confirm_yes_selected =
- !self.state.episode_download_confirm_yes_selected;
- } else if !self.state.subtitle_popup
+ if !self.state.subtitle_popup
&& !self.state.player_picker_popup
&& !self.state.is_download_subtitle_popup
{
self.action_sender.send(Action::BackTabPane).ok();
}
}
- KeyCode::Char('y') | KeyCode::Char('Y') => {
- if self.state.show_season_download_confirm {
- self.action_sender.send(Action::ConfirmDownloadSeason).ok();
- } else if self.state.show_episode_download_confirm {
- self.action_sender.send(Action::ConfirmDownloadEpisode).ok();
- } else {
- return None;
- }
- }
- KeyCode::Char('n') | KeyCode::Char('N') => {
- if self.state.show_season_download_confirm {
- self.state.show_season_download_confirm = false;
- } else if self.state.show_episode_download_confirm {
- self.state.show_episode_download_confirm = false;
- } else {
- return None;
- }
- }
KeyCode::Esc => {
- if self.state.show_season_download_confirm {
- self.state.show_season_download_confirm = false;
- } else if self.state.show_episode_download_confirm {
- self.state.show_episode_download_confirm = false;
- } else {
- self.action_sender.send(Action::GoBack).ok();
- }
+ self.action_sender.send(Action::GoBack).ok();
}
KeyCode::Char(' ') | KeyCode::Char('p') | KeyCode::Char('P') => {
if !self.state.subtitle_popup
&& !self.state.player_picker_popup
&& !self.state.is_download_subtitle_popup
- && !self.state.show_season_download_confirm
- && !self.state.show_episode_download_confirm
{
match self.state.details_pane {
crate::tui::state::DetailsPane::Streams => {
@@ -1230,10 +1192,10 @@ impl App {
self.state.details_pane
{
if !self.state.available_seasons.is_empty() {
- self.action_sender.send(Action::PromptDownloadSeason).ok();
+ self.action_sender.send(Action::DownloadSeason).ok();
}
} else {
- self.action_sender.send(Action::PromptDownloadEpisode).ok();
+ self.action_sender.send(Action::DownloadEpisode).ok();
}
}
}
@@ -1241,8 +1203,6 @@ impl App {
if !self.state.subtitle_popup
&& !self.state.player_picker_popup
&& !self.state.is_download_subtitle_popup
- && !self.state.show_season_download_confirm
- && !self.state.show_episode_download_confirm
{
if let Some((title, content)) = self.state.active_overview() {
self.state.open_overview_modal(title, content);
@@ -1253,8 +1213,6 @@ impl App {
if !self.state.subtitle_popup
&& !self.state.player_picker_popup
&& !self.state.is_download_subtitle_popup
- && !self.state.show_season_download_confirm
- && !self.state.show_episode_download_confirm
{
self.action_sender.send(Action::Refresh).ok();
}
@@ -1266,8 +1224,6 @@ impl App {
if !self.state.subtitle_popup
&& !self.state.player_picker_popup
&& !self.state.is_download_subtitle_popup
- && !self.state.show_season_download_confirm
- && !self.state.show_episode_download_confirm
&& self.state.favorites_available()
{
self.action_sender.send(Action::ToggleFavorite).ok();
@@ -1281,11 +1237,7 @@ impl App {
self.action_sender.send(Action::MoveDown).ok();
}
KeyCode::Left | KeyCode::Char('h') | KeyCode::Char('H') => {
- if self.state.show_season_download_confirm {
- self.state.season_download_confirm_yes_selected = true;
- } else if self.state.show_episode_download_confirm {
- self.state.episode_download_confirm_yes_selected = true;
- } else if !self.state.subtitle_popup
+ if !self.state.subtitle_popup
&& !self.state.player_picker_popup
&& !self.state.is_download_subtitle_popup
{
@@ -1293,11 +1245,7 @@ impl App {
}
}
KeyCode::Right | KeyCode::Char('l') | KeyCode::Char('L') => {
- if self.state.show_season_download_confirm {
- self.state.season_download_confirm_yes_selected = false;
- } else if self.state.show_episode_download_confirm {
- self.state.episode_download_confirm_yes_selected = false;
- } else if !self.state.subtitle_popup
+ if !self.state.subtitle_popup
&& !self.state.player_picker_popup
&& !self.state.is_download_subtitle_popup
{
@@ -1305,19 +1253,7 @@ impl App {
}
}
KeyCode::Enter => {
- if self.state.show_season_download_confirm {
- if self.state.season_download_confirm_yes_selected {
- self.action_sender.send(Action::ConfirmDownloadSeason).ok();
- } else {
- self.state.show_season_download_confirm = false;
- }
- } else if self.state.show_episode_download_confirm {
- if self.state.episode_download_confirm_yes_selected {
- self.action_sender.send(Action::ConfirmDownloadEpisode).ok();
- } else {
- self.state.show_episode_download_confirm = false;
- }
- } else if self.state.subtitle_popup
+ if self.state.subtitle_popup
|| self.state.player_picker_popup
|| self.state.is_download_subtitle_popup
{
@@ -1712,4 +1648,29 @@ mod tests {
.await;
assert!(!app.state.show_overview_modal);
}
+
+ #[tokio::test]
+ async fn test_details_download_key_triggers_download_directly() {
+ 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('d'), KeyModifiers::empty()))
+ .await;
+ assert!(matches!(
+ app.action_receiver.try_recv().ok(),
+ Some(Action::DownloadEpisode)
+ ));
+
+ app.state.details_pane = crate::tui::state::DetailsPane::Seasons;
+ app.state.available_seasons = vec![crate::providers::models::Season {
+ number: 1,
+ episodes: vec![],
+ }];
+ app.handle_key(KeyEvent::new(KeyCode::Char('d'), KeyModifiers::empty()))
+ .await;
+ assert!(matches!(
+ app.action_receiver.try_recv().ok(),
+ Some(Action::DownloadSeason)
+ ));
+ }
}
diff --git a/src/tui/app/mouse.rs b/src/tui/app/mouse.rs
index c51e7c2..03151a5 100644
--- a/src/tui/app/mouse.rs
+++ b/src/tui/app/mouse.rs
@@ -412,56 +412,6 @@ impl App {
return true;
}
- if self.state.show_season_download_confirm {
- let summary = crate::tui::screens::details::season_confirm_summary(&self.state);
- let longest = summary
- .iter()
- .map(|line| crate::tui::text::width(line))
- .max()
- .unwrap_or(36);
- let popup = crate::tui::overlay::download_confirm_layout(area, summary.len(), longest);
- if popup.contains(ratatui::layout::Position::new(col, row)) {
- let action_y =
- crate::tui::overlay::download_confirm_action_row(popup, summary.len());
- if row == action_y {
- let mid_x = popup.x + popup.width / 2;
- if col < mid_x {
- self.action_sender.send(Action::ConfirmDownloadSeason).ok();
- } else {
- self.state.show_season_download_confirm = false;
- }
- }
- } else {
- self.state.show_season_download_confirm = false;
- }
- return true;
- }
-
- if self.state.show_episode_download_confirm {
- let summary = crate::tui::screens::details::episode_confirm_summary(&self.state);
- let longest = summary
- .iter()
- .map(|line| crate::tui::text::width(line))
- .max()
- .unwrap_or(36);
- let popup = crate::tui::overlay::download_confirm_layout(area, summary.len(), longest);
- if popup.contains(ratatui::layout::Position::new(col, row)) {
- let action_y =
- crate::tui::overlay::download_confirm_action_row(popup, summary.len());
- if row == action_y {
- let mid_x = popup.x + popup.width / 2;
- if col < mid_x {
- self.action_sender.send(Action::ConfirmDownloadEpisode).ok();
- } else {
- self.state.show_episode_download_confirm = false;
- }
- }
- } else {
- self.state.show_episode_download_confirm = false;
- }
- return true;
- }
-
if self.state.tv_config_popup {
let rows = self.state.tv_manager_rows();
let total_rows = rows.len();
@@ -1268,9 +1218,9 @@ impl App {
}
FooterAction::Download => {
if is_seasons {
- self.action_sender.send(Action::PromptDownloadSeason).ok();
+ self.action_sender.send(Action::DownloadSeason).ok();
} else {
- self.action_sender.send(Action::PromptDownloadEpisode).ok();
+ self.action_sender.send(Action::DownloadEpisode).ok();
}
}
FooterAction::Favorite => {
diff --git a/src/tui/app/run.rs b/src/tui/app/run.rs
index 454ab32..d28f877 100644
--- a/src/tui/app/run.rs
+++ b/src/tui/app/run.rs
@@ -475,10 +475,8 @@ impl App {
Action::DownloadStream(..)
| Action::StartDownload(..)
- | Action::PromptDownloadEpisode
- | Action::ConfirmDownloadEpisode
- | Action::PromptDownloadSeason
- | Action::ConfirmDownloadSeason
+ | Action::DownloadEpisode
+ | Action::DownloadSeason
| Action::ProcessDownloadQueue
| Action::UpdateDownload(..)
| Action::DownloadCompleted(..)
diff --git a/src/tui/app/system.rs b/src/tui/app/system.rs
index 1065859..66724fd 100644
--- a/src/tui/app/system.rs
+++ b/src/tui/app/system.rs
@@ -132,8 +132,6 @@ impl App {
self.state.player_picker_popup = false;
self.state.subtitle_popup = false;
self.state.is_download_subtitle_popup = false;
- self.state.show_season_download_confirm = false;
- self.state.show_episode_download_confirm = false;
}
}
}
diff --git a/src/tui/app/tv.rs b/src/tui/app/tv.rs
index adbbe32..ac1a959 100644
--- a/src/tui/app/tv.rs
+++ b/src/tui/app/tv.rs
@@ -18,8 +18,6 @@ impl App {
self.state.pending_play_link = None;
self.state.subtitle_list.clear();
self.state.subtitle_list_state.select(None);
- self.state.show_season_download_confirm = false;
- self.state.show_episode_download_confirm = false;
self.state.is_resolving_playback = false;
self.state.tv_input_active = false;
self.state.tv_input_buffer.clear();
diff --git a/src/tui/overlay.rs b/src/tui/overlay.rs
index 68eaf39..b0048ed 100644
--- a/src/tui/overlay.rs
+++ b/src/tui/overlay.rs
@@ -1,6 +1,6 @@
use ratatui::{
Frame,
- layout::{Alignment, Constraint, Layout, Rect},
+ layout::{Alignment, Rect},
style::{Modifier, Style},
text::{Line, Span},
widgets::{Block, BorderType, Borders, List, ListItem, ListState, Paragraph},
@@ -182,25 +182,6 @@ pub fn help_modal_layout(area: Rect, desired_width: u16, desired_height: u16) ->
Rect::new(x, y, width, height)
}
-pub fn download_confirm_layout(
- area: Rect,
- summary_lines: usize,
- longest_line_width: usize,
-) -> Rect {
- let content_width = longest_line_width.max(36);
- centered(
- area,
- content_width.saturating_add(4) as u16,
- summary_lines as u16 + 4,
- 36,
- 64,
- )
-}
-
-pub fn download_confirm_action_row(popup: Rect, summary_lines: usize) -> u16 {
- (popup.y + summary_lines as u16 + 1).min(popup.bottom().saturating_sub(1))
-}
-
pub fn overview_modal_layout_with_wrapped(area: Rect, content: &str) -> (Rect, Vec<String>) {
let available_w = area.width.saturating_sub(4);
let width = 72u16.min(available_w).max(36);
@@ -450,68 +431,6 @@ pub fn browse_category_badge<'a>(label: &str, theme: &'a Theme) -> (Span<'a>, &'
}
}
-pub fn confirmation(
- frame: &mut Frame,
- area: Rect,
- title: &str,
- summary: &[Line<'_>],
- confirm_selected: bool,
- theme: &Theme,
- basic_terminal: bool,
-) {
- let content_width = summary.iter().map(Line::width).max().unwrap_or(0).max(36);
- let popup = centered(
- area,
- content_width.saturating_add(4) as u16,
- summary.len() as u16 + 4,
- 36,
- 64,
- );
- let inner = crate::tui::widgets::ModalFrame::new(title, theme, basic_terminal)
- .render(frame, popup, area);
- let sections = Layout::vertical([
- Constraint::Length(summary.len() as u16),
- Constraint::Length(2),
- ])
- .split(inner);
- frame.render_widget(
- Paragraph::new(summary.to_vec()).alignment(Alignment::Center),
- sections[0],
- );
- let confirm_btn_style = if confirm_selected {
- if basic_terminal {
- theme.text.add_modifier(Modifier::REVERSED | Modifier::BOLD)
- } else {
- Style::default()
- .bg(theme.accent.fg.unwrap_or(theme.base))
- .fg(theme.crust_color())
- .add_modifier(Modifier::BOLD)
- }
- } else {
- theme.subtext1
- };
-
- let cancel_btn_style = if !confirm_selected {
- if basic_terminal {
- theme.text.add_modifier(Modifier::REVERSED | Modifier::BOLD)
- } else {
- Style::default()
- .bg(theme.surface1_color())
- .fg(theme.text.fg.unwrap_or(theme.base))
- .add_modifier(Modifier::BOLD)
- }
- } else {
- theme.subtext1
- };
-
- let actions = vec![
- Span::styled(" [ Download ] ", confirm_btn_style),
- Span::raw(" "),
- Span::styled(" [ Cancel ] ", cancel_btn_style),
- ];
- crate::tui::widgets::render_modal_footer(frame, sections[1], actions, theme);
-}
-
pub fn notifications(
frame: &mut Frame,
area: Rect,
@@ -999,28 +918,6 @@ mod tests {
assert!(large.has_more);
}
- #[test]
- fn test_download_confirm_action_row_matches_rendered_button_section() {
- let popup = Rect::new(10, 10, 40, 10);
- let summary_lines = 3;
- let action_row = download_confirm_action_row(popup, summary_lines);
-
- assert_eq!(action_row, popup.y + 4);
- assert!(popup.contains(ratatui::layout::Position::new(popup.x + 2, action_row)));
- }
-
- #[test]
- fn test_download_confirm_zones_do_not_overlap() {
- let area = Rect::new(0, 0, 80, 24);
- let summary_lines = 4;
- let longest = 30;
- let popup = download_confirm_layout(area, summary_lines, longest);
- let action_row = download_confirm_action_row(popup, summary_lines);
-
- assert!(popup.contains(ratatui::layout::Position::new(popup.x + 1, action_row)));
- assert!(action_row < popup.bottom() - 1);
- }
-
#[test]
fn test_browse_category_badges() {
let theme = Theme::mocha();
diff --git a/src/tui/screens/details.rs b/src/tui/screens/details.rs
index f416589..760d46e 100644
--- a/src/tui/screens/details.rs
+++ b/src/tui/screens/details.rs
@@ -1569,136 +1569,9 @@ pub fn draw(frame: &mut Frame, area: Rect, state: &mut AppState, theme: &Theme)
theme,
state.basic_terminal,
);
- } else if state.show_season_download_confirm {
- let summary_strings = season_confirm_summary(state);
- let summary_lines: Vec<Line<'_>> = summary_strings
- .iter()
- .map(|s| Line::from(s.as_str()))
- .collect();
- crate::tui::overlay::confirmation(
- frame,
- area,
- " Confirm Season Download ",
- &summary_lines,
- state.season_download_confirm_yes_selected,
- theme,
- state.basic_terminal,
- );
- } else if state.show_episode_download_confirm {
- let summary_strings = episode_confirm_summary(state);
- let summary_lines: Vec<Line<'_>> = summary_strings
- .iter()
- .map(|s| Line::from(s.as_str()))
- .collect();
- crate::tui::overlay::confirmation(
- frame,
- area,
- " Confirm Episode Download ",
- &summary_lines,
- state.episode_download_confirm_yes_selected,
- theme,
- state.basic_terminal,
- );
}
}
-pub(crate) fn season_confirm_summary(state: &AppState) -> Vec<String> {
- let title = state
- .selected_details
- .as_ref()
- .map(|d| d.title.as_str())
- .unwrap_or("Series");
- let season_idx = state.season_list_state.selected().unwrap_or(0);
- let eps_count = state
- .available_episode_numbers
- .get(season_idx)
- .map(|eps| eps.len())
- .unwrap_or(0);
- let season_number = state.selected_season;
- let mut summary = vec![format!(
- "{title} • Season {season_number} ({eps_count} Episodes)"
- )];
- if let Some(stream) = selected_stream_summary(state) {
- summary.push(format!("Quality: {stream}"));
- }
- let dest = state
- .download_dir
- .as_ref()
- .map(|p| p.to_string_lossy().to_string())
- .unwrap_or_else(|| {
- crate::service::resolve_download_dir(None)
- .to_string_lossy()
- .to_string()
- });
- summary.push(format!("Save to: {dest}"));
- summary
-}
-
-pub(crate) fn episode_confirm_summary(state: &AppState) -> Vec<String> {
- let title = state
- .selected_details
- .as_ref()
- .map(|d| d.title.as_str())
- .unwrap_or("Media");
- let year = state
- .selected_details
- .as_ref()
- .and_then(|d| d.year.as_deref())
- .unwrap_or("");
- let season_idx = state.selected_season;
- let ep_idx = state.selected_episode;
- let is_series = state
- .selected_details
- .as_ref()
- .is_some_and(|d| d.is_series());
- let mut summary = if is_series {
- vec![format!("{title} • Season {season_idx} Episode {ep_idx}")]
- } else if !year.is_empty() && year != "N/A" {
- vec![format!("{title} ({year}) • Movie")]
- } else {
- vec![format!("{title} • Movie")]
- };
- if let Some(stream) = selected_stream_summary(state) {
- summary.push(format!("Quality: {stream}"));
- }
- let dest = state
- .download_dir
- .as_ref()
- .map(|p| p.to_string_lossy().to_string())
- .unwrap_or_else(|| {
- crate::service::resolve_download_dir(None)
- .to_string_lossy()
- .to_string()
- });
- summary.push(format!("Save to: {dest}"));
- summary
-}
-
-fn selected_stream_summary(state: &AppState) -> Option<String> {
- let idx = state.resource_list_state.selected().unwrap_or(0);
- let resource = state.selected_resources.get(idx)?;
- let resolution = if resource.is_multi_resolution() {
- Some("Multi-Res".to_string())
- } else if resource.resolution_u64() > 0 {
- Some(format!("{}p", resource.resolution_u64()))
- } else {
- None
- };
- let codec = resource
- .codec
- .as_deref()
- .filter(|value| !value.is_empty())
- .map(str::to_uppercase);
- let size = resource
- .size_bytes
- .map(|value| crate::tui::text::format_file_size(value as f64));
- let fields = [size, resolution, codec]
- .into_iter()
- .flatten()
- .collect::<Vec<_>>();
- (!fields.is_empty()).then(|| fields.join(" · "))
-}
-
fn clean_language_name(value: &str) -> String {
let mut name = if value.to_ascii_lowercase().starts_with("original") {
"Original".to_string()
@@ -3399,7 +3272,9 @@ mod tests {
resource_id: Some("res-1".to_string()),
}],
details_pane: crate::tui::state::DetailsPane::Streams,
- show_episode_download_confirm: true,
+ show_overview_modal: true,
+ overview_modal_title: "Overview Modal".to_string(),
+ overview_modal_content: "Overview content".to_string(),
basic_terminal: false,
..Default::default()
};
@@ -3419,7 +3294,7 @@ mod tests {
.map(|cell| cell.symbol())
.collect::<String>();
- assert!(content.contains("Confirm Episode Download"));
+ assert!(content.contains("Overview Modal"));
assert!(!content.contains("› Streams"));
assert!(content.contains("Multi"));
assert!(content.contains("Hindi"));
diff --git a/src/tui/state.rs b/src/tui/state.rs
index dd15f3b..a3a89ce 100644
--- a/src/tui/state.rs
+++ b/src/tui/state.rs
@@ -183,10 +183,6 @@ pub struct AppState {
pub selected_resources: Vec<Release>,
pub stream_pool: std::collections::HashMap<String, SubjectStreamPool>,
pub fetch_cancel: std::sync::Arc<std::sync::atomic::AtomicBool>,
- pub show_season_download_confirm: bool,
- pub season_download_confirm_yes_selected: bool,
- pub show_episode_download_confirm: bool,
- pub episode_download_confirm_yes_selected: bool,
pub is_waiting_for_download_stream: bool,
pub auto_play_on_ready: bool,
pub is_fetching_streams: bool,
@@ -363,10 +359,6 @@ impl Default for AppState {
selected_resources: vec![],
stream_pool: std::collections::HashMap::new(),
fetch_cancel: std::sync::Arc::new(std::sync::atomic::AtomicBool::new(false)),
- show_season_download_confirm: false,
- season_download_confirm_yes_selected: false,
- show_episode_download_confirm: false,
- episode_download_confirm_yes_selected: false,
is_waiting_for_download_stream: false,
is_fetching_streams: false,
auto_play_on_ready: false,
@@ -532,8 +524,6 @@ impl AppState {
self.subtitle_popup = false;
self.is_download_subtitle_popup = false;
self.player_picker_popup = false;
- self.show_season_download_confirm = false;
- self.show_episode_download_confirm = false;
self.selected_details = None;
self.selected_resources.clear();
self.active_subject_id = None;
@@ -816,8 +806,6 @@ impl AppState {
|| self.player_picker_popup
|| self.subtitle_popup
|| self.is_download_subtitle_popup
- || self.show_season_download_confirm
- || self.show_episode_download_confirm
|| self.show_overview_modal
|| (self.update_available.is_some() && self.input_mode != InputMode::Editing)
|| self.is_updating
@@ -1470,14 +1458,6 @@ mod tests {
assert!(state.has_active_modal());
state.is_download_subtitle_popup = false;
- state.show_season_download_confirm = true;
- assert!(state.has_active_modal());
- state.show_season_download_confirm = false;
-
- state.show_episode_download_confirm = true;
- assert!(state.has_active_modal());
- state.show_episode_download_confirm = false;
-
state.update_available = Some(("v2.0.0".to_string(), "Notes".to_string()));
assert!(state.has_active_modal());
state.input_mode = InputMode::Editing;