diff --git a/src/main/index.ts b/src/main/index.ts index c892a87..21bb3ca 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -36,16 +36,19 @@ import { DEFAULT_OLLAMA_ENDPOINT, DEFAULT_OLLAMA_MODEL } from '../shared/constan const HIDDEN_ARG = '--hidden'; const startedHidden = process.argv.includes(HIDDEN_ARG); -// CRITICAL — single-instance lock. 두 번째 .exe 실행 시 즉시 종료. -// 미적용 시 SQLite 동시 접근 + AiWorker 중복 처리 + HealthChecker 중복 polling 등 -// 데이터 corruption 위험. activate (Mac) / second-instance (Win/Linux) 이벤트로 -// 기존 inbox 창에 focus. -const gotLock = app.requestSingleInstanceLock(); +// CRITICAL — single-instance lock + hidden-flag 전달 (v0.2.6 #46). +// 두 번째 .exe 가 hidden 으로 spawn 됐다면 (autostart) 첫 instance 의 inbox 창 +// 띄우지 않음 — 사용자가 명시적으로 클릭한 게 아니므로. +const additionalData = { hidden: startedHidden }; +const gotLock = app.requestSingleInstanceLock(additionalData); if (!gotLock) { app.quit(); } else { - app.on('second-instance', () => { - // 새 .exe 실행 또는 트레이 외 entry 시 기존 inbox 창 보이게 + app.on('second-instance', (_e, _argv, _cwd, secondData) => { + const data = secondData as { hidden?: boolean } | undefined; + // 두 번째가 hidden 으로 spawn (autostart 등) — UI 띄우지 않음 + if (data?.hidden === true) return; + // 사용자가 명시적으로 .exe / 단축키 / 트레이로 띄움 → inbox 창 보이게 const win = getInboxWindow(); if (win) { if (win.isMinimized()) win.restore();