mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-07-09 03:49:52 +02:00
## Summary of the Pull Request Adds a unit selection setting to the Performance Monitor extension in Command Palette that allows users to choose how network transmission speed is displayed. The setting offers three options: bits per second (Kbps/Mbps/Gbps, the default), bytes per second (KB/s/MB/s/GB/s), and binary bytes per second using IEC prefixes (KiB/s/MiB/s/GiB/s). ## PR Checklist - [ ] **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 ## Detailed Description of the Pull Request / Additional comments The following files were changed: - **`NetworkSpeedUnit.cs`** (new): Enum defining the three supported unit modes — `BitsPerSecond`, `BytesPerSecond`, and `BinaryBytesPerSecond`. - **`SettingsManager.cs`** (new): A `JsonSettingsManager` subclass for the Performance Monitor extension. Defines a `ChoiceSetSetting` for `NetworkSpeedUnit` (default: `BitsPerSecond`), stored under the `performanceMonitor` namespace in the shared CmdPal `settings.json`. - **`PerformanceWidgetsPage.cs`**: - `PerformanceWidgetsPage` constructor now accepts `SettingsManager` and passes it to `SystemNetworkUsageWidgetPage`. - `SystemNetworkUsageWidgetPage` stores the settings manager and calls `SpeedToString()`, which dispatches via a switch expression to `FormatAsBitsPerSecString()` (e.g. `12.5 Mbps`), `FormatAsBytesPerSecString()` (e.g. `1.6 MB/s`), or `FormatAsBinaryBytesPerSecString()` (e.g. `1.5 MiB/s`) based on the selected unit. - **`PerformanceMonitorCommandsProvider.cs`**: Holds the `SettingsManager`, passes it to both the list page and dock band via `SetEnabledState()`, exposes `Settings` on the provider, and adds the settings page to the command's `MoreCommands`. The crash-recovery hardening from main (`ProviderCrashSentinel`, `TryReactivateImmediately`, `SetDisabledState`, thread-safe locking) is fully preserved and integrated with the settings manager. - **`Resources.resw`**: Updated `Network_Speed_Unit_Setting_Title` and `Network_Speed_Unit_Setting_Description` to neutral language; added three choice label strings (`Network_Speed_Unit_BitsPerSec`, `Network_Speed_Unit_BytesPerSec`, `Network_Speed_Unit_BinaryBytesPerSec`). Also includes the disabled-state strings merged from main. ## Validation Steps Performed - Manually verified that the setting appears in the Performance Monitor extension's settings page (accessible via the ⋯ context menu on the Performance Monitor command item). - Verified that network speed values display in Kbps/Mbps/Gbps by default, switch to KB/s/MB/s/GB/s when the bytes option is selected, and switch to KiB/s/MiB/s/GiB/s when the binary bytes option is selected. - Setting persists across Command Palette restarts via the shared CmdPal settings file. - Verified that the crash-recovery re-enable flow correctly restores pages with the settings manager wired up. <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>[Command Palette] Allows network transmission speed units to be switched between bits per second and bytes per second</issue_title> > <issue_description>### Description of the new feature / enhancement > > Add a setting that allows network monitoring in the Command Palette Dock to be displayed in bytes per second. > > ### Scenario when this would be used? > > In everyday usage, byte units are more commonly used. > > ### Supporting information > > _No response_</issue_description> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > <comment_new><author>@niels9001</author><body> > @copilot Can you add a setting for this?</body></comment_new> > </comments> > </details> <!-- START COPILOT CODING AGENT SUFFIX --> - Fixes microsoft/PowerToys#46271 <!-- START COPILOT CODING AGENT TIPS --> --- ✨ Let Copilot coding agent [set things up for you](https://github.com/microsoft/PowerToys/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: niels9001 <9866362+niels9001@users.noreply.github.com>
PowerToys Source Code
Code organization
The PowerToys are split into DLLs for each PowerToy module (modules folder), and an executable (runner folder) that loads and manages those DLLs.
The settings window is a separate executable, contained in settings-ui folder. It utilizes a WebView to display an HTML-based settings window.
The common contains code for a static library with helper functions, used by both the runner and the PowerToys modules.