Consolidate diverged formatBytes copies into shared/lib/format-bytes - #899
Merged
Merged
Conversation
The server (release-tarball-cache.ts) and web (release-utils.ts) each carried their own formatBytes for the same release-tarball byte counts, and they had drifted: the server copy emitted compact units with no GB tier, so a >1GB tarball logged as e.g. '1536.0M'. One dependency-free shared implementation now serves both, with a compact option for the server's terse log lines (which gain the GB tier). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Uh oh!
There was an error while loading. Please reload this page.
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 freeto 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.
What
Consolidates two diverged
formatBytesimplementations —apps/server/src/release-tarball-cache.ts(compact1.5M/12K/900B, no GB tier) andapps/web/src/components/app/release-utils.ts(spaced1.5 GB/1.5 MB) — into one dependency-free shared module,apps/server/src/shared/lib/format-bytes.ts, with acompact?: booleanoption. Same shape as the media-file-types (#844) and agent-types (#849) consolidations: server imports it directly; web re-exports it throughrelease-utils.tsso all web importers (and the existing unit tests pinning the spaced output) stay untouched.Why it's tech debt
Both functions format the same release-tarball byte counts, and they had drifted: a >1GB tarball logged by the server as e.g.
1536.0M. Cross-boundary helper duplication is the dominant recurring debt category in this repo (tracked in the tech-debt brain state).Intentional behavior change (log strings only): the server's compact download-progress messages gain a GB tier — a >1GB download now logs
1.5Ginstead of1536.0M. No other output changes; the web formatter's output is byte-identical (pinned byrelease-utils.test.ts).Not in scope:
service-resources-format.tshas a thirdformatByteswith genuinely different semantics (nullable input, TB tier, adaptive precision for the resources dashboard) — deliberately left alone. Inline MB/KB math inmedia-lightbox.tsx/media-content.tsxlikewise.Validation
pnpm run check✓pnpm run finalize:web✓format-bytes.test.tscovering both modes), web 667 passed ✓Queued next
errorMessagehelper regression sweep (~14 inline copies in apps/server/src plus a web reimplementation).🤖 Generated with Claude Code