mirror of
https://github.com/openswarm-ai/openswarm.git
synced 2026-08-29 11:19:44 +02:00
[eric] electron: hard-reset IPC (kill backend, wipe data dir, relaunch) for factory reset
This commit is contained in:
@@ -2561,6 +2561,25 @@ ipcMain.handle('get-install-state', () => {
|
||||
}
|
||||
});
|
||||
|
||||
// Factory reset ("Erase all content and settings"). Stop the backend FIRST so
|
||||
// nothing rewrites the dir mid-wipe (on Windows a live process even locks the
|
||||
// files), wipe everything under userData/data, then relaunch into a clean first
|
||||
// run. install.json lives OUTSIDE /data so the install + affiliate identity
|
||||
// survives, exactly like a real reinstall would. Best-effort throughout: a
|
||||
// failed kill or wipe still relaunches rather than wedging the user.
|
||||
ipcMain.handle('hard-reset', async () => {
|
||||
try { killBackend(); } catch (e) { console.error('[hard-reset] killBackend failed', e); }
|
||||
try {
|
||||
const dataDir = path.join(app.getPath('userData'), 'data');
|
||||
fs.rmSync(dataDir, { recursive: true, force: true });
|
||||
console.log('[hard-reset] wiped data dir');
|
||||
} catch (e) {
|
||||
console.error('[hard-reset] wipe failed', e);
|
||||
}
|
||||
app.relaunch();
|
||||
app.exit(0);
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// CDP debugger bridge for the browser sub-agent
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
@@ -55,6 +55,8 @@ contextBridge.exposeInMainWorld('openswarm', {
|
||||
// Renderer attaches the ref to Stripe checkout + sign-in flows so
|
||||
// the cloud can credit the affiliate. Resolves to {} if no state yet.
|
||||
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'),
|
||||
connectSlack: () => ipcRenderer.invoke('connect-slack'),
|
||||
sendCdpCommand: (wcId, method, params, sessionId) => ipcRenderer.invoke('send-cdp-command', wcId, method, params, sessionId),
|
||||
cdpCacheSet: (wcId, indexMap) => ipcRenderer.invoke('cdp-cache-set', wcId, indexMap),
|
||||
|
||||
Reference in New Issue
Block a user