Skip to content

Optimize registry and Windows service status detection - #4886

Closed
vyas-devgna wants to merge 1 commit into
ChrisTitusTech:mainfrom
vyas-devgna:refactor-current-system
Closed

Optimize registry and Windows service status detection#4886
vyas-devgna wants to merge 1 commit into
ChrisTitusTech:mainfrom
vyas-devgna:refactor-current-system

Conversation

@vyas-devgna

Copy link
Copy Markdown
Contributor

Type of Change

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

Description

Optimizes Invoke-WinUtilCurrentSystem.ps1 by eliminating repetitive WMI service queries and redundant registry operations:

  • Pre-fetches service states into an in-memory hashtable before evaluating tweak criteria.
  • Replaces paired Test-Path / Get-ItemProperty pipeline reads with single, direct calls to Get-ItemPropertyValue.
  • Replaces slow pipeline iterations (| ForEach-Object) with direct loops where applicable.

Issue related to PR

  • Resolves #

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Improved detection of installed Chocolatey and Winget applications when processing selections.
    • Corrected handling of missing or unsupported package identifiers.
    • Improved validation of registry-based tweaks and service startup settings.
    • Reduced potential issues when checking multiple tweak configurations.

Walkthrough

Changes

Invoke-WinUtilCurrentSystem.ps1 refactors Chocolatey and winget package matching, and updates tweak validation to cache services and directly retrieve registry values.

Current system detection

Layer / File(s) Summary
Package matching iteration and filtering
functions/private/Invoke-WinUtilCurrentSystem.ps1
Chocolatey matching uses explicit iteration, while winget skips null, whitespace, and na package IDs before matching.
Tweak registry and service validation
functions/private/Invoke-WinUtilCurrentSystem.ps1
Tweak properties are enumerated directly, services are cached once, registry values are read with Get-ItemPropertyValue, and service startup types are compared against expected values.

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

Suggested reviewers: christitustech

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main refactor around registry checks and Windows service status detection.
Description check ✅ Passed The description matches the changeset by describing service caching, registry access simplification, and loop refactors.
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

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

@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.

🧹 Nitpick comments (1)
functions/private/Invoke-WinUtilCurrentSystem.ps1 (1)

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

Add regression coverage for tweak detection.

Add focused Pester tests for registry-value fallback, service startup matches/mismatches, missing-service behavior, and the cached Get-Service call.

Also applies to: 76-79, 106-110

🤖 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/private/Invoke-WinUtilCurrentSystem.ps1` around lines 54 - 60, In
the Pester tests covering tweak detection in Invoke-WinUtilCurrentSystem, add
focused regression cases for registry-value fallback, matching and mismatching
service startup values, missing services, and reuse of the cached Get-Service
result. Verify each expected detection outcome and assert Get-Service is called
only once for the cached service map.
🤖 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 `@functions/private/Invoke-WinUtilCurrentSystem.ps1`:
- Around line 54-60: In the Pester tests covering tweak detection in
Invoke-WinUtilCurrentSystem, add focused regression cases for registry-value
fallback, matching and mismatching service startup values, missing services, and
reuse of the cached Get-Service result. Verify each expected detection outcome
and assert Get-Service is called only once for the cached service map.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: bd1fdb14-de93-47ec-8286-91ed664c5722

📥 Commits

Reviewing files that changed from the base of the PR and between 5f37ef4 and 020e3bf.

📒 Files selected for processing (1)
  • functions/private/Invoke-WinUtilCurrentSystem.ps1

@vyas-devgna

Copy link
Copy Markdown
Contributor Author

Superseded by comprehensive refactor in #4906

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