Add environment report export - #4928
Conversation
📝 WalkthroughSummary by CodeRabbit
WalkthroughAdds an allowlisted Windows environment report, a Diagnostics JSON export action, feature configuration, documentation, generator support, and Pester coverage for fallback behavior and sensitive-field exclusion. ChangesEnvironment report feature
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant InvokeWPFExportEnvironmentReport
participant GetWinUtilEnvironmentReport
participant JSONFile
User->>InvokeWPFExportEnvironmentReport: select Diagnostics export
InvokeWPFExportEnvironmentReport->>GetWinUtilEnvironmentReport: request report
GetWinUtilEnvironmentReport-->>InvokeWPFExportEnvironmentReport: return report object
InvokeWPFExportEnvironmentReport->>JSONFile: write UTF-8 JSON
JSONFile-->>User: display export confirmation
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@functions/private/Get-WinUtilEnvironmentReport.ps1`:
- Line 61: Update the developer-tool probe in Get-WinUtilEnvironmentReport
around the command invocation to start each native process with a finite
timeout. If the timeout expires, terminate that process, avoid blocking the UI
path, and leave the tool’s version unavailable rather than collecting output.
🪄 Autofix
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: 0ba97080-6d4f-49f2-84ab-76eb1768b165
📒 Files selected for processing (6)
config/feature.jsondocs/src/content/docs/guides/features.mdxfunctions/private/Get-WinUtilEnvironmentReport.ps1functions/public/Invoke-WPFExportEnvironmentReport.ps1pester/environment-report.Tests.ps1tools/devdocs-generator.ps1
| Select-Object -First 1 | ||
| if ($null -ne $command) { | ||
| $toolReport.installed = $true | ||
| $output = @(& $command.Source $toolDefinitions[$toolName][1] 2>&1 | ForEach-Object { $_.ToString().Trim() }) -join "`n" |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Add a timeout for each developer-tool probe.
At Line 61, the native command waits without a timeout. Invoke-WPFExportEnvironmentReport calls this collector on the UI event path at Line 19. If a tool process does not exit, the Diagnostics action remains blocked until it exits.
Start each process with a finite timeout. If it expires, terminate the process and leave its version unavailable.
🤖 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/Get-WinUtilEnvironmentReport.ps1` at line 61, Update the
developer-tool probe in Get-WinUtilEnvironmentReport around the command
invocation to start each native process with a finite timeout. If the timeout
expires, terminate that process, avoid blocking the UI path, and leave the
tool’s version unavailable rather than collecting output.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ff88e64aa6
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| $command = Get-Command -Name $toolDefinitions[$toolName][0] -CommandType Application -ErrorAction Stop | | ||
| Select-Object -First 1 | ||
| if ($null -ne $command) { | ||
| $toolReport.installed = $true |
There was a problem hiding this comment.
Avoid marking Store aliases as installed tools
On stock Windows systems where the Microsoft Store Python execution alias is enabled but Python is not actually installed, Get-Command python still returns the WindowsApps stub, so setting installed = $true before validating a usable version makes the exported report say Python is installed with a null version. This makes the diagnostic report's installed-state data misleading for a common default environment; only mark the tool installed after the command produces a recognizable version, or explicitly ignore Store alias stubs.
Useful? React with 👍 / 👎.
| } | ||
|
|
||
| foreach ($featureName in $featureDefinitions.Keys) { | ||
| $featureReport = [ordered]@{ enabled = $false } |
There was a problem hiding this comment.
Preserve unknown optional-feature states
When Get-WindowsOptionalFeature cannot run, such as the repo's documented PowerShell 7 MSIX Class not registered DISM failure, this default leaves enabled as false, so a machine with Hyper-V, WSL, or Sandbox enabled is exported as disabled rather than unknown. Because this diagnostic is meant to report whether those features are enabled, troubleshooting data becomes misleading in that environment; use a nullable/unknown state or an error flag instead of defaulting failures to false.
Useful? React with 👍 / 👎.
| Select-Object -First 1 | ||
| if ($null -ne $command) { | ||
| $toolReport.installed = $true | ||
| $output = @(& $command.Source $toolDefinitions[$toolName][1] 2>&1 | ForEach-Object { $_.ToString().Trim() }) -join "`n" |
There was a problem hiding this comment.
Do not execute PATH tools for a read-only report
WinUtil relaunches itself elevated before the UI starts, so this diagnostic button runs whichever git, java, node, python, or docker executable appears first on the user's PATH with admin rights. In environments with user-writable PATH entries, per-user installs, or WindowsApps aliases, clicking an advertised read-only export can execute arbitrary local code just to collect a version; prefer non-executing discovery or restrict version probing to trusted locations.
Useful? React with 👍 / 👎.
Type of Change
Description
Issue related to PR