From f15323e37e9fc4128f5eb9ec6cfb373cee8a88c2 Mon Sep 17 00:00:00 2001 From: David Kaya Date: Thu, 16 Apr 2026 13:54:22 +0200 Subject: [PATCH] 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> --- src/main/index.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/index.ts b/src/main/index.ts index c71d1ac..b541b1b 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -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 { autoUpdateService.start(); } +app.on('second-instance', () => { + showAndFocusWindow(); +}); + app.whenReady().then(bootstrap); app.on('window-all-closed', () => {