on main help sign in
feat(ui): add hypercredit readout to small top header
ce314b8Christian Rocha
internal/ui/common/elements.go+3−3
@@ -81,7 +81,7 @@ func ModelInfo(t *styles.Styles, modelName, providerName, reasoningInfo string,
81 if providerName == hyper.DisplayName && hyperCredits != nil {
81 if providerName == hyper.DisplayName && hyperCredits != nil {
82 hcInfo := t.ModelInfo.HypercreditIcon.Render(styles.HypercreditIcon)
82 hcInfo := t.ModelInfo.HypercreditIcon.Render(styles.HypercreditIcon)
83 hcInfo += " "
83 hcInfo += " "
84− hcInfo += t.ModelInfo.HypercreditText.Render(fmt.Sprintf("%s Hypercredits", formatCredits(*hyperCredits)))
84+ hcInfo += t.ModelInfo.HypercreditText.Render(fmt.Sprintf("%s Hypercredits", FormatCredits(*hyperCredits)))
85 parts = append(parts, "", hcInfo)
85 parts = append(parts, "", hcInfo)
86 }
86 }
87
87
@@ -124,8 +124,8 @@ func formatTokensAndCost(t *styles.Styles, tokens, contextWindow int64, cost flo
124 return fmt.Sprintf("%s %s", formattedTokens, formattedCost)
124 return fmt.Sprintf("%s %s", formattedTokens, formattedCost)
125}
125}
126
126
127−// formatCredits formats an integer with comma separators for thousands.
127+// FormatCredits formats an integer with comma separators for thousands.
128−func formatCredits(n int) string {
128+func FormatCredits(n int) string {
129 s := strconv.FormatInt(int64(n), 10)
129 s := strconv.FormatInt(int64(n), 10)
130 if n < 1000 {
130 if n < 1000 {
131 return s
131 return s
internal/ui/model/header.go+8
@@ -69,6 +69,7 @@ func (h *header) drawHeader(
69 compact bool,
69 compact bool,
70 detailsOpen bool,
70 detailsOpen bool,
71 width int,
71 width int,
72+ hyperCredits *int,
72) {
73) {
73 t := h.com.Styles
74 t := h.com.Styles
74 if width != h.width || compact != h.compact {
75 if width != h.width || compact != h.compact {
@@ -101,6 +102,7 @@ func (h *header) drawHeader(
101 lspErrorCount,
102 lspErrorCount,
102 detailsOpen,
103 detailsOpen,
103 availDetailWidth,
104 availDetailWidth,
105+ hyperCredits,
104 )
106 )
105
107
106 remainingWidth := width -
108 remainingWidth := width -
@@ -131,6 +133,7 @@ func renderHeaderDetails(
131 lspErrorCount int,
133 lspErrorCount int,
132 detailsOpen bool,
134 detailsOpen bool,
133 availWidth int,
135 availWidth int,
136+ hyperCredits *int,
134) string {
137) string {
135 t := com.Styles
138 t := com.Styles
136
139
@@ -148,6 +151,11 @@ func renderHeaderDetails(
148 parts = append(parts, formattedPercentage)
151 parts = append(parts, formattedPercentage)
149 }
152 }
150
153
154+ if com.IsHyper() && hyperCredits != nil {
155+ hc := t.Header.Hypercredit.Render(styles.HypercreditIcon) + " " + t.Header.Percentage.Render(common.FormatCredits(*hyperCredits))
156+ parts = append(parts, hc)
157+ }
158+
151 const keystroke = "ctrl+d"
159 const keystroke = "ctrl+d"
152 if detailsOpen {
160 if detailsOpen {
153 parts = append(parts, t.Header.Keystroke.Render(keystroke)+t.Header.KeystrokeTip.Render(" close"))
161 parts = append(parts, t.Header.Keystroke.Render(keystroke)+t.Header.KeystrokeTip.Render(" close"))
internal/ui/model/ui.go+1
@@ -2109,6 +2109,7 @@ func (m *UI) drawHeader(scr uv.Screen, area uv.Rectangle) {
2109 m.isCompact,
2109 m.isCompact,
2110 m.detailsOpen,
2110 m.detailsOpen,
2111 area.Dx(),
2111 area.Dx(),
2112+ m.hyperCredits,
2112 )
2113 )
2113}
2114}
2114
2115
internal/ui/styles/quickstyle.go+1
@@ -577,6 +577,7 @@ func quickStyle(o quickStyleOpts) Styles {
577 s.Header.Charm = base.Foreground(o.secondary)
577 s.Header.Charm = base.Foreground(o.secondary)
578 s.Header.Diagonals = base.Foreground(o.primary)
578 s.Header.Diagonals = base.Foreground(o.primary)
579 s.Header.Percentage = muted
579 s.Header.Percentage = muted
580+ s.Header.Hypercredit = base.Foreground(charmtone.Dolly)
580 s.Header.Keystroke = muted
581 s.Header.Keystroke = muted
581 s.Header.KeystrokeTip = subtle
582 s.Header.KeystrokeTip = subtle
582 s.Header.WorkingDir = muted
583 s.Header.WorkingDir = muted
internal/ui/styles/styles.go+1
@@ -64,6 +64,7 @@ type Styles struct {
64 Charm lipgloss.Style // Style for "Charm™" label
64 Charm lipgloss.Style // Style for "Charm™" label
65 Diagonals lipgloss.Style // Style for diagonal separators (╱)
65 Diagonals lipgloss.Style // Style for diagonal separators (╱)
66 Percentage lipgloss.Style // Style for context percentage
66 Percentage lipgloss.Style // Style for context percentage
67+ Hypercredit lipgloss.Style // Style for Hypercredit count (◆ N)
67 Keystroke lipgloss.Style // Style for keystroke hints (e.g., "ctrl+d")
68 Keystroke lipgloss.Style // Style for keystroke hints (e.g., "ctrl+d")
68 KeystrokeTip lipgloss.Style // Style for keystroke action text (e.g., "open", "close")
69 KeystrokeTip lipgloss.Style // Style for keystroke action text (e.g., "open", "close")
69 WorkingDir lipgloss.Style // Style for current working directory
70 WorkingDir lipgloss.Style // Style for current working directory