Skip to content

fix(webui): show 1.00 MB instead of 1024 KB just below a unit boundary - #1793

Merged
harry0703 merged 1 commit into
harry0703:mainfrom
kevin9327:fix/format-file-size-unit-rounding
Nov 12, 2026
Merged

harry0703 merged 1 commit into
harry0703:mainfrom
kevin9327:fix/format-file-size-unit-rounding

Conversation

@kevin9327

Copy link
Copy Markdown
Contributor

Summary

_format_file_size compared the unrounded value to 1024, then printed B and KB with .0f. A cache of 1,048,575 bytes therefore appeared as 1024 KB on the settings page, next to 1.00 MB at exactly 1,048,576 bytes. The same happens at the GB boundary.

The formatter now steps up when rounding already reaches 1024 of the current unit.

How Has This Been Tested?

  • Added test/services/test_webui_format_file_size.py, which loads _format_file_size from webui/Main.py without rendering the Streamlit app.
  • pytest test/services/test_webui_format_file_size.py passes (2 tests).

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have added/updated unit tests that prove my fix is effective
  • New and existing unit tests pass locally with my changes

_format_file_size compared the unrounded value to 1024, then printed
B and KB with .0f. A cache of 1048575 bytes therefore appeared as
1024 KB next to 1.00 MB at 1048576 bytes. Step up when rounding
already reaches 1024 of the current unit.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-12T02:52:25.849138Z 6f5e45d PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@harry0703
harry0703 merged commit dd09658 into harry0703:main Nov 12, 2026
3 checks passed
@harry0703

Copy link
Copy Markdown
Owner

Thanks, @kevin9327! I checked the MB and GB boundaries in the settings page, and the display looks right now. Merged. Thanks for the fix and the regression tests!

Sign up for free to 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.

2 participants