From dde73675e89fec4d0910f2ea54c7aa57ce1ea908 Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Tue, 16 Jun 2026 01:17:52 +0900 Subject: [PATCH] [PM-38565] Replace tray settings with "Keep Bitwarden running in the background" (#21044) * Implement new settings behavior * Copy changes * Migrate setting * Fix build * Fix --- .../accounts/settings-dialog.component.html | 40 +------ .../settings-dialog.component.spec.ts | 5 +- .../app/accounts/settings-dialog.component.ts | 85 ++------------ .../src/app/accounts/settings.component.html | 65 ++--------- .../app/accounts/settings.component.spec.ts | 5 +- .../src/app/accounts/settings.component.ts | 87 ++------------- apps/desktop/src/locales/en/messages.json | 57 ++-------- apps/desktop/src/main.ts | 9 +- apps/desktop/src/main/messaging.main.ts | 14 +-- apps/desktop/src/main/tray.main.ts | 104 ++++++++---------- apps/desktop/src/main/window.main.ts | 12 +- .../services/desktop-settings.service.ts | 76 +++---------- libs/state/src/state-migrations/migrate.ts | 6 +- ...solidate-tray-to-run-in-background.spec.ts | 76 +++++++++++++ ...0-consolidate-tray-to-run-in-background.ts | 62 +++++++++++ 15 files changed, 262 insertions(+), 441 deletions(-) create mode 100644 libs/state/src/state-migrations/migrations/80-consolidate-tray-to-run-in-background.spec.ts create mode 100644 libs/state/src/state-migrations/migrations/80-consolidate-tray-to-run-in-background.ts diff --git a/apps/desktop/src/app/accounts/settings-dialog.component.html b/apps/desktop/src/app/accounts/settings-dialog.component.html index abf1cfe1aeb..13f01bbcbfd 100644 --- a/apps/desktop/src/app/accounts/settings-dialog.component.html +++ b/apps/desktop/src/app/accounts/settings-dialog.component.html @@ -100,34 +100,15 @@ - - - {{ enableTrayText }} - {{ enableTrayDescText }} - - - @if (showMinToTray) { - - - {{ enableMinToTrayText }} - {{ enableMinToTrayDescText }} - - } - - {{ enableCloseToTrayText }} - {{ enableCloseToTrayDescText }} + {{ runInBackgroundText }} + {{ runInBackgroundDescText }} @if (showOpenAtLoginOption) { @@ -143,19 +124,6 @@ } - @if (showAlwaysShowDock) { - - - {{ "alwaysShowDock" | i18n }} - {{ "alwaysShowDockDesc" | i18n }} - - } - { biometricStateService.promptAutomatically$ = of(false); autofillSettingsServiceAbstraction.clearClipboardDelay$ = of(null); desktopSettingsService.minimizeOnCopy$ = of(false); - desktopSettingsService.trayEnabled$ = of(false); - desktopSettingsService.minimizeToTray$ = of(false); - desktopSettingsService.closeToTray$ = of(false); + desktopSettingsService.runInBackground$ = of(false); desktopSettingsService.openAtLogin$ = of(false); - desktopSettingsService.alwaysShowDock$ = of(false); desktopSettingsService.browserIntegrationEnabled$ = of(false); desktopSettingsService.hardwareAcceleration$ = of(false); desktopSettingsService.sshAgentEnabled$ = of(false); diff --git a/apps/desktop/src/app/accounts/settings-dialog.component.ts b/apps/desktop/src/app/accounts/settings-dialog.component.ts index fdd1377c5a8..d1ff0ce91a0 100644 --- a/apps/desktop/src/app/accounts/settings-dialog.component.ts +++ b/apps/desktop/src/app/accounts/settings-dialog.component.ts @@ -136,20 +136,13 @@ export class SettingsDialogComponent implements OnInit { protected readonly isWindows: boolean; protected readonly isLinux: boolean; protected readonly isMac: boolean; - protected readonly requireEnableTray: boolean; protected readonly showOpenAtLoginOption: boolean; protected readonly showDuckDuckGoIntegrationOption: boolean; - protected readonly enableTrayText: string; - protected readonly enableTrayDescText: string; - protected readonly enableMinToTrayText: string; - protected readonly enableMinToTrayDescText: string; - protected readonly enableCloseToTrayText: string; - protected readonly enableCloseToTrayDescText: string; + protected readonly runInBackgroundText: string; + protected readonly runInBackgroundDescText: string; protected readonly supportsBiometric = signal(false); protected readonly showEnableAutotype = signal(false); - protected readonly showMinToTray: boolean; - protected readonly showAlwaysShowDock: boolean; private readonly activeAccount = toSignal(this.accountService.activeAccount$, { requireSync: true, }); @@ -182,11 +175,8 @@ export class SettingsDialogComponent implements OnInit { minimizeOnCopyToClipboard: false, enableFavicons: false, // App Settings - enableTray: false, - enableMinToTray: false, - enableCloseToTray: false, + runInBackground: false, openAtLogin: false, - alwaysShowDock: false, enableBrowserIntegration: false, enableHardwareAcceleration: true, enableSshAgent: false, @@ -206,23 +196,11 @@ export class SettingsDialogComponent implements OnInit { this.isMac = this.platformUtilsService.getDevice() === DeviceType.MacOsDesktop; this.isLinux = this.platformUtilsService.getDevice() === DeviceType.LinuxDesktop; this.isWindows = this.platformUtilsService.getDevice() === DeviceType.WindowsDesktop; - this.showMinToTray = !this.isLinux; - this.showAlwaysShowDock = this.isMac; - // Workaround to avoid ghosting trays https://github.com/electron/electron/issues/17622 - this.requireEnableTray = this.platformUtilsService.getDevice() === DeviceType.LinuxDesktop; - - const trayKey = this.isMac ? "enableMenuBar" : "enableTray"; - this.enableTrayText = this.i18nService.t(trayKey); - this.enableTrayDescText = this.i18nService.t(trayKey + "Desc"); - - const minToTrayKey = this.isMac ? "enableMinToMenuBar" : "enableMinToTray"; - this.enableMinToTrayText = this.i18nService.t(minToTrayKey); - this.enableMinToTrayDescText = this.i18nService.t(minToTrayKey + "Desc"); - - const closeToTrayKey = this.isMac ? "enableCloseToMenuBar" : "enableCloseToTray"; - this.enableCloseToTrayText = this.i18nService.t(closeToTrayKey); - this.enableCloseToTrayDescText = this.i18nService.t(closeToTrayKey + "Desc"); + this.runInBackgroundText = this.i18nService.t("runInBackground"); + this.runInBackgroundDescText = this.i18nService.t( + this.isMac ? "runInBackgroundDescMac" : "runInBackgroundDesc", + ); this.showOpenAtLoginOption = this.showAutostartSetting(); @@ -294,11 +272,8 @@ export class SettingsDialogComponent implements OnInit { clearClipboard: await firstValueFrom(this.autofillSettingsService.clearClipboardDelay$), minimizeOnCopyToClipboard: await firstValueFrom(this.desktopSettingsService.minimizeOnCopy$), enableFavicons: await firstValueFrom(this.domainSettingsService.showFavicons$), - enableTray: await firstValueFrom(this.desktopSettingsService.trayEnabled$), - enableMinToTray: await firstValueFrom(this.desktopSettingsService.minimizeToTray$), - enableCloseToTray: await firstValueFrom(this.desktopSettingsService.closeToTray$), + runInBackground: await firstValueFrom(this.desktopSettingsService.runInBackground$), openAtLogin: await firstValueFrom(this.desktopSettingsService.openAtLogin$), - alwaysShowDock: await firstValueFrom(this.desktopSettingsService.alwaysShowDock$), enableBrowserIntegration: await firstValueFrom( this.desktopSettingsService.browserIntegrationEnabled$, ), @@ -556,44 +531,8 @@ export class SettingsDialogComponent implements OnInit { this.messagingService.send("refreshCiphers"); } - protected async saveMinToTray() { - await this.desktopSettingsService.setMinimizeToTray(this.form.value.enableMinToTray); - } - - protected async saveCloseToTray() { - if (this.requireEnableTray) { - this.form.controls.enableTray.setValue(true); - await this.desktopSettingsService.setTrayEnabled(this.form.value.enableTray); - } - - await this.desktopSettingsService.setCloseToTray(this.form.value.enableCloseToTray); - } - - protected async saveTray() { - if ( - this.requireEnableTray && - !this.form.value.enableTray && - this.form.value.enableCloseToTray - ) { - const confirm = await this.dialogService.openSimpleDialog({ - title: { key: "confirmTrayTitle" }, - content: { key: "confirmTrayDesc" }, - type: "warning", - }); - - if (confirm) { - this.form.controls.enableCloseToTray.setValue(false, { emitEvent: false }); - await this.desktopSettingsService.setCloseToTray(this.form.value.enableCloseToTray); - } else { - this.form.controls.enableTray.setValue(true); - } - - return; - } - - await this.desktopSettingsService.setTrayEnabled(this.form.value.enableTray); - // TODO: Ideally the DesktopSettingsService.trayEnabled$ could be subscribed to instead of using messaging. - this.messagingService.send(this.form.value.enableTray ? "showTray" : "removeTray"); + protected async saveRunInBackground() { + await this.desktopSettingsService.setRunInBackground(this.form.value.runInBackground); } private async saveLocale(newValue: string) { @@ -615,10 +554,6 @@ export class SettingsDialogComponent implements OnInit { await this.autofillSettingsService.setClearClipboardDelay(newValue); } - protected async saveAlwaysShowDock() { - await this.desktopSettingsService.setAlwaysShowDock(this.form.value.alwaysShowDock); - } - private showAutostartSetting(): boolean { // Windows store does not support autostart // Dev mode should not show auto-start, because it would result in an empty electron window starting on login diff --git a/apps/desktop/src/app/accounts/settings.component.html b/apps/desktop/src/app/accounts/settings.component.html index 893eb08d7d7..4f2cf92addc 100644 --- a/apps/desktop/src/app/accounts/settings.component.html +++ b/apps/desktop/src/app/accounts/settings.component.html @@ -183,51 +183,19 @@
-
- {{ enableTrayDescText }} -
-
-
- -
- {{ - enableMinToTrayDescText - }} -
-
-
- -
- {{ - enableCloseToTrayDescText + {{ + runInBackgroundDescText }}
@@ -247,23 +215,6 @@ "openAtLoginDesc" | i18n }}
-
-
- -
- {{ - "alwaysShowDockDesc" | i18n - }} -