mirror of
https://github.com/openai/codex.git
synced 2026-12-04 00:51:02 +00:00
Include empty-preview threads in relationship listings (#35691)
## What changed - Include threads without preview text when listing direct children or descendants from the persisted spawn graph. - Continue filtering those threads out of the global thread list. ## Testing - Extend the relationship pagination test to cover an empty-preview child in direct-child and descendant results. GitOrigin-RevId: c2e7bb04c5f64558a48b1d7877bd24edaa364bb4
This commit is contained in:
committed by
copyberry
parent
8d6a91b1ff
commit
63682c4e1a
@@ -1151,7 +1151,12 @@ WITH RECURSIVE subtree(child_thread_id, parent_thread_id) AS (
|
||||
};
|
||||
let include_thread_id_tiebreaker =
|
||||
relation_filter.is_some() || filters.sort_key == SortKey::RecencyAt;
|
||||
push_thread_filters(builder, filters, include_thread_id_tiebreaker);
|
||||
push_thread_filters_with_preview(
|
||||
builder,
|
||||
filters,
|
||||
include_thread_id_tiebreaker,
|
||||
/*include_empty_preview*/ relation_filter.is_some(),
|
||||
);
|
||||
match relation_filter {
|
||||
Some(crate::ThreadRelationFilter::DirectChildrenOf(parent_thread_id)) => {
|
||||
builder.push(" AND listed_edge.parent_thread_id = ");
|
||||
@@ -1255,6 +1260,20 @@ pub(super) fn push_thread_filters<'a>(
|
||||
builder: &mut QueryBuilder<Sqlite>,
|
||||
options: ThreadFilterOptions<'a>,
|
||||
include_thread_id_tiebreaker: bool,
|
||||
) {
|
||||
push_thread_filters_with_preview(
|
||||
builder,
|
||||
options,
|
||||
include_thread_id_tiebreaker,
|
||||
/*include_empty_preview*/ false,
|
||||
);
|
||||
}
|
||||
|
||||
fn push_thread_filters_with_preview<'a>(
|
||||
builder: &mut QueryBuilder<Sqlite>,
|
||||
options: ThreadFilterOptions<'a>,
|
||||
include_thread_id_tiebreaker: bool,
|
||||
include_empty_preview: bool,
|
||||
) {
|
||||
let ThreadFilterOptions {
|
||||
archived_only,
|
||||
@@ -1273,7 +1292,9 @@ pub(super) fn push_thread_filters<'a>(
|
||||
} else {
|
||||
builder.push(" AND threads.archived = 0");
|
||||
}
|
||||
builder.push(" AND threads.preview <> ''");
|
||||
if !include_empty_preview {
|
||||
builder.push(" AND threads.preview <> ''");
|
||||
}
|
||||
if let Some(is_pinned) = is_pinned {
|
||||
builder.push(" AND threads.is_pinned = ");
|
||||
builder.push_bind(is_pinned);
|
||||
@@ -2121,6 +2142,10 @@ mod tests {
|
||||
metadata.created_at =
|
||||
DateTime::<Utc>::from_timestamp(created_at, 0).expect("valid timestamp");
|
||||
metadata.updated_at = metadata.created_at;
|
||||
if thread_id == first_child_id {
|
||||
metadata.preview = None;
|
||||
metadata.first_user_message = None;
|
||||
}
|
||||
runtime
|
||||
.upsert_thread(&metadata)
|
||||
.await
|
||||
@@ -2192,6 +2217,12 @@ mod tests {
|
||||
sort_direction: SortDirection::Desc,
|
||||
search_term: None,
|
||||
};
|
||||
let global_page = runtime
|
||||
.list_threads(/*page_size*/ 10, filters(None))
|
||||
.await
|
||||
.expect("global thread list should succeed");
|
||||
let mut global_ids = global_page.items.iter().map(|item| item.id);
|
||||
assert!(!global_ids.any(|id| id == first_child_id));
|
||||
let first_page = runtime
|
||||
.list_threads_by_parent(/*page_size*/ 1, parent_id, filters(None))
|
||||
.await
|
||||
|
||||
Reference in New Issue
Block a user