The formatBytes / formatFileSize / formatSize utility function is duplicated ~15 times across the codebase instead of being imported from the canonical location.
Canonical location: web/src/lib/utils.ts exports formatBytes and formatSize
Duplicate locations include:
web/src/utils/change-helpers.tsx line 54
web/src/hooks/useMobileUpload.ts line 83
web/src/components/sync/FileChangeList.tsx line 40
web/src/components/sync/SyncProgressDialog.tsx line 48
web/src/components/sync/FileDiffViewer.tsx line 85
web/src/components/settings/SettingsDialog.tsx line 149
web/src/components/tools/DropZone.tsx line 107
web/src/components/plugins/PluginResults.tsx line 253
web/src/store/offline-queue.store.ts line 66
web/src/agent/tools/ls.tool.ts line 116
- ... and more
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
pnpm -C web run 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 ~15 times across the codebase instead of being imported from the canonical location.Canonical location:
web/src/lib/utils.tsexportsformatBytesandformatSizeDuplicate locations include:
web/src/utils/change-helpers.tsxline 54web/src/hooks/useMobileUpload.tsline 83web/src/components/sync/FileChangeList.tsxline 40web/src/components/sync/SyncProgressDialog.tsxline 48web/src/components/sync/FileDiffViewer.tsxline 85web/src/components/settings/SettingsDialog.tsxline 149web/src/components/tools/DropZone.tsxline 107web/src/components/plugins/PluginResults.tsxline 253web/src/store/offline-queue.store.tsline 66web/src/agent/tools/ls.tool.tsline 116What to do:
formatBytes/formatSize/formatFileSizefunctionimport { formatBytes } from '@/lib/utils'(orformatSize)pnpm -C web run typecheckto confirm no errorsSkills needed: TypeScript, ability to refactor imports
Estimated time: 1-2 hours (can be done incrementally, a few files per PR)