mirror of
https://github.com/zed-industries/zed.git
synced 2026-11-19 06:59:22 +01:00
Fix transparent Threads Sidebar backgrounds in some themes (#65343)
## Summary > PR #62597 changed the Threads Sidebar background color, but introduced a regression where the background becomes transparent in some themes, such as VSCode Dark Modern, which assigns a semi-transparent color to `surface_background`. > > This PR blends the Threads Sidebar background color with `background` to prevent it from becoming transparent. > > Additionally, while the default themes are unaffected, the Threads Sidebar background was found to be inconsistent with other panels in themes such as VSCode Dark Modern. To address this, this PR also changes the blended color from `surface_background` to `panel_background`, preserving the appearance of Zed's bundled themes while improving consistency in other themes. #62597でThreads Sidebarの背景色が変更されましたが、`surface_background`に半透明の色が割り当てられているVSCode Dark Modernなど一部のテーマでサイドバーの背景色が透明になってしまうリグレッションが発生しました。 このPRでは、Threads Sidebarの背景色を`background`とブレンドし、背景色が透明になることを防ぎます。 また、デフォルトのテーマでは問題ありませんが、VSCode Dark ModernなどではThreads Sidebarの背景色がほかのパネルと一致せず一貫性がなくなることが判明したため、ブレンドする色を`surface_background`から`panel_background`に変更しました。これにより、Zedに同梱されているテーマでの外観を維持しつつ、一部のテーマで背景色に一貫性を持たせます。 Before: <img width="867" height="457" alt="image" src="https://github.com/user-attachments/assets/c98e5063-abee-4110-bf6c-2b7ae91d2fbc" /> After: <img width="846" height="388" alt="image" src="https://github.com/user-attachments/assets/72e253c4-a713-4245-9c18-ce57572bbb6c" /> Closes #65310 ## Testing > Install a theme that assigns a semi-transparent or transparent color to `surface_background`, such as VSCode Dark Modern. > > Before this change, the Threads Sidebar background appears transparent (or white on Windows). After this change, the background remains opaque. VSCode Dark Modernテーマなど、`surface_background`に半透明または透明の色が割り当てられているテーマをインストールします。変更前はThreads Sidebarの背景色が透明(Windowsでは白色)になってしまいますが、変更後は不透明の背景色になります。 ## Self-review - [x] I've reviewed my diff for quality, security, reliability, and performance. - [x] UI changes follow the [checklist](https://zed.dev/docs/development/ui-checklist). - [x] Tests cover the new or changed behavior. Release Notes: - Fixed an issue where the background color of the Threads Sidebar was transparent in some themes
This commit is contained in:
@@ -663,6 +663,7 @@ impl ThreadsArchiveView {
|
||||
let archived_color = Color::Custom(cx.theme().colors().icon_muted.opacity(0.6));
|
||||
|
||||
let base = ThreadItem::new(id, thread.display_title())
|
||||
.base_bg(cx.theme().colors().panel_background)
|
||||
.icon(icon)
|
||||
.when(is_archived, |this| {
|
||||
this.archived(true)
|
||||
|
||||
@@ -2350,9 +2350,9 @@ impl Sidebar {
|
||||
|
||||
let color = cx.theme().colors();
|
||||
let sidebar_base_bg = if is_sticky {
|
||||
color.surface_overlay_background()
|
||||
color.panel_background_for_overlay()
|
||||
} else {
|
||||
color.surface_background
|
||||
color.panel_background
|
||||
};
|
||||
|
||||
// The fade gradient renders as a visible patch on transparent windows,
|
||||
@@ -3292,7 +3292,7 @@ impl Sidebar {
|
||||
.unwrap_or(px(0.));
|
||||
|
||||
let color = cx.theme().colors();
|
||||
let background = color.surface_overlay_background();
|
||||
let background = color.panel_background_for_overlay();
|
||||
|
||||
let element = v_flex()
|
||||
.absolute()
|
||||
@@ -6281,7 +6281,7 @@ impl Sidebar {
|
||||
let id = SharedString::from(format!("thread-entry-{}", ix));
|
||||
|
||||
let color = cx.theme().colors();
|
||||
let sidebar_bg = color.surface_background;
|
||||
let sidebar_bg = color.panel_background;
|
||||
let button_hover_bg = color.element_background;
|
||||
let button_active_bg = color.element_active;
|
||||
|
||||
@@ -6610,7 +6610,7 @@ impl Sidebar {
|
||||
let timestamp = format_history_entry_timestamp(terminal.metadata.created_at);
|
||||
let is_hovered = self.hovered_thread_index == Some(ix);
|
||||
let color = cx.theme().colors();
|
||||
let sidebar_bg = color.surface_background;
|
||||
let sidebar_bg = color.panel_background;
|
||||
let button_hover_bg = color.element_background;
|
||||
let button_active_bg = color.element_active;
|
||||
let metadata = terminal.metadata.clone();
|
||||
@@ -7952,7 +7952,7 @@ impl Render for Sidebar {
|
||||
let sticky_header = self.render_sticky_header(window, cx);
|
||||
|
||||
let color = cx.theme().colors();
|
||||
let bg = color.surface_background;
|
||||
let bg = color.background.blend(color.panel_background);
|
||||
|
||||
let no_open_projects = !self.contents.has_open_projects;
|
||||
let no_search_results = self.contents.entries.is_empty();
|
||||
|
||||
@@ -707,6 +707,33 @@ fn visible_entries_as_strings(
|
||||
})
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_sidebar_background_with_transparent_panel(cx: &mut TestAppContext) {
|
||||
let (_, project) = init_multi_project_test(&["/my-project"], cx).await;
|
||||
let (multi_workspace, cx) =
|
||||
cx.add_window_view(|window, cx| MultiWorkspace::test_new(project, window, cx));
|
||||
let sidebar = setup_sidebar(&multi_workspace, cx);
|
||||
|
||||
for panel_alpha in [0.0, 0.4] {
|
||||
set_sidebar_test_panel_alpha(panel_alpha, cx);
|
||||
let background = cx.update(|_, cx| {
|
||||
let colors = cx.theme().colors();
|
||||
colors.background.blend(colors.panel_background)
|
||||
});
|
||||
cx.draw(
|
||||
gpui::point(px(0.), px(0.)),
|
||||
gpui::size(px(400.), px(240.)),
|
||||
|_, _| sidebar.clone().into_any_element(),
|
||||
);
|
||||
|
||||
cx.update(|window, _| {
|
||||
let quads = window.painted_quads();
|
||||
let sidebar_background = quads.first().expect("Sidebar should paint its background");
|
||||
assert_eq!(sidebar_background.background.as_solid(), Some(background));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_sidebar_action_hover_contrasts_with_row(cx: &mut TestAppContext) {
|
||||
let project = init_test_project_with_agent_panel("/my-project", cx).await;
|
||||
@@ -716,8 +743,8 @@ async fn test_sidebar_action_hover_contrasts_with_row(cx: &mut TestAppContext) {
|
||||
let (sidebar, _panel) = setup_sidebar_with_agent_panel(&multi_workspace, cx);
|
||||
save_n_test_threads(1, &project, cx).await;
|
||||
|
||||
for (query, surface_alpha) in [("my-project", 1.0), ("", 1.0), ("", 0.0), ("", 0.2)] {
|
||||
set_sidebar_test_surface_alpha(surface_alpha, cx);
|
||||
for (query, panel_alpha) in [("my-project", 1.0), ("", 1.0), ("", 0.0), ("", 0.2)] {
|
||||
set_sidebar_test_panel_alpha(panel_alpha, cx);
|
||||
type_in_search(&sidebar, query, cx);
|
||||
let row_bounds = sidebar.read_with(cx, |sidebar, _| {
|
||||
sidebar
|
||||
@@ -779,8 +806,8 @@ async fn test_sidebar_action_hover_contrasts_with_row(cx: &mut TestAppContext) {
|
||||
.bounds
|
||||
.map(|value| px(value.as_f32() / window.scale_factor()))
|
||||
});
|
||||
for surface_alpha in [1.0, 0.0, 0.2] {
|
||||
set_sidebar_test_surface_alpha(surface_alpha, cx);
|
||||
for panel_alpha in [1.0, 0.0, 0.2] {
|
||||
set_sidebar_test_panel_alpha(panel_alpha, cx);
|
||||
assert_sidebar_action_hover(selector, row_bounds, cx);
|
||||
}
|
||||
}
|
||||
@@ -15824,11 +15851,12 @@ async fn test_find_or_create_workspace_returns_the_created_remote_workspace(
|
||||
);
|
||||
}
|
||||
|
||||
fn set_sidebar_test_surface_alpha(alpha: f32, cx: &mut VisualTestContext) {
|
||||
fn set_sidebar_test_panel_alpha(alpha: f32, cx: &mut VisualTestContext) {
|
||||
cx.update(|window, cx| {
|
||||
let mut theme = cx.theme().as_ref().clone();
|
||||
theme.styles.colors.background = Hsla::from(gpui::rgb(0xdcdcdd));
|
||||
theme.styles.colors.surface_background = Hsla::from(gpui::rgb(0xebebec)).alpha(alpha);
|
||||
theme.styles.colors.surface_background = Hsla::from(gpui::rgb(0xff00ff));
|
||||
theme.styles.colors.panel_background = Hsla::from(gpui::rgb(0xebebec)).alpha(alpha);
|
||||
theme.styles.colors.element_background = Hsla::from(gpui::rgb(0xebebec));
|
||||
theme.styles.colors.ghost_element_hover = Hsla::from(gpui::rgb(0xdfdfe0));
|
||||
theme::GlobalTheme::update_theme(cx, Arc::new(theme));
|
||||
|
||||
@@ -463,9 +463,9 @@ pub enum ThemeColorField {
|
||||
}
|
||||
|
||||
impl ThemeColors {
|
||||
pub fn surface_overlay_background(&self) -> Hsla {
|
||||
if self.background.a >= 1.0 || self.surface_background.a >= 1.0 {
|
||||
self.background.blend(self.surface_background)
|
||||
pub fn panel_background_for_overlay(&self) -> Hsla {
|
||||
if self.background.a >= 1.0 || self.panel_background.a >= 1.0 {
|
||||
self.background.blend(self.panel_background)
|
||||
} else {
|
||||
self.panel_overlay_background
|
||||
}
|
||||
@@ -649,11 +649,11 @@ mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn surface_overlay_background() {
|
||||
fn panel_background_for_overlay() {
|
||||
let mut colors = ThemeColors::light();
|
||||
colors.panel_overlay_background = Hsla::from(gpui::rgb(0xff0000));
|
||||
|
||||
for (surface, background, expected) in [
|
||||
for (panel, background, expected) in [
|
||||
(0x58585a00, 0xdcdcddff, 0xdcdcddff),
|
||||
(0x00000080, 0xdcdcddff, 0x6d6d6eff),
|
||||
(0xebebecff, 0x24252900, 0xebebecff),
|
||||
@@ -661,12 +661,12 @@ mod tests {
|
||||
(0xebebec00, 0x24252980, 0xff0000ff),
|
||||
(0x24252980, 0x24252980, 0xff0000ff),
|
||||
] {
|
||||
colors.surface_background = Hsla::from(gpui::rgba(surface));
|
||||
colors.panel_background = Hsla::from(gpui::rgba(panel));
|
||||
colors.background = Hsla::from(gpui::rgba(background));
|
||||
assert_eq!(
|
||||
u32::from(Rgba::from(colors.surface_overlay_background())),
|
||||
u32::from(Rgba::from(colors.panel_background_for_overlay())),
|
||||
expected,
|
||||
"surface {surface:#010x}, background {background:#010x}"
|
||||
"panel {panel:#010x}, background {background:#010x}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user