Repository navigation
(janitor/dedupe): consolidate duplicated formatBytes helpers - #7405
Merged
Merged
Conversation
Two near-identical decimal byte-size formatters had drifted apart: - apps/web/src/lib/kiloclaw/instance-display.ts (B/KB/MB/GB) - apps/web/src/app/admin/data-exports/data-export-format.ts (B/KB/MB/GB/TB + null/NaN guard) Move the superset implementation into @/lib/utils and re-export it from both sites so the algorithm has a single owner. No caller behavior change: kiloclaw callers pass non-negative numbers, and data-export callers keep the same null handling and TB unit.
Contributor
Author
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (3 files)
Reviewed by deepseek-v4.1-flash · Input: 48.9K · Output: 10.6K · Cached: 341.4K Review guidance: REVIEW.md from base branch |
Contributor
Author
|
Meta Janitor: Safety review passed; requesting approval. |
Contributor
There was a problem hiding this comment.
Meta-janitor safety approval for 896759c. Signal: #7405 (comment). GitHub auto-merge remains responsible for merging.
This was referenced Oct 17, 2026
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
Two near-identical decimal byte-size formatters had drifted apart in
apps/web:apps/web/src/lib/kiloclaw/instance-display.ts—B/KB/MB/GBunits, no guard.apps/web/src/app/admin/data-exports/data-export-format.ts—B/KB/MB/GB/TBunits plus anull/NaN/negative guard.The
data-exportcopy is a strict functional superset of thekiloclawcopy (same log-1024 algorithm, adds theTBunit and input guard). This PR moves that superset implementation into@/lib/utilsand re-exports it from both call sites, so the algorithm has a single owner and future changes (new units, rounding fixes) apply everywhere.Why this is safe
formatVolumeUsage,KiloclawInstanceDetail,DataExportsClient) pass non-negative finite numbers, and the data-export callers keep identical null/NaN handling and theTBunit.InstanceTab.test.ts,data-export-components.test.ts) assert outputs that the unified implementation produces unchanged.apps/web); the canonical home@/lib/utilsalready holds sibling helpers likeformatLargeNumber.Intentionally left alone
Other
formatBytes/byte formatters are not consolidated because their differences are intentional:SessionContainerTelemetry.tsxuses IECKiB/MiB/GiB/TiBunits.CodeIndexing/ClusterStatusCard.tsxuses fixed 2-decimalGB/MB/KBoutput.Verification
oxfmtandoxlintpass on the changed files.tsgo --noEmittypecheck passes forapps/web(exit 0).workerSetup.tscleanupDbForTest), which is unavailable in this environment; theirformatBytesassertions were verified against the unified implementation via a standalone run of the same vectors (all match).