diff options
| author | Timo Clasen <[email protected]> | 2025-07-10 12:56:36 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-07-10 05:56:36 -0500 |
| commit | c411a26d6fbc4bd785ca001c529bc67c97a0a1bc (patch) | |
| tree | abc70ee5d02fc855824caea7ce2e501d70fd6425 | |
| parent | 85dbfeb3147cefa597938a315f0848a0d978640b (diff) | |
| download | opencode-c411a26d6fbc4bd785ca001c529bc67c97a0a1bc.tar.gz opencode-c411a26d6fbc4bd785ca001c529bc67c97a0a1bc.zip | |
feat(tui): hide cost if using subscription model (#828)
| -rw-r--r-- | packages/tui/internal/components/status/status.go | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/packages/tui/internal/components/status/status.go b/packages/tui/internal/components/status/status.go index 7d5820de3..a92cbf2f6 100644 --- a/packages/tui/internal/components/status/status.go +++ b/packages/tui/internal/components/status/status.go @@ -53,7 +53,7 @@ func (m statusComponent) logo() string { Render(open + code + version) } -func formatTokensAndCost(tokens float64, contextWindow float64, cost float64) string { +func formatTokensAndCost(tokens float64, contextWindow float64, cost float64, isSubscriptionModel bool) string { // Format tokens in human-readable format (e.g., 110K, 1.2M) var formattedTokens string switch { @@ -73,10 +73,17 @@ func formatTokensAndCost(tokens float64, contextWindow float64, cost float64) st formattedTokens = strings.Replace(formattedTokens, ".0M", "M", 1) } - // Format cost with $ symbol and 2 decimal places - formattedCost := fmt.Sprintf("$%.2f", cost) percentage := (float64(tokens) / float64(contextWindow)) * 100 + if isSubscriptionModel { + return fmt.Sprintf( + "Context: %s (%d%%)", + formattedTokens, + int(percentage), + ) + } + + formattedCost := fmt.Sprintf("$%.2f", cost) return fmt.Sprintf( "Context: %s (%d%%), Cost: %s", formattedTokens, @@ -119,11 +126,15 @@ func (m statusComponent) View() string { } } + // Check if current model is a subscription model (cost is 0 for both input and output) + isSubscriptionModel := m.app.Model != nil && + m.app.Model.Cost.Input == 0 && m.app.Model.Cost.Output == 0 + sessionInfo = styles.NewStyle(). Foreground(t.TextMuted()). Background(t.BackgroundElement()). Padding(0, 1). - Render(formatTokensAndCost(tokens, contextWindow, cost)) + Render(formatTokensAndCost(tokens, contextWindow, cost, isSubscriptionModel)) } // diagnostics := styles.Padded().Background(t.BackgroundElement()).Render(m.projectDiagnostics()) |
