Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/next/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
- Experimental pane graphics now support bounded named layers, acknowledged full-RGBA primary-layer direct file frames on audited local terminals, owned BGRA fallback, exact pixel mouse input, and placement-only resize replay.

### Fixed
- Text selections remain visible over Mosh and other terminals that do not report their background color. (#2708)
- Prefix keybindings now disambiguate layout-aware shifted punctuation, so a shifted `\` no longer triggers `prefix+|` on keyboard layouts where the same key produces both characters. (#2674)
- Remote clients now continue redrawing at very large terminal sizes instead of freezing when a full ANSI frame exceeds the transport limit. (#2670)
- OpenCode panes now track the root conversation selected in their own TUI for native restore without adopting activity from attached clients. (#2450)
Expand Down
24 changes: 22 additions & 2 deletions src/ui/panes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -875,8 +875,13 @@ fn automatic_selection_style(
}

fn automatic_selection_bg(p: &Palette, host_theme: crate::terminal_theme::TerminalTheme) -> Color {
let Some(background) = host_theme.background.map(terminal_theme_to_rgb) else {
return selection_palette_background(p);
let fallback = selection_palette_background(p);
let Some(background) = host_theme
.background
.map(terminal_theme_to_rgb)
.or_else(|| color_to_rgb(fallback))
else {
return fallback;
};

let target = if relative_luminance(background) < 0.5 {
Expand Down Expand Up @@ -1604,4 +1609,19 @@ mod tests {
};
assert!(relative_luminance((r, g, b)) > relative_luminance((12, 14, 16)));
}

#[test]
fn automatic_selection_background_contrasts_when_host_background_is_unknown() {
for panel_bg in [Color::Rgb(0x2d, 0x35, 0x3b), Color::Rgb(239, 241, 245)] {
let mut palette = Palette::catppuccin();
palette.panel_bg = panel_bg;

let selected =
automatic_selection_bg(&palette, crate::terminal_theme::TerminalTheme::default());
let base_luminance = relative_luminance(color_to_rgb(panel_bg).unwrap());
let selected_luminance = relative_luminance(color_to_rgb(selected).unwrap());

assert!((selected_luminance - base_luminance).abs() > 0.08);
}
}
}
Loading