Files
zed/crates/git_ui/src/git_panel_settings.rs
T
mulham c83abe7d0e git_ui: Allow collapsing the commit editor and commit details (#63236)
## Summary

- The commit message editor in the Git panel is pinned to six lines and
its only two controls both make it *larger* — one fills the panel, the
other opens the modal. Anyone who commits from a terminal pays for an
input they never use, and the Changes list is what gets squeezed.
- In the Git Graph detail panel, the author metadata and the commit
message render at a fixed size above the changed-files list, so
shortening the panel (e.g. dragging the terminal up) hides the file list
entirely.

## Changes

**Git panel — collapsible commit editor**

- New `git::ToggleCommitEditor` action.
- A chevron beside the commit button hides the editor down to a thin
bar; the commit button row stays available.
- State persists per workspace via `SerializedGitPanel`, seeded from a
new `git_panel.commit_editor` setting (`expanded` | `collapsed`, default
`expanded`).
- Collapsing clears the fill state — a hidden editor cannot also fill
the panel.
- `activation_focus_handle` no longer focuses an editor that isn't
rendered.

**Git Graph — collapsible commit details**

- A disclosure folds the author metadata (avatar, refs, email, SHA,
provider link) down to a single author + short-sha line.
- A second disclosure folds the commit message body.
- The changed-files container is already `flex_1().min_h_0()`, so it
reclaims the freed space with no other layout change.

**Settings plumbing**

- `GitPanelCommitEditor` in `settings_content`, wired through
`GitPanelSettings`, `assets/settings/default.json`, the settings UI, and
`docs/src/reference/all-settings.md`.

## Test plan

- [x] `test_toggle_commit_editor_collapsed` added, covering the toggle,
persistence of the flag, and the fill/collapse exclusion.
- [x] Manually verified in a dev build: chevron hides and restores the
editor, Changes list expands into the freed space, action appears in the
command palette, state survives a restart, and the `collapsed` setting
seeds a new workspace.
- [x] Manually verified both disclosures in the Git Graph detail panel
with the panel shortened, including that the collapse state survives
selecting a different commit.

Release Notes:

- Improved the Git panel by allowing the commit message editor to be
collapsed, and the Git Graph commit details by making the metadata and
commit message sections collapsible.

### Evidance Test
| Expand | Collapse | Settings Git Panel |
| ------- | --------- | ------------------ |
| <img width="675" height="965" alt="Screenshot 2026-08-26 at 15 00 46"
src="https://github.com/user-attachments/assets/70c56d02-35fc-45ac-988c-24ccd6d1a19e"
/> | <img width="661" height="962" alt="Screenshot 2026-08-26 at 15 00
57"
src="https://github.com/user-attachments/assets/2c32fa5d-30fc-4f35-8323-afbc2a031210"
/> | <img width="1041" height="956" alt="Screenshot 2026-08-26 at 16 50
40"
src="https://github.com/user-attachments/assets/67f166b6-5cd9-4430-bba3-fa765715c557"
/> |

---------

Co-authored-by: Christopher Biscardi <chris@christopherbiscardi.com>
2026-10-02 17:25:11 +00:00

90 lines
3.5 KiB
Rust

use editor::{EditorSettings, ui_scrollbar_settings_from_raw};
use gpui::Pixels;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use settings::{
FolderIndicator, GitPanelClickBehavior, GitPanelCommitEditor, GitPanelGroupBy, GitPanelSortBy,
IntoGpui, RegisterSetting, Settings, StatusStyle,
};
use ui::scrollbars::{ScrollbarVisibility, ShowScrollbar};
use workspace::dock::DockPosition;
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
pub struct ScrollbarSettings {
pub show: Option<ShowScrollbar>,
}
#[derive(Debug, Clone, PartialEq, RegisterSetting)]
pub struct GitPanelSettings {
pub button: bool,
pub dock: DockPosition,
pub default_width: Pixels,
pub status_style: StatusStyle,
pub file_icons: bool,
pub folder_indicator: FolderIndicator,
pub scrollbar: ScrollbarSettings,
pub fallback_branch_name: String,
pub sort_by: GitPanelSortBy,
pub group_by: GitPanelGroupBy,
pub collapse_untracked_diff: bool,
pub tree_view: bool,
pub diff_stats: bool,
pub show_count_badge: bool,
pub starts_open: bool,
pub commit_title_max_length: usize,
pub entry_primary_click_action: GitPanelClickBehavior,
pub commit_editor: GitPanelCommitEditor,
}
#[derive(Default)]
pub(crate) struct GitPanelScrollbarAccessor;
impl ScrollbarVisibility for GitPanelScrollbarAccessor {
fn visibility(&self, cx: &ui::App) -> ShowScrollbar {
// TODO: This PR should have defined Editor's `scrollbar.axis`
// as an Option<ScrollbarAxis>, not a ScrollbarAxes as it would allow you to
// `.unwrap_or(EditorSettings::get_global(cx).scrollbar.show)`.
//
// Once this is fixed we can extend the GitPanelSettings with a `scrollbar.axis`
// so we can show each axis based on the settings.
//
// We should fix this. PR: https://github.com/zed-industries/zed/pull/19495
GitPanelSettings::get_global(cx)
.scrollbar
.show
.unwrap_or_else(|| EditorSettings::get_global(cx).scrollbar.show)
}
}
impl Settings for GitPanelSettings {
fn from_settings(content: &settings::SettingsContent) -> Self {
let git_panel = content.git_panel.clone().unwrap();
Self {
button: git_panel.button.unwrap(),
dock: git_panel.dock.unwrap().into(),
default_width: git_panel.default_width.unwrap().into_gpui(),
status_style: git_panel.status_style.unwrap(),
file_icons: git_panel.file_icons.unwrap(),
folder_indicator: git_panel.folder_indicator.unwrap(),
scrollbar: ScrollbarSettings {
show: git_panel
.scrollbar
.unwrap()
.show
.map(ui_scrollbar_settings_from_raw),
},
fallback_branch_name: git_panel.fallback_branch_name.unwrap(),
sort_by: git_panel.sort_by.unwrap(),
group_by: git_panel.group_by.unwrap(),
collapse_untracked_diff: git_panel.collapse_untracked_diff.unwrap(),
tree_view: git_panel.tree_view.unwrap(),
diff_stats: git_panel.diff_stats.unwrap(),
show_count_badge: git_panel.show_count_badge.unwrap(),
starts_open: git_panel.starts_open.unwrap(),
commit_title_max_length: git_panel.commit_title_max_length.unwrap(),
entry_primary_click_action: git_panel.entry_primary_click_action.unwrap(),
commit_editor: git_panel.commit_editor.unwrap(),
}
}
}