mirror of
https://github.com/openai/codex.git
synced 2026-11-18 23:02:23 +00:00
Add recency sorting to project/list (#41223)
## What changed - Include `recencyAt`, derived from the newest non-archived assigned thread, in project responses. - Let `project/list` sort by `position` or `recencyAt` in either direction, with recency as the default descending order for that key and projects without activity placed last. - Encode the sort key, direction, and millisecond-precision anchor in new cursors while retaining existing ascending-position cursors. - Add an index for project recency lookups and document the API's sorting and pagination behavior. ## Testing - Cover recency updates when threads are assigned, archived, unarchived, or deleted. - Cover ordering, null handling, tie-breaking, cursor pagination, invalid sort combinations, and cursor mismatches. GitOrigin-RevId: 6165e2b9976b0b45cfa16bcd42978b67811f6df5
This commit is contained in:
1 parent
2d929eb7c3
commit
f6726e8986
22 files changed
+796
-122
No files matched your search
@@ -7,6 +7,8 @@ use codex_utils_absolute_path::AbsolutePathBuf;
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
|
||||
use super::SortDirection;
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
@@ -28,6 +30,17 @@ pub struct Project {
|
||||
pub created_at: i64,
|
||||
#[ts(type = "number")]
|
||||
pub updated_at: i64,
|
||||
/// Newest non-archived member thread's recency, in Unix seconds; null when none exist.
|
||||
#[ts(type = "number | null")]
|
||||
pub recency_at: Option<i64>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(rename_all = "camelCase", export_to = "v2/")]
|
||||
pub enum ProjectSortKey {
|
||||
Position,
|
||||
RecencyAt,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS, ExperimentalApi)]
|
||||
@@ -38,6 +51,12 @@ pub struct ProjectListParams {
|
||||
pub cursor: Option<String>,
|
||||
#[ts(optional = nullable)]
|
||||
pub limit: Option<u32>,
|
||||
/// Defaults to position. Recency sorting always places empty projects last.
|
||||
#[ts(optional = nullable)]
|
||||
pub sort_key: Option<ProjectSortKey>,
|
||||
/// Requires sortKey. Defaults to asc for position and desc for recencyAt.
|
||||
#[ts(optional = nullable)]
|
||||
pub sort_direction: Option<SortDirection>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
|
||||
|
||||
@@ -1500,7 +1500,7 @@ pub enum ThreadSearchSortKey {
|
||||
RecencyAt,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, JsonSchema, TS)]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub enum SortDirection {
|
||||
|
||||
Reference in new issue
Block a user