persisting credits if new snapshot does not contain credit info (#7490)

in response to incoming changes to responses headers where the header
may sometimes not contain credits info (no longer forcing a credit
check)
This commit is contained in:
zhao-oai
2025-12-02 16:23:24 -05:00
committed by GitHub
parent f6a7da4ac3
commit 5ebdc9af1b
4 changed files with 149 additions and 2 deletions
+14 -1
View File
@@ -20,6 +20,7 @@ use codex_core::protocol::AgentReasoningRawContentDeltaEvent;
use codex_core::protocol::AgentReasoningRawContentEvent;
use codex_core::protocol::ApplyPatchApprovalRequestEvent;
use codex_core::protocol::BackgroundEventEvent;
use codex_core::protocol::CreditsSnapshot;
use codex_core::protocol::DeprecationNoticeEvent;
use codex_core::protocol::ErrorEvent;
use codex_core::protocol::Event;
@@ -558,7 +559,19 @@ impl ChatWidget {
}
pub(crate) fn on_rate_limit_snapshot(&mut self, snapshot: Option<RateLimitSnapshot>) {
if let Some(snapshot) = snapshot {
if let Some(mut snapshot) = snapshot {
if snapshot.credits.is_none() {
snapshot.credits = self
.rate_limit_snapshot
.as_ref()
.and_then(|display| display.credits.as_ref())
.map(|credits| CreditsSnapshot {
has_credits: credits.has_credits,
unlimited: credits.unlimited,
balance: credits.balance.clone(),
});
}
let warnings = self.rate_limit_warnings.take_warnings(
snapshot
.secondary