Skip to content

Consolidate diverged formatBytes copies into shared/lib/format-bytes - #899

Merged
selfcontained merged 1 commit into
mainfrom
agt_46798007da63/job-debt-collector-82a66817
Aug 8, 2026
Merged

Consolidate diverged formatBytes copies into shared/lib/format-bytes#899
selfcontained merged 1 commit into
mainfrom
agt_46798007da63/job-debt-collector-82a66817

Conversation

@selfcontained

Copy link
Copy Markdown
Owner

What

Consolidates two diverged formatBytes implementations — apps/server/src/release-tarball-cache.ts (compact 1.5M/12K/900B, no GB tier) and apps/web/src/components/app/release-utils.ts (spaced 1.5 GB/1.5 MB) — into one dependency-free shared module, apps/server/src/shared/lib/format-bytes.ts, with a compact?: boolean option. Same shape as the media-file-types (#844) and agent-types (#849) consolidations: server imports it directly; web re-exports it through release-utils.ts so 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.5G instead of 1536.0M. No other output changes; the web formatter's output is byte-identical (pinned by release-utils.test.ts).

Not in scope:service-resources-format.ts has a third formatBytes with genuinely different semantics (nullable input, TB tier, adaptive precision for the resources dashboard) — deliberately left alone. Inline MB/KB math in media-lightbox.tsx/media-content.tsx likewise.

Validation

  • pnpm run check
  • pnpm run finalize:web
  • Unit: server 2432 passed (incl. new format-bytes.test.ts covering both modes), web 667 passed ✓
  • E2E: 176 passed ✓

Queued next

errorMessage helper regression sweep (~14 inline copies in apps/server/src plus a web reimplementation).

🤖 Generated with Claude Code

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>
@selfcontained
selfcontained merged commit eecfb13 into mainAug 8, 2026
1 check passed
@selfcontained
selfcontained deleted the agt_46798007da63/job-debt-collector-82a66817 branch August 8, 2026 09:13
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@selfcontained