Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Image sizes can read 1024 KB instead of 1.0 MB

Open Beginner friendly
#29 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
88/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
electron, react, typescript
Domain
frontend, testing

Research direction

Start with formatBytes in src/renderer/src/lib/format.ts and the existing tests in tests/format.test.ts. Add a describe('formatBytes') covering the listed boundary cases, a plain B value, and 1.5 KB; run pnpm test. Done means no output shows 1024 of a unit and values that round to 10 or more have no decimal.

Written by the indexing model from the issue text.

Description

bug good first issue

formatBytes picks the unit before rounding, so a size just under the next unit rounds up to 1024 of the smaller one. Image cards and the inspector use it for file sizes.

Bytes Shows now Should show
1048575 1024 KB 1.0 MB
1073741823 1024 MB 1.0 GB
10239 10.0 KB 10 KB
10240 10 KB 10 KB

The last two rows are the same problem one digit down: values that round to 10 or more are meant to drop the decimal, but 9.999 passes the >= 10 check before it's rounded.

Where to look
  • src/renderer/src/lib/format.ts: formatBytes
  • tests/format.test.ts: already imports from @renderer/lib/format, so add a describe('formatBytes') next to the hostOf tests

#12 asks for broader tests of this file and to leave bugs for separate pull requests. This is that separate fix, so it's fine to do either one first.

Done when
  • No size shows as 1024 of a unit, and anything that rounds to 10 or more has no decimal
  • Tests cover the rows above plus a plain B value and a 1.5 KB value, and pnpm test passes

Suggested pull request title: fix(shelf): show 1.0 MB instead of 1024 KB


New to OpenPaste? CONTRIBUTING.md covers setup, the code conventions and the checks to run before a pull request (pnpm typecheck, pnpm test, pnpm format, pnpm cleaner). Leave a comment if you're picking this up so nobody doubles up.


Generated by Claude Code

Dominant language
TypeScript
Stars
0
Forks
3
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from alexsilver8/openpaste

All issues in alexsilver8/openpaste

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.