This commit is contained in:
Owen Lin
2025-11-03 15:12:38 -08:00
parent dd2638edbc
commit e65a269010
7 changed files with 15 additions and 17 deletions

View File

@@ -644,17 +644,17 @@ pub struct RateLimitWindow {
/// Rolling window duration, in minutes.
#[ts(type = "number | null")]
pub window_duration_mins: Option<i64>,
/// Unix timestamp (milliseconds since epoch) when the window resets.
/// Unix timestamp (seconds since epoch) when the window resets.
#[ts(type = "number | null")]
pub resets_at_ms: Option<i64>,
pub resets_at: Option<i64>,
}
impl From<codex_protocol::protocol::RateLimitWindow> for RateLimitWindow {
fn from(value: codex_protocol::protocol::RateLimitWindow) -> Self {
Self {
used_percent: value.used_percent as i64,
used_percent: value.used_percent.round() as i64,
window_duration_mins: value.window_minutes,
resets_at_ms: value.resets_at.map(|ms| ms * 1000),
resets_at: value.resets_at,
}
}
}

View File

@@ -68,7 +68,6 @@ use codex_app_server_protocol::ThreadResumeResponse;
use codex_app_server_protocol::ThreadStartParams;
use codex_app_server_protocol::ThreadStartResponse;
use codex_app_server_protocol::ThreadStartedNotification;
use codex_app_server_protocol::Turn;
use codex_app_server_protocol::UserInfoResponse;
use codex_app_server_protocol::UserInput as V2UserInput;
use codex_app_server_protocol::UserSavedConfig;

View File

@@ -183,7 +183,7 @@ mod tests {
primary: Some(RateLimitWindow {
used_percent: 25,
window_duration_mins: Some(15),
resets_at_ms: Some(123),
resets_at: Some(123),
}),
secondary: None,
},
@@ -197,8 +197,8 @@ mod tests {
"params": {
"rateLimits": {
"primary": {
"usedPercent": 25.0,
"windowMinutes": 15,
"usedPercent": 25,
"windowDurationMins": 15,
"resetsAt": 123
},
"secondary": null

View File

@@ -7,7 +7,6 @@ mod fuzzy_file_search;
mod interrupt;
mod list_resume;
mod login;
mod rate_limits;
mod send_message;
mod set_default_model;
mod user_agent;

View File

@@ -1,4 +1,5 @@
mod model_list;
mod rate_limits;
mod thread_archive;
mod thread_list;
mod thread_resume;

View File

@@ -26,7 +26,7 @@ use wiremock::matchers::path;
const DEFAULT_READ_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(10);
const INVALID_REQUEST_ERROR_CODE: i64 = -32600;
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
#[tokio::test]
async fn get_account_rate_limits_requires_auth() -> Result<()> {
let codex_home = TempDir::new()?;
@@ -51,7 +51,7 @@ async fn get_account_rate_limits_requires_auth() -> Result<()> {
Ok(())
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
#[tokio::test]
async fn get_account_rate_limits_requires_chatgpt_auth() -> Result<()> {
let codex_home = TempDir::new()?;
@@ -78,7 +78,7 @@ async fn get_account_rate_limits_requires_chatgpt_auth() -> Result<()> {
Ok(())
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
#[tokio::test]
async fn get_account_rate_limits_returns_snapshot() -> Result<()> {
let codex_home = TempDir::new()?;
write_chatgpt_auth(
@@ -143,13 +143,13 @@ async fn get_account_rate_limits_returns_snapshot() -> Result<()> {
let expected = GetAccountRateLimitsResponse {
rate_limits: RateLimitSnapshot {
primary: Some(RateLimitWindow {
used_percent: 42.0,
window_minutes: Some(60),
used_percent: 42,
window_duration_mins: Some(60),
resets_at: Some(primary_reset_timestamp),
}),
secondary: Some(RateLimitWindow {
used_percent: 5.0,
window_minutes: Some(1440),
used_percent: 5,
window_duration_mins: Some(1440),
resets_at: Some(secondary_reset_timestamp),
}),
},

View File

@@ -43,7 +43,6 @@ async fn thread_start_creates_thread_and_emits_started() -> Result<()> {
.await??;
let ThreadStartResponse { thread } = to_response::<ThreadStartResponse>(resp)?;
assert!(!thread.id.is_empty(), "thread id should not be empty");
assert!(thread.turn.is_empty(), "thread should start with no turns");
// A corresponding thread/started notification should arrive.
let notif: JSONRPCNotification = timeout(