Skip to content

feat: add ClinePass usage limits support for Cline API key accounts#15

Merged
DimazzzZ merged 2 commits into
mainfrom
feat/clinepass-support
Jul 6, 2026
Merged

feat: add ClinePass usage limits support for Cline API key accounts#15
DimazzzZ merged 2 commits into
mainfrom
feat/clinepass-support

Conversation

@DimazzzZ

@DimazzzZ DimazzzZ commented Jul 6, 2026

Copy link
Copy Markdown
Owner

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 Key accounts 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 of GET /api/v1/users/me/plan/usage-limits after the existing balance call. Recognized remote type values (five_hour, weekly, monthly) are mapped to provider-specific metadata keys:

    • clinePassFiveHourUsed, clinePassFiveHourResetsAt
    • clinePassWeeklyUsed, clinePassWeeklyResetsAt
    • clinePassMonthlyUsed, clinePassMonthlyResetsAt

    percentUsed is clamped to 0..100 before storing, blank resetsAt values are omitted, unknown limit types are ignored, and any failure (non-2xx, malformed body, success:false, missing data, parse errors) is silently swallowed and produces an empty metadata map.

  • UI renderer (ClinePassUsageRenderer) — new object that converts ClinePass metadata into tooltip rows via the existing ProgressBarRenderer.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 a ConnectionType.CLINE_API tooltip branch that always renders the existing Cline balance rows first and only appends the optional ClinePass block when ClinePassUsageRenderer.hasUsage(metadata) is true.

Scope / non-goals

  • Cline remains a dollar-based provider for status bar formatting, account table formatting, balance history behavior, and supported balance format settings.
  • No config or dependency changes.
  • No scraping or session capture — only authenticated API calls with the existing Cline API key.

Validation

Targeted tests passed (./gradlew test):

  • ClinePassUsageRendererTest
  • ClineProviderClientTest (25 tests, including 7 new ClinePass cases)
  • StatusBarFormatterTest (24 tests, unchanged)
  • ProgressBarRendererTest (16 tests, unchanged)

Provider-test scenarios covered:

  • successful response populates all six metadata keys
  • endpoint failure (404/500) still returns ProviderResult.Success with existing balance data and no ClinePass metadata
  • success:false or empty limits produces no metadata
  • unknown limit types are ignored while recognized ones are preserved
  • percentUsed is clamped to 0..100

Renderer-test scenarios covered:

  • hasUsage returns false for null/empty/unrecognized metadata
  • buildRows returns an empty string when no ClinePass usage is available
  • a single ClinePass section header is emitted when at least one limit is available
  • 5-hour / Weekly / Monthly rows are emitted in the expected order
  • Resets: ... lines are emitted only when a reset timestamp is present
  • invalid numeric used values are silently skipped

Files

  • Added: src/main/kotlin/org/zhavoronkov/tokenpulse/ui/ClinePassUsageRenderer.kt, src/test/kotlin/org/zhavoronkov/tokenpulse/ui/ClinePassUsageRendererTest.kt
  • Modified: src/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

@DimazzzZ DimazzzZ merged commit 0064e89 into main Jul 6, 2026
2 checks passed
@DimazzzZ DimazzzZ deleted the feat/clinepass-support branch July 6, 2026 13:06
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.

2 participants