From 49503afc89138cced74268593005b95c3275ec67 Mon Sep 17 00:00:00 2001 From: dataCenter430 Date: Sun, 15 Feb 2026 16:21:49 -0700 Subject: [PATCH 1/2] fix(electron): skip single-instance lock in dev to prevent dev server exit --- electron/main/index.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/electron/main/index.ts b/electron/main/index.ts index b2001bbf0..171c9b829 100644 --- a/electron/main/index.ts +++ b/electron/main/index.ts @@ -209,7 +209,9 @@ if (os.release().startsWith('6.1')) app.disableHardwareAcceleration(); // Set application name for Windows 10+ notifications if (process.platform === 'win32') app.setAppUserModelId(app.getName()); -if (!app.requestSingleInstanceLock()) { +// Only enforce single-instance in production. In dev, a second instance (e.g. second +// npm run dev) would quit here and take its dev server down; skip so multiple dev instances work. +if (!VITE_DEV_SERVER_URL && !app.requestSingleInstanceLock()) { app.quit(); process.exit(0); } @@ -303,6 +305,10 @@ function processQueuedProtocolUrls() { // ==================== single instance lock ==================== const setupSingleInstanceLock = () => { + if (VITE_DEV_SERVER_URL) { + // Dev: allow multiple instances so a second npm run dev doesn't quit and kill its dev server + return; + } const gotLock = app.requestSingleInstanceLock(); if (!gotLock) { log.info('no-lock'); From 8fa8eef34e0bc1e09bc11eccf47b05932131ff42 Mon Sep 17 00:00:00 2001 From: dataCenter430 Date: Thu, 12 Mar 2026 23:43:09 +0100 Subject: [PATCH 2/2] feat: use multiple electron instances in dev --- .env.development | 3 +++ electron/main/index.ts | 14 +++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.env.development b/.env.development index 81b3be797..7ce20482e 100644 --- a/.env.development +++ b/.env.development @@ -11,3 +11,6 @@ VITE_USE_LOCAL_PROXY=false VITE_STACK_PROJECT_ID=dummy_project_id VITE_STACK_PUBLISHABLE_CLIENT_KEY=dummy_publishable_key VITE_STACK_SECRET_SERVER_KEY=dummy_secret_server_key + +# Allow multiple Electron instances in dev (e.g. multiple `npm run dev`). Remove or set to 0 for single-instance. +# EIGENT_DEV_MULTI_INSTANCE=1 diff --git a/electron/main/index.ts b/electron/main/index.ts index 171c9b829..d1db30a45 100644 --- a/electron/main/index.ts +++ b/electron/main/index.ts @@ -72,6 +72,11 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url)); const MAIN_DIST = path.join(__dirname, '../..'); const RENDERER_DIST = path.join(MAIN_DIST, 'dist'); const VITE_DEV_SERVER_URL = process.env.VITE_DEV_SERVER_URL; +/** When set to '1', allows multiple Electron instances in dev (e.g. multiple `npm run dev`). Default: single-instance. */ +const EIGENT_DEV_MULTI_INSTANCE = process.env.EIGENT_DEV_MULTI_INSTANCE === '1'; +const skipSingleInstanceInDev = Boolean( + VITE_DEV_SERVER_URL && EIGENT_DEV_MULTI_INSTANCE +); const VITE_PUBLIC = VITE_DEV_SERVER_URL ? path.join(MAIN_DIST, 'public') : RENDERER_DIST; @@ -209,9 +214,8 @@ if (os.release().startsWith('6.1')) app.disableHardwareAcceleration(); // Set application name for Windows 10+ notifications if (process.platform === 'win32') app.setAppUserModelId(app.getName()); -// Only enforce single-instance in production. In dev, a second instance (e.g. second -// npm run dev) would quit here and take its dev server down; skip so multiple dev instances work. -if (!VITE_DEV_SERVER_URL && !app.requestSingleInstanceLock()) { +// Enforce single-instance unless in dev with EIGENT_DEV_MULTI_INSTANCE=1 (allows multiple npm run dev). +if (!skipSingleInstanceInDev && !app.requestSingleInstanceLock()) { app.quit(); process.exit(0); } @@ -305,8 +309,8 @@ function processQueuedProtocolUrls() { // ==================== single instance lock ==================== const setupSingleInstanceLock = () => { - if (VITE_DEV_SERVER_URL) { - // Dev: allow multiple instances so a second npm run dev doesn't quit and kill its dev server + if (skipSingleInstanceInDev) { + // Dev with EIGENT_DEV_MULTI_INSTANCE=1: allow multiple instances return; } const gotLock = app.requestSingleInstanceLock();