From 71f0c96e935f387971f6554ce50bf7335d0ff229 Mon Sep 17 00:00:00 2001 From: Local Dev Date: Sat, 3 Oct 2026 23:01:56 +0200 Subject: [PATCH] Theseus: reopen the previous tabs even when history is cleared on quit "Open previous windows and tabs" and "Clear history on quit" both default to on, and the quit clear deleted session.json along with the history, so every launch started from the start page and the restore setting did nothing. The open tabs are what the user asked to reopen, not history: while restore is on, the quit clear keeps them and still drops back/forward and address-bar history. With restore off, the tab list is deleted as before. --- main.js | 21 ++++++++++++++------- settings.html | 4 ++-- 2 files changed, 16 insertions(+), 9 deletions(-) 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.

Startup

-
Open previous windows and tabs
Restore the tabs from your last session when Theseus starts.
+
Open previous windows and tabs
Restore the tabs from your last session when Theseus starts, even when history is cleared on quit.
@@ -812,7 +812,7 @@
-
Clear history on quit
Drops navigation history + the saved-tabs session file (overrides "Reopen previous tabs").
+
Clear history on quit
Drops back/forward history and address-bar history. With "Open previous windows and tabs" on, the tabs themselves still reopen.