Skip to content

Comments

fix: resolve Electron helper battery drain on macOS#4

Open
TerminallyLazy wants to merge 3 commits intoagent0ai:mainfrom
TerminallyLazy:launcher-mem-leak
Open

fix: resolve Electron helper battery drain on macOS#4
TerminallyLazy wants to merge 3 commits intoagent0ai:mainfrom
TerminallyLazy:launcher-mem-leak

Conversation

@TerminallyLazy
Copy link
Contributor

Summary

Fixes battery drain caused by Electron helper processes persisting after closing the A0 Launcher app on macOS.

  • Fix IPC listener accumulation: Add proper tracking and cleanup of IPC listeners in preload.js to prevent memory leaks when windows are recreated
  • Add window cleanup handler: Clear mainWindow reference on close to prevent stale references
  • Quit app on macOS window close: Remove the darwin exception so Electron helpers terminate instead of persisting in the dock

Root Cause

On macOS, the app followed standard behavior of staying alive when windows close. This kept all Electron helper processes (GPU, Renderer, Utility) running and consuming battery even with no visible window.

Test Plan

  • App launches normally and shows loading screen
  • Content loads successfully with status updates
  • Window close terminates all Electron processes (verified via Activity Monitor)
  • No console errors during lifecycle
  • Code passes syntax verification

🤖 Generated with Claude Code

Add listener tracking and cleanup to prevent memory leaks when
windows are recreated. Each onStatusUpdate/onError call now removes
any existing listener before adding a new one.
Ensures mainWindow is set to null when window closes to prevent
stale reference issues.
A launcher app doesn't need dock persistence. Quitting when windows
close ensures Electron helper processes don't drain battery.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant