diff options
| author | Can Celik <ogulcancelik@gmail.com> | 2026-08-14 05:01:12 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-08-14 05:01:12 +0300 |
| commit | d2c317adc4b5fd73a7054d74f92d633a31069391 (patch) | |
| tree | c3db5184138d7eaaff9be05049d120a727a4e128 /src/ui | |
| parent | 1af1a5b86f642ae7b053037bc472913cfbc1e206 (diff) | |
fix: keep active sidebar rows visible (#2794)
refs #2792
Diffstat (limited to 'src/ui')
| -rw-r--r-- | src/ui/sidebar.rs | 55 | ||||
| -rw-r--r-- | src/ui/tab_surface.rs | 2 |
2 files changed, 43 insertions, 14 deletions
diff --git a/src/ui/sidebar.rs b/src/ui/sidebar.rs index bc294cfe..252fc507 100644 --- a/src/ui/sidebar.rs +++ b/src/ui/sidebar.rs @@ -790,14 +790,14 @@ pub(super) fn render_sidebar_collapsed(app: &AppState, frame: &mut Frame, area: let row_style = if is_selected { Style::default().bg(p.surface0) } else if is_active { - Style::default().bg(p.surface_dim) + Style::default().bg(p.active_row_bg) } else { Style::default() }; let num_style = if is_selected { Style::default().fg(p.overlay1).bg(p.surface0) } else if is_active { - Style::default().fg(p.text).bg(p.surface_dim) + Style::default().fg(p.text).bg(p.active_row_bg) } else { Style::default().fg(p.overlay0) }; @@ -846,7 +846,7 @@ pub(super) fn render_sidebar_collapsed(app: &AppState, frame: &mut Frame, area: let position = detail_idx + 1; let is_active = app.is_active_pane(detail.ws_idx, detail.tab_idx, detail.pane_id); let position_style = if is_active { - Style::default().fg(p.text).bg(p.surface_dim) + Style::default().fg(p.text).bg(p.active_row_bg) } else { Style::default().fg(p.overlay0) }; @@ -856,7 +856,7 @@ pub(super) fn render_sidebar_collapsed(app: &AppState, frame: &mut Frame, area: if is_active { let buf = frame.buffer_mut(); for x in detail_content_area.x..detail_content_area.x + detail_content_area.width { - buf[(x, y)].set_style(Style::default().bg(p.surface_dim)); + buf[(x, y)].set_style(Style::default().bg(p.active_row_bg)); } } @@ -1252,7 +1252,7 @@ fn render_workspace_list( } else if is_dragged { p.surface1 } else { - p.surface_dim + p.active_row_bg }; let buf = frame.buffer_mut(); for y in row_y..row_y + row_height { @@ -1493,7 +1493,7 @@ fn render_agent_detail( let is_active = app.is_active_pane(detail.ws_idx, detail.tab_idx, detail.pane_id); let row_style = if is_active { - Style::default().bg(p.surface_dim) + Style::default().bg(p.active_row_bg) } else { Style::default() }; @@ -1677,14 +1677,14 @@ mod tests { assert_eq!(workspace_style.fg, Some(app.palette.text)); assert!(workspace_style.add_modifier.contains(Modifier::BOLD)); assert!(!workspace_style.add_modifier.contains(Modifier::DIM)); - assert_eq!(workspace_style.bg, Some(app.palette.surface_dim)); + assert_eq!(workspace_style.bg, Some(app.palette.active_row_bg)); let agent_x = find_symbol_x(buffer, body.y + 1, body.width, "p"); let agent_style = buffer[(agent_x, body.y + 1)].style(); assert_eq!(agent_style.fg, Some(app.palette.overlay0)); assert!(agent_style.add_modifier.contains(Modifier::DIM)); assert!(!agent_style.add_modifier.contains(Modifier::BOLD)); - assert_eq!(agent_style.bg, Some(app.palette.surface_dim)); + assert_eq!(agent_style.bg, Some(app.palette.active_row_bg)); } #[test] @@ -1745,7 +1745,7 @@ rows = [[{ token = "workspace", bold = false }, { token = "agent", dim = false } assert_eq!(active.fg, Some(app.palette.text)); assert!(active.add_modifier.contains(Modifier::BOLD)); assert!(!active.add_modifier.contains(Modifier::DIM)); - assert_eq!(active.bg, Some(app.palette.surface_dim)); + assert_eq!(active.bg, Some(app.palette.active_row_bg)); let inactive = buffer[(find_symbol_x(buffer, second_row, 25, "t"), second_row)].style(); assert_eq!(inactive.fg, Some(app.palette.subtext0)); @@ -1756,6 +1756,35 @@ rows = [[{ token = "workspace", bold = false }, { token = "agent", dim = false } } #[test] + fn navigate_selection_keeps_its_existing_background_beside_active_workspace() { + let mut app = crate::app::state::AppState::test_new(); + app.workspaces = vec![Workspace::test_new("one"), Workspace::test_new("two")]; + app.active = Some(0); + app.selected = 1; + app.mode = Mode::Navigate; + let area = Rect::new(0, 0, 26, 20); + app.view.workspace_card_areas = compute_workspace_card_areas(&app, area); + let active_row = app.view.workspace_card_areas[0].rect.y; + let selected_row = app.view.workspace_card_areas[1].rect.y; + let mut terminal = Terminal::new(TestBackend::new(26, 20)).unwrap(); + terminal + .draw(|frame| render_sidebar(&app, &TerminalRuntimeRegistry::new(), frame, area)) + .unwrap(); + let buffer = terminal.backend().buffer(); + + assert_eq!( + buffer[(0, active_row)].bg, + app.palette.active_row_bg, + "active workspace should keep its dedicated background" + ); + assert_eq!( + buffer[(0, selected_row)].bg, + app.palette.surface0, + "navigate selection should keep its existing surface0 background" + ); + } + + #[test] fn space_occurrence_style_applies_without_styling_separator() { let config: crate::config::Config = toml::from_str( r##" @@ -1791,12 +1820,12 @@ rows = [[{ token = "$hype", fg = "#abcdef", bold = true, dim = false }, "workspa assert_eq!(style.fg, Some(ratatui::style::Color::Rgb(0xab, 0xcd, 0xef))); assert!(style.add_modifier.contains(Modifier::BOLD)); assert!(!style.add_modifier.contains(Modifier::DIM)); - assert_eq!(style.bg, Some(app.palette.surface_dim)); + assert_eq!(style.bg, Some(app.palette.active_row_bg)); } assert_eq!(separator.fg, Some(app.palette.overlay0)); assert!(separator.add_modifier.contains(Modifier::DIM)); assert!(!separator.add_modifier.contains(Modifier::BOLD)); - assert_eq!(separator.bg, Some(app.palette.surface_dim)); + assert_eq!(separator.bg, Some(app.palette.active_row_bg)); } #[test] @@ -2237,7 +2266,7 @@ rows = [[{ token = "git_status", fg = "#123456" }]] .filter(|cells| { cells .iter() - .all(|style| style.bg == Some(app.palette.surface_dim)) + .all(|style| style.bg == Some(app.palette.active_row_bg)) }) .collect(); assert_eq!( @@ -2269,7 +2298,7 @@ rows = [[{ token = "git_status", fg = "#123456" }]] for cells in rows { assert_eq!(cells[0].fg, Some(app.palette.overlay0)); for style in cells { - assert_ne!(style.bg, Some(app.palette.surface_dim)); + assert_ne!(style.bg, Some(app.palette.active_row_bg)); } } } diff --git a/src/ui/tab_surface.rs b/src/ui/tab_surface.rs index 99ca9727..dd627711 100644 --- a/src/ui/tab_surface.rs +++ b/src/ui/tab_surface.rs @@ -304,7 +304,7 @@ mod tests { assert_eq!(frame.hyperlinks, vec![uri.to_owned()]); assert_eq!( frame_digest(&frame), - "a7c21fa42305a41231c7ae254f264f6ef923f46301d8fc4cd35ab6dfdd651b6b" + "f692e425877ef32cd0f3435dd8e252f33fff4e6dd5088a9324620895a6bd4c13" ); } |
