feat(registry-cleaner): targeted backup mode (default)#175
Conversation
Exports only the registry keys being modified into one consolidated .reg file per run instead of dumping HKLM\SOFTWARE and HKCR\* hives (which produced 300-660 MB of backups for ~10 deleted entries — see #171). Adds a `backupMode` setting (`targeted` | `full`, default `targeted`) with a Settings → Backups dropdown to switch back to the old full-hive behavior. Task ops (disable-task, delete-task) export the task XML via schtasks for re-import via `schtasks /create /xml`. Closes #171 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 88dd2fb5ca
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| > | ||
| <select | ||
| value={settings.backupMode ?? 'targeted'} | ||
| onChange={(e) => save({ backupMode: e.target.value as 'targeted' | 'full' })} |
There was a problem hiding this comment.
Allow backupMode in validated settings payloads
Persisting this new setting is currently broken: the UI sends save({ backupMode: ... }), but IPC.SETTINGS_SET validates payloads with validateSettingsPartial, whose allowedTopKeys does not include backupMode (src/main/services/ipc-validation.ts). That causes the request to be rejected ({ success: false }), so users cannot actually switch to Full hive mode even though the dropdown appears to work locally.
Useful? React with 👍 / 👎.
| const safeName = parts.name.replace(/[\\/:*?"<>|]/g, '_').slice(0, 100) || 'task' | ||
| try { | ||
| const { stdout } = await execNativeUtf8('schtasks', ['/query', '/xml', '/tn', fullName], { timeout: 10000, signal }) | ||
| writeFileSync(join(taskDir, `${safeName}.xml`), stdout, 'utf-8') |
There was a problem hiding this comment.
Preserve distinct task backups when task names collide
Task XML backups are keyed only by sanitized task name, so two tasks with the same name in different folders (for example \Microsoft\X\Update and \Vendor\Y\Update) will write to the same <name>.xml and the later export overwrites the earlier one. In that case, one task backup is silently lost and cannot be restored after a cleanup run.
Useful? React with 👍 / 👎.
Summary
Fixes #171 — replaces the full-hive registry backup (300-660 MB for ~10 deleted entries) with a targeted export that only saves the keys being touched.
targetedmode (new default): per-run consolidated.regfile plus task XMLs fordisable-task/delete-task. One file per run = one double-click to undo.fullmode: previous behavior preserved as an opt-in for users who want the safety of a complete hive snapshot.The
pruneOldBackupshelper now also cleans up the per-runregistry-backup-tasks-<timestamp>/task XML directories.Test plan
npm test— 2074 passing, including 15 new tests coveringcollectBackupTargetsandstripRegHeadernpm run build— cleanregistry-backup-targeted-<timestamp>.regappearsregistry-backup-tasks-<timestamp>/<task>.xmlis written and restorable viaschtasks /create /xmlCloses #171
🤖 Generated with Claude Code