Skip to content

fix: preserve selections when config import is invalid - #4994

Open
Suze021 wants to merge 3 commits into
ChrisTitusTech:mainfrom
Suze021:fix/atomic-config-import
Open

fix: preserve selections when config import is invalid#4994
Suze021 wants to merge 3 commits into
ChrisTitusTech:mainfrom
Suze021:fix/atomic-config-import

Conversation

@Suze021

@Suze021 Suze021 commented Aug 17, 2026

Copy link
Copy Markdown

Summary

  • validate every imported selection before replacing the current selection state
  • reject unsupported and unknown selection keys without leaving partial selections behind
  • add coverage for valid replacement and invalid import preservation

Validation

  • ./Compile.ps1`n- Invoke-Pester -Path 'pester/*.Tests.ps1' -Output Detailed -CI (552 passed)

@coderabbitai

coderabbitai Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 52c92ad9-ac0e-46f7-810f-cfa50e34a868

📥 Commits

Reviewing files that changed from the base of the PR and between 2d0fd43 and afd1007.

📒 Files selected for processing (3)
  • functions/private/Update-WinUtilSelections.ps1
  • functions/public/Invoke-WPFImpex.ps1
  • pester/ui-state.Tests.ps1

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Improved configuration imports by validating all selections before applying changes.
    • Invalid or unsupported selections no longer leave the app in a partially updated state.
    • Existing selections are replaced cleanly when importing a configuration.
    • Successful imports now consistently reset the related UI state.
  • Tests
    • Added coverage for successful imports, invalid configurations, selection preservation, and UI reset behavior.

Walkthrough

Update-WinUtilSelections now validates imported selection keys before updating state. Invoke-WPFImpex uses atomic replacement during imports. Tests cover valid imports, invalid imports, preserved state, and UI reset behavior.

Changes

Selection import state

Layer / File(s) Summary
Selection validation and replacement
functions/private/Update-WinUtilSelections.ps1
The function requires a typed selection array, validates category prefixes and keys, and supports append or replacement behavior.
Validated import integration
functions/public/Invoke-WPFImpex.ps1
The import path calls Update-WinUtilSelections with -Replace instead of clearing selection lists first.
Import behavior coverage
pester/ui-state.Tests.ps1
Tests add WPF and catalog fixtures and verify replacement imports, invalid-import preservation, error logging, and checkbox reset behavior.

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

Merge Risk: ⚪ Minimal · up to afd10

This change validates imported selections before replacing existing state and includes coverage for valid and invalid imports; no actionable merge-blocking risk remains after normal checks and review.

Possibly related PRs

Suggested labels: bug

Suggested reviewers: christitustech

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: preserving selections when a configuration import is invalid.
Description check ✅ Passed The description directly explains atomic import validation, selection preservation, tests, and validation results.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot added the bug Something isn't working label Aug 19, 2026

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: afd100756c

ℹ️ 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".

Comment on lines +49 to +50
if (-not $isKnownSelection) {
throw "Unknown selection key '$cbkey'."

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 Document stale-key import rejection

When an exported configuration contains a key removed or renamed in a newer WinUtil catalog, this condition now aborts the entire import instead of applying the remaining selections. The automation guide currently recommends reusing exported baselines across installations without explaining that imports are catalog-version-dependent, how atomic rejection is reported, or how users should recover; update the user guide alongside this behavior change.

AGENTS.md reference: AGENTS.md:L138-L138

Useful? React with 👍 / 👎.

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

Labels

bug Something isn't working

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants