title_bar: Add show_worktree_name setting (#61137)
Adds a title_bar.show_worktree_name setting (default: true) that hides the worktree picker button in the title bar, mirroring how show_branch_name gates the branch picker. The "/" separator only renders when both buttons are visible, and the container is omitted entirely when both are hidden. The setting is hide-only: it deliberately does not join the render_project_items gate, so configurations with show_branch_name and show_project_items both disabled keep hiding the whole group as before. Requested in discussion [zed-industries/zed#54902](https://github.com/zed-industries/zed/discussions/54902). # Objective The worktree name is always present in the title bar even when unused. Unlike the branch name it has no dedicated option to disable it. Requested in discussion [zed-industries/zed#54902](https://github.com/zed-industries/zed/discussions/54902). ## Solution Adds a `title_bar.show_worktree_name` setting (default: true) that hides the worktree picker button in the title bar, mirroring how show_branch_name gates the branch picker. The "/" separator only renders when both buttons are visible, and the container is omitted entirely when both are hidden. The setting is hide-only: it deliberately does not join the render_project_items gate, so configurations with show_branch_name and show_project_items both disabled keep hiding the whole group as before. ## Testing I tested the setting added by running the application by adding, removing and toggling the `title_bar.show_worktree_name` setting in the `settings.json` ## Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [ ] Unsafe blocks (if any) have justifying comments - [x] The content adheres to Zed's UI standards ([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) and [icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md) guidelines) - [x] Tests cover the new/changed behavior - [ ] Performance impact has been considered and is acceptable ## Showcase <img width="1496" height="982" alt="title_bar.show_worktree_name = false" src="https://github.com/user-attachments/assets/b2c502de-a8d8-4409-ba04-5ab807c77a8e" /> <img width="1496" height="982" alt="title_bar.show_worktree_name = true" src="https://github.com/user-attachments/assets/6cea7eb5-0e88-454c-9c97-3b4ad62aed51" /> --- Release Notes: - title_bar: Added title_bar.show_worktree_name (default: true) to hide worktree picker button Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9a653485a7
commit
8ef6930d97
7 files changed
+46
-6
No files matched your search
@@ -548,6 +548,8 @@
|
||||
"show_branch_status_icon": false,
|
||||
// Whether to show the branch name button in the titlebar.
|
||||
"show_branch_name": true,
|
||||
// Whether to show the worktree name button in the titlebar.
|
||||
"show_worktree_name": true,
|
||||
// Whether to show the project host and name in the titlebar.
|
||||
"show_project_items": true,
|
||||
// Whether to show onboarding banners in the titlebar.
|
||||
|
||||
@@ -99,6 +99,10 @@ pub struct TitleBarSettingsContent {
|
||||
///
|
||||
/// Default: true
|
||||
pub show_branch_name: Option<bool>,
|
||||
/// Whether to show the worktree name button in the titlebar.
|
||||
///
|
||||
/// Default: true
|
||||
pub show_worktree_name: Option<bool>,
|
||||
/// Whether to show the project host and name in the titlebar.
|
||||
///
|
||||
/// Default: true
|
||||
|
||||
@@ -3989,7 +3989,7 @@ fn window_and_layout_page() -> SettingsPage {
|
||||
]
|
||||
}
|
||||
|
||||
fn title_bar_section() -> [SettingsPageItem; 10] {
|
||||
fn title_bar_section() -> [SettingsPageItem; 11] {
|
||||
[
|
||||
SettingsPageItem::SectionHeader("Title Bar"),
|
||||
SettingsPageItem::SettingItem(SettingItem {
|
||||
@@ -4038,6 +4038,29 @@ fn window_and_layout_page() -> SettingsPage {
|
||||
metadata: None,
|
||||
files: USER,
|
||||
}),
|
||||
SettingsPageItem::SettingItem(SettingItem {
|
||||
title: "Show Worktree Name",
|
||||
description: "Show the worktree name button in the titlebar.",
|
||||
field: Box::new(SettingField {
|
||||
organization_override: None,
|
||||
json_path: Some("title_bar.show_worktree_name"),
|
||||
pick: |settings_content| {
|
||||
settings_content
|
||||
.title_bar
|
||||
.as_ref()?
|
||||
.show_worktree_name
|
||||
.as_ref()
|
||||
},
|
||||
write: |settings_content, value, _| {
|
||||
settings_content
|
||||
.title_bar
|
||||
.get_or_insert_default()
|
||||
.show_worktree_name = value;
|
||||
},
|
||||
}),
|
||||
metadata: None,
|
||||
files: USER,
|
||||
}),
|
||||
SettingsPageItem::SettingItem(SettingItem {
|
||||
title: "Show Project Items",
|
||||
description: "Show the project host and name in the titlebar.",
|
||||
|
||||
@@ -988,7 +988,7 @@ impl TitleBar {
|
||||
worktree_label.clone()
|
||||
};
|
||||
|
||||
let worktree_button = {
|
||||
let worktree_button = settings.show_worktree_name.then(|| {
|
||||
let project = self.project.clone();
|
||||
let workspace_handle = workspace.downgrade();
|
||||
PopoverMenu::new("worktree-picker-menu")
|
||||
@@ -1022,7 +1022,7 @@ impl TitleBar {
|
||||
},
|
||||
)
|
||||
.anchor(gpui::Anchor::TopLeft)
|
||||
};
|
||||
});
|
||||
|
||||
let branch_picker = branch_name.and_then(|branch_name| {
|
||||
settings.show_branch_name.then(|| {
|
||||
@@ -1084,19 +1084,25 @@ impl TitleBar {
|
||||
})
|
||||
});
|
||||
|
||||
if worktree_button.is_none() && branch_picker.is_none() {
|
||||
return None;
|
||||
}
|
||||
|
||||
let show_separator = worktree_button.is_some() && branch_picker.is_some();
|
||||
|
||||
Some(
|
||||
h_flex()
|
||||
.gap_px()
|
||||
.child(worktree_button)
|
||||
.when_some(branch_picker, |this, branch_picker| {
|
||||
.children(worktree_button)
|
||||
.when(show_separator, |this| {
|
||||
this.child(
|
||||
Label::new("/")
|
||||
.size(LabelSize::Small)
|
||||
.color(Color::Muted)
|
||||
.alpha(0.25),
|
||||
)
|
||||
.child(branch_picker)
|
||||
})
|
||||
.children(branch_picker)
|
||||
.into_any_element(),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ pub struct TitleBarSettings {
|
||||
pub show_onboarding_banner: bool,
|
||||
pub show_user_picture: bool,
|
||||
pub show_branch_name: bool,
|
||||
pub show_worktree_name: bool,
|
||||
pub show_project_items: bool,
|
||||
pub show_sign_in: bool,
|
||||
pub show_user_menu: bool,
|
||||
@@ -22,6 +23,7 @@ impl Settings for TitleBarSettings {
|
||||
show_onboarding_banner: content.show_onboarding_banner.unwrap(),
|
||||
show_user_picture: content.show_user_picture.unwrap(),
|
||||
show_branch_name: content.show_branch_name.unwrap(),
|
||||
show_worktree_name: content.show_worktree_name.unwrap(),
|
||||
show_project_items: content.show_project_items.unwrap(),
|
||||
show_sign_in: content.show_sign_in.unwrap(),
|
||||
show_user_menu: content.show_user_menu.unwrap(),
|
||||
|
||||
@@ -4943,6 +4943,7 @@ Run the {#action theme_selector::Toggle} action in the command palette to see a
|
||||
"title_bar": {
|
||||
"show_branch_status_icon": false,
|
||||
"show_branch_name": true,
|
||||
"show_worktree_name": true,
|
||||
"show_project_items": true,
|
||||
"show_onboarding_banner": true,
|
||||
"show_user_picture": true,
|
||||
@@ -4958,6 +4959,7 @@ Run the {#action theme_selector::Toggle} action in the command palette to see a
|
||||
|
||||
- `show_branch_status_icon`: Whether to show git status indicators on the branch icon in the titlebar
|
||||
- `show_branch_name`: Whether to show the branch name button in the titlebar
|
||||
- `show_worktree_name`: Whether to show the worktree name button in the titlebar
|
||||
- `show_project_items`: Whether to show the project host and name in the titlebar
|
||||
- `show_onboarding_banner`: Whether to show onboarding banners in the titlebar
|
||||
- `show_user_picture`: Whether to show user picture in the titlebar
|
||||
|
||||
@@ -130,6 +130,7 @@ To disable this behavior use:
|
||||
"title_bar": {
|
||||
"show_branch_status_icon": false, // Show git status on branch icon
|
||||
"show_branch_name": true, // Show/hide branch name
|
||||
"show_worktree_name": true, // Show/hide worktree name
|
||||
"show_project_items": true, // Show/hide project host and name
|
||||
"show_onboarding_banner": true, // Show/hide onboarding banners
|
||||
"show_user_picture": true, // Show/hide user avatar
|
||||
|
||||
Reference in new issue
Block a user