feat: enforce single-instance app launch

Use Electron's requestSingleInstanceLock() to prevent opening
multiple instances. When a second instance is attempted, the
existing window is restored and focused instead.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
David Kaya
2026-04-16 13:54:22 +02:00
co-authored by Copilot
parent 6c24754749
commit f15323e37e
+10
View File
@@ -16,6 +16,12 @@ import { createDefaultQuickPromptSettings } from '@shared/domain/tooling';
const { app, BrowserWindow } = electron;
// Enforce single instance — quit immediately if another instance already holds the lock.
const gotTheLock = app.requestSingleInstanceLock();
if (!gotTheLock) {
app.quit();
}
let mainWindow: BrowserWindowType | undefined;
let quickPromptWindow: BrowserWindowType | undefined;
let appService: AryxAppService | undefined;
@@ -109,6 +115,10 @@ async function bootstrap(): Promise<void> {
autoUpdateService.start();
}
app.on('second-instance', () => {
showAndFocusWindow();
});
app.whenReady().then(bootstrap);
app.on('window-all-closed', () => {