Skip to content

Show OpenRouter credit balance in settings#23

Open
GSmithBoltz wants to merge 1 commit into
beradeep:masterfrom
GSmithBoltz:feature/credit-balance
Open

Show OpenRouter credit balance in settings#23
GSmithBoltz wants to merge 1 commit into
beradeep:masterfrom
GSmithBoltz:feature/credit-balance

Conversation

@GSmithBoltz

Copy link
Copy Markdown
Contributor

What

Adds the user's OpenRouter credit balance to Settings, in the API Configuration section under the API key field: remaining balance with used/total detail, plus a manual refresh button. Loaded on screen open and on refresh.

Implementation notes

  • New AccountRepository (domain) + AccountRepositoryImpl (data) fetching GET /api/v1/credits with the stored key via ktor, parsed with kotlinx.serialization; wired through Hilt.
  • New dependency: ktor-client-core in :data (version managed by the existing openai-client BOM, same as the already-present ktor-client-okhttp).
  • Graceful states: no API key set (hint text, no request), loading, and fetch failure (retry hint). Refresh is manual-only; typing in the key field does not trigger requests.
  • UI uses only basics components, matching the existing settings rows.
  • No migrations, no new permissions. The key never leaves the device except to OpenRouter itself.

Note: this branch shares the ktor-client-core catalog addition with #21 — if both are merged, whichever lands second will merge cleanly (identical change).

Testing

  • :app:compileDebugKotlin, testDebugUnitTest, and ktlint for :domain/:data/:app pass (:ui has pre-existing violations on master; this change adds none).
  • Manually tested on a physical device with a real key:

Settings screen showing Credits row with remaining balance and refresh button under the API key field

🤖 Generated with Claude Code

Adds an AccountRepository that fetches /api/v1/credits with the user's
key and displays remaining/used credits in the API Configuration
section of Settings, with a manual refresh button.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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