Skip to content

Commit 4aeea74

Browse files
authored
Merge pull request #10337 from schpet/window-title
Include project name in window title
2 parents 6e6e730 + e8616a3 commit 4aeea74

File tree

7 files changed

+38
-0
lines changed

7 files changed

+38
-0
lines changed

apps/desktop/cypress/e2e/support/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ Cypress.on('window:before:load', (win) => {
162162
return MOCK_USER;
163163
case 'plugin:window|theme':
164164
return 'light';
165+
case 'plugin:window|set_title':
166+
return await Promise.resolve();
165167
case 'update_feature_flags':
166168
return await Promise.resolve();
167169
case 'get_app_settings':

apps/desktop/src/lib/backend/backend.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ export interface IBackend {
6969
* Loads a disk store from a file.
7070
*/
7171
loadDiskStore: (fileName: string) => Promise<DiskStore>;
72+
/**
73+
* Sets the window title.
74+
*/
75+
setWindowTitle: (title: string) => void;
7276
}
7377

7478
export interface DiskStore {

apps/desktop/src/lib/backend/tauri.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ export default class Tauri implements IBackend {
5959
const store = await Store.load(fileName, { autoSave: true });
6060
return new TauriDiskStore(store);
6161
}
62+
setWindowTitle(title: string): void {
63+
if (!this.appWindow) {
64+
this.appWindow = getCurrentWindow();
65+
}
66+
this.appWindow.setTitle(title);
67+
}
6268
}
6369

6470
class TauriDiskStore implements DiskStore {

apps/desktop/src/lib/backend/web.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ export default class Web implements IBackend {
3232
// For the web version, we don't have a disk store, so we return a no-op implementation
3333
return new WebDiskStore();
3434
}
35+
setWindowTitle(title: string): void {
36+
document.title = title;
37+
}
3538
}
3639

3740
class WebDiskStore implements DiskStore {

apps/desktop/src/routes/+layout.svelte

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,13 @@
7474
const shortcutService = inject(SHORTCUT_SERVICE);
7575
$effect(() => shortcutService.listen());
7676
77+
// Reset window title when not in a project
78+
$effect(() => {
79+
if (!projectId) {
80+
backend.setWindowTitle('GitButler');
81+
}
82+
});
83+
7784
// =============================================================================
7885
// ANALYTICS & NAVIGATION
7986
// =============================================================================

apps/desktop/src/routes/[projectId]/+layout.svelte

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import ProjectSettingsMenuAction from '$components/ProjectSettingsMenuAction.svelte';
1212
import ReduxResult from '$components/ReduxResult.svelte';
1313
import { OnboardingEvent, POSTHOG_WRAPPER } from '$lib/analytics/posthog';
14+
import { BACKEND } from '$lib/backend';
1415
import { BASE_BRANCH_SERVICE } from '$lib/baseBranch/baseBranchService.svelte';
1516
import { BRANCH_SERVICE } from '$lib/branches/branchService.svelte';
1617
import { SETTINGS_SERVICE } from '$lib/config/appSettingsV2';
@@ -59,6 +60,7 @@
5960
// Project data
6061
const projectsResult = $derived(projectsService.projects());
6162
const projects = $derived(projectsResult.current.data);
63+
const currentProject = $derived(projects?.find((p) => p.id === projectId));
6264
6365
// =============================================================================
6466
// REPOSITORY & BRANCH MANAGEMENT
@@ -172,6 +174,19 @@
172174
};
173175
});
174176
177+
// =============================================================================
178+
// WINDOW TITLE
179+
// =============================================================================
180+
181+
const backend = inject(BACKEND);
182+
$effect(() => {
183+
if (currentProject?.title) {
184+
backend.setWindowTitle(`${currentProject.title} — GitButler`);
185+
} else {
186+
backend.setWindowTitle('GitButler');
187+
}
188+
});
189+
175190
// =============================================================================
176191
// FEED & UPDATES MANAGEMENT
177192
// =============================================================================

crates/gitbutler-tauri/capabilities/main.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"permissions": [
88
"core:default",
99
"core:window:allow-start-dragging",
10+
"core:window:allow-set-title",
1011
"core:window:default",
1112
"dialog:allow-open",
1213
"fs:allow-read-file",

0 commit comments

Comments
 (0)