Skip to content

Fix legacy json import compatibility, UI sidebar refactor, and improved test coverage - #4911

Merged
ChrisTitusTech merged 11 commits into
ChrisTitusTech:mainfrom
yadavnikhil03:fix-ui-and-json-import
Aug 19, 2026
Merged

Fix legacy json import compatibility, UI sidebar refactor, and improved test coverage#4911
ChrisTitusTech merged 11 commits into
ChrisTitusTech:mainfrom
yadavnikhil03:fix-ui-and-json-import

Conversation

@yadavnikhil03

Copy link
Copy Markdown
Contributor

Type of Change

  • New feature
  • Bug fix
  • Documentation update
  • Refactor
  • UI/UX improvement

Description

fixes a couple of TODOs from the codebase and adds some missing test coverage.

  • legacy json import: tweaked Invoke-WPFImpex.ps1 to detect and flatten old PSCustomObject configs so legacy backups import properly instead of silently failing.
  • sidebar ui generation: moved the appscategory UI generation out of Initialize-WinUtilTabContent.ps1 and into Initialize-WPFUI.ps1 where it actually belongs.
  • fixed the pester tests (lazy-tabs and configs) that broke from the UI move.
  • added unit tests for Get-WinUtilVariables since it had no coverage.

compiled locally and all 475 pester tests are passing green.

Issue related to PR

@github-actions github-actions Bot added the bug Something isn't working label Aug 4, 2026
@coderabbitai coderabbitai Bot added the ui update UI/UX improvements label Aug 4, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
pester/lazy-tabs.Tests.ps1 (1)

42-42: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Restore runtime coverage for app-category rendering.

The removed assertion no longer verifies that Initialize-WPFUI -TargetGridName "appscategory" calls Invoke-WPFUIElements with $sync.configs.appnavigation and -columncount 1. Add a focused test for Initialize-WPFUI; keep this test focused on one-time tab initialization.

🤖 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 `@pester/lazy-tabs.Tests.ps1` at line 42, Add a focused test for
Initialize-WPFUI targeting "appscategory" that verifies Invoke-WPFUIElements
receives $sync.configs.appnavigation with -columncount 1, and keep the test
limited to one-time tab initialization behavior.
functions/public/Invoke-WPFImpex.ps1 (1)

76-85: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add regression tests for both import shapes.

The provided tests do not execute this compatibility branch. Add Pester cases for a legacy object containing WPFTweaks, WPFFeature, and Install, and for a flat array. Mock Update-WinUtilSelections and assert that only selection keys reach it.

🤖 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 `@functions/public/Invoke-WPFImpex.ps1` around lines 76 - 85, Add Pester
regression cases covering the compatibility branch in Invoke-WPFImpex: one
legacy PSCustomObject containing WPFTweaks, WPFFeature, and Install, and one
flat string array. Mock Update-WinUtilSelections, invoke the import flow for
each shape, and assert that only WPFTweaks and WPFFeature selection values are
passed, excluding Install.
🤖 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.

Inline comments:
In `@pester/variables.Tests.ps1`:
- Around line 5-22: Preserve the original process-wide value of $global:sync
before replacing it in BeforeAll, then restore that saved value during the
test-file cleanup, such as AfterAll or the existing Describe cleanup scope.
Update the setup and cleanup around the Get-WinUtilVariables test so later
Pester files observe the original $global:sync state.

---

Nitpick comments:
In `@functions/public/Invoke-WPFImpex.ps1`:
- Around line 76-85: Add Pester regression cases covering the compatibility
branch in Invoke-WPFImpex: one legacy PSCustomObject containing WPFTweaks,
WPFFeature, and Install, and one flat string array. Mock
Update-WinUtilSelections, invoke the import flow for each shape, and assert that
only WPFTweaks and WPFFeature selection values are passed, excluding Install.

In `@pester/lazy-tabs.Tests.ps1`:
- Line 42: Add a focused test for Initialize-WPFUI targeting "appscategory" that
verifies Invoke-WPFUIElements receives $sync.configs.appnavigation with
-columncount 1, and keep the test limited to one-time tab initialization
behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e09fe5cc-2220-44c1-866b-e2d0117e4de1

📥 Commits

Reviewing files that changed from the base of the PR and between a0142ac and 958da3b.

📒 Files selected for processing (6)
  • functions/private/Initialize-WinUtilTabContent.ps1
  • functions/public/Initialize-WPFUI.ps1
  • functions/public/Invoke-WPFImpex.ps1
  • pester/configs.Tests.ps1
  • pester/lazy-tabs.Tests.ps1
  • pester/variables.Tests.ps1
💤 Files with no reviewable changes (1)
  • functions/private/Initialize-WinUtilTabContent.ps1

Comment thread pester/variables.Tests.ps1
@yadavnikhil03
yadavnikhil03 force-pushed the fix-ui-and-json-import branch from ea151ea to 7dab1ee Compare August 5, 2026 04:44
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@mewclouds

Copy link
Copy Markdown
Contributor

Thanks for looking into this. I agree that the legacy JSON format needs to be addressed, but I have some concerns with the current import change.

The importer currently explicitly skips the old Install section. That section contains the legacy winget and choco package IDs, so excluding it means the backup is not being fully restored. Was that an intentional design decision? I don't remember that being established in issue #4877, and the reporter only recently clarified that the backup was from April 2025. I dug around and the workflow changed on February 17, which is almost 6 months ago. This is a product-design decision.

Could you add a small legacy JSON fixture, or otherwise document the exact config and expected result used for validation? Right now it's difficult for a reviewer to reproduce this manually, and the existing tests don't appear to validate the new legacy-import path.

I don't want to over-focus on the unrelated refactors here, but before calling this issue resolved, I think the expected migration behavior needs to be agreed on and tested, especially around the old Install and WPFInstall sections.

@obrientg

obrientg commented Aug 6, 2026

Copy link
Copy Markdown

Oh, good point @mewclouds and one I feared, that in the current state by not IDing the package sources some applications will not be installed on the device - and there are no warnings or communications to let the end user know this is the state of things.

Keep modern imports strict while allowing legacy backups to skip retired entries with clear logging and user feedback. Add fixtures covering partial and all-retired imports.
Exercise app category rendering through Initialize-WPFUI and restore global sync without leaking test state.
Limit legacy selection migration to supported WPF key families so unrelated string metadata does not produce false retired-setting warnings.
@ChrisTitusTech

Copy link
Copy Markdown
Owner

Resolved the legacy import compatibility questions and synced this branch with current main.

Legacy behavior is now explicit:

  • Historical exports stored checkbox selection keys under WPFInstall and duplicated package-manager metadata under Install; the old importer also excluded Install from restored selections.
  • Supported legacy WPFInstall, WPFTweaks, WPFToggle, WPFFeature, and WPFAppx keys are restored against the current catalog.
  • Retired keys are skipped with a log entry and user-facing warning. If every key is retired, existing selections are preserved.
  • Unrelated legacy metadata fields are ignored rather than reported as retired selections.

Regression coverage includes an exact legacy fixture, partial and all-retired imports, metadata filtering, strict modern imports, runtime app-category initialization, and global test-state cleanup.

Validation on 9f9d71c:

  • ./Compile.ps1: passed
  • Pester 5.8.0: 569 passed, 0 failed
  • Script Analyzer: no findings in the changed import function; the full scan has only the repository's existing accepted convention warnings
  • Local Codex review: no actionable regression identified
  • CodeRabbit: 0 issues on the full PR diff

@ChrisTitusTech ChrisTitusTech left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Reviewed the updated branch after synchronization with current main. Legacy and modern import paths are covered by focused regression tests; compilation, the full 569-test Pester suite, GitHub checks, local review, and independent CodeRabbit review are clean.

@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: 9f9d71cd89

ℹ️ 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 thread functions/public/Invoke-WPFImpex.ps1
Distinguish strict modern flat imports from partial legacy object migration, including single-setting export shape and historical groups.
# Conflicts:
#	functions/public/Invoke-WPFImpex.ps1
#	pester/ui-state.Tests.ps1
@ChrisTitusTech

Copy link
Copy Markdown
Owner

Follow-up review feedback is resolved and the branch is synchronized with current main at 42fb172.

  • Updated automation.mdx to distinguish strict modern flat imports from tolerant legacy grouped-object imports, including the single-setting JSON string shape and the historical legacy groups.
  • Preserved main's legacy-detection log while retaining this PR's stricter schema detection, metadata filtering, retired-key warnings, and state preservation.
  • Resolved the Codex review thread; 0 unresolved review threads remain.

Final validation:

  • ./Compile.ps1: passed
  • Focused import/state Pester: 23 passed, 0 failed
  • Full Pester 5.8.0: 581 passed, 0 failed
  • Script Analyzer: no findings in the merged import function
  • Local Codex review: no actionable findings in the effective PR diff (one base-only finding was verified unchanged from main)
  • CodeRabbit: 0 issues on the final merged PR diff
  • GitHub Compile-and-Check, label-pr, and CodeRabbit: successful

The docs container build was not run because Docker is unavailable on this host; this was a prose-only MDX edit and was proofread per the repository's docs-only validation guidance.

Repository owner deleted a comment from coderabbitai Bot Aug 19, 2026
@ChrisTitusTech
ChrisTitusTech merged commit 436773d into ChrisTitusTech:main Aug 19, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ui update UI/UX improvements

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Change in JSON file format provides An error occurred while importing: Key cannot be null.

4 participants