Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🐛 fix(desktop): restore minimized window on notification click (#16355)

Arvin Xub3afb1ea5c2a
diff --git a/apps/desktop/src/main/controllers/NotificationCtr.ts b/apps/desktop/src/main/controllers/NotificationCtr.ts
index 17d0cec89f1..ad9131bd70d 100644
--- a/apps/desktop/src/main/controllers/NotificationCtr.ts
+++ b/apps/desktop/src/main/controllers/NotificationCtr.ts
@@ -152,11 +152,13 @@ export default class NotificationCtr extends ControllerModule {
notification.on('click', () => {
logger.debug('User clicked notification, showing main window');
- const mainWindow = this.app.browserManager.getMainWindow();
- mainWindow.show();
- mainWindow.browserWindow.focus();
+ // Reuse the shared show path so a *minimized* window is restored first.
+ // A bare `Browser.show()` cannot un-minimize on macOS, which made the
+ // notification intermittently fail to surface the app (worked only when
+ // the window was hidden, not when minimized to the Dock).
+ this.app.browserManager.showMainWindow();
if (params.navigate?.path) {
- mainWindow.broadcast('navigate', params.navigate);
+ this.app.browserManager.getMainWindow().broadcast('navigate', params.navigate);
}
});
diff --git a/apps/desktop/src/main/controllers/__tests__/NotificationCtr.test.ts b/apps/desktop/src/main/controllers/__tests__/NotificationCtr.test.ts
index 76398d868ae..d97a8a42851 100644
--- a/apps/desktop/src/main/controllers/__tests__/NotificationCtr.test.ts
+++ b/apps/desktop/src/main/controllers/__tests__/NotificationCtr.test.ts
@@ -60,12 +60,14 @@ const mockBrowserWindow = {
};
const mockMainWindow = {
+ broadcast: vi.fn(),
browserWindow: mockBrowserWindow,
show: vi.fn(),
};
const mockBrowserManager = {
getMainWindow: vi.fn(() => mockMainWindow),
+ showMainWindow: vi.fn(),
};
const mockApp = {
@@ -329,8 +331,9 @@ describe('NotificationCtr', () => {
// Simulate click
clickHandler();
- expect(mockMainWindow.show).toHaveBeenCalled();
- expect(mockBrowserWindow.focus).toHaveBeenCalled();
+ // Delegates to the shared show path, which restores a minimized window
+ // before showing/focusing — a bare `show()` cannot un-minimize on macOS.
+ expect(mockBrowserManager.showMainWindow).toHaveBeenCalled();
});
it('should handle notification error', async () => {