Skip to content

Improve registry backup safety and add optional backup skipping - #710

Merged
Raphire merged 9 commits into
masterfrom
improve-registry-backup
Jul 25, 2026
Merged

Improve registry backup safety and add optional backup skipping#710
Raphire merged 9 commits into
masterfrom
improve-registry-backup

Conversation

@Raphire

@Raphire Raphire commented Jul 19, 2026

Copy link
Copy Markdown
Owner

This should address the concerns raised in #686

Summary by CodeRabbit

  • Added a “registry backup (Recommended)” checkbox to the main deployment UI and wired it through apply/export/import via the SkipRegistryBackup flag (unchecked => SkipRegistryBackup=true, checked => SkipRegistryBackup=false), including updated options text and import persistence.
  • Extended the CLI/script surface to accept -SkipRegistryBackup and pass it through to Win11Debloat.ps1, plus updated Import-ConfigToParams to read SkipRegistryBackup from exported configs.
  • Updated registry-backup orchestration in Invoke-AllChanges so the registry-backup phase (and step counting) runs only when registry backup is needed and SkipRegistryBackup is not set.
  • Improved backup safety and restore correctness: Convert-RegistryKeyToSnapshot now throws when an included child subkey can’t be opened; registry restore adds a full snapshot preflight check and restores more safely by enforcing direct parent→child relationships and avoiding the prior “force full tree” deletion behavior.
  • Strengthened test coverage for SkipRegistryBackup and backup/restore safety (including unreadable subkey snapshot failure and new snapshot preflight validation), plus added new exported config/test data for skipping registry backup.
  • Minor JSON formatting touch-up in Config/DefaultSettings.json (re-emitted the final closing-brace line).

@coderabbitai

coderabbitai Bot commented Jul 19, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The PR adds an optional registry-backup deployment setting, propagates SkipRegistryBackup through UI, configuration, launcher, and script parameters, gates backup execution, and adds registry snapshot capture and restoration validation.

Changes

Registry backup option and propagation

Layer / File(s) Summary
Registry backup setting flow
Schemas/MainWindow.xaml, Scripts/GUI/*, Scripts/Get.ps1, Scripts/Helpers/Import-ConfigToParams.ps1, Win11Debloat.ps1, Config/DefaultSettings.json, Tests/TestData/*, Tests/Import-ConfigToParams.Tests.ps1
Adds the registry-backup checkbox and propagates SkipRegistryBackup through UI state, imported/exported settings, launcher arguments, script control parameters, and test data.
Conditional backup execution
Scripts/Features/Invoke-Changes.ps1, Tests/Invoke-Changes.Tests.ps1
Skips registry-backup progress and execution when SkipRegistryBackup is set while continuing feature application and undo operations.

Registry snapshot safety

Layer / File(s) Summary
Snapshot capture and restoration validation
Scripts/Features/Backup-RegistrySnapshotCapture.ps1, Scripts/Features/Restore-RegistryApplyState.ps1, Tests/Registry-SnapshotApply.Tests.ps1
Unreadable subkeys now fail snapshot capture; restoration validates values and direct subkey paths before modifying registry state and recursively restores direct descendants.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant MainWindow
  participant Win11Debloat
  participant InvokeAllChanges
  participant Registry
  User->>MainWindow: uncheck RegistryBackupCheckBox
  MainWindow->>Win11Debloat: queue SkipRegistryBackup
  Win11Debloat->>InvokeAllChanges: pass SkipRegistryBackup
  InvokeAllChanges->>Registry: apply features without registry backup
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Powershell Docstrings ⚠️ Warning Get-DeploymentSettings and Get-DeploymentCategoryDetailString changed for SkipRegistryBackup but have no comment-based help; other touched funcs do. Add comment-based help blocks for the changed helper functions in Show-ImportExportConfigWindow.ps1 and verify any changed doc text matches the new SkipRegistryBackup behavior.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main registry backup safety and optional skip changes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Raphire

Raphire commented Jul 19, 2026

Copy link
Copy Markdown
Owner Author

@HetCreep This should address your concerns described in #686, please let me know your thoughts!

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
Scripts/Features/Restore-RegistryApplyState.ps1 (1)

72-75: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Keep docstrings complete and in sync with current behavior.

As per coding guidelines, functions added or changed in PowerShell scripts must have comment-based docstrings that are kept in sync with their behavior. Several docstrings need updates to reflect the new changes or describe all parameters:

  • Scripts/Features/Restore-RegistryApplyState.ps1#L72-L75: Add the missing .PARAMETER description for $Snapshot and update the .SYNOPSIS to mention that this function also validates subkey paths, not just values.
  • Scripts/Features/Restore-RegistryApplyState.ps1#L101-L104: Add missing .PARAMETER descriptions for $ParentPath and $ChildPath.
  • Scripts/Features/Backup-RegistrySnapshotCapture.ps1#L198-L205: Update the .DESCRIPTION to mention that the function will now throw an exception if a requested subkey cannot be read.
  • Scripts/Features/Invoke-Changes.ps1#L299-L312: Update the .DESCRIPTION to note that Phase 1 (Registry backup) is skipped when SkipRegistryBackup is present.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Scripts/Features/Restore-RegistryApplyState.ps1` around lines 72 - 75, The
comment-based docstrings require synchronization across four locations: in
Scripts/Features/Restore-RegistryApplyState.ps1 lines 72-75, update the function
synopsis to mention validation of subkey paths as well as registry values and
add a .PARAMETER description for $Snapshot; in lines 101-104, add .PARAMETER
descriptions for $ParentPath and $ChildPath; in
Scripts/Features/Backup-RegistrySnapshotCapture.ps1 lines 198-205, update the
function .DESCRIPTION to state that unreadable requested subkeys cause an
exception; and in Scripts/Features/Invoke-Changes.ps1 lines 299-312, document
that Phase 1 registry backup is skipped when SkipRegistryBackup is present.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@Scripts/Features/Restore-RegistryApplyState.ps1`:
- Around line 72-75: The comment-based docstrings require synchronization across
four locations: in Scripts/Features/Restore-RegistryApplyState.ps1 lines 72-75,
update the function synopsis to mention validation of subkey paths as well as
registry values and add a .PARAMETER description for $Snapshot; in lines
101-104, add .PARAMETER descriptions for $ParentPath and $ChildPath; in
Scripts/Features/Backup-RegistrySnapshotCapture.ps1 lines 198-205, update the
function .DESCRIPTION to state that unreadable requested subkeys cause an
exception; and in Scripts/Features/Invoke-Changes.ps1 lines 299-312, document
that Phase 1 registry backup is skipped when SkipRegistryBackup is present.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 5669f08b-cad4-4793-a4f6-b7dc0ba0d6f1

📥 Commits

Reviewing files that changed from the base of the PR and between a9c1736 and 1934031.

📒 Files selected for processing (14)
  • Config/DefaultSettings.json
  • Schemas/MainWindow.xaml
  • Scripts/Features/Backup-RegistrySnapshotCapture.ps1
  • Scripts/Features/Invoke-Changes.ps1
  • Scripts/Features/Restore-RegistryApplyState.ps1
  • Scripts/GUI/Show-ImportExportConfigWindow.ps1
  • Scripts/GUI/Show-MainWindow.ps1
  • Scripts/Get.ps1
  • Scripts/Helpers/Import-ConfigToParams.ps1
  • Tests/Import-ConfigToParams.Tests.ps1
  • Tests/Invoke-Changes.Tests.ps1
  • Tests/Registry-SnapshotApply.Tests.ps1
  • Tests/TestData/JsonFileLoading/ExportedConfig.WithSettings.json
  • Win11Debloat.ps1

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
Scripts/Features/Invoke-Changes.ps1 (1)

329-330: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Keep SkipRegistryBackup out of $applyIds.

When the option is enabled, SkipRegistryBackup is appended to $applyIds and later treated as a feature by Invoke-ApplyFeatures. This creates a bogus apply step with an empty label and inflates totalSteps. Exclude it alongside CreateRestorePoint, and strengthen Tests/Invoke-Changes.Tests.ps1 to assert that only real feature IDs are passed.

Proposed fix
         if ($key -eq 'CreateRestorePoint') { continue }
+        if ($key -eq 'SkipRegistryBackup') { continue }
         $applyIds += $key
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Scripts/Features/Invoke-Changes.ps1` around lines 329 - 330, Exclude the
SkipRegistryBackup key from $applyIds in the feature-ID collection logic
alongside CreateRestorePoint, so Invoke-ApplyFeatures receives only real feature
IDs. Strengthen the relevant Invoke-Changes tests to assert that the resulting
IDs contain no SkipRegistryBackup and include only applicable features.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@Scripts/Features/Invoke-Changes.ps1`:
- Around line 329-330: Exclude the SkipRegistryBackup key from $applyIds in the
feature-ID collection logic alongside CreateRestorePoint, so
Invoke-ApplyFeatures receives only real feature IDs. Strengthen the relevant
Invoke-Changes tests to assert that the resulting IDs contain no
SkipRegistryBackup and include only applicable features.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: be4ec9b0-81b0-4f1e-b6f3-faccbcaf41cb

📥 Commits

Reviewing files that changed from the base of the PR and between 1934031 and 8346621.

📒 Files selected for processing (1)
  • Scripts/Features/Invoke-Changes.ps1

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants