Skip to content

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

fix(ui): Eliminate 4-sided background halo artifact on search suggestions dropdown

Samir Hossainsdff5f71cd264
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d1b25c5..d7d6dd5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,6 +3,7 @@
## [Unreleased]
### Fixed
+- **Search suggestions background halo artifact**: Suppressed landing favorites background rendering when search suggestions are active and cleanly aligned dropdown container bounds, eliminating 4-sided dark shadow artifacts around suggestion borders.
- **Search Suggestions Overlay Bleed**: Wrapped search suggestions in an elevated, bordered card with opaque background clearing (`theme.surface0`), and gated terminal graphics poster rendering while typing suggestions, eliminating text and image collisions over background search results.
- **Season Download Stream Error Recovery**: Prevented download queue stalls when resolving individual episode stream URLs fails; failed streams report diagnostics and allow the remaining queue to continue.
- **Favorites & Watch History Corruption Recovery**: Corrupted JSON configuration and history state files now rotate to `.corrupt` backups instead of hard deletion, preserving recoverable user data.
diff --git a/src/tui/app/mouse.rs b/src/tui/app/mouse.rs
index 559df4e..d6dda74 100644
--- a/src/tui/app/mouse.rs
+++ b/src/tui/app/mouse.rs
@@ -393,37 +393,17 @@ impl App {
let search_width =
crate::tui::screens::home::search_deck_width(area, &self.state, is_landing);
- let search_bar_area = if is_landing {
- let (tier, rows) = crate::tui::screens::home::landing_split(
+ let landing_layout = if is_landing {
+ Some(crate::tui::screens::home::landing_split(
area,
self.state.is_tv_mode,
self.state.basic_terminal,
- );
- let compact = tier.is_compact();
-
- if row == rows.rects[rows.mode_row].y {
- if compact {
- let util_split = area.width.saturating_sub(19);
- if col < util_split {
- self.handle_home_mode_click(col, util_split, true);
- } else {
- self.handle_home_util_click(col.saturating_sub(util_split), 19, true);
- }
- } else {
- self.handle_home_mode_click(col, area.width, false);
- }
- return None;
- }
- if rows.util_row.is_some() && row == rows.rects[rows.util_row.unwrap()].y {
- self.handle_home_util_click(col, area.width, false);
- return None;
- }
- if self.state.favorites_landing_visible()
- && self.handle_favorites_landing_click(col, row, rows.rects[rows.favorites])
- {
- return None;
- }
+ ))
+ } else {
+ None
+ };
+ let search_bar_area = if let Some((_, ref rows)) = landing_layout {
centered_width_rect(rows.rects[rows.search], search_width)
} else {
let chunks = Layout::default()
@@ -442,7 +422,6 @@ impl App {
height: chunks[0].height,
}
};
-
if self.state.input_mode == InputMode::Editing && !self.state.search_suggestions.is_empty()
{
let visible_count = self.state.search_suggestions.len().min(6);
@@ -493,6 +472,33 @@ impl App {
}
}
+ if let Some((tier, rows)) = landing_layout {
+ let compact = tier.is_compact();
+
+ if row == rows.rects[rows.mode_row].y {
+ if compact {
+ let util_split = area.width.saturating_sub(19);
+ if col < util_split {
+ self.handle_home_mode_click(col, util_split, true);
+ } else {
+ self.handle_home_util_click(col.saturating_sub(util_split), 19, true);
+ }
+ } else {
+ self.handle_home_mode_click(col, area.width, false);
+ }
+ return None;
+ }
+ if rows.util_row.is_some() && row == rows.rects[rows.util_row.unwrap()].y {
+ self.handle_home_util_click(col, area.width, false);
+ return None;
+ }
+ if self.state.favorites_landing_visible()
+ && self.handle_favorites_landing_click(col, row, rows.rects[rows.favorites])
+ {
+ return None;
+ }
+ }
+
if row >= search_bar_area.y && row < search_bar_area.y + search_bar_area.height {
self.state.input_mode = InputMode::Editing;
self.state.favorites_focus = false;
diff --git a/src/tui/screens/home.rs b/src/tui/screens/home.rs
index 43393cd..bdd4f51 100644
--- a/src/tui/screens/home.rs
+++ b/src/tui/screens/home.rs
@@ -1838,7 +1838,7 @@ fn suggestion_source_badge<'a>(
}
pub fn search_suggestions_bounds(area: Rect, search_bar_area: Rect, count: usize) -> (Rect, Rect) {
- if count == 0 || search_bar_area.width == 0 {
+ if count == 0 || search_bar_area.width == 0 || area.width == 0 || area.height == 0 {
return (Rect::default(), Rect::default());
}
@@ -1846,14 +1846,18 @@ pub fn search_suggestions_bounds(area: Rect, search_bar_area: Rect, count: usize
let max_h = area.bottom().saturating_sub(start_y);
let container_h = ((count as u16).saturating_add(2)).min(max_h);
- let max_w = area
- .right()
- .saturating_sub(search_bar_area.x)
- .saturating_sub(1);
- let container_w = search_bar_area.width.max(48).min(max_w);
+ let is_centered = search_bar_area.x > area.x;
+ let container_w = search_bar_area.width.min(area.width);
+ let x = if is_centered {
+ search_bar_area.x + search_bar_area.width.saturating_sub(container_w) / 2
+ } else {
+ search_bar_area
+ .x
+ .min(area.right().saturating_sub(container_w))
+ };
let container_area = Rect {
- x: search_bar_area.x,
+ x,
y: start_y,
width: container_w,
height: container_h,
@@ -2088,6 +2092,50 @@ mod tests {
assert!(!rendered.contains('└'));
}
+ #[test]
+ fn test_landing_draw_hides_favorites_when_suggestions_open() {
+ let backend = TestBackend::new(90, 24);
+ let mut terminal = Terminal::new(backend).unwrap();
+ let mut state = AppState {
+ input_mode: InputMode::Editing,
+ streaming_enabled: true,
+ search_suggestions: vec!["/help".to_string(), "Inception".to_string()],
+ suggest_index: Some(0),
+ ..Default::default()
+ };
+ state.favorites.items.push(crate::favorites::FavoriteItem {
+ provider: "moviebox".to_string(),
+ subject_id: "fav-1".to_string(),
+ title: "Secret Favorite Movie".to_string(),
+ cover_url: None,
+ stype: 1,
+ release_year: "2024".to_string(),
+ added_at: 0,
+ });
+ let theme = Theme::mocha();
+
+ terminal
+ .draw(|frame| {
+ let area = Rect::new(0, 0, 90, 24);
+ draw(frame, area, &mut state, &theme);
+ })
+ .unwrap();
+
+ let buffer = terminal.backend().buffer();
+ let mut rendered = String::new();
+ for y in 0..24 {
+ for x in 0..90 {
+ rendered.push_str(buffer[(x, y)].symbol());
+ }
+ rendered.push('\n');
+ }
+
+ assert!(rendered.contains("help"));
+ assert!(rendered.contains("Inception"));
+ assert!(!rendered.contains("Favorites"));
+ assert!(!rendered.contains("Secret Favorite Movie"));
+ }
+
#[test]
fn test_search_suggestions_bounds() {
let area = Rect::new(0, 0, 80, 24);
diff --git a/src/tui/state.rs b/src/tui/state.rs
index 4bf7194..c111a98 100644
--- a/src/tui/state.rs
+++ b/src/tui/state.rs
@@ -593,7 +593,9 @@ impl AppState {
}
pub fn favorites_landing_visible(&self) -> bool {
- self.favorites_available() && !self.favorites.items.is_empty()
+ self.favorites_available()
+ && !self.favorites.items.is_empty()
+ && !(self.input_mode == InputMode::Editing && !self.search_suggestions.is_empty())
}
pub fn favorites_landing_items(&self) -> Vec<&crate::favorites::FavoriteItem> {
@@ -819,4 +821,33 @@ mod tests {
assert!(!state.has_active_modal());
}
+
+ #[test]
+ fn test_favorites_landing_visible_conditions() {
+ let mut state = AppState::default();
+ state.favorites.items.clear();
+ state.streaming_enabled = true;
+ assert!(!state.favorites_landing_visible());
+ state.favorites.items.push(crate::favorites::FavoriteItem {
+ provider: "moviebox".to_string(),
+ subject_id: "fav-1".to_string(),
+ title: "Favorite Movie".to_string(),
+ cover_url: None,
+ stype: 1,
+ release_year: "2024".to_string(),
+ added_at: 0,
+ });
+ assert!(state.favorites_landing_visible());
+
+ state.input_mode = InputMode::Editing;
+ state.search_suggestions = vec!["suggestion".to_string()];
+ assert!(!state.favorites_landing_visible());
+
+ state.search_suggestions.clear();
+ assert!(state.favorites_landing_visible());
+
+ state.search_suggestions = vec!["suggestion".to_string()];
+ state.input_mode = InputMode::Normal;
+ assert!(state.favorites_landing_visible());
+ }
}