on main help sign in
fix(ui): guard divide-by-zero display error

Otherwise, if contextWindow == 0, then it's a divide-by-zero error and a wild number % is shown. Now it defaults to 0% in that case. Signed-off-by: Evan Wies <evan@neomantra.net>

commit5b1b2b435cd805462e6c01fa6d3453bea0199166 authorEvan Wies <evan@neomantra.net> dateThu 21 May 2026, 10:22 (5 months ago) parent5d7797d
1 file changed+4−1
internal/ui/common/elements.go+4−1
internal/ui/common/elements.go+4−1
@@ -111,7 +111,10 @@ func formatTokensAndCost(t *styles.Styles, tokens, contextWindow int64, cost flo
111111 formattedTokens = strings.Replace(formattedTokens, ".0M", "M", 1)
112112 }
113113
114− percentage := (float64(tokens) / float64(contextWindow)) * 100
114+ var percentage float64
115+ if contextWindow > 0 {
116+ percentage = (float64(tokens) / float64(contextWindow)) * 100
117+ }
115118
116119 formattedCost := t.ModelInfo.Cost.Render(fmt.Sprintf("$%.2f", cost))
117120