diff --git a/main.js b/main.js index d58cb01e..525134e7 100644 --- a/main.js +++ b/main.js @@ -489,7 +489,7 @@ const SETTINGS_DEFAULTS = { // means a session leaves no trace on disk unless the user opts in per-type. clearCookiesOnQuit: true, // drop cookies + logins + saved-form data clearCacheOnQuit: true, // drop HTTP cache (images, scripts, etc.) - clearHistoryOnQuit: true, // drop navigation history + saved tabs + clearHistoryOnQuit: true, // drop navigation history (+ saved tabs unless restoreSession) clearStorageOnQuit: true, // drop localStorage / IndexedDB / service workers / cache API // Anti-fingerprinting — each: show (real) | hide (neutral) | spoof (auto decoy) | manual (user value) timezoneMode: "show", timezoneValue: "Europe/Berlin", // IANA zone for manual @@ -1134,11 +1134,14 @@ async function clearBrowsingData({ cookies = false, cache = false, storage = fal // navigation history lives in each webContents; drop it too when history-clear was asked. // (called separately by the before-quit hook, since history-clear also deletes session.json) } -async function clearHistoryNow() { +// keepSession: leave session.json (the open tabs) in place. The quit clear +// passes it while "Open previous windows and tabs" is on — both default to on, +// and deleting the tab list made the restore setting a no-op for everyone. +async function clearHistoryNow({ keepSession = false } = {}) { for (const t of tabs) { try { t.view.webContents.navigationHistory.clear(); } catch {} } - try { fs.unlinkSync(sessionFile()); } catch {} + if (!keepSession) { try { fs.unlinkSync(sessionFile()); } catch {} } // Address-bar suggestions history — wipe both in-memory + on-disk. history = []; clearTimeout(historySaveTimer); historySaveTimer = null; @@ -8144,9 +8147,9 @@ if (!process.env.THESEUS_NO_AUTOSTART && !app.requestSingleInstanceLock()) { if (quitClearing) return; quitClearing = true; flushAddonStores(); // add-on stores write coalesced; land them now - // Auto-clear per user settings. saveSession() runs first so restoreSession - // still works UNLESS the user asked to drop history — in which case we - // wipe the session file too so the next launch is genuinely blank. + // Auto-clear per user settings. saveSession() runs first; clearing + // history keeps that tab list while restoreSession is on, and deletes it + // otherwise so the next launch is genuinely blank. saveSession(); stopTor(); stopBnsPolling(); // silence the background delta refresh before exit @@ -8158,7 +8161,11 @@ if (!process.env.THESEUS_NO_AUTOSTART && !app.requestSingleInstanceLock()) { storage: settings.clearStorageOnQuit, }); // Session file AND the address-bar history (history.json). - if (settings.clearHistoryOnQuit) { await clearHistoryNow(); sessionDroppedForQuit = true; } + if (settings.clearHistoryOnQuit) { + const keepSession = !!settings.restoreSession; + await clearHistoryNow({ keepSession }); + if (!keepSession) sessionDroppedForQuit = true; + } })().catch((err) => console.error("before-quit clear failed:", err?.message)); Promise.race([clear, new Promise((r) => setTimeout(r, 5000))]) .finally(() => { quitCleared = true; app.quit(); }); diff --git a/settings.html b/settings.html index 7489ec2f..87278f15 100644 --- a/settings.html +++ b/settings.html @@ -273,7 +273,7 @@
Changes apply immediately and are saved for next time.