Skip to content

Add environment report export - #4928

Open
BhumilNariya wants to merge 1 commit into
ChrisTitusTech:mainfrom
BhumilNariya:feature/export-environment-report
Open

Add environment report export#4928
BhumilNariya wants to merge 1 commit into
ChrisTitusTech:mainfrom
BhumilNariya:feature/export-environment-report

Conversation

@BhumilNariya

@BhumilNariya BhumilNariya commented Aug 6, 2026

Copy link
Copy Markdown

Type of Change

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

Description

Issue related to PR

  • Resolves #

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added a Diagnostics option to export a read-only environment report as UTF-8 JSON.
    • Reports include Windows, hardware, PowerShell, developer tool, and optional feature details while excluding sensitive information.
    • Added confirmation and error messages for report exports; canceling the save dialog exits without creating a file.
  • Documentation

    • Added guidance describing report contents, privacy safeguards, and the fact that WinUtil does not upload reports.
  • Tests

    • Added coverage for report structure, privacy protections, and unavailable system information.

Walkthrough

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

Changes

Environment report feature

Layer / File(s) Summary
Report collection and validation
functions/private/Get-WinUtilEnvironmentReport.ps1, pester/environment-report.Tests.ps1
Collects Windows, hardware, PowerShell, developer-tool, and optional-feature data. Returns an allowlisted versioned schema with error-tolerant fallbacks. Tests verify the schema, exclusions, and fallback behavior.
Diagnostics export integration
functions/public/Invoke-WPFExportEnvironmentReport.ps1, config/feature.json, tools/devdocs-generator.ps1, docs/src/content/docs/guides/features.mdx
Adds the Diagnostics button and export handler. The handler writes UTF-8 JSON after save-dialog confirmation. Documentation and generator categories include Diagnostics.

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
Loading

Suggested reviewers: christitustech

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The description contains only an unused template and does not explain the environment report export changes. Add a concise description of the environment report, export workflow, diagnostics documentation, and related tests.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly summarizes the main change: adding environment report export functionality.
✨ 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 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

🤖 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

📥 Commits

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

📒 Files selected for processing (6)
  • config/feature.json
  • docs/src/content/docs/guides/features.mdx
  • functions/private/Get-WinUtilEnvironmentReport.ps1
  • functions/public/Invoke-WPFExportEnvironmentReport.ps1
  • pester/environment-report.Tests.ps1
  • tools/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"

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.

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

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

@github-actions github-actions Bot added the new feature New feature or request label Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant