Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

Include empty-preview threads in relationship listings (#35691)

Tamir Duberstein63682c4e1ad8
diff --git a/codex-rs/state/src/runtime/threads.rs b/codex-rs/state/src/runtime/threads.rs
index 584a5b9910..69bcd9bcd1 100644
--- a/codex-rs/state/src/runtime/threads.rs
+++ b/codex-rs/state/src/runtime/threads.rs
@@ -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