fix: render basis with explicit sign and absolute delta

Format basis row as +/-$abs(delta) to match the spec and avoid
awkward %+s formatting behavior.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-04-26 17:39:57 +07:00
parent 88de029e14
commit 95e9217ef4
2 changed files with 21 additions and 2 deletions
+6 -1
View File
@@ -2,6 +2,7 @@ package view
import (
"fmt"
"math"
"strings"
"time"
@@ -102,7 +103,11 @@ func RenderRichTokenMessage(in RichTokenMessageInput) string {
if in.HasSpot && in.HasFuture && in.SpotPrice > 0 {
delta := in.FuturePrice - in.SpotPrice
deltaPct := delta / in.SpotPrice * 100
rows = append(rows, fmt.Sprintf("🧭 Basis: $%+s (%+.2f%%)", RenderPrice(delta), deltaPct))
sign := "+"
if delta < 0 {
sign = "-"
}
rows = append(rows, fmt.Sprintf("🧭 Basis: %s$%s (%+.2f%%)", sign, RenderPrice(math.Abs(delta)), deltaPct))
}
if in.HasFuture {