From 408c8d3d9c172363c66d5e322c99de0d72aad936 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Thu, 21 May 2026 15:50:34 +0000 Subject: [PATCH] fix: clamp progress percentage to prevent panic with negative repeat count This fixes a panic in internal/display/display.go where if a job's Current exceeded Total, or Total was 0, pct evaluated to >1.0 or NaN. This caused the progress bar filled length to be longer than the allowed width, resulting in empty width being negative and crashing strings.Repeat. We now handle Total=0 and clamp the percentage. Co-authored-by: Tanq16 <37408906+Tanq16@users.noreply.github.com> --- internal/display/display.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/internal/display/display.go b/internal/display/display.go index a1603f6..b8549ac 100644 --- a/internal/display/display.go +++ b/internal/display/display.go @@ -358,7 +358,15 @@ func (d *Display) buildDisplay() []string { extraInfo = truncateString(extraInfo, innerWidth-4-1-1-6-progressWidth) } - pct := float64(job.Current) / float64(job.Total) + var pct float64 + if job.Total > 0 { + pct = float64(job.Current) / float64(job.Total) + } + if pct > 1.0 { + pct = 1.0 + } else if pct < 0 { + pct = 0 + } filled := int(pct * float64(progressWidth)) empty := progressWidth - filled