mirror of
https://github.com/openai/codex.git
synced 2026-11-28 23:34:06 +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
@@ -19,14 +19,18 @@ use codex_app_server_protocol::ProjectMoveResponse;
|
||||
use codex_app_server_protocol::ProjectReadParams;
|
||||
use codex_app_server_protocol::ProjectReadResponse;
|
||||
use codex_app_server_protocol::ProjectRoot;
|
||||
use codex_app_server_protocol::ProjectSortKey;
|
||||
use codex_app_server_protocol::ProjectUpdateParams;
|
||||
use codex_app_server_protocol::ProjectUpdateResponse;
|
||||
use codex_app_server_protocol::ServerNotification;
|
||||
use codex_app_server_protocol::SortDirection;
|
||||
use codex_app_server_protocol::ThreadProjectUpdatedNotification;
|
||||
use codex_thread_store::CreateProjectParams as StoreCreateProjectParams;
|
||||
use codex_thread_store::ListProjectsParams as StoreListProjectsParams;
|
||||
use codex_thread_store::MoveProjectParams as StoreMoveProjectParams;
|
||||
use codex_thread_store::ProjectMoveOutcome;
|
||||
use codex_thread_store::ProjectSortKey as StoreProjectSortKey;
|
||||
use codex_thread_store::SortDirection as StoreSortDirection;
|
||||
use codex_thread_store::StoredProject;
|
||||
use codex_thread_store::StoredProjectRoot;
|
||||
use codex_thread_store::ThreadStore;
|
||||
@@ -66,10 +70,27 @@ impl ProjectRequestProcessor {
|
||||
&self,
|
||||
params: ProjectListParams,
|
||||
) -> Result<Option<ClientResponsePayload>, JSONRPCErrorError> {
|
||||
if params.sort_key.is_none() && params.sort_direction.is_some() {
|
||||
return Err(invalid_params("sortDirection requires sortKey"));
|
||||
}
|
||||
let sort_key = match params.sort_key.unwrap_or(ProjectSortKey::Position) {
|
||||
ProjectSortKey::Position => StoreProjectSortKey::Position,
|
||||
ProjectSortKey::RecencyAt => StoreProjectSortKey::RecencyAt,
|
||||
};
|
||||
let sort_direction = match params.sort_direction {
|
||||
Some(SortDirection::Asc) => StoreSortDirection::Asc,
|
||||
Some(SortDirection::Desc) => StoreSortDirection::Desc,
|
||||
None => match sort_key {
|
||||
StoreProjectSortKey::Position => StoreSortDirection::Asc,
|
||||
StoreProjectSortKey::RecencyAt => StoreSortDirection::Desc,
|
||||
},
|
||||
};
|
||||
let page = self
|
||||
.thread_store
|
||||
.list_projects(StoreListProjectsParams {
|
||||
cursor: params.cursor,
|
||||
sort_key,
|
||||
sort_direction,
|
||||
limit: params
|
||||
.limit
|
||||
.map(|limit| limit as usize)
|
||||
@@ -359,6 +380,9 @@ fn api_project(project: StoredProject) -> Result<Project, JSONRPCErrorError> {
|
||||
position: project.position,
|
||||
created_at: project.created_at_ms / 1000,
|
||||
updated_at: project.updated_at_ms / 1000,
|
||||
recency_at: project
|
||||
.recency_at_ms
|
||||
.map(|timestamp| timestamp.div_euclid(/*rhs*/ 1000)),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user