Skip to content

fix(plugins/claude): add fallback primary candidates for tray percentage#548

Merged
robinebers merged 3 commits into
robinebers:mainfrom
krismolendyke:fix-tray-percentage
Jun 4, 2026
Merged

fix(plugins/claude): add fallback primary candidates for tray percentage#548
robinebers merged 3 commits into
robinebers:mainfrom
krismolendyke:fix-tray-percentage

Conversation

@krismolendyke
Copy link
Copy Markdown
Contributor

@krismolendyke krismolendyke commented Jun 3, 2026

Description

Fixes an issue where the menu bar tray and tooltip display --% for Claude accounts that lack rolling session limits (e.g., Claude Enterprise or Team accounts).

The tray progress bar calculator ( getTrayPrimaryBars ) selects a metric by matching runtime data against configured primaryCandidates (metrics with a primaryOrder defined in the plugin's manifest). Previously, only the "Session" limit was configured with a primaryOrder for Claude. If the reverse-engineered API response does not include rolling session limits, no candidate matched, resulting in an undefined percentage formatted as --% .

  1. Added fallback primaryOrder definitions to Claude's other usage metrics:
    • "Weekly" limit: primaryOrder: 2
    • "Extra usage spent" limit: primaryOrder: 3
  2. Updated the bundled assets via bun run bundle:plugins .
  3. Added a regression/unit test verifying the fallback ordering.

Type of Change

  • Bug fix
  • New feature
  • New provider plugin
  • Documentation
  • Performance improvement
  • Other (describe below)

Testing

  • I ran bun run build and it succeeded
  • I ran bun run test and all tests pass
  • I tested the change locally with bun tauri dev

Screenshots

Before:

image

After:

image

Checklist

  • I read CONTRIBUTING.md
  • My PR targets the main branch
  • I did not introduce new dependencies without justification

Summary by cubic

Fixes the tray and tooltip percentage for Claude accounts without rolling session limits by falling back to Weekly or Extra usage spent instead of showing --%. Also moves Extra usage spent to the overview scope so it can be used as a primary metric.

  • Bug Fixes
    • Set primaryOrder for "Weekly" (2) and "Extra usage spent" (3) in plugins/claude/plugin.json.
    • Changed "Extra usage spent" scope to overview to make it eligible for the tray.
    • Refactored and expanded tests to cover fallback ordering (Session → Weekly → Extra usage spent).

Written for commit 455f721. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • Chores
    • Reordered progress metrics and adjusted display ordering for overview items.
    • Promoted an "extra usage" metric to the overview and refined how weekly/extra metrics are prioritized.
  • Tests
    • Added test coverage for progress-bar metric fallback logic to ensure correct metric selection and displayed fractions.

@krismolendyke krismolendyke requested a review from robinebers as a code owner June 3, 2026 18:01
Copilot AI review requested due to automatic review settings June 3, 2026 18:01
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 3, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 75119c72-5375-445b-b96a-35dd1aa9e62d

📥 Commits

Reviewing files that changed from the base of the PR and between 83911d8 and 455f721.

📒 Files selected for processing (2)
  • plugins/claude/plugin.json
  • src/lib/tray-primary-progress.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • plugins/claude/plugin.json
  • src/lib/tray-primary-progress.test.ts

📝 Walkthrough

Walkthrough

This PR adds primaryOrder metadata to Claude progress metrics (Weekly=2, Extra usage spent=3, Extra usage moved to overview) and introduces a test that checks getTrayPrimaryBars selects metrics in the expected precedence: Extra usage spent -> Weekly -> Session.

Changes

Claude progress metric fallback ordering

Layer / File(s) Summary
Progress metric primaryOrder configuration
plugins/claude/plugin.json
Adds primaryOrder values and moves "Extra usage spent" to overview, establishing an ordered candidate list for tray display.
Fallback candidate selection test
src/lib/tray-primary-progress.test.ts
Adds a Vitest test that validates getTrayPrimaryBars computes the tray fraction from: (1) "Extra usage spent" when it's the only candidate, (2) "Weekly" when present and "Session" absent, and (3) "Session" when present alongside others.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding fallback primary candidates for Claude's tray percentage display to fix the '--% issue when session limits are unavailable.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds explicit primary ordering for Claude progress lines and extends tests to verify fallback selection of the tray’s primary progress bar when preferred labels aren’t present.

Changes:

  • Added a new unit test covering fallback selection for Claude from Weekly to Extra usage spent.
  • Updated Claude plugin metadata to include primaryOrder for Weekly and Extra usage spent.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

File Description
src/lib/tray-primary-progress.test.ts Adds a regression test for Claude primary-bar fallback behavior.
plugins/claude/plugin.json Assigns primaryOrder values to better control which Claude line becomes the primary tray bar.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread plugins/claude/plugin.json Outdated
Comment thread src/lib/tray-primary-progress.test.ts
Comment thread src/lib/tray-primary-progress.test.ts Outdated
Comment thread src/lib/tray-primary-progress.test.ts Outdated
Comment thread src/lib/tray-primary-progress.test.ts Outdated
Comment thread src/lib/tray-primary-progress.test.ts Outdated
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 2 files

Re-trigger cubic

Copy link
Copy Markdown
Owner

@robinebers robinebers left a comment

Choose a reason for hiding this comment

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

Awesome. This LGTM and is surgical.

@robinebers robinebers merged commit 14cd195 into robinebers:main Jun 4, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants