Skip to content

Commit ca5f0e4

Browse files
committed
Fix quit and install handoff
1 parent 1fb93b0 commit ca5f0e4

9 files changed

Lines changed: 44 additions & 17 deletions

File tree

package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "setlist",
33
"private": true,
4-
"version": "0.6.1-beta.9",
4+
"version": "0.6.1-beta.10",
55
"license": "Apache-2.0",
66
"type": "module",
77
"workspaces": [

packages/app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@setlist/app",
3-
"version": "0.6.1-beta.9",
3+
"version": "0.6.1-beta.10",
44
"private": true,
55
"type": "module",
66
"main": "./out/main/index.js",

packages/app/src/main/index.ts

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { listPinnedProjects, registerIpcHandlers } from './ipc.js';
66
import { initAutoUpdater } from './auto-update.js';
77
import { getAppBehaviorPrefs, loadPrefs } from './prefs.js';
88
import { installAppMenu, handleMenuCheckForUpdates } from './menu.js';
9-
import { registerQuitPrompt } from './quit-prompt.js';
9+
import { isInstallingDownloadedUpdate, registerQuitPrompt } from './quit-prompt.js';
1010
import { installTray } from './tray.js';
1111
import {
1212
getShortcutRegistrationStatuses,
@@ -80,6 +80,15 @@ function quitApp(): void {
8080
app.quit();
8181
}
8282

83+
function shouldHideWindowInsteadOfClosing(): boolean {
84+
const prefs = getAppBehaviorPrefs();
85+
return (
86+
prefs.menu_bar_persistence_enabled &&
87+
!isQuitting &&
88+
!isInstallingDownloadedUpdate()
89+
);
90+
}
91+
8392
function refreshTray(): void {
8493
installTray({
8594
showWindow,
@@ -144,17 +153,15 @@ function createWindow(): void {
144153
});
145154

146155
mainWindow.on('close', (event) => {
147-
const prefs = getAppBehaviorPrefs();
148-
if (prefs.menu_bar_persistence_enabled && !isQuitting) {
156+
if (shouldHideWindowInsteadOfClosing()) {
149157
event.preventDefault();
150158
mainWindow?.hide();
151159
updateDockVisibility();
152160
}
153161
});
154162

155163
onPreventableMinimize(mainWindow, (event) => {
156-
const prefs = getAppBehaviorPrefs();
157-
if (prefs.menu_bar_persistence_enabled) {
164+
if (shouldHideWindowInsteadOfClosing()) {
158165
event.preventDefault();
159166
mainWindow?.hide();
160167
updateDockVisibility();
@@ -219,7 +226,11 @@ app.on('will-quit', () => {
219226
});
220227

221228
app.on('window-all-closed', () => {
222-
if (!getAppBehaviorPrefs().menu_bar_persistence_enabled || isQuitting) {
229+
if (
230+
!getAppBehaviorPrefs().menu_bar_persistence_enabled ||
231+
isQuitting ||
232+
isInstallingDownloadedUpdate()
233+
) {
223234
app.quit();
224235
} else {
225236
updateDockVisibility();

packages/app/src/main/quit-prompt.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,11 @@ describe('quit prompt update install flow', () => {
4444

4545
it('direct install marks the update handoff so a follow-up quit is not intercepted', async () => {
4646
const { app, quitAndInstall, mod } = await loadQuitPrompt();
47+
expect(mod.isInstallingDownloadedUpdate()).toBe(false);
48+
4749
expect(mod.installDownloadedUpdate()).toBe(true);
4850
expect(quitAndInstall).toHaveBeenCalledTimes(1);
51+
expect(mod.isInstallingDownloadedUpdate()).toBe(true);
4952

5053
mod.registerQuitPrompt(app as never, () => null);
5154
const event = { preventDefault: vi.fn() };
@@ -62,6 +65,7 @@ describe('quit prompt update install flow', () => {
6265
app.emitBeforeQuit(firstEvent);
6366
expect(firstEvent.preventDefault).toHaveBeenCalledTimes(1);
6467
expect(quitAndInstall).toHaveBeenCalledTimes(1);
68+
expect(mod.isInstallingDownloadedUpdate()).toBe(true);
6569

6670
const secondEvent = { preventDefault: vi.fn() };
6771
app.emitBeforeQuit(secondEvent);
@@ -79,4 +83,12 @@ describe('quit prompt update install flow', () => {
7983
expect(quitAndInstall).not.toHaveBeenCalled();
8084
expect(app.exit).toHaveBeenCalledWith(0);
8185
});
86+
87+
it('does not mark install handoff when no update is downloaded', async () => {
88+
const { quitAndInstall, mod } = await loadQuitPrompt({ downloaded: false });
89+
90+
expect(mod.installDownloadedUpdate()).toBe(false);
91+
expect(mod.isInstallingDownloadedUpdate()).toBe(false);
92+
expect(quitAndInstall).not.toHaveBeenCalled();
93+
});
8294
});

packages/app/src/main/quit-prompt.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ export function installDownloadedUpdate(): boolean {
2222
return true;
2323
}
2424

25+
export function isInstallingDownloadedUpdate(): boolean {
26+
return installing;
27+
}
28+
2529
/**
2630
* Register a before-quit listener that surfaces the install-or-skip
2731
* prompt when an update is staged. Must be called once during

packages/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@setlist/cli",
3-
"version": "0.6.1-beta.9",
3+
"version": "0.6.1-beta.10",
44
"license": "Apache-2.0",
55
"type": "module",
66
"main": "./dist/index.js",

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@setlist/core",
3-
"version": "0.6.1-beta.9",
3+
"version": "0.6.1-beta.10",
44
"license": "Apache-2.0",
55
"type": "module",
66
"main": "./dist/index.js",

packages/mcp/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@setlist/mcp",
3-
"version": "0.6.1-beta.9",
3+
"version": "0.6.1-beta.10",
44
"license": "Apache-2.0",
55
"type": "module",
66
"main": "./dist/index.js",

0 commit comments

Comments
 (0)