diff --git a/src/main/handlers/app.ts b/src/main/handlers/app.ts index 953aaeb41..7d7770564 100644 --- a/src/main/handlers/app.ts +++ b/src/main/handlers/app.ts @@ -5,7 +5,6 @@ import { EVENTS } from '../../shared/events'; import { Paths } from '../config'; import { handleMainEvent, onMainEvent } from '../events'; -import { setKeepRunningInTray } from '../lifecycle/window'; /** * Register IPC handlers for general application queries and window/app control. @@ -21,10 +20,6 @@ export function registerAppHandlers(mb: Menubar): void { onMainEvent(EVENTS.QUIT, () => mb.app.quit()); - onMainEvent(EVENTS.UPDATE_KEEP_RUNNING_IN_TRAY, (_, value: boolean) => { - setKeepRunningInTray(value); - }); - // Path handlers for renderer queries about resource locations handleMainEvent(EVENTS.NOTIFICATION_SOUND_PATH, () => { return Paths.notificationSound; diff --git a/src/main/lifecycle/window.test.ts b/src/main/lifecycle/window.test.ts index 280c7e230..6bf021ce8 100644 --- a/src/main/lifecycle/window.test.ts +++ b/src/main/lifecycle/window.test.ts @@ -3,7 +3,6 @@ import type { Menubar } from 'menubar'; import { __resetWindowLifecycleForTests, configureWindowEvents, - setKeepRunningInTray, } from './window'; const appOnMock = vi.fn(); @@ -57,7 +56,6 @@ describe('main/lifecycle/window.ts', () => { appOnMock.mockClear(); appQuitMock.mockClear(); __resetWindowLifecycleForTests(); - setKeepRunningInTray(false); setPlatform('linux'); menubar = { @@ -128,9 +126,8 @@ describe('main/lifecycle/window.ts', () => { }); describe('window close handler', () => { - it('hides the window and restores menubar reference when keepRunningInTray is enabled', async () => { + it('hides the window and restores menubar reference on a WM close', async () => { configureWindowEvents(menubar); - setKeepRunningInTray(true); const closeHandler = findWindowHandler(menubar, 'close'); const event = { preventDefault: vi.fn() }; @@ -153,7 +150,6 @@ describe('main/lifecycle/window.ts', () => { it('skips the deferred hide when the captured window is destroyed', async () => { configureWindowEvents(menubar); - setKeepRunningInTray(true); const captured = menubar.window; const closeHandler = findWindowHandler(menubar, 'close'); @@ -166,23 +162,9 @@ describe('main/lifecycle/window.ts', () => { expect(captured?.hide).not.toHaveBeenCalled(); }); - it('lets the window close normally when keepRunningInTray is disabled', async () => { + it('lets the window close during quit', async () => { configureWindowEvents(menubar); - const closeHandler = findWindowHandler(menubar, 'close'); - const event = { preventDefault: vi.fn() }; - closeHandler?.(event); - - await flushDeferred(); - - expect(event.preventDefault).not.toHaveBeenCalled(); - expect(menubar.window?.hide).not.toHaveBeenCalled(); - }); - - it('lets the window close during quit even when keepRunningInTray is enabled', async () => { - configureWindowEvents(menubar); - setKeepRunningInTray(true); - findAppHandler('before-quit')?.(); const closeHandler = findWindowHandler(menubar, 'close'); @@ -197,26 +179,16 @@ describe('main/lifecycle/window.ts', () => { }); describe('window-all-closed handler', () => { - it('keeps the app alive when keepRunningInTray is enabled', () => { + it('keeps the app alive when not quitting', () => { configureWindowEvents(menubar); - setKeepRunningInTray(true); findAppHandler('window-all-closed')?.(); expect(appQuitMock).not.toHaveBeenCalled(); }); - it('quits when keepRunningInTray is disabled (linux)', () => { - configureWindowEvents(menubar); - - findAppHandler('window-all-closed')?.(); - - expect(appQuitMock).toHaveBeenCalled(); - }); - - it('quits when the user is quitting even if keepRunningInTray is enabled', () => { + it('quits on linux when the user is quitting', () => { configureWindowEvents(menubar); - setKeepRunningInTray(true); findAppHandler('before-quit')?.(); findAppHandler('window-all-closed')?.(); @@ -224,10 +196,11 @@ describe('main/lifecycle/window.ts', () => { expect(appQuitMock).toHaveBeenCalled(); }); - it('does not quit on macOS when keepRunningInTray is disabled', () => { + it('does not quit on macOS', () => { setPlatform('darwin'); configureWindowEvents(menubar); + findAppHandler('before-quit')?.(); findAppHandler('window-all-closed')?.(); expect(appQuitMock).not.toHaveBeenCalled(); diff --git a/src/main/lifecycle/window.ts b/src/main/lifecycle/window.ts index 15f9c46d8..90cf679f1 100644 --- a/src/main/lifecycle/window.ts +++ b/src/main/lifecycle/window.ts @@ -6,19 +6,8 @@ import { isMacOS } from '../../shared/platform'; import { WindowConfig } from '../config'; -let keepRunningInTray = false; let isQuitting = false; -/** - * Update the "keep running in tray" preference. When `true`, an OS / window - * manager close request hides the window instead of quitting the app. - * - * @param value - `true` to hide on window close, `false` to quit. - */ -export function setKeepRunningInTray(value: boolean): void { - keepRunningInTray = value; -} - /** * Reset module-level lifecycle flags. Module-level state is unavoidable * because `app.on(...)` listeners are registered once at startup; this @@ -27,7 +16,6 @@ export function setKeepRunningInTray(value: boolean): void { * @internal */ export function __resetWindowLifecycleForTests(): void { - keepRunningInTray = false; isQuitting = false; } @@ -94,7 +82,7 @@ export function configureWindowEvents(mb: Menubar): void { * first. */ win.on('close', (event) => { - if (!keepRunningInTray || isQuitting) { + if (isQuitting) { return; } @@ -117,7 +105,7 @@ export function configureWindowEvents(mb: Menubar): void { * the next tray click. */ app.on('window-all-closed', () => { - if (keepRunningInTray && !isQuitting) { + if (!isQuitting) { return; } if (!isMacOS()) { diff --git a/src/preload/index.ts b/src/preload/index.ts index ab285a64c..a3730d14c 100644 --- a/src/preload/index.ts +++ b/src/preload/index.ts @@ -55,15 +55,6 @@ export const api = { openAsHidden: value, }), - /** - * Enable or disable hiding the application window to the tray when the - * window receives a close request (e.g. from the OS / window manager). - * - * @param value - `true` to hide on close, `false` to quit on close. - */ - setKeepRunningInTray: (value: boolean) => - sendMainEvent(EVENTS.UPDATE_KEEP_RUNNING_IN_TRAY, value), - /** * Apply the global keyboard shortcut for toggling the app window visibility. * diff --git a/src/renderer/__helpers__/vitest.setup.ts b/src/renderer/__helpers__/vitest.setup.ts index 5ef2b3e52..9b7a18670 100644 --- a/src/renderer/__helpers__/vitest.setup.ts +++ b/src/renderer/__helpers__/vitest.setup.ts @@ -60,7 +60,6 @@ window.gitify = { onAuthCallback: vi.fn(), onResetApp: vi.fn(), setAutoLaunch: vi.fn(), - setKeepRunningInTray: vi.fn(), applyKeyboardShortcut: vi.fn().mockResolvedValue({ success: true }), raiseNativeNotification: vi.fn(), }; diff --git a/src/renderer/__mocks__/state-mocks.ts b/src/renderer/__mocks__/state-mocks.ts index f9b8e8b21..4e7f58be4 100644 --- a/src/renderer/__mocks__/state-mocks.ts +++ b/src/renderer/__mocks__/state-mocks.ts @@ -65,7 +65,6 @@ const mockSystemSettings: SystemSettingsState = { playSound: true, notificationVolume: 20 as Percentage, openAtStartup: false, - keepRunningInTray: false, }; export const mockSettings: SettingsState = { diff --git a/src/renderer/components/settings/SystemSettings.tsx b/src/renderer/components/settings/SystemSettings.tsx index 607c56212..b04e40674 100644 --- a/src/renderer/components/settings/SystemSettings.tsx +++ b/src/renderer/components/settings/SystemSettings.tsx @@ -372,28 +372,6 @@ export const SystemSettings: FC = () => { } visible={!window.gitify.platform.isLinux()} /> - - - updateSetting('keepRunningInTray', !settings.keepRunningInTray) - } - tooltip={ - - - Hide {APPLICATION.NAME} to the system tray when the window is - closed by the operating system or window manager, instead of - quitting the application. - - - Use the tray menu or the Quit shortcut to fully exit{' '} - {APPLICATION.NAME}. - - - } - /> ); diff --git a/src/renderer/context/App.tsx b/src/renderer/context/App.tsx index 181622d2a..ffda09e52 100644 --- a/src/renderer/context/App.tsx +++ b/src/renderer/context/App.tsx @@ -58,7 +58,6 @@ import { decryptValue, encryptValue, setAutoLaunch, - setKeepRunningInTray, setUseAlternateIdleIcon, setUseUnreadActiveIcon, } from '../utils/system/comms'; @@ -401,10 +400,6 @@ export const AppProvider = ({ children }: { children: ReactNode }) => { setAutoLaunch(settings.openAtStartup); }, [settings.openAtStartup]); - useEffect(() => { - setKeepRunningInTray(settings.keepRunningInTray); - }, [settings.keepRunningInTray]); - useEffect(() => { window.gitify.onResetApp(() => { clearState(); diff --git a/src/renderer/context/defaults.ts b/src/renderer/context/defaults.ts index 02150c4d4..ae22026cc 100644 --- a/src/renderer/context/defaults.ts +++ b/src/renderer/context/defaults.ts @@ -56,7 +56,6 @@ const defaultSystemSettings: SystemSettingsState = { playSound: true, notificationVolume: 20 as Percentage, openAtStartup: false, - keepRunningInTray: false, }; export const defaultSettings: SettingsState = { diff --git a/src/renderer/routes/__snapshots__/Settings.test.tsx.snap b/src/renderer/routes/__snapshots__/Settings.test.tsx.snap index 4246d0d95..bf0640eec 100644 --- a/src/renderer/routes/__snapshots__/Settings.test.tsx.snap +++ b/src/renderer/routes/__snapshots__/Settings.test.tsx.snap @@ -2138,55 +2138,6 @@ exports[`renderer/routes/Settings.tsx > should render itself & its children 1`] -
- - - -
should render itself & its children 1`] data-wrap="nowrap" >