Add cwd as an optional field to thread/list (#11651)

Add's the ability to filter app-server thread/list by cwd
This commit is contained in:
acrognale-oai
2026-02-12 21:05:04 -05:00
committed by GitHub
parent 537102e657
commit ebe359b876
10 changed files with 148 additions and 14 deletions

View File

@@ -266,6 +266,13 @@ use crate::thread_state::ThreadStateManager;
const THREAD_LIST_DEFAULT_LIMIT: usize = 25;
const THREAD_LIST_MAX_LIMIT: usize = 100;
struct ThreadListFilters {
model_providers: Option<Vec<String>>,
source_kinds: Option<Vec<ThreadSourceKind>>,
archived: bool,
cwd: Option<PathBuf>,
}
// Duration before a ChatGPT login attempt is abandoned.
const LOGIN_CHATGPT_TIMEOUT: Duration = Duration::from_secs(10 * 60);
const APP_LIST_LOAD_TIMEOUT: Duration = Duration::from_secs(90);
@@ -2430,6 +2437,7 @@ impl CodexMessageProcessor {
model_providers,
source_kinds,
archived,
cwd,
} = params;
let requested_page_size = limit
@@ -2444,10 +2452,13 @@ impl CodexMessageProcessor {
.list_threads_common(
requested_page_size,
cursor,
model_providers,
source_kinds,
core_sort_key,
archived.unwrap_or(false),
ThreadListFilters {
model_providers,
source_kinds,
archived: archived.unwrap_or(false),
cwd: cwd.map(PathBuf::from),
},
)
.await
{
@@ -3221,10 +3232,13 @@ impl CodexMessageProcessor {
.list_threads_common(
requested_page_size,
cursor,
model_providers,
None,
CoreThreadSortKey::UpdatedAt,
false,
ThreadListFilters {
model_providers,
source_kinds: None,
archived: false,
cwd: None,
},
)
.await
{
@@ -3242,11 +3256,15 @@ impl CodexMessageProcessor {
&self,
requested_page_size: usize,
cursor: Option<String>,
model_providers: Option<Vec<String>>,
source_kinds: Option<Vec<ThreadSourceKind>>,
sort_key: CoreThreadSortKey,
archived: bool,
filters: ThreadListFilters,
) -> Result<(Vec<ConversationSummary>, Option<String>), JSONRPCErrorError> {
let ThreadListFilters {
model_providers,
source_kinds,
archived,
cwd,
} = filters;
let mut cursor_obj: Option<RolloutCursor> = match cursor.as_ref() {
Some(cursor_str) => {
Some(parse_cursor(cursor_str).ok_or_else(|| JSONRPCErrorError {
@@ -3327,6 +3345,9 @@ impl CodexMessageProcessor {
if source_kind_filter
.as_ref()
.is_none_or(|filter| source_kind_matches(&summary.source, filter))
&& cwd
.as_ref()
.is_none_or(|expected_cwd| &summary.cwd == expected_cwd)
{
filtered.push(summary);
if filtered.len() >= remaining {