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): skip browser beforeunload guard so auto-update can quit (#15525)

Arvin Xu2453fc351595
diff --git a/src/store/chat/utils/index.ts b/src/store/chat/utils/index.ts
index adeea743c98..21d973cf747 100644
--- a/src/store/chat/utils/index.ts
+++ b/src/store/chat/utils/index.ts
@@ -1,7 +1,13 @@
+import { isDesktop } from '@lobechat/const';
import i18n from 'i18next';
import { produce } from 'immer';
export const preventLeavingFn = (e: BeforeUnloadEvent) => {
+ // On desktop the main process manages window close / app quit (keepAlive + isQuiting),
+ // so the browser "are you sure you want to leave" guard is unnecessary here — and it can
+ // block window.close() during auto-update, leaving the app unable to quit & install.
+ if (isDesktop) return;
+
// set returnValue to trigger alert modal
// Note: No matter what value is set, the browser will display the standard text
e.returnValue = i18n.t('beforeUnload.confirmLeave', { ns: 'chat' });