mirror of
https://github.com/openai/codex.git
synced 2026-05-02 02:17:22 +00:00
[codex] Propagate rate limit reached type (#18227)
## Summary First PR in the split from #17956. - adds the core/app-server `RateLimitReachedType` shape - maps backend `rate_limit_reached_type` into Codex rate-limit snapshots - carries the field through app-server notifications/responses and generated schemas - updates existing constructors/tests for the new optional field ## Validation - `cargo test -p codex-backend-client` - `cargo test -p codex-app-server-protocol` - `cargo test -p codex-app-server rate_limits` - `cargo test -p codex-tui workspace_` - `cargo test -p codex-tui status_` - `just fmt` - `just fix -p codex-backend-client` - `just fix -p codex-app-server-protocol` - `just fix -p codex-app-server` - `just fix -p codex-tui`
This commit is contained in:
@@ -32,6 +32,8 @@ pub use self::additional_rate_limit_details::AdditionalRateLimitDetails;
|
||||
|
||||
pub(crate) mod rate_limit_status_payload;
|
||||
pub use self::rate_limit_status_payload::PlanType;
|
||||
pub use self::rate_limit_status_payload::RateLimitReachedKind;
|
||||
pub use self::rate_limit_status_payload::RateLimitReachedType;
|
||||
pub use self::rate_limit_status_payload::RateLimitStatusPayload;
|
||||
|
||||
pub(crate) mod rate_limit_status_details;
|
||||
|
||||
@@ -37,6 +37,13 @@ pub struct RateLimitStatusPayload {
|
||||
skip_serializing_if = "Option::is_none"
|
||||
)]
|
||||
pub additional_rate_limits: Option<Option<Vec<models::AdditionalRateLimitDetails>>>,
|
||||
#[serde(
|
||||
rename = "rate_limit_reached_type",
|
||||
default,
|
||||
with = "::serde_with::rust::double_option",
|
||||
skip_serializing_if = "Option::is_none"
|
||||
)]
|
||||
pub rate_limit_reached_type: Option<Option<RateLimitReachedType>>,
|
||||
}
|
||||
|
||||
impl RateLimitStatusPayload {
|
||||
@@ -46,10 +53,36 @@ impl RateLimitStatusPayload {
|
||||
rate_limit: None,
|
||||
credits: None,
|
||||
additional_rate_limits: None,
|
||||
rate_limit_reached_type: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct RateLimitReachedType {
|
||||
#[serde(rename = "type")]
|
||||
pub kind: RateLimitReachedKind,
|
||||
}
|
||||
|
||||
#[derive(
|
||||
Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize, Default,
|
||||
)]
|
||||
pub enum RateLimitReachedKind {
|
||||
#[serde(rename = "rate_limit_reached")]
|
||||
RateLimitReached,
|
||||
#[serde(rename = "workspace_owner_credits_depleted")]
|
||||
WorkspaceOwnerCreditsDepleted,
|
||||
#[serde(rename = "workspace_member_credits_depleted")]
|
||||
WorkspaceMemberCreditsDepleted,
|
||||
#[serde(rename = "workspace_owner_usage_limit_reached")]
|
||||
WorkspaceOwnerUsageLimitReached,
|
||||
#[serde(rename = "workspace_member_usage_limit_reached")]
|
||||
WorkspaceMemberUsageLimitReached,
|
||||
#[serde(rename = "unknown", other)]
|
||||
#[default]
|
||||
Unknown,
|
||||
}
|
||||
|
||||
#[derive(
|
||||
Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize, Default,
|
||||
)]
|
||||
|
||||
Reference in New Issue
Block a user