Fix sidebar and no titlebar aligment (#66877)

Follow-up to https://github.com/zed-industries/zed/pull/65671

Make the vertical size of the tab bar and "Search threads" elements
aligned.

<img width="1728" height="51" alt="Screenshot 2026-11-12 at 12 34 07"
src="https://github.com/user-attachments/assets/8ce6294d-4392-440b-9b1d-9a99625124c1"
/>


Release Notes:

- N/A (Nightly only)
This commit is contained in:
Kirill Bulatov
2026-11-12 15:02:44 +00:00
committed by GitHub
parent eda58e5040
commit 3c846c3d49
3 changed files with 176 additions and 24 deletions
+21 -10
View File
@@ -28,7 +28,7 @@ use picker::{
Picker, PickerDelegate,
highlighted_match_with_paths::{HighlightedMatch, HighlightedMatchWithPaths},
};
use platform_title_bar::{SidebarWindowControls, apply_title_bar_insets};
use platform_title_bar::{SidebarWindowControls, TitleBarSettings, apply_title_bar_insets};
use project::{AgentId, AgentServerStore};
use settings::Settings as _;
use theme::ActiveTheme;
@@ -864,20 +864,31 @@ impl ThreadsArchiveView {
left: left_window_controls,
right: right_window_controls,
} = SidebarWindowControls::new(AgentSettings::get_global(cx).sidebar_side(), window, cx);
let header_height = platform_title_bar_height(window);
let title_bar_visible = TitleBarSettings::is_title_bar_visible(window, cx);
let header_height = if title_bar_visible {
platform_title_bar_height(window)
} else {
Tab::container_height(cx)
};
let show_focus_keybinding =
self.selection.is_some() && !self.filter_editor.focus_handle(cx).is_focused(window);
h_flex()
.debug_selector(|| "threads-archive-header".into())
.h(header_height)
.map(|header| match window.window_decorations() {
Decorations::Client { .. } => apply_title_bar_insets(
header,
left_window_controls,
right_window_controls,
false,
),
Decorations::Server => header.mt_px().pb_px(),
.map(|header| {
if !title_bar_visible {
return header.mt_px();
}
match window.window_decorations() {
Decorations::Client { .. } => apply_title_bar_insets(
header,
left_window_controls,
right_window_controls,
false,
),
Decorations::Server => header.mt_px().pb_px(),
}
})
.when(left_window_controls, |this| {
this.children(Self::render_left_window_controls(window, cx))
+22 -11
View File
@@ -39,7 +39,7 @@ use menu::{
Cancel, Confirm, SelectChild, SelectFirst, SelectLast, SelectNext, SelectParent, SelectPrevious,
};
use notifications::status_toast::StatusToast;
use platform_title_bar::{SidebarWindowControls, apply_title_bar_insets};
use platform_title_bar::{SidebarWindowControls, TitleBarSettings, apply_title_bar_insets};
use project::{AgentId, AgentRegistryStore, Event as ProjectEvent, WorktreeId};
use recent_projects::sidebar_recent_projects::SidebarRecentProjects;
use remote::RemoteConnectionOptions;
@@ -7382,19 +7382,30 @@ impl Sidebar {
left: left_window_controls,
right: right_window_controls,
} = SidebarWindowControls::new(self.side(cx), window, cx);
let header_height = platform_title_bar_height(window);
let title_bar_visible = TitleBarSettings::is_title_bar_visible(window, cx);
let header_height = if title_bar_visible {
platform_title_bar_height(window)
} else {
Tab::container_height(cx)
};
h_flex()
.debug_selector(|| "sidebar-header".into())
.h(header_height)
.map(|header| match window.window_decorations() {
// Without projects there's no bottom border to match the title bar's.
Decorations::Client { .. } => apply_title_bar_insets(
header,
left_window_controls,
right_window_controls,
no_open_projects,
),
Decorations::Server => header.mt_px().pb_px(),
.map(|header| {
if !title_bar_visible {
return header.mt_px();
}
match window.window_decorations() {
// Without projects there's no bottom border to match the title bar's.
Decorations::Client { .. } => apply_title_bar_insets(
header,
left_window_controls,
right_window_controls,
no_open_projects,
),
Decorations::Server => header.mt_px().pb_px(),
}
})
.when(left_window_controls, |this| {
this.children(Self::render_left_window_controls(window, cx))
+133 -3
View File
@@ -23,9 +23,9 @@ use gpui::{
use platform_title_bar::PlatformTitleBar;
use pretty_assertions::assert_eq;
use project::AgentId;
#[cfg(target_os = "macos")]
use settings::TitleBarVisibility;
use settings::{Settings, SettingsStore, SidebarDockPosition};
use settings::{
FontSize, Settings, SettingsStore, SidebarDockPosition, TitleBarVisibility, UiDensity,
};
use std::{
path::{Path, PathBuf},
sync::Arc,
@@ -2123,6 +2123,136 @@ async fn test_headers_follow_title_bar_visibility(cx: &mut TestAppContext) {
assert_ne!(archive.hidden, archive.shown);
}
#[gpui::test]
async fn test_header_alignment_with_title_bar_and_tabs(cx: &mut TestAppContext) {
let project = init_test_project_with_agent_panel("/my-project", cx).await;
cx.update(|cx| AgentRegistryStore::init_test_global(cx, Vec::new()));
let (multi_workspace, cx) =
cx.add_window_view(|window, cx| MultiWorkspace::test_new(project, window, cx));
let (sidebar, _panel) = setup_sidebar_with_agent_panel(&multi_workspace, cx);
let workspace =
multi_workspace.read_with(cx, |multi_workspace, _| multi_workspace.workspace().clone());
let title_bar = cx.new(|cx| {
PlatformTitleBar::new("title-bar", cx).with_multi_workspace(multi_workspace.downgrade())
});
workspace.update_in(cx, |workspace, window, cx| {
let item = cx.new(TestItem::new);
workspace.add_item_to_active_pane(Box::new(item), None, false, window, cx);
});
let window_handle = cx.update(|window, _| window.window_handle());
for (header_selector, search_selector) in [
("sidebar-header", "sidebar-header-search"),
("threads-archive-header", "threads-archive-header-search"),
] {
if header_selector == "threads-archive-header" {
sidebar.update_in(cx, |sidebar, window, cx| sidebar.show_archive(window, cx));
}
for ((font_size, density, decorations, position), scale_factor) in [
(
12.,
UiDensity::Compact,
Decorations::Server,
SidebarDockPosition::Left,
),
(
16.,
UiDensity::Default,
Decorations::Client {
tiling: Tiling::default(),
},
SidebarDockPosition::Left,
),
(
24.,
UiDensity::Comfortable,
Decorations::Client {
tiling: Tiling::default(),
},
SidebarDockPosition::Right,
),
(
16.,
UiDensity::Comfortable,
Decorations::Client {
tiling: Tiling {
top: true,
left: true,
right: true,
bottom: true,
},
},
SidebarDockPosition::Right,
),
]
.into_iter()
.cartesian_product([1., 2.])
{
cx.simulate_scale_factor_change(scale_factor);
cx.simulate_window_decorations_change(window_handle, decorations);
for (visibility, fullscreen, title_bar_visible) in [
(TitleBarVisibility::Always, false, true),
(TitleBarVisibility::Never, false, false),
(TitleBarVisibility::HideInFullScreen, false, true),
(TitleBarVisibility::HideInFullScreen, true, false),
(TitleBarVisibility::Always, true, true),
] {
cx.update_global::<SettingsStore, _>(|store, cx| {
store.update_user_settings(cx, |settings| {
settings.title_bar.get_or_insert_default().show = Some(visibility);
settings.theme.ui_font_size = Some(FontSize(font_size));
settings.theme.ui_density = Some(density);
settings
.agent
.get_or_insert_default()
.threads_sidebar
.get_or_insert_default()
.position = Some(position);
});
});
workspace.update_in(cx, |workspace, window, cx| {
if window.is_fullscreen() != fullscreen {
window.toggle_fullscreen();
}
if title_bar_visible {
workspace.set_titlebar_item(AnyView::from(title_bar.clone()), window, cx);
} else {
workspace.clear_titlebar_item(window, cx);
}
cx.refresh_windows();
});
cx.run_until_parked();
let header = cx
.debug_bounds(header_selector)
.expect("header is rendered");
let tab = cx.debug_bounds("TAB-0").expect("tab is rendered");
let search = cx
.debug_bounds(search_selector)
.expect("search is rendered");
let center = if title_bar_visible {
assert_eq!(header.bottom(), tab.top());
match decorations {
Decorations::Client { .. } => header.center().y,
Decorations::Server => header.center().y - px(1.),
}
} else {
assert_eq!(header.top(), tab.top());
assert_eq!(header.bottom(), tab.bottom());
tab.center().y - px(0.5)
};
let expected_top =
((center - search.size.height / 2.) * scale_factor).floor() / scale_factor;
assert_eq!(
search.top(),
expected_top,
"{header_selector}, {visibility:?}, {font_size}px, {scale_factor}x"
);
}
}
}
}
#[gpui::test]
async fn test_keyboard_confirm_on_project_header_toggles_collapse(cx: &mut TestAppContext) {
let project = init_test_project("/my-project", cx).await;