From 97a859e504df020f4aa7bc6f7a5cb20955789c7e Mon Sep 17 00:00:00 2001 From: ciregenz Date: Thu, 25 Jun 2026 19:50:33 -0700 Subject: [PATCH] [eric] browser: Settings "Clear browsing data" wipes the browser partition only --- electron/main.js | 8 ++++ electron/preload.js | 2 + .../sections/general/DataPrivacySection.tsx | 48 +++++++++++++++++++ frontend/src/types/electron.d.ts | 1 + 4 files changed, 59 insertions(+) diff --git a/electron/main.js b/electron/main.js index f5242128..4e75dbd7 100644 --- a/electron/main.js +++ b/electron/main.js @@ -2448,6 +2448,14 @@ ipcMain.handle('get-webview-preload-path', () => { return `file://${path.join(__dirname, 'webview-preload.js')}`; }); +// Wipe ONLY the browser-card partition (cookies/cache/localStorage/IndexedDB), never the app's defaultSession. Surfaced as Settings -> Data & Privacy -> Clear browsing data. +ipcMain.handle('browser:clear-data', async () => { + const ses = session.fromPartition(BROWSER_PARTITION); + await ses.clearStorageData(); + await ses.clearCache(); + return { ok: true }; +}); + ipcMain.handle('get-update-status', () => cachedUpdateStatus); // One-shot recovery info: if the crash-watchdog relaunched us, returns the diff --git a/electron/preload.js b/electron/preload.js index 9bb2010c..99647e74 100644 --- a/electron/preload.js +++ b/electron/preload.js @@ -57,6 +57,8 @@ contextBridge.exposeInMainWorld('openswarm', { getInstallState: () => ipcRenderer.invoke('get-install-state'), // Factory reset: wipes the data dir and relaunches. Never resolves on success (the app exits first). hardReset: () => ipcRenderer.invoke('hard-reset'), + // Clears cookies/cache/localStorage for the browser-card partition only (never the app's defaultSession). Logs you out of sites opened in browser cards. + clearBrowserData: () => ipcRenderer.invoke('browser:clear-data'), connectSlack: () => ipcRenderer.invoke('connect-slack'), sendCdpCommand: (wcId, method, params, sessionId) => ipcRenderer.invoke('send-cdp-command', wcId, method, params, sessionId), cdpDetachClean: (wcId) => ipcRenderer.invoke('cdp-detach-clean', wcId), diff --git a/frontend/src/app/pages/Settings/sections/general/DataPrivacySection.tsx b/frontend/src/app/pages/Settings/sections/general/DataPrivacySection.tsx index 0ee8b13f..1186b0d4 100644 --- a/frontend/src/app/pages/Settings/sections/general/DataPrivacySection.tsx +++ b/frontend/src/app/pages/Settings/sections/general/DataPrivacySection.tsx @@ -20,11 +20,15 @@ const DataPrivacySection: React.FC<{ styles: SettingsStyles }> = ({ styles }) => const [busy, setBusy] = useState(false); const [eraseText, setEraseText] = useState(''); const [err, setErr] = useState(null); + const [clearOpen, setClearOpen] = useState(false); + const [clearedOk, setClearedOk] = useState(false); const closeAll = () => { if (busy) return; setResetOpen(false); setEraseOpen(false); + setClearOpen(false); + setClearedOk(false); setEraseText(''); setErr(null); }; @@ -59,6 +63,24 @@ const DataPrivacySection: React.FC<{ styles: SettingsStyles }> = ({ styles }) => } }; + const doClearBrowser = async () => { + const api = window.openswarm; + if (!api?.clearBrowserData) { + setErr('This only works in the desktop app.'); + return; + } + setBusy(true); + setErr(null); + try { + await api.clearBrowserData(); + setBusy(false); + setClearedOk(true); + } catch { + setBusy(false); + setErr("Couldn't clear browsing data just now. Try again in a moment."); + } + }; + const dialogPaperSx = { bgcolor: c.bg.surface, border: `1px solid ${c.border.subtle}`, @@ -100,6 +122,14 @@ const DataPrivacySection: React.FC<{ styles: SettingsStyles }> = ({ styles }) => + + + Clear browsing data + Signs you out of sites opened in browser cards and clears their cookies, cache, and local storage. Your chats, apps, and settings stay. + + + + Erase all content and settings @@ -120,6 +150,24 @@ const DataPrivacySection: React.FC<{ styles: SettingsStyles }> = ({ styles }) => + + + {clearedOk ? 'Browsing data cleared' : 'Clear browsing data?'} + {clearedOk ? 'Cookies, cache, and local storage for browser cards are gone. Reload a browser card to see it signed out.' : 'This signs you out of sites in browser cards and clears their cookies, cache, and local storage. Your chats, apps, and settings stay.'} + {err && {err}} + + {clearedOk ? ( + + ) : ( + <> + + + + )} + + + + Erase all content and settings? diff --git a/frontend/src/types/electron.d.ts b/frontend/src/types/electron.d.ts index 2f416e7b..e129804e 100644 --- a/frontend/src/types/electron.d.ts +++ b/frontend/src/types/electron.d.ts @@ -49,6 +49,7 @@ declare global { onWebviewNewWindow: (cb: (url: string, webContentsId: number) => void) => () => void; openExternal: (url: string) => Promise; hardReset?: () => Promise; + clearBrowserData?: () => Promise<{ ok: boolean }>; onAuthUrl?: (cb: (url: string) => void) => () => void; onOauthClaim?: (cb: (url: string) => void) => () => void; }