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
109 changes: 24 additions & 85 deletions Sources/PingClaude/ClaudeInfoView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,87 +85,34 @@ struct ClaudeInfoView: View {
// Usage Pace
GroupBox(label: Text("Usage Pace").font(.headline)) {
VStack(alignment: .leading, spacing: 8) {
Group {
// Detected model indicator
HStack {
Text("Active model:")
.font(.system(size: 12, weight: .medium))
.frame(width: 90, alignment: .leading)
Text(velocityTracker.detectedModelDisplay)
.font(.system(size: 12, weight: .semibold, design: .monospaced))
.foregroundColor(.accentColor)
Spacer()
}

HStack {
Text("This session:")
.font(.system(size: 12, weight: .medium))
.frame(width: 90, alignment: .leading)
Text(velocityTracker.sessionVelocityString)
.font(.system(size: 12, design: .monospaced))
Spacer()
Text(velocityTracker.timeRemainingString)
.font(.system(size: 12, weight: .semibold))
.foregroundColor(timeRemainingColor)
}
}

Group {
HStack {
Text("Past week:")
.font(.system(size: 12, weight: .medium))
.frame(width: 90, alignment: .leading)
Text(velocityTracker.weeklyVelocityString)
.font(.system(size: 12, design: .monospaced))
Spacer()
}

HStack {
Text("All time:")
.font(.system(size: 12, weight: .medium))
.frame(width: 90, alignment: .leading)
Text(velocityTracker.allTimeVelocityString)
.font(.system(size: 12, design: .monospaced))
Spacer()
}
HStack {
Text("This session:")
.font(.system(size: 12, weight: .medium))
.frame(width: 90, alignment: .leading)
Text(velocityTracker.sessionVelocityString)
.font(.system(size: 12, design: .monospaced))
Spacer()
Text(velocityTracker.timeRemainingString)
.font(.system(size: 12, weight: .semibold))
.foregroundColor(timeRemainingColor)
}

// Per-model time remaining table
if !velocityTracker.modelTimeEstimates.isEmpty &&
velocityTracker.modelTimeEstimates.contains(where: { $0.timeRemaining != nil }) {
Divider()
Text("Estimated time by model:")
.font(.system(size: 11, weight: .medium))
.foregroundColor(.secondary)

ForEach(velocityTracker.modelTimeEstimates) { estimate in
HStack {
Text(estimate.model.capitalized)
.font(.system(size: 12, weight: estimate.isCurrent ? .semibold : .regular))
.frame(width: 60, alignment: .leading)
Text(estimate.displayString)
.font(.system(size: 12, design: .monospaced))
.foregroundColor(modelTimeColor(estimate))
if estimate.isCurrent {
Text("(current)")
.font(.system(size: 10))
.foregroundColor(.secondary)
}
Spacer()
}
}
HStack {
Text("Past week:")
.font(.system(size: 12, weight: .medium))
.frame(width: 90, alignment: .leading)
Text(velocityTracker.weeklyVelocityString)
.font(.system(size: 12, design: .monospaced))
Spacer()
}

// Budget advisor tip
if let advice = velocityTracker.budgetAdvisorMessage {
HStack(spacing: 4) {
Text("\u{1F4A1}")
.font(.system(size: 11))
Text(advice)
.font(.system(size: 11, weight: .medium))
.foregroundColor(.orange)
}
.padding(.vertical, 2)
HStack {
Text("All time:")
.font(.system(size: 12, weight: .medium))
.frame(width: 90, alignment: .leading)
Text(velocityTracker.allTimeVelocityString)
.font(.system(size: 12, design: .monospaced))
Spacer()
}

Text("Based on \(velocityTracker.sessionSampleCount) samples since last reset")
Expand Down Expand Up @@ -299,14 +246,6 @@ struct ClaudeInfoView: View {
return .green
}

private func modelTimeColor(_ estimate: ModelTimeEstimate) -> Color {
guard let remaining = estimate.timeRemaining else { return .secondary }
let hours = remaining / 3600
if hours < 1 { return .red }
if hours < 2 { return .orange }
return .green
}

private func resetDetail(_ usage: UsageData) -> String {
var parts: [String] = []
if let remaining = usage.sessionResetsInString {
Expand Down
24 changes: 0 additions & 24 deletions Sources/PingClaude/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,30 +76,6 @@ enum Constants {
// API ping timeout (longer than CLI since it involves create + send + delete)
static let apiPingTimeoutSeconds: TimeInterval = 45

// Model pricing ratios (relative cost: Opus is 15x Haiku, Sonnet is 3x Haiku)
enum ModelPricing {
static let ratios: [String: Double] = ["opus": 15.0, "sonnet": 3.0, "haiku": 1.0]
static let modelsInCostOrder = ["haiku", "sonnet", "opus"] // cheapest first
static let advisorThresholdHours: Double = 2.0

/// Estimate velocity on `toModel` given observed velocity on `fromModel`
static func estimateVelocity(observed: Double, fromModel: String, toModel: String) -> Double {
let fromRatio = ratios[fromModel] ?? 1.0
let toRatio = ratios[toModel] ?? 1.0
return observed * (toRatio / fromRatio)
}

/// Short display label for a model: "O", "S", "H"
static func shortLabel(_ model: String) -> String {
switch model {
case "opus": return "O"
case "sonnet": return "S"
case "haiku": return "H"
default: return model.prefix(1).uppercased()
}
}
}

// Interval options (in minutes)
static let intervalOptions: [(label: String, minutes: Int)] = [
("15 minutes", 15),
Expand Down
32 changes: 3 additions & 29 deletions Sources/PingClaude/StatusBarController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class StatusBarController {
private var breakdownMenuItems: [NSMenuItem] = []
private var usageErrorMenuItem: NSMenuItem!
private var velocityMenuItem: NSMenuItem!
private var budgetAdvisorMenuItem: NSMenuItem!
private var scheduleToggleMenuItem: NSMenuItem!

private let timeFormatter: DateFormatter = {
Expand Down Expand Up @@ -96,11 +95,6 @@ class StatusBarController {
velocityMenuItem.isEnabled = false
menu.addItem(velocityMenuItem)

budgetAdvisorMenuItem = NSMenuItem(title: "", action: nil, keyEquivalent: "")
budgetAdvisorMenuItem.isEnabled = false
budgetAdvisorMenuItem.isHidden = true
menu.addItem(budgetAdvisorMenuItem)

weeklyUsageMenuItem = NSMenuItem(title: "Weekly: --", action: nil, keyEquivalent: "")
weeklyUsageMenuItem.isEnabled = false
menu.addItem(weeklyUsageMenuItem)
Expand Down Expand Up @@ -263,20 +257,6 @@ class StatusBarController {
}
.store(in: &cancellables)

// Watch budget advisor
velocityTracker.$budgetAdvisorMessage
.receive(on: RunLoop.main)
.sink { [weak self] message in
guard let self = self else { return }
if let message = message {
self.budgetAdvisorMenuItem.title = "\u{1F4A1} \(message)"
self.budgetAdvisorMenuItem.isHidden = false
} else {
self.budgetAdvisorMenuItem.isHidden = true
}
}
.store(in: &cancellables)

// Watch plan tier
usageService.$planTier
.receive(on: RunLoop.main)
Expand Down Expand Up @@ -320,15 +300,10 @@ class StatusBarController {
break // fall through to usage-based display
}

// If we have live usage data, show "CC·44%·O" (with model indicator)
// If we have live usage data, show "CC·44%"
if let usage = usageService.latestUsage {
let pct = Int(usage.sessionUtilization)
if let model = velocityTracker.detectedModel {
let modelChar = Constants.ModelPricing.shortLabel(model)
button.title = "CC\u{00B7}\(pct)%\u{00B7}\(modelChar)"
} else {
button.title = "CC\u{00B7}\(pct)%"
}
button.title = "CC\u{00B7}\(pct)%"
return
}

Expand Down Expand Up @@ -392,13 +367,12 @@ class StatusBarController {
private func updateVelocityDisplay() {
let timeStr = velocityTracker.timeRemainingString
let rateStr = velocityTracker.sessionVelocityString
let modelTag = velocityTracker.detectedModel.map { " [\($0.capitalized)]" } ?? ""
if velocityTracker.sessionVelocity == nil {
velocityMenuItem.title = "Pace: \(rateStr)"
} else if let vel = velocityTracker.sessionVelocity, vel <= 0 {
velocityMenuItem.title = "Pace: \(rateStr)"
} else {
velocityMenuItem.title = "\u{23F1} \(timeStr) (\(rateStr))\(modelTag)"
velocityMenuItem.title = "\u{23F1} \(timeStr) (\(rateStr))"
}
}

Expand Down
Loading
Loading