From d11f9cc2e4747eef57a99b9eeb7ae19fb7da2765 Mon Sep 17 00:00:00 2001 From: Owen Lin Date: Mon, 3 Nov 2025 13:39:26 -0800 Subject: [PATCH] remove sort on model list, add back comment --- .../src/protocol/common.rs | 3 +-- .../app-server-protocol/src/protocol/v2.rs | 10 ---------- .../app-server/src/codex_message_processor.rs | 19 ++++++++----------- codex-rs/app-server/tests/suite/model_list.rs | 4 ---- 4 files changed, 9 insertions(+), 27 deletions(-) diff --git a/codex-rs/app-server-protocol/src/protocol/common.rs b/codex-rs/app-server-protocol/src/protocol/common.rs index 6b0ff22494..097066019a 100644 --- a/codex-rs/app-server-protocol/src/protocol/common.rs +++ b/codex-rs/app-server-protocol/src/protocol/common.rs @@ -828,8 +828,7 @@ mod tests { "id": 6, "params": { "limit": null, - "cursor": null, - "order": null, + "cursor": null } }), serde_json::to_value(&request)?, diff --git a/codex-rs/app-server-protocol/src/protocol/v2.rs b/codex-rs/app-server-protocol/src/protocol/v2.rs index b0ae725bef..1fc43ea78c 100644 --- a/codex-rs/app-server-protocol/src/protocol/v2.rs +++ b/codex-rs/app-server-protocol/src/protocol/v2.rs @@ -113,14 +113,6 @@ impl From for SandboxPolicy { } } -#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)] -#[serde(rename_all = "camelCase")] -#[ts(export_to = "v2/")] -pub enum SortOrder { - Asc, - Desc, -} - #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)] #[serde(tag = "type", rename_all = "camelCase")] #[ts(tag = "type")] @@ -195,8 +187,6 @@ pub struct ModelListParams { pub cursor: Option, /// Optional page size; defaults to a reasonable server-side value. pub limit: Option, - /// Optional sort order; defaults to descending. - pub order: Option, } #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)] diff --git a/codex-rs/app-server/src/codex_message_processor.rs b/codex-rs/app-server/src/codex_message_processor.rs index 57f2b07836..d89b65a5f8 100644 --- a/codex-rs/app-server/src/codex_message_processor.rs +++ b/codex-rs/app-server/src/codex_message_processor.rs @@ -58,7 +58,6 @@ use codex_app_server_protocol::ServerRequestPayload; use codex_app_server_protocol::SessionConfiguredNotification; use codex_app_server_protocol::SetDefaultModelParams; use codex_app_server_protocol::SetDefaultModelResponse; -use codex_app_server_protocol::SortOrder; use codex_app_server_protocol::Thread; use codex_app_server_protocol::ThreadArchiveParams; use codex_app_server_protocol::ThreadArchiveResponse; @@ -1587,19 +1586,12 @@ impl CodexMessageProcessor { } async fn list_models(&self, request_id: RequestId, params: ModelListParams) { - let ModelListParams { - cursor, - limit, - order, - } = params; + let ModelListParams { cursor, limit } = params; let mut models = supported_models(); - // Sort models according to requested order; default to descending. - match order.unwrap_or(SortOrder::Desc) { - SortOrder::Asc => models.sort_by(|a, b| a.id.cmp(&b.id)), - SortOrder::Desc => models.sort_by(|a, b| b.id.cmp(&a.id)), - } + // Sort models in descending order by id (default behavior). + models.sort_by(|a, b| b.id.cmp(&a.id)); let total = models.len(); @@ -2106,6 +2098,7 @@ impl CodexMessageProcessor { loop { tokio::select! { _ = &mut cancel_rx => { + // User has unsubscribed, so exit this task. break; } event = conversation_for_task.next_event() => { @@ -2122,6 +2115,10 @@ impl CodexMessageProcessor { continue; } + // For now, we send a notification for every event, + // JSON-serializing the `Event` as-is, but these should + // be migrated to be variants of `ServerNotification` + // instead. let method = format!("codex/event/{}", event.msg); let mut params = match serde_json::to_value(event.clone()) { Ok(serde_json::Value::Object(map)) => map, diff --git a/codex-rs/app-server/tests/suite/model_list.rs b/codex-rs/app-server/tests/suite/model_list.rs index 40d5f600b7..71bcda36c7 100644 --- a/codex-rs/app-server/tests/suite/model_list.rs +++ b/codex-rs/app-server/tests/suite/model_list.rs @@ -30,7 +30,6 @@ async fn list_models_returns_all_models_with_large_limit() -> Result<()> { .send_list_models_request(ModelListParams { cursor: None, limit: Some(100), - order: None, }) .await?; @@ -115,7 +114,6 @@ async fn list_models_pagination_works() -> Result<()> { .send_list_models_request(ModelListParams { cursor: None, limit: Some(1), - order: None, }) .await?; @@ -138,7 +136,6 @@ async fn list_models_pagination_works() -> Result<()> { .send_list_models_request(ModelListParams { cursor: Some(next_cursor.clone()), limit: Some(1), - order: None, }) .await?; @@ -170,7 +167,6 @@ async fn list_models_rejects_invalid_cursor() -> Result<()> { .send_list_models_request(ModelListParams { cursor: Some("invalid".to_string()), limit: None, - order: None, }) .await?;