mirror of
https://github.com/AgentSeal/codeburn.git
synced 2026-12-03 03:29:51 +00:00
Add icon-only menubar display mode (#396)
Some checks are pending
CI / semgrep (push) Waiting to run
Some checks are pending
CI / semgrep (push) Waiting to run
Adds "Icon Only" option to the Metric picker in Settings. When selected, the menubar shows only the flame icon without any cost or token text. Flame tinting for quota/budget alerts still works.
This commit is contained in:
parent
820a5bd2b7
commit
ce043631ed
3 changed files with 28 additions and 23 deletions
|
|
@ -1058,7 +1058,7 @@ enum SubscriptionLoadState: Sendable, Equatable {
|
|||
}
|
||||
|
||||
enum DisplayMetric: String {
|
||||
case cost, tokens, totalTokens
|
||||
case cost, tokens, totalTokens, iconOnly
|
||||
}
|
||||
|
||||
enum InsightMode: String, CaseIterable, Identifiable {
|
||||
|
|
|
|||
|
|
@ -746,31 +746,35 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSPopoverDelegate {
|
|||
let menubarPayload = store.menubarPayload
|
||||
let hasPayload = menubarPayload != nil
|
||||
let compact = isCompact
|
||||
let suffix = menubarPeriod.menubarSuffix(compact: compact)
|
||||
let valueText: String
|
||||
if store.displayMetric == .tokens, let p = menubarPayload?.current {
|
||||
let out = formatTokensMenubar(Double(p.outputTokens))
|
||||
let inp = formatTokensMenubar(Double(p.inputTokens))
|
||||
valueText = compact ? "↑\(out)↓\(inp)\(suffix)" : " ↑\(out) ↓\(inp)\(suffix)"
|
||||
} else if store.displayMetric == .totalTokens, let p = menubarPayload?.current {
|
||||
let total = formatTokensMenubar(Double(p.inputTokens + p.outputTokens))
|
||||
valueText = compact ? "\(total)\(suffix)" : " \(total) tok\(suffix)"
|
||||
} else {
|
||||
let fallback = compact ? "$-" : "$—"
|
||||
let formatted = menubarPayload?.current.cost
|
||||
valueText = compact
|
||||
? (formatted?.asCompactCurrencyWhole() ?? fallback) + suffix
|
||||
: " " + (formatted?.asCompactCurrency() ?? fallback) + suffix
|
||||
}
|
||||
|
||||
var textAttrs: [NSAttributedString.Key: Any] = [.font: font, .baselineOffset: -1.0]
|
||||
if !hasPayload {
|
||||
textAttrs[.foregroundColor] = NSColor.secondaryLabelColor
|
||||
}
|
||||
|
||||
let composed = NSMutableAttributedString()
|
||||
composed.append(NSAttributedString(attachment: attachment))
|
||||
composed.append(NSAttributedString(string: valueText, attributes: textAttrs))
|
||||
|
||||
if store.displayMetric != .iconOnly {
|
||||
let suffix = menubarPeriod.menubarSuffix(compact: compact)
|
||||
let valueText: String
|
||||
if store.displayMetric == .tokens, let p = menubarPayload?.current {
|
||||
let out = formatTokensMenubar(Double(p.outputTokens))
|
||||
let inp = formatTokensMenubar(Double(p.inputTokens))
|
||||
valueText = compact ? "↑\(out)↓\(inp)\(suffix)" : " ↑\(out) ↓\(inp)\(suffix)"
|
||||
} else if store.displayMetric == .totalTokens, let p = menubarPayload?.current {
|
||||
let total = formatTokensMenubar(Double(p.inputTokens + p.outputTokens))
|
||||
valueText = compact ? "\(total)\(suffix)" : " \(total) tok\(suffix)"
|
||||
} else {
|
||||
let fallback = compact ? "$-" : "$—"
|
||||
let formatted = menubarPayload?.current.cost
|
||||
valueText = compact
|
||||
? (formatted?.asCompactCurrencyWhole() ?? fallback) + suffix
|
||||
: " " + (formatted?.asCompactCurrency() ?? fallback) + suffix
|
||||
}
|
||||
|
||||
var textAttrs: [NSAttributedString.Key: Any] = [.font: font, .baselineOffset: -1.0]
|
||||
if !hasPayload {
|
||||
textAttrs[.foregroundColor] = NSColor.secondaryLabelColor
|
||||
}
|
||||
composed.append(NSAttributedString(string: valueText, attributes: textAttrs))
|
||||
}
|
||||
|
||||
button.attributedTitle = composed
|
||||
button.toolTip = "CodeBurn \(menubarPeriod.menubarMetricLabel)"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ private struct GeneralSettingsTab: View {
|
|||
Text("Cost ($)").tag(DisplayMetric.cost)
|
||||
Text("Tokens (↑↓)").tag(DisplayMetric.tokens)
|
||||
Text("Total Tokens").tag(DisplayMetric.totalTokens)
|
||||
Text("Icon Only").tag(DisplayMetric.iconOnly)
|
||||
}
|
||||
Picker("Period", selection: Binding(
|
||||
get: { store.menubarPeriod },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue