Skip to content

feat: enhance progress bar status handling and alignment#845

Merged
ilopezluna merged 1 commit intomainfrom
fix/progess-bar
Apr 8, 2026
Merged

feat: enhance progress bar status handling and alignment#845
ilopezluna merged 1 commit intomainfrom
fix/progess-bar

Conversation

@ilopezluna
Copy link
Copy Markdown
Contributor

@ilopezluna ilopezluna commented Apr 7, 2026

This pull request improves the progress display logic for Docker operations in the progress.go file. The main focus is on standardizing and aligning the status messages in progress updates, making the output more readable and consistent.

Progress display improvements:

  • Introduced constants for all progress status strings (e.g., Waiting, Downloading, Pull complete, Uploading, Push complete) and a computed progressStatusWidth to ensure all status messages are padded to the same width. This keeps progress bars horizontally aligned in the CLI output.
  • Updated the code to use these new constants throughout the progress display logic, and padded the status string in the Docker JSON message to the fixed width for consistent
Screenshot 2026-04-07 at 16 30 36 alignment.

@ilopezluna ilopezluna requested a review from a team April 7, 2026 14:31
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 1 issue, and left some high level feedback:

  • The progressStatusWidth declaration as a const using max(...) will not compile in Go since const expressions cannot call functions; consider making it a var initialized in init() or hard-coding the computed width.
  • The comment says status strings are "left-padded", but fmt.Sprintf("%-*s", ...) right-pads (left-justifies) the text; either update the comment to match the behavior or adjust the format string if you really want left-padding.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `progressStatusWidth` declaration as a `const` using `max(...)` will not compile in Go since const expressions cannot call functions; consider making it a `var` initialized in `init()` or hard-coding the computed width.
- The comment says status strings are "left-padded", but `fmt.Sprintf("%-*s", ...)` right-pads (left-justifies) the text; either update the comment to match the behavior or adjust the format string if you really want left-padding.

## Individual Comments

### Comment 1
<location path="cmd/cli/desktop/progress.go" line_range="247-249" />
<code_context>
 		displayID = displayID[:12]
 	}

 	dockerMsg := jsonstream.Message{
-		ID:       displayID,
-		Status:   status,
+		ID: displayID,
+		// Pad status to a fixed width so all progress bars start at the
+		// same column regardless of status string length.
+		Status:   fmt.Sprintf("%-*s", progressStatusWidth, status),
</code_context>
<issue_to_address>
**question (bug_risk):** Padding the Status field may affect downstream consumers expecting exact status strings.

Previously `Status` contained the raw value (e.g., "Downloading"), but now it includes trailing spaces for alignment. If any callers or external tools do string equality checks or log `Status` as-is, this change could break them. Please confirm `Status` is only used for display, or consider doing the padding only in the presentation layer (or via a separate display field).
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines 247 to +249
dockerMsg := jsonstream.Message{
ID: displayID,
Status: status,
ID: displayID,
// Pad status to a fixed width so all progress bars start at the
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

question (bug_risk): Padding the Status field may affect downstream consumers expecting exact status strings.

Previously Status contained the raw value (e.g., "Downloading"), but now it includes trailing spaces for alignment. If any callers or external tools do string equality checks or log Status as-is, this change could break them. Please confirm Status is only used for display, or consider doing the padding only in the presentation layer (or via a separate display field).

Copy link
Copy Markdown
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 replaces hardcoded status strings with constants and introduces a padding mechanism to ensure that progress bars are horizontally aligned in the CLI output. A critical review comment points out that the use of the max built-in function for calculating padding width requires Go 1.21 or later, which may cause build failures if compatibility with older Go versions is required.

Comment on lines +190 to +196
progressStatusWidth = max(
len(progressStatusWaiting),
len(progressStatusDownloading),
len(progressStatusPullComplete),
len(progressStatusUploading),
len(progressStatusPushComplete),
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

critical

Critical

  • Compatibility Issue: The max built-in function was introduced in Go 1.21. Using it within a const block requires the project to be built with Go 1.21 or later. If this CLI tool needs to support older Go versions (which is common for distribution), this will cause a build failure.

Suggested fix: Use a literal constant or a var block with an init() function if compatibility with Go < 1.21 is required.

	// progressStatusWidth is the column width to which all status strings
	// are left-padded, keeping progress bars horizontally aligned.
	progressStatusWidth = 13
References
  1. Pragmatism: Use the simplest viable approach that maintains compatibility with the project's environment. (link)

@ilopezluna ilopezluna merged commit 9a742ad into main Apr 8, 2026
18 of 19 checks passed
@ilopezluna ilopezluna deleted the fix/progess-bar branch April 8, 2026 08:40
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.

4 participants