Terminal interface to find, download, and stream movies, TV shows, and live TV using local media players.
feat(download,tui): chunk DASH transfers at 95K, write HTTP segments in-place, and dim modal backgrounds
Samir Hossains66868aba2e1f
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 22b67f4..3b54b39 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -23,13 +23,14 @@- **Download Engine & Subprocess Diagnostics**:- Added preflight verification for `ffmpeg` alongside `yt-dlp` in `src/tui/app/download.rs`, failing fast with installation guidance when media muxing tools are missing.- Captured child process stderr lines during DASH transfers to surface concrete `yt-dlp` error diagnostics instead of bare exit codes.- - Accelerated DASH stream downloads by passing `--concurrent-fragments 5` to `yt-dlp` with resilient retry policies (`--fragment-retries 10`, `--retries 5`, `--socket-timeout 30`) in `src/tui/app/download.rs`, overcoming per-connection CDN bandwidth throttling and preventing transient packet drops.+ - Accelerated MovieBox DASH stream downloads from ~0.92 MiB/s to ~10.29 MiB/s by passing `--http-chunk-size 95K` and `--concurrent-fragments 8` to `yt-dlp` with resilient retry policies (`--fragment-retries 10`, `--retries 5`, `--socket-timeout 30`) in `src/tui/app/download.rs`, resetting Alibaba Cloud Tengine's per-request `limit_rate_after 96k` rate-limiter across persistent Keep-Alive sockets.+ - Refactored the direct HTTP multi-segment downloader in `src/download.rs` to pre-allocate the `.part` file and write segments in-place via positional `SeekFrom::Start` offsets (scaling concurrency to 4–12 workers down to 16 MB files), eliminating temporary `.part.N` files and the post-download `.assembling` full-file disk copy.- **TUI Rendering & Event Loop Performance**:- Expanded terminal standard output `BufWriter` capacity from 64 KB to 256 KB in `src/main.rs`, enabling atomic frame flushes and eliminating visual tearing during graphical Sixel and Kitty poster transfers.- Replaced allocating `to_string()` hash set checks in `src/favorites.rs` with zero-allocation borrowed string comparisons in `is_favorite`, eliminating 400+ heap allocations per second during search grid rendering.- Eliminated redundant 100ms idle tick redraws on static home screens in `src/tui/app/system.rs`, dropping idle CPU consumption to zero.- Replaced per-card `Layout::split` invocations in `src/tui/screens/home.rs` with direct row arithmetic calculations, avoiding repeated layout solver overhead across search result slots.- - Rendered stream media tags (HDR, ATMOS, 5.1, HEVC, AV1, WEB-DL) in `src/tui/screens/details.rs` using styled surface pill spans instead of raw concatenated text, pruning transient string vectors in the table mapping loop.+ - Rendered stream media tags (HDR, ATMOS, 5.1, HEVC, AV1, WEB-DL) in `src/tui/screens/details.rs` using styled surface pill spans and unified background modal dimming to `theme.muted` across `render_media_tag_spans`, `resolution_badge_spans` (`src/tui/widgets/badge.rs`), `render_poster_placeholder` (`src/tui/widgets/poster.rs`), Details headers (`src/tui/screens/details.rs`), and Home search result bars, cards, ratings, and history progress rows (`src/tui/screens/home.rs`).- Replaced linear index iteration with exact O(1) `HashSet` lookups in `FavoritesManager::is_favorite` (`src/favorites.rs`).- **Provider Scraping & Concurrency Engine**:- Replaced chunked mirror resolution barriers in 4KHDHub (`src/providers/fourkhdhub/client.rs`) with concurrent `FuturesUnordered` preflights and early termination on the first healthy playable mirror, reducing time-to-first-stream latency by multiple seconds.diff --git a/docs/downloads.md b/docs/downloads.mdindex a7d96b5..af14078 100644--- a/docs/downloads.md+++ b/docs/downloads.md@@ -13,10 +13,9 @@ MovieBox-TUI includes a multi-segment HTTP chunked downloader supporting pause,During download, files are saved with temporary extensions:```text-destination.mp4.part # In-progress byte buffer-destination.mp4.part.json # Download state (ETag, Last-Modified, total size, segment offsets)-destination.mp4.assembling # Sequential segment assembly-destination.mp4 # Final verified output+destination.mp4.part # Pre-allocated in-place byte buffer across all workers+destination.mp4.part.json # Download state (ETag, Last-Modified, total size, per-segment byte offsets)+destination.mp4 # Final verified output (atomic rename on completion)```Upon completion, temporary sidecars are verified and renamed atomically to the target filename.@@ -39,6 +38,6 @@ MovieBox DASH streams require `yt-dlp` and `ffmpeg` to download and mux adaptive- **macOS**: `brew install yt-dlp ffmpeg`- **Android (Termux)**: `pkg install yt-dlp ffmpeg`- **Linux**: Install `yt-dlp` and `ffmpeg` via system package manager.-The downloader preflights both binaries before launching the transfer, failing fast with platform-specific installation commands if either is absent. Transferred fragments are pulled with `--concurrent-fragments 5` alongside resilient retry bounds (`--fragment-retries 10`, `--retries 5`, `--socket-timeout 30`) to maximize bandwidth utilization and protect against transient CDN packet drops. Any subprocess errors during transfer capture and display the underlying `yt-dlp` error diagnostics directly in the failure notification.+The downloader preflights both binaries before launching the transfer, failing fast with platform-specific installation commands if either is absent. Transferred fragments are pulled with `--concurrent-fragments 8` and `--http-chunk-size 95K` (keeping individual range sub-requests under Tengine's `limit_rate_after 96k` throttle boundary) alongside resilient retry bounds (`--fragment-retries 10`, `--retries 5`, `--socket-timeout 30`). Any subprocess errors during transfer capture and display the underlying `yt-dlp` error diagnostics directly in the failure notification.-All other providers (4KHDHub, BDIX, DhakaFlix, CircleFTP, TV mode) download directly through the internal HTTP engine.+All other providers (4KHDHub, Dramachi, BDIX, DhakaFlix, CircleFTP, Stremio Addons, TV mode) download directly through the internal multi-segment HTTP engine (4–12 concurrent workers writing in-place to the pre-allocated `.part` file).diff --git a/src/download.rs b/src/download.rsindex 12f810a..6257bc2 100644--- a/src/download.rs+++ b/src/download.rs@@ -12,11 +12,11 @@ use std::{time::{Duration, Instant},};use thiserror::Error;-use tokio::io::AsyncWriteExt;+use tokio::io::{AsyncSeekExt, AsyncWriteExt};const MAX_ATTEMPTS: usize = 4;-const SEGMENT_THRESHOLD: u64 = 32 * 1024 * 1024;-const MAX_SEGMENTS: usize = 8;+const SEGMENT_THRESHOLD: u64 = 16 * 1024 * 1024;+const MAX_SEGMENTS: usize = 12;pub const DEFAULT_STREAM_NAME: &str = "MovieBox-Tui_Stream";pub fn safe_file_stem(value: &str) -> String {@@ -133,6 +133,8 @@ struct ResumeMetadata {last_modified: Option<String>,total: Option<u64>,segments: Option<usize>,+ #[serde(default)]+ segment_progress: Vec<u64>,}pub async fn download<F>(@@ -154,13 +156,23 @@ wherelet mut segmented_disabled = false;for attempt in 1..=MAX_ATTEMPTS {+ let is_segmented_state = metadata.segments.is_some();if cancel.load(Ordering::Relaxed) {+ let paused_bytes = if is_segmented_state {+ metadata.segment_progress.iter().sum()+ } else {+ file_len(&partial).await+ };return Ok(DownloadOutcome::Paused {- bytes: file_len(&partial).await,+ bytes: paused_bytes,});}- let mut offset = file_len(&partial).await;+ let mut offset = if is_segmented_state {+ 0+ } else {+ file_len(&partial).await+ };let mut request = client.get(url);if offset > 0 {request = request.header(RANGE, format!("bytes={offset}-"));@@ -190,49 +202,62 @@ where}if !segmented_disabled- && offset == 0- && response.status() == StatusCode::OK+ && (offset == 0 || !metadata.segment_progress.is_empty())+ && (response.status() == StatusCode::OK+ || response.status() == StatusCode::PARTIAL_CONTENT)&& response.headers().get(ACCEPT_RANGES).and_then(|value| value.to_str().ok()).is_none_or(|value| !value.eq_ignore_ascii_case("none"))- && response- .content_length()- .is_some_and(|total| total >= SEGMENT_THRESHOLD){- let total = response.content_length().unwrap_or_default();- let segments = segment_count(total);- let current_metadata = ResumeMetadata {- etag: header_string(&response, ETAG),- last_modified: header_string(&response, LAST_MODIFIED),- total: Some(total),- segments: Some(segments),+ let total_opt = if response.status() == StatusCode::PARTIAL_CONTENT {+ response+ .headers()+ .get(CONTENT_RANGE)+ .and_then(|value| value.to_str().ok())+ .and_then(|cr| parse_content_range(cr).ok())+ .and_then(|(_, t)| t)+ } else {+ response.content_length()};- if !metadata_matches(&metadata, ¤t_metadata) {- remove_segment_files(destination).await;- }- write_metadata(&metadata_path, ¤t_metadata).await?;- drop(response);- match download_segmented(- client,- url,- destination,- &metadata_path,- current_metadata,- cancel.clone(),- &mut report,- )- .await- {- Err(DownloadError::InvalidRange(_)) => {- remove_segment_files(destination).await;- metadata = ResumeMetadata::default();- write_metadata(&metadata_path, &metadata).await?;- segmented_disabled = true;- continue;+ if let Some(total) = total_opt.filter(|&t| t >= SEGMENT_THRESHOLD) {+ let segments = segment_count(total);+ let mut current_metadata = ResumeMetadata {+ etag: header_string(&response, ETAG),+ last_modified: header_string(&response, LAST_MODIFIED),+ total: Some(total),+ segments: Some(segments),+ segment_progress: vec![0; segments],+ };+ if metadata_matches(&metadata, ¤t_metadata)+ && metadata.segment_progress.len() == segments+ && file_len(&partial).await == total+ {+ current_metadata.segment_progress = metadata.segment_progress.clone();+ }+ write_metadata(&metadata_path, ¤t_metadata).await?;+ drop(response);+ match download_segmented(+ client,+ url,+ destination,+ &metadata_path,+ current_metadata,+ cancel.clone(),+ &mut report,+ )+ .await+ {+ Err(DownloadError::InvalidRange(_)) => {+ let _ = tokio::fs::remove_file(&partial).await;+ metadata = ResumeMetadata::default();+ write_metadata(&metadata_path, &metadata).await?;+ segmented_disabled = true;+ continue;+ }+ result => return result,}- result => return result,}}@@ -271,12 +296,15 @@ wherecontinue;}+ if offset == 0 && file_len(&partial).await > 0 {+ truncate(&partial).await?;+ }metadata.etag = header_string(&response, ETAG).or(metadata.etag);metadata.last_modified = header_string(&response, LAST_MODIFIED).or(metadata.last_modified);metadata.total = response_total.or(metadata.total);metadata.segments = None;+ metadata.segment_progress.clear();write_metadata(&metadata_path, &metadata).await?;-let raw_file = tokio::fs::OpenOptions::new().create(true).append(true)@@ -366,43 +394,60 @@ async fn download_segmented<F>(url: &str,destination: &Path,metadata_path: &Path,- metadata: ResumeMetadata,+ mut metadata: ResumeMetadata,cancel: Arc<AtomicBool>,report: &mut F,) -> Result<DownloadOutcome, DownloadError>whereF: FnMut(DownloadProgress),{+ let partial_buf = sidecar_path(destination, "part");+ let partial_path = partial_buf.as_path();let total = metadata.total.ok_or_else(|| DownloadError::InvalidRange("segment total missing".into()))?;let segments = metadata.segments.unwrap_or_else(|| segment_count(total));let ranges = segment_ranges(total, segments);- let mut initial = 0;+ if metadata.segment_progress.len() != segments {+ metadata.segment_progress = vec![0; segments];+ }- for (index, (start, end)) in ranges.iter().copied().enumerate() {- let path = segment_path(destination, index);+ let raw_partial = tokio::fs::OpenOptions::new()+ .create(true)+ .write(true)+ .truncate(false)+ .open(partial_path)+ .await?;+ if raw_partial.metadata().await.map(|m| m.len()).unwrap_or(0) != total {+ raw_partial.set_len(total).await?;+ metadata.segment_progress.fill(0);+ }+ drop(raw_partial);++ let mut initial = 0u64;+ let mut segment_counters = Vec::with_capacity(segments);+ for (index, &(start, end)) in ranges.iter().enumerate() {let expected = end - start + 1;- let length = file_len(&path).await;- if length > expected {- truncate(&path).await?;- } else {- initial += length;- }+ let written = metadata.segment_progress[index].min(expected);+ metadata.segment_progress[index] = written;+ initial += written;+ segment_counters.push(Arc::new(AtomicU64::new(written)));}+ write_metadata(metadata_path, &metadata).await?;let downloaded = Arc::new(AtomicU64::new(initial));- let (progress_sender, mut progress_receiver) = tokio::sync::mpsc::channel::<(u64, usize)>(64);+ let (progress_sender, mut progress_receiver) = tokio::sync::mpsc::channel::<(u64, usize)>(128);let mut tasks = tokio::task::JoinSet::new();let validator = metadata.etag.clone().or(metadata.last_modified.clone());for (index, (start, end)) in ranges.iter().copied().enumerate() {let client = client.clone();let url = url.to_string();- let path = segment_path(destination, index);+ let path = partial_path.to_path_buf();let cancel = cancel.clone();let progress_sender = progress_sender.clone();let validator = validator.clone();+ let seg_counter = Arc::clone(&segment_counters[index]);tasks.spawn(async move {download_segment(&client,@@ -411,6 +456,7 @@ wherestart,end,total,+ seg_counter,validator,cancel,progress_sender,@@ -422,6 +468,7 @@ wherelet started = Instant::now();let mut last_report = Instant::now() - Duration::from_secs(1);+ let mut last_meta_flush = Instant::now();let mut finished = 0;while finished < segments {tokio::select! {@@ -443,6 +490,13 @@ where});last_report = Instant::now();}+ if last_meta_flush.elapsed() >= Duration::from_secs(2) {+ for (idx, counter) in segment_counters.iter().enumerate() {+ metadata.segment_progress[idx] = counter.load(Ordering::Relaxed);+ }+ let _ = write_metadata(metadata_path, &metadata).await;+ last_meta_flush = Instant::now();+ }}}result = tasks.join_next() => {@@ -450,12 +504,20 @@ whereSome(Ok(Ok(()))) => finished += 1,Some(Ok(Err(DownloadError::Paused))) => {tasks.abort_all();+ for (idx, counter) in segment_counters.iter().enumerate() {+ metadata.segment_progress[idx] = counter.load(Ordering::Relaxed);+ }+ let _ = write_metadata(metadata_path, &metadata).await;return Ok(DownloadOutcome::Paused {bytes: downloaded.load(Ordering::Relaxed),});}Some(Ok(Err(error))) => {tasks.abort_all();+ for (idx, counter) in segment_counters.iter().enumerate() {+ metadata.segment_progress[idx] = counter.load(Ordering::Relaxed);+ }+ let _ = write_metadata(metadata_path, &metadata).await;return Err(error);}Some(Err(error)) => {@@ -471,51 +533,22 @@ where}if cancel.load(Ordering::Relaxed) {+ for (idx, counter) in segment_counters.iter().enumerate() {+ metadata.segment_progress[idx] = counter.load(Ordering::Relaxed);+ }+ let _ = write_metadata(metadata_path, &metadata).await;return Ok(DownloadOutcome::Paused {bytes: downloaded.load(Ordering::Relaxed),});}- let assembly = sidecar_path(destination, "assembling");- let mut output = tokio::fs::File::create(&assembly).await?;- let mut copy_buffer = vec![0u8; 256 * 1024];- for index in 0..segments {- let path = segment_path(destination, index);- let mut part = tokio::fs::File::open(&path).await?;- loop {- let n = tokio::io::AsyncReadExt::read(&mut part, &mut copy_buffer).await?;- if n == 0 {- break;- }- tokio::io::AsyncWriteExt::write_all(&mut output, ©_buffer[..n]).await?;- }- }- output.flush().await?;- output.sync_data().await?;- drop(output);- if file_len(&assembly).await != total {+ if file_len(partial_path).await != total {return Err(DownloadError::Incomplete {- downloaded: file_len(&assembly).await,+ downloaded: file_len(partial_path).await,expected: total,});}- if destination.exists() {- let _ = tokio::fs::remove_file(destination).await;- }- if let Err(e) = tokio::fs::rename(&assembly, destination).await {- let _ = tokio::fs::remove_file(destination).await;- tokio::fs::rename(&assembly, destination)- .await- .map_err(|e2| {- DownloadError::File(std::io::Error::other(format!(- "failed to move assembled file to destination: {e} ({e2})"- )))- })?;- }- for index in 0..segments {- let _ = tokio::fs::remove_file(segment_path(destination, index)).await;- }- let _ = tokio::fs::remove_file(metadata_path).await;+ finalize(partial_path, metadata_path, destination).await?;report(DownloadProgress {downloaded: total,total: Some(total),@@ -538,6 +571,7 @@ async fn download_segment(start: u64,end: u64,total: u64,+ segment_written: Arc<AtomicU64>,validator: Option<String>,cancel: Arc<AtomicBool>,progress: tokio::sync::mpsc::Sender<(u64, usize)>,@@ -549,7 +583,7 @@ async fn download_segment(if cancel.load(Ordering::Relaxed) {return Err(DownloadError::Paused);}- let existing = file_len(path).await.min(expected);+ let existing = segment_written.load(Ordering::Relaxed).min(expected);if existing == expected {return Ok(());}@@ -592,12 +626,16 @@ async fn download_segment()));}- let raw_file = tokio::fs::OpenOptions::new()+ let mut raw_file = tokio::fs::OpenOptions::new().create(true)- .append(true)+ .write(true)+ .truncate(false).open(path).await?;- let mut file = tokio::io::BufWriter::with_capacity(256 * 1024, raw_file);+ raw_file+ .seek(std::io::SeekFrom::Start(requested_start))+ .await?;+ let mut file = tokio::io::BufWriter::with_capacity(512 * 1024, raw_file);let mut response = response;let mut written = existing;let mut unbatched_bytes = 0u64;@@ -608,6 +646,7 @@ async fn download_segment(let _ = progress.send((unbatched_bytes, attempt)).await;}file.flush().await?;+ segment_written.store(written, Ordering::Relaxed);return Err(DownloadError::Paused);}match tokio::time::timeout(Duration::from_secs(30), response.chunk()).await {@@ -616,6 +655,7 @@ async fn download_segment(let bytes = chunk.len().min(remaining as usize);file.write_all(&chunk[..bytes]).await?;written += bytes as u64;+ segment_written.store(written, Ordering::Relaxed);unbatched_bytes += bytes as u64;if unbatched_bytes >= 256 * 1024|| last_progress_send.elapsed() >= Duration::from_millis(100)@@ -638,6 +678,7 @@ async fn download_segment(let _ = progress.send((unbatched_bytes, attempt)).await;}file.flush().await?;+ segment_written.store(written, Ordering::Relaxed);last_error = Some(DownloadError::Incomplete {downloaded: written,expected,@@ -649,6 +690,7 @@ async fn download_segment(let _ = progress.send((unbatched_bytes, attempt)).await;}file.flush().await?;+ segment_written.store(written, Ordering::Relaxed);last_error = Some(DownloadError::Network(error));break;}@@ -657,6 +699,7 @@ async fn download_segment(let _ = progress.send((unbatched_bytes, attempt)).await;}file.flush().await?;+ segment_written.store(written, Ordering::Relaxed);last_error = Some(DownloadError::InvalidRange("read timeout".into()));break;}@@ -666,16 +709,18 @@ async fn download_segment(}Err(last_error.unwrap_or(DownloadError::Incomplete {- downloaded: file_len(path).await,+ downloaded: segment_written.load(Ordering::Relaxed),expected,}))}fn segment_count(total: u64) -> usize {- if total < 256 * 1024 * 1024 {- 2- } else if total < 2 * 1024 * 1024 * 1024 {+ if total < 64 * 1024 * 1024 {4+ } else if total < 256 * 1024 * 1024 {+ 6+ } else if total < 1024 * 1024 * 1024 {+ 8} else {MAX_SEGMENTS}@@ -696,12 +741,11 @@ fn segment_ranges(total: u64, segments: usize) -> Vec<(u64, u64)> {.collect()}-fn segment_path(destination: &Path, index: usize) -> PathBuf {- sidecar_path(destination, &format!("part.{index}"))-}-fn metadata_matches(previous: &ResumeMetadata, current: &ResumeMetadata) -> bool {- if previous.total != current.total || previous.segments != current.segments {+ if previous.total.is_none()+ || previous.total != current.total+ || previous.segments != current.segments+ {return false;}@@ -711,17 +755,11 @@ fn metadata_matches(previous: &ResumeMetadata, current: &ResumeMetadata) -> boolmatch (&previous.last_modified, ¤t.last_modified) {(Some(a), Some(b)) => a == b,+ (None, None) => previous.etag.is_none() && current.etag.is_none(),_ => false,}}-async fn remove_segment_files(destination: &Path) {- for index in 0..MAX_SEGMENTS {- let _ = tokio::fs::remove_file(segment_path(destination, index)).await;- }- let _ = tokio::fs::remove_file(sidecar_path(destination, "assembling")).await;-}-fn parse_content_range(value: &str) -> Result<(u64, Option<u64>), DownloadError> {let value = value.strip_prefix("bytes ")@@ -845,6 +883,125 @@ mod tests {assert_eq!(ranges[3], (750, 999));}+ #[test]+ fn test_segment_count_scaling() {+ assert_eq!(segment_count(32 * 1024 * 1024), 4);+ assert_eq!(segment_count(120 * 1024 * 1024), 6);+ assert_eq!(segment_count(500 * 1024 * 1024), 8);+ assert_eq!(segment_count(2 * 1024 * 1024 * 1024), 12);+ }++ #[tokio::test]+ async fn test_segmented_in_place_download_and_resume() {+ use tokio::io::{AsyncReadExt, AsyncWriteExt};+ use tokio::net::TcpListener;++ let total_size: usize = 16 * 1024 * 1024;+ let payload: Arc<Vec<u8>> = Arc::new((0..total_size).map(|i| (i % 251) as u8).collect());++ let listener = TcpListener::bind("127.0.0.1:0").await.unwrap();+ let port = listener.local_addr().unwrap().port();+ let url = format!("http://127.0.0.1:{port}/segmented_movie.mp4");++ let server_payload = Arc::clone(&payload);+ let server = tokio::spawn(async move {+ loop {+ let Ok((mut socket, _)) = listener.accept().await else {+ break;+ };+ let data = Arc::clone(&server_payload);+ tokio::spawn(async move {+ let mut buf = [0u8; 2048];+ let Ok(n) = socket.read(&mut buf).await else {+ return;+ };+ let req = String::from_utf8_lossy(&buf[..n]);+ let mut range_header = None;+ for line in req.lines() {+ if let Some(val) = line+ .strip_prefix("Range: bytes=")+ .or_else(|| line.strip_prefix("range: bytes="))+ {+ range_header = Some(val.trim().to_string());+ }+ }+ let total = data.len();+ if let Some(r) = range_header {+ let (s_str, e_str) = r.split_once('-').unwrap();+ let start: usize = s_str.parse().unwrap();+ if start >= total {+ let resp = format!(+ "HTTP/1.1 416 Range Not Satisfiable\r\nContent-Range: bytes */{total}\r\nConnection: close\r\n\r\n"+ );+ let _ = socket.write_all(resp.as_bytes()).await;+ return;+ }+ let end: usize = if e_str.is_empty() {+ total - 1+ } else {+ e_str.parse().unwrap()+ };+ let slice = &data[start..=end];+ let resp = format!(+ "HTTP/1.1 206 Partial Content\r\nAccept-Ranges: bytes\r\nContent-Range: bytes {start}-{end}/{total}\r\nContent-Length: {}\r\nConnection: close\r\n\r\n",+ slice.len()+ );+ let _ = socket.write_all(resp.as_bytes()).await;+ let _ = socket.write_all(slice).await;+ } else {+ let resp = format!(+ "HTTP/1.1 200 OK\r\nAccept-Ranges: bytes\r\nContent-Length: {total}\r\nConnection: close\r\n\r\n"+ );+ let _ = socket.write_all(resp.as_bytes()).await;+ }+ });+ }+ });++ let temp_dir = std::env::temp_dir().join(format!("mbx_seg_inplace_{}", std::process::id()));+ tokio::fs::create_dir_all(&temp_dir).await.unwrap();+ let dest_file = temp_dir.join("movie.mp4");+ let client = crate::net::streaming_client_builder().build().unwrap();+ let cancel = Arc::new(AtomicBool::new(false));+ let mut max_workers = 0usize;++ let part_file = sidecar_path(&dest_file, "part");+ let meta_file = sidecar_path(&dest_file, "part.json");+ let seg_len = (total_size / 4) as u64;+ let mut pre_buf = vec![0u8; total_size];+ pre_buf[..seg_len as usize].copy_from_slice(&payload[..seg_len as usize]);+ tokio::fs::write(&part_file, &pre_buf).await.unwrap();+ write_metadata(+ &meta_file,+ &ResumeMetadata {+ etag: None,+ last_modified: None,+ total: Some(total_size as u64),+ segments: Some(4),+ segment_progress: vec![seg_len, 0, 0, 0],+ },+ )+ .await+ .unwrap();+ let res = download(&client, &url, &dest_file, cancel, |prog| {+ max_workers = max_workers.max(prog.workers);+ })+ .await;++ server.abort();+ assert!(+ matches!(res, Ok(DownloadOutcome::Completed { bytes }) if bytes == total_size as u64)+ );+ assert_eq!(max_workers, 4);+ let saved = tokio::fs::read(&dest_file).await.unwrap();+ assert_eq!(saved.len(), total_size);+ assert_eq!(saved, *payload);+ assert!(!sidecar_path(&dest_file, "part").exists());+ assert!(!sidecar_path(&dest_file, "part.json").exists());++ let _ = tokio::fs::remove_dir_all(&temp_dir).await;+ }+#[test]fn test_safe_file_stem_empty_fallback() {assert_eq!(safe_file_stem(""), DEFAULT_STREAM_NAME);diff --git a/src/tui/app/download.rs b/src/tui/app/download.rsindex 0de7d14..235bdb4 100644--- a/src/tui/app/download.rs+++ b/src/tui/app/download.rs@@ -278,7 +278,9 @@ impl App {.arg("--newline").arg("--part").arg("--concurrent-fragments")- .arg("5")+ .arg("8")+ .arg("--http-chunk-size")+ .arg("95K").arg("--fragment-retries").arg("10").arg("--retries")diff --git a/src/tui/screens/details.rs b/src/tui/screens/details.rsindex 1634ab2..a5f48a6 100644--- a/src/tui/screens/details.rs+++ b/src/tui/screens/details.rs@@ -348,22 +348,46 @@ pub fn draw(frame: &mut Frame, area: Rect, state: &mut AppState, theme: &Theme)let error_block = Block::default().borders(Borders::ALL).border_type(crate::tui::overlay::border_type(state.basic_terminal))- .border_style(theme.error)+ .border_style(if modal_active {+ theme.muted+ } else {+ theme.error+ }).title(Line::from(vec![Span::styled(" Error Loading Details ",- theme.error.add_modifier(Modifier::BOLD),+ if modal_active {+ theme.muted+ } else {+ theme.error.add_modifier(Modifier::BOLD)+ },)]));let err_msg =crate::tui::text::truncate_width(err, (box_width.saturating_sub(4)) as usize);let mut text = vec![Line::from(""),- Line::from(Span::styled(err_msg, theme.text)),+ Line::from(Span::styled(+ err_msg,+ if modal_active {+ theme.muted+ } else {+ theme.text+ },+ )),Line::from(""),];- let mut hint_spans = crate::tui::overlay::key_hint("r", "Retry", theme);- hint_spans.push(Span::raw(" "));- hint_spans.extend(crate::tui::overlay::key_hint("Esc", "Back", theme));+ let hint_spans = if modal_active {+ vec![+ Span::styled("[r] Retry", theme.muted),+ Span::raw(" "),+ Span::styled("[Esc] Back", theme.muted),+ ]+ } else {+ let mut s = crate::tui::overlay::key_hint("r", "Retry", theme);+ s.push(Span::raw(" "));+ s.extend(crate::tui::overlay::key_hint("Esc", "Back", theme));+ s+ };text.push(Line::from(hint_spans));let error_p = Paragraph::new(text)@@ -385,7 +409,16 @@ pub fn draw(frame: &mut Frame, area: Rect, state: &mut AppState, theme: &Theme)]).split(area);- let loading_spans = if state.basic_terminal {+ let loading_spans = if modal_active {+ vec![Span::styled(+ if state.basic_terminal {+ format!("Loading details {spinner}")+ } else {+ format!("{spinner} Loading details...")+ },+ theme.muted,+ )]+ } else if state.basic_terminal {vec![Span::styled(format!("Loading details {spinner}"),theme.lavender,@@ -578,6 +611,7 @@ pub fn draw(frame: &mut Frame, area: Rect, state: &mut AppState, theme: &Theme)state.basic_terminal,is_in_flight,state.tick_count,+ modal_active,);}@@ -591,7 +625,7 @@ pub fn draw(frame: &mut Frame, area: Rect, state: &mut AppState, theme: &Theme)let mut rendered_lines: Vec<Line> = Vec::new();let title_style = if modal_active {- theme.overlay0.add_modifier(Modifier::BOLD)+ theme.muted} else {theme.title.add_modifier(Modifier::BOLD)};@@ -1425,8 +1459,12 @@ pub fn draw(frame: &mut Frame, area: Rect, state: &mut AppState, theme: &Theme)let codec_str = codec.to_uppercase();let tags = extract_media_tags(&file.filename, &codec_str);- let media_tag_spans =- crate::tui::widgets::render_media_tag_spans(&tags, theme, state.basic_terminal);+ let media_tag_spans = crate::tui::widgets::render_media_tag_spans(+ &tags,+ theme,+ state.basic_terminal,+ modal_active,+ );let tags_cell = if !media_tag_spans.is_empty() {Cell::from(ratatui::text::Line::from(media_tag_spans))} else if codec != "None" && !codec.is_empty() {@@ -3471,8 +3509,8 @@ mod tests {{assert_eq!(cell.style().fg,- theme.overlay1.fg,- "Multi badge foreground should be overlay1"+ theme.muted.fg,+ "Multi badge foreground should be muted");}if cell.symbol() == "H" && x + 4 < 120 && buffer[(x + 1, y)].symbol() == "i" {diff --git a/src/tui/screens/home.rs b/src/tui/screens/home.rsindex 60db848..327ba8b 100644--- a/src/tui/screens/home.rs+++ b/src/tui/screens/home.rs@@ -174,6 +174,7 @@ fn render_search_state(" • "};+ let modal_active = state.has_active_modal();let mut lines: Vec<Line> = Vec::new();match view {@@ -195,7 +196,14 @@ fn render_search_state(} else {format!("Loading{dots}")};- lines.push(Line::from(vec![Span::styled(text, theme.lavender)]));+ lines.push(Line::from(vec![Span::styled(+ text,+ if modal_active {+ theme.muted+ } else {+ theme.lavender+ },+ )]));} else {let spinner =crate::tui::widgets::loading_spinner(state.tick_count, state.basic_terminal);@@ -214,10 +222,21 @@ fn render_search_state(lines.push(Line::from(vec![Span::styled(format!("{spinner} "),- theme.accent.add_modifier(Modifier::BOLD),+ if modal_active {+ theme.muted+ } else {+ theme.accent.add_modifier(Modifier::BOLD)+ },),Span::raw(" "),- Span::styled(text, theme.subtext1.add_modifier(Modifier::BOLD)),+ Span::styled(+ text,+ if modal_active {+ theme.muted+ } else {+ theme.subtext1.add_modifier(Modifier::BOLD)+ },+ ),]));}}@@ -241,7 +260,11 @@ fn render_search_state(};lines.push(Line::from(vec![Span::styled(msg,- theme.text.add_modifier(Modifier::BOLD),+ if modal_active {+ theme.muted+ } else {+ theme.text.add_modifier(Modifier::BOLD)+ },)]));lines.push(Line::from(""));@@ -249,6 +272,16 @@ fn render_search_state(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");+ let sub_s = if modal_active {+ theme.muted+ } else {+ theme.subtext1+ };+ let key_s = if modal_active {+ theme.muted+ } else {+ theme.shortcut+ };let pills = if is_history_or_fav {vec![]} else if state.is_tv_mode {@@ -258,9 +291,9 @@ fn render_search_state("[ Clear Search ("};vec![- Span::styled(btn_label, theme.subtext1),- Span::styled("c", theme.shortcut),- Span::styled(") ]", theme.subtext1),+ Span::styled(btn_label, sub_s),+ Span::styled("c", key_s),+ Span::styled(") ]", sub_s),]} else {let btn2_label = if is_compact_btn {@@ -274,13 +307,13 @@ fn render_search_state(format!("[ Try on {} (", next_provider.label())};vec![- Span::styled(btn1_label, theme.subtext1),- Span::styled(ctrl_p, theme.shortcut),- Span::styled(") ]", theme.subtext1),+ Span::styled(btn1_label, sub_s),+ Span::styled(ctrl_p, key_s),+ Span::styled(") ]", sub_s),Span::raw(sep),- Span::styled(btn2_label, theme.subtext1),- Span::styled("c", theme.shortcut),- Span::styled(") ]", theme.subtext1),+ Span::styled(btn2_label, sub_s),+ Span::styled("c", key_s),+ Span::styled(") ]", sub_s),]};@@ -300,39 +333,61 @@ fn render_search_state(let wrap_width = area.width.min(72).saturating_sub(8).max(10) as usize;let wrapped_err_lines = crate::tui::text::wrap_text(err_text, wrap_width);+ let err_s = if modal_active {+ theme.muted+ } else {+ theme.error+ };+ let err_bold_s = if modal_active {+ theme.muted+ } else {+ theme.error.add_modifier(Modifier::BOLD)+ };+ let sub_s = if modal_active {+ theme.muted+ } else {+ theme.subtext1+ };+ let dim_s = if modal_active {+ theme.muted+ } else {+ theme.text_dim+ };+ let key_s = if modal_active {+ theme.muted+ } else {+ theme.shortcut+ };lines.push(Line::from(vec![- Span::styled(format!("{symbol} "), theme.error),- Span::styled(- "Search Request Error",- theme.error.add_modifier(Modifier::BOLD),- ),+ Span::styled(format!("{symbol} "), err_s),+ Span::styled("Search Request Error", err_bold_s),]));if !wrapped_err_lines.is_empty() {for eline in wrapped_err_lines {- lines.push(Line::from(vec![Span::styled(eline, theme.subtext1)]));+ lines.push(Line::from(vec![Span::styled(eline, sub_s)]));}} else {lines.push(Line::from(vec![Span::styled("Unable to complete search request with the current provider.",- theme.subtext1,+ sub_s,)]));}lines.push(Line::from(""));lines.push(Line::from(vec![- Span::styled("[", theme.text_dim),- Span::styled("r", theme.shortcut),- Span::styled("] ", theme.text_dim),- Span::styled("Retry", theme.subtext1),- Span::styled(bullet, theme.text_dim),- Span::styled("[", theme.text_dim),- Span::styled(ctrl_p, theme.shortcut),- Span::styled("] ", theme.text_dim),- Span::styled("Switch Provider", theme.subtext1),- Span::styled(bullet, theme.text_dim),- Span::styled("[", theme.text_dim),- Span::styled("Esc", theme.shortcut),- Span::styled("] ", theme.text_dim),- Span::styled("Back", theme.subtext1),+ Span::styled("[", dim_s),+ Span::styled("r", key_s),+ Span::styled("] ", dim_s),+ Span::styled("Retry", sub_s),+ Span::styled(bullet, dim_s),+ Span::styled("[", dim_s),+ Span::styled(ctrl_p, key_s),+ Span::styled("] ", dim_s),+ Span::styled("Switch Provider", sub_s),+ Span::styled(bullet, dim_s),+ Span::styled("[", dim_s),+ Span::styled("Esc", key_s),+ Span::styled("] ", dim_s),+ Span::styled("Back", sub_s),]));}_ => return,@@ -357,11 +412,15 @@ fn render_search_state(};if is_boxed && card.height >= 3 {- let (border_style, title_text, title_style) = (- theme.error,- " Error ",- theme.error.add_modifier(Modifier::BOLD),- );+ let (border_style, title_text, title_style) = if modal_active {+ (theme.muted, " Error ", theme.muted)+ } else {+ (+ theme.error,+ " Error ",+ theme.error.add_modifier(Modifier::BOLD),+ )+ };let block = Block::default().borders(Borders::ALL).border_type(crate::tui::overlay::border_type(state.basic_terminal))@@ -696,7 +755,9 @@ pub(crate) fn render_landing_deck(frame: &mut Frame, area: Rect, state: &AppStatcrate::tui::state::HomeDeckTab::Favorites => "/favorites",};let pill_text = format!("+{overflow} more {sep} {cmd}");- let pill_style = if state.basic_terminal {+ let pill_style = if modal_active {+ theme.muted+ } else if state.basic_terminal {theme.sapphire} else {theme.sapphire.add_modifier(Modifier::BOLD)@@ -924,11 +985,7 @@ fn render_search_bar(let sep = if state.basic_terminal { "-" } else { "·" };format!("[{label} {sep} {ctrl_p}]")};- let style = if state.basic_terminal {- theme.muted- } else {- theme.muted.add_modifier(Modifier::BOLD)- };+ let style = theme.muted;(text, style)} else if modal_active {let text = if !is_query_empty {@@ -1138,8 +1195,9 @@ fn render_search_bar(]).split(area);+ let modal_active = state.has_active_modal();let editing = view == SearchViewState::Editing;- let real_cursor = editing && !state.basic_terminal;+ let real_cursor = editing && !state.basic_terminal && !modal_active;let has_status = state.status_timer > 0&& !state.status_message.is_empty()&& state.search_query.is_empty()@@ -1155,7 +1213,12 @@ fn render_search_bar(dynamic_search_placeholder(state)};- if has_status {+ if modal_active {+ Line::from(vec![+ Span::styled(prefix, theme.muted),+ Span::styled(placeholder_text, theme.muted),+ ])+ } else if has_status {Line::from(vec![Span::styled(prefix, theme.accent),Span::styled(placeholder_text, theme.accent),@@ -1173,6 +1236,11 @@ fn render_search_bar(Span::styled(placeholder_text, theme.text_dim),])}+ } else if modal_active {+ Line::from(vec![+ Span::styled(prefix, theme.muted),+ Span::styled(state.search_query.as_str(), theme.muted),+ ])} else {Line::from(vec![Span::styled(prefix, if editing { theme.accent } else { theme.text }),@@ -1200,7 +1268,11 @@ fn render_search_bar(if let Some(status) = result_status {frame.render_widget(Paragraph::new(status)- .style(theme.accent)+ .style(if modal_active {+ theme.muted+ } else {+ theme.accent+ }).alignment(Alignment::Right),content_row[1],);@@ -1555,6 +1627,7 @@ pub fn draw(frame: &mut Frame, area: Rect, state: &mut AppState, theme: &Theme)state.basic_terminal,is_in_flight,state.tick_count,+ modal_active,);}} else if poster_area.width > 0 {@@ -1565,6 +1638,7 @@ pub fn draw(frame: &mut Frame, area: Rect, state: &mut AppState, theme: &Theme)state.basic_terminal,false,state.tick_count,+ modal_active,);}@@ -1723,16 +1797,26 @@ pub fn draw(frame: &mut Frame, area: Rect, state: &mut AppState, theme: &Theme)let mut row3_spans = vec![ratatui::text::Span::raw(" ")];if is_history {+ let hist_text_style = if modal_active {+ theme.muted+ } else {+ theme.text+ };+ let hist_dim_style = if modal_active {+ theme.muted+ } else {+ theme.text_dim+ };if !type_tag.is_empty() {- row2_spans.push(ratatui::text::Span::styled(&type_tag, theme.text));- row2_spans.push(ratatui::text::Span::styled(" ", theme.text_dim));+ row2_spans.push(ratatui::text::Span::styled(&type_tag, hist_text_style));+ row2_spans.push(ratatui::text::Span::styled(" ", hist_dim_style));}if res.season > 0 {row2_spans.push(ratatui::text::Span::styled(format!("S{:02}E{:02}", res.season, res.episode),- theme.text,+ hist_text_style,));- row2_spans.push(ratatui::text::Span::styled(" ", theme.text_dim));+ row2_spans.push(ratatui::text::Span::styled(" ", hist_dim_style));}if let Some(hist) = state.history.get_item(@@ -1744,36 +1828,38 @@ pub fn draw(frame: &mut Frame, area: Rect, state: &mut AppState, theme: &Theme)) {if hist.is_in_progress() {let (filled, empty) = hist.progress_bar_parts(8);+ let filled_style = if modal_active {+ theme.muted+ } else {+ theme.accent.add_modifier(ratatui::style::Modifier::BOLD)+ };let mut progress_spans = vec![- ratatui::text::Span::styled(- filled,- theme.accent.add_modifier(ratatui::style::Modifier::BOLD),- ),- ratatui::text::Span::styled(empty, theme.text_dim),+ ratatui::text::Span::styled(filled, filled_style),+ ratatui::text::Span::styled(empty, hist_dim_style),];let pct = hist.progress_percentage().map(|p| format!(" {:.0}%", p)).unwrap_or_default();- progress_spans.push(ratatui::text::Span::styled(pct, theme.text));+ progress_spans.push(ratatui::text::Span::styled(pct, hist_text_style));if let Some(r) = hist.formatted_remaining() {progress_spans.push(ratatui::text::Span::styled(format!(" ({r})"),- theme.text_dim,+ hist_dim_style,));}if use_three_rows {row3_spans.extend(progress_spans);- row3_spans.push(ratatui::text::Span::styled(" ", theme.text_dim));+ row3_spans.push(ratatui::text::Span::styled(" ", hist_dim_style));row3_spans.push(ratatui::text::Span::styled(format!("Watched {}", hist.formatted_relative_time()),- theme.text_dim,+ hist_dim_style,));} else {row2_spans.extend(progress_spans);- row2_spans.push(ratatui::text::Span::styled(" ", theme.text_dim));+ row2_spans.push(ratatui::text::Span::styled(" ", hist_dim_style));}} else if hist.completed {let comp_span = ratatui::text::Span::styled(@@ -1782,18 +1868,18 @@ pub fn draw(frame: &mut Frame, area: Rect, state: &mut AppState, theme: &Theme)} else {"[✓ Completed]"},- theme.text_dim,+ hist_dim_style,);if use_three_rows {row3_spans.push(comp_span);- row3_spans.push(ratatui::text::Span::styled(" ", theme.text_dim));+ row3_spans.push(ratatui::text::Span::styled(" ", hist_dim_style));row3_spans.push(ratatui::text::Span::styled(format!("Watched {}", hist.formatted_relative_time()),- theme.text_dim,+ hist_dim_style,));} else {row2_spans.push(comp_span);- row2_spans.push(ratatui::text::Span::styled(" ", theme.text_dim));+ row2_spans.push(ratatui::text::Span::styled(" ", hist_dim_style));}}}@@ -1811,9 +1897,30 @@ pub fn draw(frame: &mut Frame, area: Rect, state: &mut AppState, theme: &Theme).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));+ row2_spans.push(ratatui::text::Span::styled(+ star,+ if modal_active {+ theme.muted+ } else {+ theme.rating+ },+ ));+ row2_spans.push(ratatui::text::Span::styled(+ r,+ if modal_active {+ theme.muted+ } else {+ theme.text+ },+ ));+ row2_spans.push(ratatui::text::Span::styled(+ " ",+ if modal_active {+ theme.muted+ } else {+ theme.text_dim+ },+ ));}let has_year = res.release_year != "Unknown" && !res.release_year.is_empty();if has_year {@@ -1859,15 +1966,28 @@ pub fn draw(frame: &mut Frame, area: Rect, state: &mut AppState, theme: &Theme)if is_selected {let genre_buf = meta.genres.join(", ");if !genre_buf.is_empty() {- row3_spans.push(ratatui::text::Span::styled(" ", theme.text_dim));+ row3_spans.push(ratatui::text::Span::styled(+ " ",+ if modal_active {+ theme.muted+ } else {+ theme.text_dim+ },+ ));let available_w = (text_area.width as usize).saturating_sub(crate::tui::text::width(res.provider.label()) + 6,);let g_trunc =crate::tui::text::truncate_width(&genre_buf, available_w).into_owned();- row3_spans- .push(ratatui::text::Span::styled(g_trunc, theme.subtext1));+ row3_spans.push(ratatui::text::Span::styled(+ g_trunc,+ if modal_active {+ theme.muted+ } else {+ theme.subtext1+ },+ ));}}} else if is_selected && state.preview_loading {@@ -1877,10 +1997,15 @@ pub fn draw(frame: &mut Frame, area: Rect, state: &mut AppState, theme: &Theme)2 => "..",_ => "...",};- row3_spans.push(ratatui::text::Span::styled(" ", theme.text_dim));+ let load_style = if modal_active {+ theme.muted+ } else {+ theme.text_dim+ };+ row3_spans.push(ratatui::text::Span::styled(" ", load_style));row3_spans.push(ratatui::text::Span::styled(format!("Loading{dots}"),- theme.text_dim,+ load_style,));}}diff --git a/src/tui/widgets/badge.rs b/src/tui/widgets/badge.rsindex 524701f..167f822 100644--- a/src/tui/widgets/badge.rs+++ b/src/tui/widgets/badge.rs@@ -56,7 +56,7 @@ pub fn resolution_badge_spans<'a>(_ => " SD ",};let badge_bg = theme.surface0_color();- let contrast_fg = theme.overlay1.fg.unwrap_or(theme.base);+ let contrast_fg = theme.muted.fg.unwrap_or(theme.base);return vec![Span::styled(label, Style::default().bg(badge_bg).fg(contrast_fg)),Span::raw(" "),@@ -358,29 +358,44 @@ pub fn render_media_tag_spans<'a>(tags: &MediaTags,theme: &'a Theme,basic_terminal: bool,+ modal_active: bool,) -> Vec<Span<'a>> {let mut tag_items = Vec::new();if let Some(hdr) = tags.hdr {- tag_items.push(Span::styled(hdr, theme.rating.add_modifier(Modifier::BOLD)));+ let style = if modal_active {+ theme.muted+ } else {+ theme.rating.add_modifier(Modifier::BOLD)+ };+ tag_items.push(Span::styled(hdr, style));}if let Some(audio) = tags.audio {- tag_items.push(Span::styled(- audio,- theme.sapphire.add_modifier(Modifier::BOLD),- ));+ let style = if modal_active {+ theme.muted+ } else {+ theme.sapphire.add_modifier(Modifier::BOLD)+ };+ tag_items.push(Span::styled(audio, style));}if let Some(codec) = tags.codec {- tag_items.push(Span::styled(codec, theme.teal.add_modifier(Modifier::BOLD)));+ let style = if modal_active {+ theme.muted+ } else {+ theme.teal.add_modifier(Modifier::BOLD)+ };+ tag_items.push(Span::styled(codec, style));}if let Some(source) = tags.source {- tag_items.push(Span::styled(- source,- theme.lavender.add_modifier(Modifier::BOLD),- ));+ let style = if modal_active {+ theme.muted+ } else {+ theme.lavender.add_modifier(Modifier::BOLD)+ };+ tag_items.push(Span::styled(source, style));}if tag_items.is_empty() {@@ -389,10 +404,15 @@ pub fn render_media_tag_spans<'a>(let mut spans = Vec::new();let sep = if basic_terminal { " - " } else { " · " };+ let sep_style = if modal_active {+ theme.muted+ } else {+ theme.text_dim+ };for (i, tag_span) in tag_items.into_iter().enumerate() {if i > 0 {- spans.push(Span::styled(sep, theme.text_dim));+ spans.push(Span::styled(sep, sep_style));}spans.push(tag_span);}@@ -450,7 +470,7 @@ mod tests {assert_eq!(basic_multi[0].content.trim(), "[Multi]");let muted_multi = resolution_badge_spans(-1, &theme, false, true, false);- assert_eq!(muted_multi[0].style.fg, theme.overlay1.fg);+ assert_eq!(muted_multi[0].style.fg, theme.muted.fg);let muted_basic = resolution_badge_spans(-1, &theme, true, true, false);assert_eq!(muted_basic[0].style.fg, theme.muted.fg);}@@ -500,9 +520,15 @@ mod tests {codec: Some("HEVC"),source: Some("WEB-DL"),};- let spans = render_media_tag_spans(&tags, &theme, false);+ let spans = render_media_tag_spans(&tags, &theme, false, false);assert_eq!(spans.len(), 8);- let basic_spans = render_media_tag_spans(&tags, &theme, true);+ assert_eq!(spans[0].style.fg, theme.rating.fg);+ let muted_spans = render_media_tag_spans(&tags, &theme, false, true);+ for span in muted_spans.iter().take(7) {+ assert_eq!(span.style.fg, theme.muted.fg);+ assert!(!span.style.add_modifier.contains(Modifier::BOLD));+ }+ let basic_spans = render_media_tag_spans(&tags, &theme, true, false);assert_eq!(basic_spans[0].content, "HDR");}#[test]diff --git a/src/tui/widgets/poster.rs b/src/tui/widgets/poster.rsindex addf3a2..47ad768 100644--- a/src/tui/widgets/poster.rs+++ b/src/tui/widgets/poster.rs@@ -13,12 +13,15 @@ pub fn render_poster_placeholder(basic_terminal: bool,is_in_flight: bool,tick: u64,+ modal_active: bool,) {if area.width < 2 || area.height < 2 {return;}let border_type = crate::tui::overlay::border_type(basic_terminal);- let border_style = if is_in_flight {+ let border_style = if modal_active {+ theme.muted+ } else if is_in_flight {theme.lavender} else {theme.surface1@@ -50,7 +53,11 @@ pub fn render_poster_placeholder(_ => "····",};let p = Paragraph::new(dots)- .style(theme.lavender)+ .style(if modal_active {+ theme.muted+ } else {+ theme.lavender+ }).alignment(Alignment::Center);frame.render_widget(p, text_area);} else {@@ -62,7 +69,11 @@ pub fn render_poster_placeholder("·"};let p = Paragraph::new(label)- .style(theme.overlay0)+ .style(if modal_active {+ theme.muted+ } else {+ theme.overlay0+ }).alignment(Alignment::Center);frame.render_widget(p, text_area);}@@ -81,14 +92,14 @@ mod tests {terminal.draw(|f| {- render_poster_placeholder(f, Rect::new(0, 0, 1, 1), &theme, false, false, 0);+ render_poster_placeholder(f, Rect::new(0, 0, 1, 1), &theme, false, false, 0, false);}).unwrap();terminal.draw(|f| {- render_poster_placeholder(f, Rect::new(0, 0, 15, 8), &theme, false, true, 4);- render_poster_placeholder(f, Rect::new(0, 0, 15, 8), &theme, true, false, 0);+ render_poster_placeholder(f, Rect::new(0, 0, 15, 8), &theme, false, true, 4, false);+ render_poster_placeholder(f, Rect::new(0, 0, 15, 8), &theme, true, false, 0, true);}).unwrap();}