Skip to content

feat(zigcli): add progress library and rename binary#78

Open
jiacai2050 wants to merge 4 commits intomainfrom
feat-progress
Open

feat(zigcli): add progress library and rename binary#78
jiacai2050 wants to merge 4 commits intomainfrom
feat-progress

Conversation

@jiacai2050
Copy link
Owner

Adds the zigcli.progress package to provide reusable progress bars and spinners. Renames the standalone binary from progress to progress-it to resolve naming collisions. Includes a demonstration program and documentation for the new library.

Adds the `zigcli.progress` package to provide reusable progress bars and spinners. Renames the standalone binary from `progress` to `progress-it` to resolve naming collisions. Includes a demonstration program and documentation for the new library.
Copilot AI review requested due to automatic review settings March 24, 2026 00:42
@gemini-code-assist
Copy link

Summary of Changes

Hello, 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 significantly enhances the zigcli project by integrating a new, versatile progress library. This library provides developers with tools for displaying progress bars, spinners, and managing multiple progress indicators simultaneously, improving user feedback for long-running operations. Concurrently, a necessary renaming of the progress binary to progress-it was performed to avoid conflicts, ensuring smoother integration and operation within diverse environments. The changes also include a comprehensive demonstration and updated build configurations.

Highlights

  • New Progress Library: Introduced a new zigcli.progress package offering reusable progress bars, spinners, and multi-progress rendering capabilities.
  • Binary Renaming: The standalone progress binary was renamed to progress-it to prevent potential naming collisions with existing system utilities.
  • Demonstration Program: A new example program, progress-demo.zig, was added to showcase the functionality and usage of the new progress library.
  • Build System Updates: The build.zig file was updated to incorporate the new progress-demo example and reflect the renaming of the progress binary to progress-it.
  • Module Export: The src/lib.zig file was modified to export the new progress module, making it accessible through the zigcli root.
  • Copilot Instructions: New instructions were added to .github/copilot-instructions.md to guide Copilot on the project's architecture and conventions, including details about the new progress binary.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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.

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

@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 introduces a well-designed progress package for creating progress bars and spinners, which is a great addition to the zigcli toolkit. The code is robust, with careful attention to memory management and a clean API. The renaming of the progress binary to progress-it to avoid conflicts is also a sensible change. I've included a few minor suggestions to improve documentation consistency and enhance code maintainability.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a reusable progress rendering library to the zigcli root module and updates the build to ship a renamed standalone binary to avoid name collisions.

Changes:

  • Introduces src/progress.zig providing progress bars, spinners, multi-progress rendering, plus reader/writer wrappers and tests.
  • Exports the new package from src/lib.zig as zigcli.progress and adds an examples/progress-demo.zig demo program.
  • Renames the standalone binary from progress to progress-it in build.zig and updates the corresponding compile-time error message.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/progress.zig New reusable progress library (bar/spinner/multi) with tests.
src/lib.zig Re-exports progress from the zigcli root module.
src/bin/progress-it.zig Updates platform compile error string to match renamed binary.
examples/progress-demo.zig Adds a demo program showing library usage.
build.zig Registers the progress-demo example and renames progress binary to progress-it with updated platform gating.
.github/copilot-instructions.md Adds repo guidance (needs small updates to match new export and binary rename).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +666 to +669
const rate_text = try formatCount(
arena,
self.style.unit,
@intFromFloat(rate),
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

@intFromFloat(rate) can trap if the computed rate exceeds the integer range (e.g., very large position with minimal elapsed time). Consider clamping the rate before converting, or formatting the rate as a float/string without converting to an integer.

Suggested change
const rate_text = try formatCount(
arena,
self.style.unit,
@intFromFloat(rate),
const max_rate_f64 = @as(f64, @floatFromInt(std.math.maxInt(u64)));
const clamped_rate = std.math.clamp(rate, 0.0, max_rate_f64);
const rate_int = @as(u64, @intFromFloat(clamped_rate));
const rate_text = try formatCount(
arena,
self.style.unit,
rate_int,

Copilot uses AI. Check for mistakes.
Comment on lines +719 to +722
const rate_text = try formatCount(
arena,
self.style.unit,
@intFromFloat(rate),
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

Same issue as the bar stats: @intFromFloat(rate) may trap if the computed rate is outside the integer range. Clamp before converting or avoid the integer conversion when formatting the rate.

Suggested change
const rate_text = try formatCount(
arena,
self.style.unit,
@intFromFloat(rate),
const max_rate_int: u64 = std.math.maxInt(u64);
const max_rate_float = @as(f64, @floatFromInt(max_rate_int));
const clamped_rate = if (rate > max_rate_float) max_rate_float else rate;
const rate_text = try formatCount(
arena,
self.style.unit,
@intFromFloat(clamped_rate),

Copilot uses AI. Check for mistakes.
Comment on lines +1036 to +1041
if (visible_index < visible_count) {
const progress_ptr = self.nthVisible(visible_index);
try progress_ptr.writeSnapshotAt(
writer,
now_ms,
self.draw_target.width_columns,
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

renderToWriterAt calls nthVisible() inside the render loop; nthVisible() linearly scans items each time, making rendering O(n^2) in the number of progress items. Consider iterating items once (skipping cleared entries) or building a temporary list of visible pointers for the current render to keep rendering O(n).

Copilot uses AI. Check for mistakes.
jiacai2050 and others added 3 commits March 24, 2026 09:26
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Replace nested if-else blocks with a switch statement to improve code readability. Group spinner-specific validation logic into its corresponding case arm.
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