[app-server] feat: add filtering on thread list (#9897)

This commit is contained in:
jif-oai
2026-01-26 21:54:19 +00:00
committed by GitHub
parent 6a02fdde76
commit 247fb2de64
9 changed files with 447 additions and 5 deletions

View File

@@ -111,6 +111,7 @@ use codex_app_server_protocol::ThreadResumeParams;
use codex_app_server_protocol::ThreadResumeResponse;
use codex_app_server_protocol::ThreadRollbackParams;
use codex_app_server_protocol::ThreadSortKey;
use codex_app_server_protocol::ThreadSourceKind;
use codex_app_server_protocol::ThreadStartParams;
use codex_app_server_protocol::ThreadStartResponse;
use codex_app_server_protocol::ThreadStartedNotification;
@@ -132,7 +133,6 @@ use codex_chatgpt::connectors;
use codex_core::AuthManager;
use codex_core::CodexThread;
use codex_core::Cursor as RolloutCursor;
use codex_core::INTERACTIVE_SESSION_SOURCES;
use codex_core::InitialHistory;
use codex_core::NewThread;
use codex_core::RolloutRecorder;
@@ -209,6 +209,9 @@ use tracing::info;
use tracing::warn;
use uuid::Uuid;
use crate::filters::compute_source_filters;
use crate::filters::source_kind_matches;
type PendingInterruptQueue = Vec<(RequestId, ApiVersion)>;
pub(crate) type PendingInterrupts = Arc<Mutex<HashMap<ThreadId, PendingInterruptQueue>>>;
@@ -1845,6 +1848,7 @@ impl CodexMessageProcessor {
limit,
sort_key,
model_providers,
source_kinds,
archived,
} = params;
@@ -1861,6 +1865,7 @@ impl CodexMessageProcessor {
requested_page_size,
cursor,
model_providers,
source_kinds,
core_sort_key,
archived.unwrap_or(false),
)
@@ -2538,6 +2543,7 @@ impl CodexMessageProcessor {
requested_page_size,
cursor,
model_providers,
None,
CoreThreadSortKey::UpdatedAt,
false,
)
@@ -2558,6 +2564,7 @@ impl CodexMessageProcessor {
requested_page_size: usize,
cursor: Option<String>,
model_providers: Option<Vec<String>>,
source_kinds: Option<Vec<ThreadSourceKind>>,
sort_key: CoreThreadSortKey,
archived: bool,
) -> Result<(Vec<ConversationSummary>, Option<String>), JSONRPCErrorError> {
@@ -2587,6 +2594,8 @@ impl CodexMessageProcessor {
None => Some(vec![self.config.model_provider_id.clone()]),
};
let fallback_provider = self.config.model_provider_id.clone();
let (allowed_sources_vec, source_kind_filter) = compute_source_filters(source_kinds);
let allowed_sources = allowed_sources_vec.as_slice();
while remaining > 0 {
let page_size = remaining.min(THREAD_LIST_MAX_LIMIT);
@@ -2596,7 +2605,7 @@ impl CodexMessageProcessor {
page_size,
cursor_obj.as_ref(),
sort_key,
INTERACTIVE_SESSION_SOURCES,
allowed_sources,
model_provider_filter.as_deref(),
fallback_provider.as_str(),
)
@@ -2612,7 +2621,7 @@ impl CodexMessageProcessor {
page_size,
cursor_obj.as_ref(),
sort_key,
INTERACTIVE_SESSION_SOURCES,
allowed_sources,
model_provider_filter.as_deref(),
fallback_provider.as_str(),
)
@@ -2641,6 +2650,11 @@ impl CodexMessageProcessor {
updated_at,
)
})
.filter(|summary| {
source_kind_filter
.as_ref()
.is_none_or(|filter| source_kind_matches(&summary.source, filter))
})
.collect::<Vec<_>>();
if filtered.len() > remaining {
filtered.truncate(remaining);