-
-
Notifications
You must be signed in to change notification settings - Fork 303
fix(dock): summon the window on launch, reopen and second launch #239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,6 +32,25 @@ const totalMB = Math.floor(totalmem() / (1024 * 1024)); | |
| const heapMB = Math.min(4096, Math.max(2048, Math.floor(totalMB * 0.5))); | ||
| app.commandLine.appendSwitch('js-flags', `--max-old-space-size=${heapMB}`); | ||
|
|
||
| // Single instance: a dockless (UIElement) app gives no way to discover zombie | ||
| // duplicates — a second launch must summon the existing window instead. | ||
| const appReady = false; | ||
| if (!app.requestSingleInstanceLock()) { | ||
| app.quit(); | ||
| } else { | ||
| app.on('second-instance', () => { | ||
| if (mainWindow && !mainWindow.isDestroyed()) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win Recreate the window when a second launch finds no window. On macOS, closing the last window leaves the primary process running and sets 🤖 Prompt for AI Agents |
||
| if (mainWindow.isMinimized()) mainWindow.restore(); | ||
| mainWindow.show(); | ||
| app.focus({ steal: true }); | ||
| } else if (appReady) { | ||
| // last window was closed (macOS keeps the app alive) — recreate it | ||
| createWindow(); | ||
| } | ||
| // while initialization is still pending, startup's own createWindow() covers us | ||
| }); | ||
| } | ||
|
|
||
| // Window icon path for non-mac platforms. | ||
| const getWindowIconPath = (): string | undefined => { | ||
| const isDev = process.env.NODE_ENV === 'development'; | ||
|
|
@@ -461,6 +480,11 @@ function createWindow(): void { | |
| title: 'claude-devtools', | ||
| }); | ||
|
|
||
| // Dockless apps (showDockIcon: false → app.dock.hide()) never take front on | ||
| // their own: summon the window on every creation. | ||
| mainWindow.show(); | ||
| app.focus({ steal: true }); | ||
|
|
||
| // Load the renderer | ||
| if (process.env.NODE_ENV === 'development') { | ||
| void mainWindow.loadURL(`http://localhost:${DEV_SERVER_PORT}`); | ||
|
|
@@ -604,6 +628,7 @@ void app.whenReady().then(async () => { | |
|
|
||
| // Then create window | ||
| createWindow(); | ||
| appReady = true; | ||
|
|
||
| // Listen for notification click events | ||
| notificationManager.on('notification-clicked', (_error) => { | ||
|
|
@@ -618,10 +643,15 @@ void app.whenReady().then(async () => { | |
| createWindow(); | ||
| } | ||
| } | ||
| appReady = true; | ||
|
|
||
| app.on('activate', () => { | ||
| if (BrowserWindow.getAllWindows().length === 0) { | ||
| createWindow(); | ||
| } else if (mainWindow && !mainWindow.isDestroyed()) { | ||
| // reopen (open -a, notification click) with a live window: summon it | ||
| mainWindow.show(); | ||
| app.focus({ steal: true }); | ||
| } | ||
| }); | ||
| }); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win
Declare
appReadywithlet.Startup assigns to
appReadyat Lines 631 and 646. TypeScript rejects both assignments because Line 37 declares it withconst. The build cannot complete until the declaration permits reassignment.Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents
Source: Linters/SAST tools