The formatBytes / formatFileSize / formatSize utility function is duplicated 24 times across the codebase (verified 2026-09) instead of being imported from the canonical location.
Canonical location: web/lib/utils.ts exports formatBytes and formatSize
Duplicate locations include:
web/utils/change-helpers.tsx — formatFileSize
web/hooks/useMobileUpload.ts — formatFileSize
web/storage/diagnostics.ts — formatBytes
web/opfs/utils/opfs-utils.ts, web/opfs/utils/storage-utils.ts — formatBytes
web/skills/skill-store.ts, web/skills/skill-resources.ts — formatBytes / formatSize
web/services/stream-reader.service.ts — formatFileSize
web/store/offline-queue.store.ts — formatFileSize
web/agent/tools/formats/image/handler.ts — formatSize
- 12+ files under
web/components/ (agent renderers, sync views, export dialogs...)
Note: web/components/agent/tool-renderers/PageScreenshotRenderer.tsx has a formatBytes(base64: string) that is semantically a different function — leave it alone.
What to do:
- Pick a few files to start with (don't need to do all at once)
- In each file, remove the local
formatBytes/formatSize/formatFileSize function
- Replace with
import { formatBytes } from '@/lib/utils' (or formatSize)
- Verify the behavior is the same (some variants differ slightly in decimal places — match the canonical version)
- Run
cd web && pnpm typecheck to confirm no errors
Skills needed: TypeScript, ability to refactor imports
Estimated time: 1-2 hours (can be done incrementally, a few files per PR)
The
formatBytes/formatFileSize/formatSizeutility function is duplicated 24 times across the codebase (verified 2026-09) instead of being imported from the canonical location.Canonical location:
web/lib/utils.tsexportsformatBytesandformatSizeDuplicate locations include:
web/utils/change-helpers.tsx—formatFileSizeweb/hooks/useMobileUpload.ts—formatFileSizeweb/storage/diagnostics.ts—formatBytesweb/opfs/utils/opfs-utils.ts,web/opfs/utils/storage-utils.ts—formatBytesweb/skills/skill-store.ts,web/skills/skill-resources.ts—formatBytes/formatSizeweb/services/stream-reader.service.ts—formatFileSizeweb/store/offline-queue.store.ts—formatFileSizeweb/agent/tools/formats/image/handler.ts—formatSizeweb/components/(agent renderers, sync views, export dialogs...)What to do:
formatBytes/formatSize/formatFileSizefunctionimport { formatBytes } from '@/lib/utils'(orformatSize)cd web && pnpm typecheckto confirm no errorsSkills needed: TypeScript, ability to refactor imports
Estimated time: 1-2 hours (can be done incrementally, a few files per PR)