Skip to content

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

Open
yadavnikhil03 wants to merge 4 commits into
ChrisTitusTech:mainfrom
yadavnikhil03:fix-ui-and-json-import
Open

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

Conversation

@yadavnikhil03

Copy link
Copy Markdown

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 commented Aug 4, 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: cc13b138-2a2a-4c9c-b3f2-969e20b089f8

📥 Commits

Reviewing files that changed from the base of the PR and between f7c0723 and 7dab1ee.

📒 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
🚧 Files skipped from review as they are similar to previous changes (5)
  • functions/public/Invoke-WPFImpex.ps1
  • pester/lazy-tabs.Tests.ps1
  • functions/public/Initialize-WPFUI.ps1
  • pester/variables.Tests.ps1
  • pester/configs.Tests.ps1

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Improved app navigation setup for more reliable app category display.
    • Added support for importing both legacy and newer configuration formats.
  • Bug Fixes

    • Fixed app category loading and Install tab initialization.
    • Improved compatibility when processing imported configuration data.
  • Tests

    • Expanded automated coverage for variable retrieval, app navigation, tab initialization, and configuration handling.
    • Added validation for configuration formats, filtering behavior, type matching, and state restoration.

Walkthrough

The change moves app-category UI population into Initialize-WPFUI, adds support for legacy and flat-array import configurations, updates related tests, and adds coverage for Get-WinUtilVariables.

Changes

UI initialization and import handling

Layer / File(s) Summary
App-category initialization wiring
functions/private/Initialize-WinUtilTabContent.ps1, functions/public/Initialize-WPFUI.ps1, pester/configs.Tests.ps1, pester/lazy-tabs.Tests.ps1
appscategory initialization now calls Invoke-WPFUIElements from Initialize-WPFUI. Install-tab initialization and tests reflect the new call location.
Import configuration compatibility
functions/public/Invoke-WPFImpex.ps1
Import parsing supports legacy object configurations by flattening values except Install, and uses flat arrays directly.

Variable discovery test coverage

Layer / File(s) Summary
Get-WinUtilVariables validation
pester/variables.Tests.ps1
Added tests for synchronized variable setup, prefix filtering, exact type matching, multiple PSCustomObject results, unmatched types, and global-state restoration.

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

Possibly related PRs

Suggested labels: ui update

Suggested reviewers: christitustech

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The sidebar refactor and Get-WinUtilVariables tests are not required by linked issue #4877, which only addresses legacy JSON import compatibility. Move unrelated sidebar refactoring and variable tests to a separate pull request, or link issues that define those objectives.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the legacy import fix, UI refactor, and added test coverage.
Description check ✅ Passed The description directly explains the import compatibility fix, UI refactor, test updates, and added coverage.
Linked Issues check ✅ Passed The import changes support legacy object-based JSON files and preserve compatibility with flat-array configurations required by issue #4877.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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 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 Outdated
@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.

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

None yet

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.

3 participants