fix: taking plan type from usage endpoint instead of thru auth token (#7610)

pull plan type from the usage endpoint, persist it in session state /
tui state, and propagate through rate limit snapshots
This commit is contained in:
zhao-oai
2025-12-04 23:34:13 -08:00
committed by GitHub
parent b1c918d8f7
commit b8eab7ce90
17 changed files with 224 additions and 35 deletions

View File

@@ -58,6 +58,7 @@ use codex_core::protocol::WebSearchBeginEvent;
use codex_core::protocol::WebSearchEndEvent;
use codex_core::skills::model::SkillMetadata;
use codex_protocol::ConversationId;
use codex_protocol::account::PlanType;
use codex_protocol::approvals::ElicitationRequestEvent;
use codex_protocol::parse_command::ParsedCommand;
use codex_protocol::user_input::UserInput;
@@ -282,6 +283,7 @@ pub(crate) struct ChatWidget {
initial_user_message: Option<UserMessage>,
token_info: Option<TokenUsageInfo>,
rate_limit_snapshot: Option<RateLimitSnapshotDisplay>,
plan_type: Option<PlanType>,
rate_limit_warnings: RateLimitWarningState,
rate_limit_switch_prompt: RateLimitSwitchPromptState,
rate_limit_poller: Option<JoinHandle<()>>,
@@ -580,6 +582,8 @@ impl ChatWidget {
});
}
self.plan_type = snapshot.plan_type.or(self.plan_type);
let warnings = self.rate_limit_warnings.take_warnings(
snapshot
.secondary
@@ -1275,6 +1279,7 @@ impl ChatWidget {
),
token_info: None,
rate_limit_snapshot: None,
plan_type: None,
rate_limit_warnings: RateLimitWarningState::default(),
rate_limit_switch_prompt: RateLimitSwitchPromptState::default(),
rate_limit_poller: None,
@@ -1357,6 +1362,7 @@ impl ChatWidget {
),
token_info: None,
rate_limit_snapshot: None,
plan_type: None,
rate_limit_warnings: RateLimitWarningState::default(),
rate_limit_switch_prompt: RateLimitSwitchPromptState::default(),
rate_limit_poller: None,
@@ -2001,6 +2007,7 @@ impl ChatWidget {
context_usage,
&self.conversation_id,
self.rate_limit_snapshot.as_ref(),
self.plan_type,
Local::now(),
));
}