mirror of
https://github.com/davidkaya/aryx.git
synced 2026-07-24 05:28:46 +02:00
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:
@@ -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', () => {
|
||||
|
||||
Reference in New Issue
Block a user