From 00bee4515e2c69fbcedcb7032420ce9dafce6aa7 Mon Sep 17 00:00:00 2001 From: Matt Van Horn Date: Wed, 18 Mar 2026 08:22:45 -0700 Subject: [PATCH] git_ui: Add starts_open setting to git panel (#51601) Fixes #51542 Adds a `git_panel.starts_open` setting for parity with `project_panel`. When set to `true`, the git panel opens automatically in new workspaces that don't have saved panel state. The default is `false`, matching current behavior (non-breaking). ### Usage ```json { "git_panel": { "starts_open": true } } ``` ### Implementation Follows the same pattern as `project_panel.starts_open`: 1. `GitPanelSettingsContent` - added `starts_open: Option` to the settings schema 2. `GitPanelSettings` - added `starts_open: bool` field 3. `GitPanel` Panel impl - overrides `starts_open()` to read from settings Release Notes: - Added `git_panel.starts_open` setting to control whether the git panel opens automatically in new workspaces (default: false) --------- Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com> Co-authored-by: Claude Opus 4.6 (1M context) --- assets/settings/default.json | 4 ++++ crates/git_ui/src/git_panel.rs | 4 ++++ crates/git_ui/src/git_panel_settings.rs | 2 ++ crates/settings_content/src/settings_content.rs | 5 +++++ docs/src/reference/all-settings.md | 4 +++- 5 files changed, 18 insertions(+), 1 deletion(-) diff --git a/assets/settings/default.json b/assets/settings/default.json index 5c45194dfe8ab3be37c2a70543b3760ea2127c3a..c86f0bff80ecef0f428794f5a07eadf6704b0872 100644 --- a/assets/settings/default.json +++ b/assets/settings/default.json @@ -922,6 +922,10 @@ /// /// Default: false "tree_view": false, + // Whether the git panel should open on startup. + // + // Default: false + "starts_open": false, // Whether to show a badge on the git panel icon with the count of uncommitted changes. // // Default: false diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rs index b9846e1df7430d7b9cf9a5267f790d44e6649447..5a63a0662272b5d627bbb8e03ebaa18127d190cd 100644 --- a/crates/git_ui/src/git_panel.rs +++ b/crates/git_ui/src/git_panel.rs @@ -5824,6 +5824,10 @@ impl Panel for GitPanel { Box::new(ToggleFocus) } + fn starts_open(&self, _: &Window, cx: &App) -> bool { + GitPanelSettings::get_global(cx).starts_open + } + fn activation_priority(&self) -> u32 { 2 } diff --git a/crates/git_ui/src/git_panel_settings.rs b/crates/git_ui/src/git_panel_settings.rs index baf453e310c02097da1d11344e79bac31f891d0b..16a1113b60a53544834f1484a2fa7e6fcbea9aca 100644 --- a/crates/git_ui/src/git_panel_settings.rs +++ b/crates/git_ui/src/git_panel_settings.rs @@ -29,6 +29,7 @@ pub struct GitPanelSettings { pub tree_view: bool, pub diff_stats: bool, pub show_count_badge: bool, + pub starts_open: bool, } impl ScrollbarVisibility for GitPanelSettings { @@ -66,6 +67,7 @@ impl Settings for GitPanelSettings { 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(), } } } diff --git a/crates/settings_content/src/settings_content.rs b/crates/settings_content/src/settings_content.rs index 8ab0ad6874a9c87a2104ba580c7fb1a90276027e..19ffca06e131c177656e229d2101eb259256f318 100644 --- a/crates/settings_content/src/settings_content.rs +++ b/crates/settings_content/src/settings_content.rs @@ -640,6 +640,11 @@ pub struct GitPanelSettingsContent { /// /// Default: false pub show_count_badge: Option, + + /// Whether the git panel should open on startup. + /// + /// Default: false + pub starts_open: Option, } #[derive( diff --git a/docs/src/reference/all-settings.md b/docs/src/reference/all-settings.md index 4af2d70de71b6372f68931826e0192ff5f218602..da93b290b4486599cf3cecc05b08f5f7a7ea1984 100644 --- a/docs/src/reference/all-settings.md +++ b/docs/src/reference/all-settings.md @@ -5097,7 +5097,8 @@ See the [debugger page](../debugger.md) for more information about debugging sup "collapse_untracked_diff": false, "scrollbar": { "show": null - } + }, + "starts_open": false } } ``` @@ -5112,6 +5113,7 @@ See the [debugger page](../debugger.md) for more information about debugging sup - `sort_by_path`: Whether to sort entries in the panel by path or by status (the default) - `collapse_untracked_diff`: Whether to collapse untracked files in the diff panel - `scrollbar`: When to show the scrollbar in the git panel +- `starts_open`: Whether the git panel should open on startup ## Git Worktree Directory