feat(web-ui): add bandwidth unit toggle (Mbps / MB/s) on status page#467
Merged
feat(web-ui): add bandwidth unit toggle (Mbps / MB/s) on status page#467
Conversation
Adds a unit selector to the status header that lets the user display bandwidth as either Mbps (default) or MB/s. The choice persists in localStorage and applies to every bandwidth readout on the page (header total, per-client table, per-worker stats). Refactor: factor the shared "persisted-enum" pattern out of useTheme, useLocale, and the new useBandwidthUnit into a single usePersistedEnum hook (also fixes an inherited no-op localStorage write on mount). Extract a HeaderSelect helper to dedupe the three icon+label+SelectBox blocks in StatusHeader. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Contributor
|
Azure Static Web Apps: Your stage site is ready! Visit it here: https://thankful-water-0a297bf00-467.eastasia.1.azurestaticapps.net |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a user-selectable bandwidth display unit (Mbps vs MB/s) to the Web UI status page and refactors “persisted enum” localStorage logic into a shared hook so theme/locale/unit preferences persist consistently.
Changes:
- Add a Bandwidth Unit selector in the status header and propagate the selection to all bandwidth readouts (total, per-client, per-worker).
- Introduce
usePersistedEnumand refactoruseTheme/useLocale(and newuseBandwidthUnit) to use it, avoiding redundant localStorage writes. - Update shared typing/i18n to support the new selector and stronger enum-style type definitions.
Reviewed changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| web-ui/src/types/ui.ts | Introduces THEME_MODES and adds BANDWIDTH_UNITS + BandwidthUnit type for shared UI enums. |
| web-ui/src/pages/status.tsx | Wires useBandwidthUnit into the status page and passes the selected unit through to header/sections; updates total bandwidth formatting. |
| web-ui/src/lib/locale.ts | Converts supported locales to a as const tuple and removes now-obsolete locale init helpers (replaced by persisted-enum hook usage). |
| web-ui/src/lib/format.ts | Updates formatBandwidth to accept a BandwidthUnit and format as Mbps (bits) or MB/s (bytes). |
| web-ui/src/i18n/status.ts | Adds translated label key for the new “Bandwidth Unit” selector. |
| web-ui/src/hooks/use-theme.ts | Refactors theme persistence to usePersistedEnum and removes redundant localStorage writes. |
| web-ui/src/hooks/use-persisted-enum.ts | Adds shared hook to persist validated string-enum selections with “don’t store default” behavior. |
| web-ui/src/hooks/use-locale.ts | Refactors locale persistence to usePersistedEnum, using browser-detected locale as the default baseline. |
| web-ui/src/hooks/use-bandwidth-unit.ts | Adds new persisted bandwidth-unit hook built on usePersistedEnum. |
| web-ui/src/components/status/workers-section.tsx | Threads bandwidth unit into worker stats formatting. |
| web-ui/src/components/status/status-header.tsx | Adds the bandwidth unit dropdown and deduplicates header select rendering via HeaderSelect. |
| web-ui/src/components/status/connections-section.tsx | Threads bandwidth unit into per-client bandwidth formatting (table + mobile cards). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Mbps; choice persists inlocalStorageand is applied to every bandwidth readout (header total, per-client table, per-worker stats).useTheme,useLocale, and the newuseBandwidthUnitinto a singleusePersistedEnumhook. Also fixes an inherited no-oplocalStoragewrite on mount.HeaderSelecthelper insideStatusHeaderto dedupe the three icon + label +SelectBoxblocks (Language / Appearance / Bandwidth Unit).Screenshots
The bandwidth unit dropdown sits to the right of Appearance and follows the same icon + label + dropdown pattern. On narrow screens it wraps to a second row, right-aligned to line up under Appearance.
Test plan
MbpstoMB/s(and back).Mbps) and reload — verify thestatus-bandwidth-unitlocalStorage key is removed (not stored as default).🤖 Generated with Claude Code