From e3a1b951fb737ea0ee92a55c30de21a189c9d58f Mon Sep 17 00:00:00 2001 From: LinYushen Date: Thu, 16 Apr 2026 16:20:37 +0800 Subject: [PATCH] fix(desktop): allow dev and production instances to coexist (#1155) Dev mode now uses a separate app name ('Multica Dev') and userData path before acquiring the single-instance lock, so the lock file no longer collides with the packaged production app. The AppUserModelId is also differentiated (ai.multica.desktop.dev vs ai.multica.desktop). This follows the same pattern VS Code uses for Stable / Insiders coexistence: isolate identity before requestSingleInstanceLock(). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- apps/desktop/src/main/index.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/apps/desktop/src/main/index.ts b/apps/desktop/src/main/index.ts index 876d6fcb2c..1fd30736f4 100644 --- a/apps/desktop/src/main/index.ts +++ b/apps/desktop/src/main/index.ts @@ -94,6 +94,18 @@ function createWindow(): void { } } +// --- Dev / production isolation ------------------------------------------- +// Give dev mode a separate app name and userData path so it gets its own +// single-instance lock file and doesn't conflict with the packaged production +// app. Must run BEFORE requestSingleInstanceLock() because the lock location +// is derived from the userData path. (Same approach VS Code uses for +// Stable / Insiders coexistence.) + +if (is.dev) { + app.setName("Multica Dev"); + app.setPath("userData", join(app.getPath("appData"), "Multica Dev")); +} + // --- Protocol registration ----------------------------------------------- if (process.defaultApp) { @@ -125,7 +137,9 @@ if (!gotTheLock) { }); app.whenReady().then(() => { - electronApp.setAppUserModelId("ai.multica.desktop"); + electronApp.setAppUserModelId( + is.dev ? "ai.multica.desktop.dev" : "ai.multica.desktop", + ); app.on("browser-window-created", (_, window) => { optimizer.watchWindowShortcuts(window);