storing credits (#6858)

Expand the rate-limit cache/TUI: store credit snapshots alongside
primary and secondary windows, render “Credits” when the backend reports
they exist (unlimited vs rounded integer balances)
This commit is contained in:
zhao-oai
2025-11-19 10:49:35 -08:00
committed by GitHub
parent b3d320433f
commit 72af589398
15 changed files with 548 additions and 41 deletions

View File

@@ -790,6 +790,7 @@ pub struct TokenCountEvent {
pub struct RateLimitSnapshot {
pub primary: Option<RateLimitWindow>,
pub secondary: Option<RateLimitWindow>,
pub credits: Option<CreditsSnapshot>,
}
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)]
@@ -804,6 +805,13 @@ pub struct RateLimitWindow {
pub resets_at: Option<i64>,
}
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)]
pub struct CreditsSnapshot {
pub has_credits: bool,
pub unlimited: bool,
pub balance: Option<String>,
}
// Includes prompts, tools and space to call compact.
const BASELINE_TOKENS: i64 = 12000;