From ce314b8e0d2ad6a8c0661ab2dbde6d8f2ecf65b1 Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Fri, 1 May 2026 12:13:05 -0400 Subject: [PATCH] feat(ui): add hypercredit readout to small top header --- internal/ui/common/elements.go | 6 +++--- internal/ui/model/header.go | 8 ++++++++ internal/ui/model/ui.go | 1 + internal/ui/styles/quickstyle.go | 1 + internal/ui/styles/styles.go | 1 + 5 files changed, 14 insertions(+), 3 deletions(-) diff --git a/internal/ui/common/elements.go b/internal/ui/common/elements.go index d4f948efbea7f29952ccad83affc526a62a82ddb..902c8a816247d97f0d9dd0ce7538b1bf130bc07d 100644 --- a/internal/ui/common/elements.go +++ b/internal/ui/common/elements.go @@ -81,7 +81,7 @@ func ModelInfo(t *styles.Styles, modelName, providerName, reasoningInfo string, if providerName == hyper.DisplayName && hyperCredits != nil { hcInfo := t.ModelInfo.HypercreditIcon.Render(styles.HypercreditIcon) hcInfo += " " - hcInfo += t.ModelInfo.HypercreditText.Render(fmt.Sprintf("%s Hypercredits", formatCredits(*hyperCredits))) + hcInfo += t.ModelInfo.HypercreditText.Render(fmt.Sprintf("%s Hypercredits", FormatCredits(*hyperCredits))) parts = append(parts, "", hcInfo) } @@ -124,8 +124,8 @@ func formatTokensAndCost(t *styles.Styles, tokens, contextWindow int64, cost flo return fmt.Sprintf("%s %s", formattedTokens, formattedCost) } -// formatCredits formats an integer with comma separators for thousands. -func formatCredits(n int) string { +// FormatCredits formats an integer with comma separators for thousands. +func FormatCredits(n int) string { s := strconv.FormatInt(int64(n), 10) if n < 1000 { return s diff --git a/internal/ui/model/header.go b/internal/ui/model/header.go index 0859d0774b1928501a26adde6870efd54615d30c..1fee1eb05942be52781173e8d63fab8de34a2f9b 100644 --- a/internal/ui/model/header.go +++ b/internal/ui/model/header.go @@ -69,6 +69,7 @@ func (h *header) drawHeader( compact bool, detailsOpen bool, width int, + hyperCredits *int, ) { t := h.com.Styles if width != h.width || compact != h.compact { @@ -101,6 +102,7 @@ func (h *header) drawHeader( lspErrorCount, detailsOpen, availDetailWidth, + hyperCredits, ) remainingWidth := width - @@ -131,6 +133,7 @@ func renderHeaderDetails( lspErrorCount int, detailsOpen bool, availWidth int, + hyperCredits *int, ) string { t := com.Styles @@ -148,6 +151,11 @@ func renderHeaderDetails( parts = append(parts, formattedPercentage) } + if com.IsHyper() && hyperCredits != nil { + hc := t.Header.Hypercredit.Render(styles.HypercreditIcon) + " " + t.Header.Percentage.Render(common.FormatCredits(*hyperCredits)) + parts = append(parts, hc) + } + const keystroke = "ctrl+d" if detailsOpen { parts = append(parts, t.Header.Keystroke.Render(keystroke)+t.Header.KeystrokeTip.Render(" close")) diff --git a/internal/ui/model/ui.go b/internal/ui/model/ui.go index aa0acbf24b276f3931b7fa8b9e701ba331b46bce..8dac275f28cce91c38134265220f84bd611eecf1 100644 --- a/internal/ui/model/ui.go +++ b/internal/ui/model/ui.go @@ -2109,6 +2109,7 @@ func (m *UI) drawHeader(scr uv.Screen, area uv.Rectangle) { m.isCompact, m.detailsOpen, area.Dx(), + m.hyperCredits, ) } diff --git a/internal/ui/styles/quickstyle.go b/internal/ui/styles/quickstyle.go index b4fc0f7bec1b595adbc3cd30e1502e2ada8d18c7..7e01299788620df6c7bc9e25f913e8968c8fd110 100644 --- a/internal/ui/styles/quickstyle.go +++ b/internal/ui/styles/quickstyle.go @@ -577,6 +577,7 @@ func quickStyle(o quickStyleOpts) Styles { s.Header.Charm = base.Foreground(o.secondary) s.Header.Diagonals = base.Foreground(o.primary) s.Header.Percentage = muted + s.Header.Hypercredit = base.Foreground(charmtone.Dolly) s.Header.Keystroke = muted s.Header.KeystrokeTip = subtle s.Header.WorkingDir = muted diff --git a/internal/ui/styles/styles.go b/internal/ui/styles/styles.go index 1319b20bf3418ae4e021704b5ab11ffaa7c2deb2..b8841e5c2881d25006840eb61d339bd104024901 100644 --- a/internal/ui/styles/styles.go +++ b/internal/ui/styles/styles.go @@ -64,6 +64,7 @@ type Styles struct { Charm lipgloss.Style // Style for "Charm™" label Diagonals lipgloss.Style // Style for diagonal separators (╱) Percentage lipgloss.Style // Style for context percentage + Hypercredit lipgloss.Style // Style for Hypercredit count (◆ N) Keystroke lipgloss.Style // Style for keystroke hints (e.g., "ctrl+d") KeystrokeTip lipgloss.Style // Style for keystroke action text (e.g., "open", "close") WorkingDir lipgloss.Style // Style for current working directory