Skip to content

Commit 3f645d5

Browse files
committed
feat: add UI settings to support native title bar style
1 parent 973751a commit 3f645d5

File tree

11 files changed

+103
-22
lines changed

11 files changed

+103
-22
lines changed

apps/desktop/cypress/e2e/support/mock/settings.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,8 @@ export const MOCK_APP_SETTINGS: AppSettings = {
3333
},
3434
reviews: {
3535
autoFillPrDescriptionFromCommit: true
36+
},
37+
ui: {
38+
useNativeTitleBar: false
3639
}
3740
};

apps/desktop/src/components/ChromeHeader.svelte

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
const isWorkspace = $derived(isWorkspacePath());
4646
const canUseActions = $derived($settingsStore?.featureFlags.actions ?? false);
4747
const singleBranchMode = $derived($settingsStore?.featureFlags.singleBranch ?? false);
48+
const enableTauriDrag = $derived(!($settingsStore?.ui.useNativeTitleBar ?? false));
4849
const backend = inject(BACKEND);
4950
5051
const mode = $derived(modeService.mode({ projectId }));
@@ -112,11 +113,11 @@
112113
<div
113114
class="chrome-header"
114115
class:mac={backend.platformName === 'macos'}
115-
data-tauri-drag-region
116+
data-tauri-drag-region={enableTauriDrag}
116117
class:single-branch={singleBranchMode}
117118
use:focusable
118119
>
119-
<div class="chrome-left" data-tauri-drag-region>
120+
<div class="chrome-left" data-tauri-drag-region={enableTauriDrag}>
120121
<div class="chrome-left-buttons" class:macos={backend.platformName === 'macos'}>
121122
<SyncButton {projectId} disabled={actionsDisabled} />
122123

@@ -138,7 +139,7 @@
138139
</div>
139140
</div>
140141

141-
<div class="chrome-center" data-tauri-drag-region>
142+
<div class="chrome-center" data-tauri-drag-region={enableTauriDrag}>
142143
<div class="chrome-selector-wrapper">
143144
<Select
144145
searchable
@@ -244,7 +245,7 @@
244245
{/if}
245246
</div>
246247

247-
<div class="chrome-right" data-tauri-drag-region>
248+
<div class="chrome-right" data-tauri-drag-region={enableTauriDrag}>
248249
{#if $ircEnabled}
249250
<NotificationButton
250251
hasUnread={isNotificationsUnread}

apps/desktop/src/lib/config/appSettingsV2.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ export class SettingsService {
6767
await this.backend.invoke('update_fetch', { update });
6868
}
6969

70+
async updateUi(update: Partial<UiSettings>) {
71+
await this.backend.invoke('update_ui', { update });
72+
}
73+
7074
private async nudge(): Promise<void> {
7175
await this.autoOptInWs3();
7276
await this.autoOptInRules();
@@ -154,6 +158,8 @@ export type AppSettings = {
154158
claude: Claude;
155159
/** Settings related to code reviews and pull requests */
156160
reviews: Reviews;
161+
/** UI settings */
162+
ui: UiSettings;
157163
};
158164

159165
export type TelemetrySettings = {
@@ -206,3 +212,8 @@ export type Reviews = {
206212
/** Whether to auto-fill PR title and description from the first commit when a branch has only one commit. */
207213
autoFillPrDescriptionFromCommit: boolean;
208214
};
215+
216+
export type UiSettings = {
217+
/** Whether to use the native system title bar. */
218+
useNativeTitleBar: boolean;
219+
};

crates/but-api/src/commands/settings.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! In place of commands.rs
22
use but_api_macros::api_cmd;
33
use but_settings::api::{
4-
ClaudeUpdate, FeatureFlagsUpdate, FetchUpdate, ReviewsUpdate, TelemetryUpdate,
4+
ClaudeUpdate, FeatureFlagsUpdate, FetchUpdate, ReviewsUpdate, TelemetryUpdate, UiUpdate,
55
};
66
use but_settings::{AppSettings, AppSettingsWithDiskSync};
77
use serde::Deserialize;
@@ -121,3 +121,18 @@ pub fn update_fetch(
121121
.update_fetch(params.update)
122122
.map_err(|e| e.into())
123123
}
124+
125+
#[derive(Deserialize)]
126+
#[serde(rename_all = "camelCase")]
127+
pub struct UpdateUiParams {
128+
pub update: UiUpdate,
129+
}
130+
131+
pub fn update_ui(
132+
app_settings_sync: &AppSettingsWithDiskSync,
133+
params: UpdateUiParams,
134+
) -> Result<(), Error> {
135+
app_settings_sync
136+
.update_ui(params.update)
137+
.map_err(|e| e.into())
138+
}

crates/but-settings/assets/defaults.jsonc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,10 @@
6464
"reviews": {
6565
// Whether to auto-fill PR title and description from the first commit when a branch has only one commit.
6666
"autoFillPrDescriptionFromCommit": true
67+
},
68+
// UI settings.
69+
"ui": {
70+
// Whether to use the native system title bar.
71+
"useNativeTitleBar": false
6772
}
6873
}

crates/but-settings/src/api.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ pub struct FetchUpdate {
4949
pub auto_fetch_interval_minutes: Option<isize>,
5050
}
5151

52+
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
53+
#[serde(rename_all = "camelCase")]
54+
/// Update request for [`crate::app_settings::UiSettings`].
55+
pub struct UiUpdate {
56+
pub use_native_title_bar: Option<bool>,
57+
}
58+
5259
/// Mutation, immediately followed by writing everything to disk.
5360
impl AppSettingsWithDiskSync {
5461
pub fn update_onboarding_complete(&self, update: bool) -> Result<()> {
@@ -151,4 +158,12 @@ impl AppSettingsWithDiskSync {
151158
}
152159
settings.save()
153160
}
161+
162+
pub fn update_ui(&self, update: UiUpdate) -> Result<()> {
163+
let mut settings = self.get_mut_enforce_save()?;
164+
if let Some(use_native_title_bar) = update.use_native_title_bar {
165+
settings.ui.use_native_title_bar = use_native_title_bar;
166+
}
167+
settings.save()
168+
}
154169
}

crates/but-settings/src/app_settings.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,10 @@ pub struct Reviews {
9191
/// Whether to auto-fill PR title and description from the first commit when a branch has only one commit.
9292
pub auto_fill_pr_description_from_commit: bool,
9393
}
94+
95+
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
96+
#[serde(rename_all = "camelCase")]
97+
pub struct UiSettings {
98+
/// Whether to use the native system title bar.
99+
pub use_native_title_bar: bool,
100+
}

crates/but-settings/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ pub struct AppSettings {
2222
pub claude: app_settings::Claude,
2323
/// Settings related to code reviews and pull requests.
2424
pub reviews: app_settings::Reviews,
25+
/// UI settings.
26+
pub ui: app_settings::UiSettings,
2527
}
2628

2729
impl Default for AppSettings {

crates/gitbutler-tauri/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ fn main() {
297297
settings::update_claude,
298298
settings::update_fetch,
299299
settings::update_reviews,
300+
settings::update_ui,
300301
action::list_actions,
301302
action::handle_changes,
302303
action::list_workflows,

crates/gitbutler-tauri/src/settings.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![allow(deprecated)]
22
use but_api::commands::settings;
33
use but_settings::api::{
4-
ClaudeUpdate, FeatureFlagsUpdate, FetchUpdate, ReviewsUpdate, TelemetryUpdate,
4+
ClaudeUpdate, FeatureFlagsUpdate, FetchUpdate, ReviewsUpdate, TelemetryUpdate, UiUpdate,
55
};
66
use but_settings::AppSettingsWithDiskSync;
77
use tauri::State;
@@ -83,3 +83,12 @@ pub fn update_reviews(
8383
) -> Result<(), Error> {
8484
settings::update_reviews(&app_settings_sync, settings::UpdateReviewsParams { update })
8585
}
86+
87+
#[tauri::command(async)]
88+
#[instrument(skip(app_settings_sync), err(Debug))]
89+
pub fn update_ui(
90+
app_settings_sync: State<'_, AppSettingsWithDiskSync>,
91+
update: UiUpdate,
92+
) -> Result<(), Error> {
93+
settings::update_ui(&app_settings_sync, settings::UpdateUiParams { update })
94+
}

0 commit comments

Comments
 (0)