From eedbe97d0240ab4d25573581416e76b5a2c8b4ff Mon Sep 17 00:00:00 2001 From: Yun Chan Date: Thu, 20 Aug 2026 22:48:58 +0900 Subject: [PATCH] fix(desktop): clean single-instance lock exit and suppress devtools console crash --- apps/desktop/src/main/index.ts | 13 +++++++++++-- apps/desktop/src/main/windows/WindowManager.ts | 2 +- run-desktop.bat | 16 ++++++---------- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/apps/desktop/src/main/index.ts b/apps/desktop/src/main/index.ts index 266038c..319f0e9 100644 --- a/apps/desktop/src/main/index.ts +++ b/apps/desktop/src/main/index.ts @@ -131,15 +131,24 @@ async function handleDeepLink(url: string): Promise { const gotTheLock = process.env.NODE_ENV === 'test' ? true : app.requestSingleInstanceLock() if (!gotTheLock) { - app.quit() + console.log('[D3RO Voice] Another instance is already running. Existing window focused.') + app.exit(0) } else { app.on('second-instance', (_event, argv) => { - // 기존 인스턴스의 메인 윈도우를 활성화 + // 기존 인스턴스의 메인 윈도우를 최상위로 활성화 const mainWindow = getMainWindow() if (mainWindow) { if (mainWindow.isMinimized()) mainWindow.restore() mainWindow.show() mainWindow.focus() + mainWindow.setAlwaysOnTop(true) + setTimeout(() => { + try { + mainWindow?.setAlwaysOnTop(false) + } catch { + // ignore + } + }, 500) } // Windows: deep link는 두 번째 인스턴스의 argv 마지막 인자로 들어옴 const deepLinkArg = argv.find((a) => a.startsWith(`${PROTOCOL}://`)) diff --git a/apps/desktop/src/main/windows/WindowManager.ts b/apps/desktop/src/main/windows/WindowManager.ts index fa0ebbf..e33aff8 100644 --- a/apps/desktop/src/main/windows/WindowManager.ts +++ b/apps/desktop/src/main/windows/WindowManager.ts @@ -115,7 +115,7 @@ export function createMainWindow(): BrowserWindow { mainWindow?.restore() mainWindow?.focus() mainWindow?.flashFrame(true) - if (is.dev && process.env['ELECTRON_RENDERER_URL']) { + if (is.dev && process.env['ELECTRON_OPEN_DEVTOOLS'] === '1') { mainWindow?.webContents.openDevTools({ mode: 'right' }) } logger.info('Main window shown') diff --git a/run-desktop.bat b/run-desktop.bat index 59fa848..7e8fdc6 100644 --- a/run-desktop.bat +++ b/run-desktop.bat @@ -1,19 +1,15 @@ @echo off -title D3RO Voice Dev Runner +title D3RO Voice Launcher echo ========================================== echo [1/2] Cleaning up previous processes... echo ========================================== -taskkill /F /IM electron.exe >nul 2>&1 +taskkill /F /IM "D3RO Voice.exe" /IM electron.exe >nul 2>&1 timeout /t 1 /nobreak >nul echo ========================================== -echo [2/2] Launching D3RO Voice... +echo [2/2] Launching D3RO Voice App... echo ========================================== cd /d "%~dp0" -call pnpm --filter @d3ro/desktop dev -if errorlevel 1 ( - echo. - echo pnpm failed, trying npm... - call npm run dev --workspace=@d3ro/desktop -) -pause +start "" "%~dp0node_modules\electron\dist\electron.exe" "%~dp0apps\desktop" +echo D3RO Voice window opened. +