mirror of
https://github.com/openai/codex.git
synced 2026-09-14 11:57:03 +00:00
remove sort on model list, add back comment
This commit is contained in:
@@ -828,8 +828,7 @@ mod tests {
|
||||
"id": 6,
|
||||
"params": {
|
||||
"limit": null,
|
||||
"cursor": null,
|
||||
"order": null,
|
||||
"cursor": null
|
||||
}
|
||||
}),
|
||||
serde_json::to_value(&request)?,
|
||||
|
||||
@@ -113,14 +113,6 @@ impl From<codex_protocol::protocol::SandboxPolicy> 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<String>,
|
||||
/// Optional page size; defaults to a reasonable server-side value.
|
||||
pub limit: Option<i32>,
|
||||
/// Optional sort order; defaults to descending.
|
||||
pub order: Option<SortOrder>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user