Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions commands/cc_statusline.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"io"
"os"
"runtime"
"strings"
"time"

Expand Down Expand Up @@ -164,8 +165,10 @@ func formatStatuslineOutput(modelName string, sessionCost, dailyCost float64, se
parts = append(parts, color.Gray.Sprint("📊 -"))
}

// Quota utilization
parts = append(parts, formatQuotaPart(fiveHourUtil, sevenDayUtil))
// Quota utilization (macOS only - requires Keychain for OAuth token)
if runtime.GOOS == "darwin" {
parts = append(parts, formatQuotaPart(fiveHourUtil, sevenDayUtil))
}

// AI agent time (magenta) - clickable link to user profile
if sessionSeconds > 0 {
Expand Down Expand Up @@ -224,8 +227,12 @@ func formatQuotaPart(fiveHourUtil, sevenDayUtil *float64) string {
}

func outputFallback() {
quotaPart := wrapOSC8Link(claudeUsageURL, "🚦 -")
fmt.Println(color.Gray.Sprint("🌿 - | 🤖 - | 💰 - | 📊 - | " + quotaPart + " | ⏱️ - | 📈 -%"))
if runtime.GOOS == "darwin" {
quotaPart := wrapOSC8Link(claudeUsageURL, "🚦 -")
fmt.Println(color.Gray.Sprint("🌿 - | 🤖 - | 💰 - | 📊 - | " + quotaPart + " | ⏱️ - | 📈 -%"))
} else {
fmt.Println(color.Gray.Sprint("🌿 - | 🤖 - | 💰 - | 📊 - | ⏱️ - | 📈 -%"))
}
Comment on lines +230 to +235
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To improve maintainability and reduce code duplication, you could refactor this function to build a slice of parts and then join them. This approach is already used in formatStatuslineOutput and would make it easier to add or remove parts of the status line in the future.

	parts := []string{"🌿 -", "🤖 -", "💰 -", "📊 -"}
	if runtime.GOOS == "darwin" {
		quotaPart := wrapOSC8Link(claudeUsageURL, "🚦 -")
		parts = append(parts, quotaPart)
	}
	parts = append(parts, "⏱️ -", "📈 -%")
	fmt.Println(color.Gray.Sprint(strings.Join(parts, " | ")))

}

// formatSessionDuration formats seconds into a human-readable duration
Expand Down
17 changes: 13 additions & 4 deletions commands/cc_statusline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"net"
"os"
"path/filepath"
"runtime"
"testing"
"time"

Expand Down Expand Up @@ -380,15 +381,23 @@ func (s *CCStatuslineTestSuite) TestFormatStatuslineOutput_WithQuota() {
sd := 23.0
output := formatStatuslineOutput("claude-opus-4", 1.23, 4.56, 3661, 75.0, "main", false, &fh, &sd, "", "", "")

assert.Contains(s.T(), output, "5h:45%")
assert.Contains(s.T(), output, "7d:23%")
assert.Contains(s.T(), output, "🚦")
if runtime.GOOS == "darwin" {
assert.Contains(s.T(), output, "5h:45%")
assert.Contains(s.T(), output, "7d:23%")
assert.Contains(s.T(), output, "🚦")
} else {
assert.NotContains(s.T(), output, "🚦")
}
}

func (s *CCStatuslineTestSuite) TestFormatStatuslineOutput_WithoutQuota() {
output := formatStatuslineOutput("claude-opus-4", 1.23, 4.56, 3661, 75.0, "main", false, nil, nil, "", "", "")

assert.Contains(s.T(), output, "🚦 -")
if runtime.GOOS == "darwin" {
assert.Contains(s.T(), output, "🚦 -")
} else {
assert.NotContains(s.T(), output, "🚦")
}
}

func (s *CCStatuslineTestSuite) TestGetDaemonInfo_PropagatesRateLimitFields() {
Expand Down