feat: add ClinePass usage limits support for Cline API key accounts#15
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds optional ClinePass usage-limit support to the existing Cline API key integration. When Cline exposes plan usage data, the tooltip for
Cline: API Keyaccounts now shows 5-hour, weekly, and monthly usage with reset timestamps. If no ClinePass data is available, the tooltip remains unchanged and only shows the normal balance rows.This keeps ClinePass handling tooltip-only and best-effort, so undocumented endpoint failures never break the existing Cline balance integration.
What changed
Provider (
ClineProviderClient) — added a best-effort fetch ofGET /api/v1/users/me/plan/usage-limitsafter the existing balance call. Recognized remotetypevalues (five_hour,weekly,monthly) are mapped to provider-specific metadata keys:clinePassFiveHourUsed,clinePassFiveHourResetsAtclinePassWeeklyUsed,clinePassWeeklyResetsAtclinePassMonthlyUsed,clinePassMonthlyResetsAtpercentUsedis clamped to0..100before storing, blankresetsAtvalues are omitted, unknown limit types are ignored, and any failure (non-2xx, malformed body,success:false, missingdata, parse errors) is silently swallowed and produces an empty metadata map.UI renderer (
ClinePassUsageRenderer) — newobjectthat converts ClinePass metadata into tooltip rows via the existingProgressBarRenderer.buildUsageSection. Returns an empty string when no recognized ClinePass usage is present, so the renderer is silent in the no-ClinePass case.Status bar widget (
TokenPulseStatusBarWidget) — adds aConnectionType.CLINE_APItooltip branch that always renders the existing Cline balance rows first and only appends the optional ClinePass block whenClinePassUsageRenderer.hasUsage(metadata)is true.Scope / non-goals
Validation
Targeted tests passed (
./gradlew test):ClinePassUsageRendererTestClineProviderClientTest(25 tests, including 7 new ClinePass cases)StatusBarFormatterTest(24 tests, unchanged)ProgressBarRendererTest(16 tests, unchanged)Provider-test scenarios covered:
ProviderResult.Successwith existing balance data and no ClinePass metadatasuccess:falseor emptylimitsproduces no metadatapercentUsedis clamped to0..100Renderer-test scenarios covered:
hasUsagereturnsfalsefor null/empty/unrecognized metadatabuildRowsreturns an empty string when no ClinePass usage is availableResets: ...lines are emitted only when a reset timestamp is presentusedvalues are silently skippedFiles
src/main/kotlin/org/zhavoronkov/tokenpulse/ui/ClinePassUsageRenderer.kt,src/test/kotlin/org/zhavoronkov/tokenpulse/ui/ClinePassUsageRendererTest.ktsrc/main/kotlin/org/zhavoronkov/tokenpulse/provider/cline/ClineProviderClient.kt,src/main/kotlin/org/zhavoronkov/tokenpulse/ui/TokenPulseStatusBarWidget.kt,src/test/kotlin/org/zhavoronkov/tokenpulse/provider/ClineProviderClientTest.kt