fix: multiple goose instances running at once (#2234)

This commit is contained in:
Zane
2025-04-17 07:58:30 -07:00
committed by GitHub
parent 66bfcc0e55
commit 086ec89283
+17 -15
View File
@@ -39,13 +39,15 @@ if (started) app.quit();
app.setAsDefaultProtocolClient('goose'); app.setAsDefaultProtocolClient('goose');
const gotTheLock = app.requestSingleInstanceLock(); // Only apply single instance lock on Windows where it's needed for deep links
let gotTheLock = true;
if (process.platform === 'win32') {
gotTheLock = app.requestSingleInstanceLock();
if (!gotTheLock) { if (!gotTheLock) {
app.quit(); app.quit();
} else { } else {
app.on('second-instance', (event, commandLine) => { app.on('second-instance', (event, commandLine) => {
if (process.platform === 'win32') {
const protocolUrl = commandLine.find((arg) => arg.startsWith('goose://')); const protocolUrl = commandLine.find((arg) => arg.startsWith('goose://'));
if (protocolUrl) { if (protocolUrl) {
const parsedUrl = new URL(protocolUrl); const parsedUrl = new URL(protocolUrl);
@@ -84,15 +86,15 @@ if (!gotTheLock) {
} }
mainWindow.focus(); mainWindow.focus();
} }
} });
}); }
if (process.platform === 'win32') {
const protocolUrl = process.argv.find((arg) => arg.startsWith('goose://')); // Handle protocol URLs on Windows startup
if (protocolUrl) { const protocolUrl = process.argv.find((arg) => arg.startsWith('goose://'));
app.whenReady().then(() => { if (protocolUrl) {
handleProtocolUrl(protocolUrl); app.whenReady().then(() => {
}); handleProtocolUrl(protocolUrl);
} });
} }
} }