Skip to content

Conversation

@subhobhai943
Copy link

Summary

Renames formatMemoryUsage to formatBytes in the core package to better reflect its general-purpose nature as a byte formatting utility.

Changes

  • Renamed formatMemoryUsageformatBytes in packages/core/src/utils/formatters.ts
  • Updated test suite name in packages/core/src/utils/formatters.test.ts
  • Updated import and usage in packages/core/src/tools/shell.ts

Why this matters

  1. Clarity: formatBytes accurately describes what the function does
  2. Reuse: The current name discourages reuse because it sounds memory-specific, even though it's a general byte formatter
  3. Consistency: Aligns with common naming conventions (formatBytes is standard across ecosystems)

Fixes #14995

@subhobhai943 subhobhai943 requested a review from a team as a code owner January 8, 2026 08:32
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @subhobhai943, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors a core utility function by renaming formatMemoryUsage to formatBytes. This change significantly improves code clarity, promotes reusability across different contexts, and ensures consistency with standard naming conventions for byte formatting. The update involves modifying the function definition, its imports, and all call sites, along with the corresponding test suite.

Highlights

  • Function Renaming: The formatMemoryUsage function in packages/core/src/utils/formatters.ts has been renamed to formatBytes to better reflect its general-purpose utility for formatting byte values.
  • Improved Clarity: The new name formatBytes more accurately describes the function's purpose, moving away from a memory-specific connotation.
  • Enhanced Reusability: Renaming encourages broader reuse of the utility, as its previous name might have discouraged its application in non-memory-related contexts.
  • Code Consistency: This change aligns the function's naming with common industry conventions for byte formatting utilities.
  • Usage Updates: All instances where formatMemoryUsage was imported or called, specifically in packages/core/src/tools/shell.ts and packages/core/src/utils/formatters.test.ts, have been updated to use formatBytes.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly renames formatMemoryUsage to formatBytes for better clarity and reusability. The changes across the files are consistent with this goal.

I've added one suggestion in packages/core/src/utils/formatters.ts to improve the correctness and efficiency of the formatBytes function, especially for small byte values. This will prevent confusing output like 0.0 KB for non-zero byte counts.

@gemini-cli gemini-cli bot added priority/p3 Backlog - a good idea but not currently a priority. area/core Issues related to User Interface, OS Support, Core Functionality labels Jan 8, 2026
@subhobhai943
Copy link
Author

@gemini-code-assist Thanks for the review! I've updated formatBytes to handle values < 1024 bytes by returning them in Bytes (B) instead of fractional KB. I've also added a test case for this scenario.

@gemini-code-assist
Copy link
Contributor

That's excellent, @subhobhai943! I've reviewed the latest changes and I see that you've addressed the handling of values less than 1024 bytes by returning them in 'B' (Bytes), and you've also added a corresponding test case for this scenario.

This is a great improvement for the formatBytes utility, enhancing its correctness and ensuring comprehensive test coverage for edge cases. Well done!

@Nubebuster
Copy link

Hi, does this PR do anything differently to #14997?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core Issues related to User Interface, OS Support, Core Functionality priority/p3 Backlog - a good idea but not currently a priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor(core): rename formatMemoryUsage to formatBytes for clarity and reuse

2 participants