Dave Rayment 5c351aee5f [Peek] Update folder preview to be more robust, show more info, include scanning status and report errors (#50213)
<!-- Enter a brief description/summary of your PR here. What does it
fix/what does it change/how was it tested (even manually, if necessary)?
-->
## Summary of the Pull Request

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [x] Closes: #50174
<!-- - [ ] Closes: #yyy (add separate lines for additional resolved
issues) -->
- [ ] **Communication:** I've discussed this with core contributors
already. If the work hasn't been agreed, this work might be rejected
- [ ] **Tests:** Added/updated and all pass
- [ ] **Localization:** All end-user-facing strings can be localized
- [ ] **Dev docs:** Added/updated
- [ ] **New binaries:** Added on the required places
- [ ] [JSON for
signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [ ] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

This updates the folder preview in Peek to:

1. Show the file and sub-folder count, like Explorer's property page
2. Show a spinner while the enumeration is in progress
3. Replace the spinner with a warning icon when there was an error and
add "incomplete" to the counts instead of navigating to the default Peek
error display
4. Add `IgnoreInaccessible = true` to the `FolderEnumerationOptions`,
which automatically skips inaccessible folders instead of raising an
error
5. Fix an issue with comparing UTC and non-UTC `DateTime`s which could
freeze the updating counts or update them too often
6. Reduce the scan's allocations by more than 60% by using
`FileSystemEnumerable` instead of `DirectoryInfo.EnumerateFiles()`. This
is because `FileInfo`/`DirectoryInfo` objects are no longer created for
each iteration
7. Use `Typography.NumeralAlignment="Tabular"` to present numeric
counts, significantly improving the readability of the fields during
iteration and removing the alignment jitter
8. Remove LINQ-based chunking. This was not actually required because
the file enumeration itself was lazy
9. Check the cancellation token every iteration instead of once per
100-file chunk

### Screenshots and video
#### Scan in progress
<img width="833" height="677" alt="Screenshot 2026-08-27 230826"
src="https://github.com/user-attachments/assets/e6f0ad16-3815-4e0e-b7b2-a7d89b9e43f2"
/>

#### Incomplete scan display
<img width="833" height="677" alt="Screenshot 2026-08-28 024556"
src="https://github.com/user-attachments/assets/2787ddc4-7e2e-455b-aa70-bb6b2bf0cfaf"
/>

#### Screen recording

https://github.com/user-attachments/assets/4bbe677a-c5dd-4f01-98f3-b8f74a15fb22

## Validation Steps Performed

- All Peek unit tests pass:
<img width="308" height="47" alt="image"
src="https://github.com/user-attachments/assets/76c33d98-3028-466a-a0f1-068d50de5872"
/>

- Tested a variety of small and large folders with differing contents
and access
- Benchmarked the new approach against the existing enumeration method
to confirm memory and timing did not regress

```
// * Summary *

BenchmarkDotNet v0.14.0, Windows 11 (10.0.26200.9168)
11th Gen Intel Core i5-1135G7 2.40GHz, 1 CPU, 8 logical and 4 physical cores
.NET SDK 10.0.400
  [Host]     : .NET 9.0.19 (9.0.1926.36724), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI
  Job-ARTJAD : .NET 9.0.19 (9.0.1926.36724), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI

IterationCount=5  WarmupCount=3

| Method                                     | Mean    | Error   | StdDev  | Ratio | Gen0       | Gen1      | Gen2      | Allocated | Alloc Ratio |
|------------------------------------------- |--------:|--------:|--------:|------:|-----------:|----------:|----------:|----------:|------------:|
| 'Old: DirectoryInfo + Chunk'               | 11.13 s | 0.297 s | 0.046 s |  1.00 | 26000.0000 | 9000.0000 | 5000.0000 | 128.23 MB |        1.00 |
| 'New: FileSystemEnumerable'                | 10.97 s | 0.394 s | 0.102 s |  0.99 | 10000.0000 | 6000.0000 | 3000.0000 |  47.51 MB |        0.37 |
| 'P/Invoke: FindFirstFileExW + LARGE_FETCH' | 12.25 s | 0.106 s | 0.016 s |  1.10 | 10000.0000 | 1000.0000 |         - |  44.99 MB |        0.35 |
```
2026-09-01 16:32:48 +08:00

Microsoft PowerToys

Microsoft PowerToys is a collection of utilities that help you customize Windows and streamline everyday tasks.

Installation · Documentation · Blog · Release notes

🔨 Utilities

PowerToys includes over 30 utilities to help you customize and optimize your Windows experience:

Advanced Paste icon Advanced Paste Always on Top icon Always on Top Awake icon Awake
Color Picker icon Color Picker Command Not Found icon Command Not Found Command Palette icon Command Palette
Crop and Lock icon Crop And Lock Environment Variables icon Environment Variables FancyZones icon FancyZones
File Explorer Add-ons icon File Explorer Add-ons File Locksmith icon File Locksmith Grab And Move icon Grab And Move
Hosts File Editor icon Hosts File Editor Image Resizer icon Image Resizer Keyboard Manager icon Keyboard Manager
Light Switch icon Light Switch Mouse Utilities icon Mouse Utilities Mouse Without Borders icon Mouse Without Borders
New+ icon New+ Peek icon Peek PowerDisplay icon PowerDisplay
PowerRename icon PowerRename PowerToys Run icon PowerToys Run Quick Accent icon Quick Accent
Registry Preview icon Registry Preview Screen Ruler icon Screen Ruler Shortcut Guide icon Shortcut Guide
Text Extractor icon Text Extractor Window Hopper icon Window Hopper Workspaces icon Workspaces
ZoomIt icon ZoomIt

📦 Installation

For detailed installation instructions and system requirements, visit the installation docs.

But to get started quickly, choose one of the installation methods below:

Download the .exe file from GitHub

Go to the PowerToys GitHub releases, scroll down and select Assets to reveal the installation files, and choose the one that matches your architecture and install scope. For most devices, that would be x64 per-user.

Microsoft Store
You can easily install PowerToys from the Microsoft Store:

WinGet
Download PowerToys from [WinGet](https://github.com/microsoft/winget-cli#installing-the-client). Updating PowerToys via winget will respect the current PowerToys installation scope. To install PowerToys, run the following command from the command line / PowerShell:
  • User scope installer (default)
winget install Microsoft.PowerToys -s winget
  • Machine-wide scope installer
winget install --scope machine Microsoft.PowerToys -s winget
Other methods
There are [community driven install methods](https://learn.microsoft.com/windows/powertoys/install#community-driven-install-tools) such as Chocolatey and Scoop. If these are your preferred install solutions, you can find the install instructions there.

What's new?

What's new image

To see what's new, check out the release notes.

🛣️ Roadmap

For v0.102, we're working on modernizing several utilities with WinUI 3, expanding Command Palette with tabs and JavaScript/TypeScript extensions, and adding new productivity improvements across PowerToys.

❤️ PowerToys Community

The PowerToys team is extremely grateful to have the support of an amazing active community. The work you do is incredibly important. PowerToys wouldn't be nearly what it is today without your help filing bugs, updating documentation, guiding the design, or writing features. We want to say thank you and take time to recognize your work. Your contributions and feedback improve PowerToys month after month!

Contributing

This project welcomes contributions of all types. Besides coding features / bug fixes, other ways to assist include spec writing, design, documentation, and finding bugs. We are excited to work with the power user community to build a set of tools for helping you get the most out of Windows. We ask that before you start work on a feature that you would like to contribute, please read our Contributor's Guide. We would be happy to work with you to figure out the best approach, provide guidance and mentorship throughout feature development, and help avoid any wasted or duplicate effort. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you grant us the rights to use your contribution and that you have permission to do so. For guidance on developing for PowerToys, please read the developer docs for a detailed breakdown. This includes how to setup your computer to compile.

Code of conduct

This project has adopted the Microsoft Open Source Code of Conduct.

Privacy statement

The application logs basic diagnostic data (telemetry). For more privacy information and what we collect, see our PowerToys Data and Privacy documentation.

Description
Microsoft PowerToys is a collection of utilities that help you customize Windows and streamline everyday tasks
Readme MIT 742 MiB
Languages
C 44.9%
C# 26.4%
JavaScript 14%
C++ 13.8%
PowerShell 0.6%
Other 0.2%