Skip to content

feat: local Claude 5H/7D usage when disconnected + branded DMG installer#18

Merged
Balanced02 merged 1 commit into
mainfrom
feat/local-usage-windows
Jul 14, 2026
Merged

feat: local Claude 5H/7D usage when disconnected + branded DMG installer#18
Balanced02 merged 1 commit into
mainfrom
feat/local-usage-windows

Conversation

@Balanced02

@Balanced02 Balanced02 commented Jul 14, 2026

Copy link
Copy Markdown
Owner

What

Two things for v0.1.6:

Local Claude usage without connecting

The Claude tab now shows your last 5H / 7D token counts and equivalent cost, derived entirely from local ~/.claude logs (ccusage-style), so the tab is useful before you ever click Connect. Connecting still adds the live limit % from Claude's usage endpoint.

  • CostSummary gains last5hTokens/USD, last7dTokens/USD (accumulated in ClaudeCostReader, cache signature bumped to v5)
  • ProviderDetailView shows LocalUsageRows in the disconnected state when there's local activity

Branded DMG installer

The release .dmg now opens to a branded window — app icon, purple drag-to-Applications arrow, name + tagline — rendered at retina resolution.

  • New dmgbggen tool renders a multi-representation TIFF (540×380 @1x + 1080×760 @2x in one file); create-dmg has no @2x support but Finder resolves the right rep per display
  • release.yml renders the background and passes it to create-dmg, with the plain-symlink fallback intact

Test

  • swift test green (added 5H/7D assertions to the cost-reader test)
  • Verified the built app's disconnected Claude tab shows the local rows
  • Built a test DMG locally and confirmed the branded window + retina crispness

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Claude details now show local token activity and estimated cost for the last 5 hours and 7 days, even before connecting.
    • Added a branded macOS installer window with app artwork, installation guidance, and retina-quality rendering.
  • Documentation

    • Updated usage and installation guidance to explain local Claude activity and account information availability.
  • Bug Fixes

    • Improved installer packaging resilience when generating the branded background fails.

Show last 5H/7D token counts and equivalent cost on the Claude tab from local
~/.claude logs (ccusage-style), so the tab is useful before you Connect. Connecting
still adds the live limit %. The release .dmg now opens to a branded, retina
drag-to-Applications window (rendered by a new dmgbggen tool as a multi-rep TIFF).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The PR adds local Claude 5H/7D token and cost metrics, displays them when live usage is unavailable, and documents the behavior. It also adds a Swift-based branded DMG background generator and integrates it into the macOS release workflow.

Changes

Claude local usage

Layer / File(s) Summary
Rolling usage contract and aggregation
Sources/AIUsageBarCore/Models.swift, Sources/AIUsageBarCore/Claude/ClaudeCostReader.swift, Tests/AIUsageBarCoreTests/CoreTests.swift
CostSummary and Claude log aggregation now provide and test local 5H/7D token and USD metrics.
Local usage display and documentation
Sources/AIUsageBarUI/ProviderDetailView.swift, README.md, CHANGELOG.md
The Claude detail view shows local activity without live windows, with matching README and release-note updates.

Branded DMG packaging

Layer / File(s) Summary
DMG background generator
Package.swift, Sources/dmgbggen/main.swift
Adds the dmgbggen executable, which renders 1x/2x branded TIFF backgrounds and a PNG preview.
Release workflow integration
.github/workflows/release.yml
Generates the DMG background with a fallback command and passes it to create-dmg, while tolerating generation failures.

Repository housekeeping

Layer / File(s) Summary
Local state ignore rule
.gitignore
Adds .superpowers/ to the ignored local state directories.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ClaudeLogs
  participant ClaudeCostReader
  participant CostSummary
  participant ProviderDetailView
  ClaudeLogs->>ClaudeCostReader: read local session entries
  ClaudeCostReader->>ClaudeCostReader: aggregate 5H and 7D totals
  ClaudeCostReader->>CostSummary: populate rolling usage fields
  CostSummary->>ProviderDetailView: provide local tokens and USD
  ProviderDetailView-->>ProviderDetailView: render LocalUsageRows
Loading
sequenceDiagram
  participant ReleaseWorkflow
  participant dmgbggen
  participant create_dmg
  ReleaseWorkflow->>dmgbggen: generate dmg-background.tiff
  dmgbggen-->>ReleaseWorkflow: write retina TIFF
  ReleaseWorkflow->>create_dmg: package app with background TIFF
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the two main changes: disconnected Claude 5H/7D usage and a branded DMG installer.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/local-usage-windows

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Balanced02
Balanced02 merged commit 9fc7bce into main Jul 14, 2026
1 of 2 checks passed
@Balanced02
Balanced02 deleted the feat/local-usage-windows branch July 14, 2026 23:34

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Sources/AIUsageBarUI/ProviderDetailView.swift`:
- Around line 234-263: Update LocalUsageRows.usageRow so the USD value uses the
provided accent color for its foreground style instead of
Theme.modelColor("Opus"), ensuring local-usage totals match the caller-supplied
account accent.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 896b273b-a6ae-4f68-8318-e9a2b8e14970

📥 Commits

Reviewing files that changed from the base of the PR and between 3b29852 and 88215b8.

📒 Files selected for processing (10)
  • .github/workflows/release.yml
  • .gitignore
  • CHANGELOG.md
  • Package.swift
  • README.md
  • Sources/AIUsageBarCore/Claude/ClaudeCostReader.swift
  • Sources/AIUsageBarCore/Models.swift
  • Sources/AIUsageBarUI/ProviderDetailView.swift
  • Sources/dmgbggen/main.swift
  • Tests/AIUsageBarCoreTests/CoreTests.swift

Comment on lines +234 to +263
/// ccusage-style local usage windows (5H / 7D) derived from the logs — token
/// volume + equivalent cost, no live quota %. Shown when a Claude account isn't
/// connected, so it stays useful without any Keychain access.
struct LocalUsageRows: View {
let cost: CostSummary
let accent: Color

var body: some View {
VStack(alignment: .leading, spacing: 8) {
usageRow("5H", tokens: cost.last5hTokens, usd: cost.last5hUSD)
usageRow("7D", tokens: cost.last7dTokens, usd: cost.last7dUSD)
Text("Local activity from your logs — Connect for the live limit %.")
.font(.caption2).foregroundStyle(.tertiary)
}
}

private func usageRow(_ label: String, tokens: Int, usd: Double) -> some View {
HStack(spacing: 10) {
Text(label).font(.system(size: 12, weight: .semibold))
.frame(width: 32, alignment: .leading)
Text("\(Theme.compactTokens(tokens) ?? "0") tok")
.font(.system(size: 12).monospacedDigit()).foregroundStyle(.secondary)
Spacer(minLength: 6)
Text(Theme.usd(usd))
.font(.system(size: 12, weight: .medium).monospacedDigit())
.foregroundStyle(Theme.modelColor("Opus"))
}
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Use the provided accent color instead of hardcoding "Opus".

The LocalUsageRows struct receives the account's accent color from the caller, but the property goes unused because the USD value's foreground style is hardcoded to Theme.modelColor("Opus"). This forces the local-usage totals to render in purple instead of matching the account's accent color.

🎨 Proposed fix
-                .foregroundStyle(Theme.modelColor("Opus"))
+                .foregroundStyle(accent)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
/// ccusage-style local usage windows (5H / 7D) derived from the logs — token
/// volume + equivalent cost, no live quota %. Shown when a Claude account isn't
/// connected, so it stays useful without any Keychain access.
struct LocalUsageRows: View {
let cost: CostSummary
let accent: Color
var body: some View {
VStack(alignment: .leading, spacing: 8) {
usageRow("5H", tokens: cost.last5hTokens, usd: cost.last5hUSD)
usageRow("7D", tokens: cost.last7dTokens, usd: cost.last7dUSD)
Text("Local activity from your logs — Connect for the live limit %.")
.font(.caption2).foregroundStyle(.tertiary)
}
}
private func usageRow(_ label: String, tokens: Int, usd: Double) -> some View {
HStack(spacing: 10) {
Text(label).font(.system(size: 12, weight: .semibold))
.frame(width: 32, alignment: .leading)
Text("\(Theme.compactTokens(tokens) ?? "0") tok")
.font(.system(size: 12).monospacedDigit()).foregroundStyle(.secondary)
Spacer(minLength: 6)
Text(Theme.usd(usd))
.font(.system(size: 12, weight: .medium).monospacedDigit())
.foregroundStyle(Theme.modelColor("Opus"))
}
}
}
/// ccusage-style local usage windows (5H / 7D) derived from the logs — token
/// volume + equivalent cost, no live quota %. Shown when a Claude account isn't
/// connected, so it stays useful without any Keychain access.
struct LocalUsageRows: View {
let cost: CostSummary
let accent: Color
var body: some View {
VStack(alignment: .leading, spacing: 8) {
usageRow("5H", tokens: cost.last5hTokens, usd: cost.last5hUSD)
usageRow("7D", tokens: cost.last7dTokens, usd: cost.last7dUSD)
Text("Local activity from your logs — Connect for the live limit %.")
.font(.caption2).foregroundStyle(.tertiary)
}
}
private func usageRow(_ label: String, tokens: Int, usd: Double) -> some View {
HStack(spacing: 10) {
Text(label).font(.system(size: 12, weight: .semibold))
.frame(width: 32, alignment: .leading)
Text("\(Theme.compactTokens(tokens) ?? "0") tok")
.font(.system(size: 12).monospacedDigit()).foregroundStyle(.secondary)
Spacer(minLength: 6)
Text(Theme.usd(usd))
.font(.system(size: 12, weight: .medium).monospacedDigit())
.foregroundStyle(accent)
}
}
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Sources/AIUsageBarUI/ProviderDetailView.swift` around lines 234 - 263, Update
LocalUsageRows.usageRow so the USD value uses the provided accent color for its
foreground style instead of Theme.modelColor("Opus"), ensuring local-usage
totals match the caller-supplied account accent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant