Skip to content

feat(registry-cleaner): targeted backup mode (default)#175

Merged
dbfx merged 2 commits into
mainfrom
feat/targeted-registry-backup
May 19, 2026
Merged

feat(registry-cleaner): targeted backup mode (default)#175
dbfx merged 2 commits into
mainfrom
feat/targeted-registry-backup

Conversation

@dbfx
Copy link
Copy Markdown
Contributor

@dbfx dbfx commented May 19, 2026

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.

  • targeted mode (new default): per-run consolidated .reg file plus task XMLs for disable-task/delete-task. One file per run = one double-click to undo.
  • full mode: previous behavior preserved as an opt-in for users who want the safety of a complete hive snapshot.
  • New Settings → Backups → "Registry backup mode" dropdown.

The pruneOldBackups helper now also cleans up the per-run registry-backup-tasks-<timestamp>/ task XML directories.

Test plan

  • npm test — 2074 passing, including 15 new tests covering collectBackupTargets and stripRegHeader
  • npm run build — clean
  • Manual: run Registry Cleaner with default settings, verify a single small registry-backup-targeted-<timestamp>.reg appears
  • Manual: re-import that .reg file and confirm deleted values are restored
  • Manual: switch to "Full hive" mode and confirm the old multi-file behavior returns
  • Manual: trigger a task fix and confirm registry-backup-tasks-<timestamp>/<task>.xml is written and restorable via schtasks /create /xml

Closes #171

🤖 Generated with Claude Code

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>
@dbfx dbfx merged commit 6beb61a into main May 19, 2026
3 checks passed
@dbfx dbfx deleted the feat/targeted-registry-backup branch May 19, 2026 17:17
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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' })}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Comment on lines +1822 to +1825
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')
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Select what backups are made when Registry Cleaner is run

1 participant