Fix: Linux tray quit and zombie icons (#24)
* Fix: Linux tray quit and zombie icons (#23) - Add before-quit handler to set isQuitting flag - Change pgrep -x to pgrep -xi for case-insensitive matching on Linux - Add antigravity-manager to self-kill exclusion filter - Destroy existing tray before creating new one in initTray() - Destroy tray in will-quit handler - Export destroyTray function for cleanup Fixes #23 Co-Authored-By: Claude Opus 4.5 <[email protected]> * Fix: Address code review feedback - Add icon validation before creating tray (isEmpty check) - Add try/catch around tray.destroy() calls for error handling - Add try/catch around destroyTray() in will-quit handler - Add explicit !manager check in Linux process filter for defensive coding Co-Authored-By: Claude Opus 4.5 <[email protected]> --------- Co-authored-by: Jirka <[email protected]> Co-authored-by: Claude Opus 4.5 <[email protected]>
This commit is contained in:
3 files changed
+51
-6
No files matched your search
@@ -38,12 +38,31 @@ function getQuotaText(account: CloudAccount | null, texts: any): string[] {
|
||||
|
||||
export function initTray(mainWindow: BrowserWindow) {
|
||||
globalMainWindow = mainWindow;
|
||||
|
||||
// PATCH 3: Destroy existing tray before creating new one (prevents zombie tray icons)
|
||||
if (tray) {
|
||||
try {
|
||||
tray.destroy();
|
||||
} catch (e) {
|
||||
logger.error('Failed to destroy existing tray', e);
|
||||
}
|
||||
tray = null;
|
||||
logger.info('Destroyed existing tray before creating new one');
|
||||
}
|
||||
|
||||
const inDevelopment = process.env.NODE_ENV === 'development';
|
||||
const iconPath = inDevelopment
|
||||
? path.join(process.cwd(), 'src/assets/tray.png')
|
||||
: path.join(process.resourcesPath, 'assets/tray.png');
|
||||
|
||||
const icon = nativeImage.createFromPath(iconPath);
|
||||
|
||||
// Verify icon is valid before creating tray
|
||||
if (icon.isEmpty()) {
|
||||
logger.error(`Tray icon not found or invalid at path: ${iconPath}`);
|
||||
return;
|
||||
}
|
||||
|
||||
tray = new Tray(icon);
|
||||
tray.setToolTip('Antigravity Manager');
|
||||
|
||||
@@ -158,3 +177,15 @@ export function updateTrayMenu(account: CloudAccount | null, language?: string)
|
||||
export function setTrayLanguage(lang: string) {
|
||||
updateTrayMenu(lastAccount, lang);
|
||||
}
|
||||
|
||||
export function destroyTray() {
|
||||
if (tray) {
|
||||
try {
|
||||
tray.destroy();
|
||||
} catch (e) {
|
||||
logger.error('Failed to destroy tray', e);
|
||||
}
|
||||
tray = null;
|
||||
logger.info('Tray destroyed');
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user