Skip to content

feat(app-server): list descendant threads by ancestor - #29591

Merged
btraut-openai merged 4 commits into
mainfrom
btraut/thread-list-descendants
Jun 24, 2026
Merged

feat(app-server): list descendant threads by ancestor#29591
btraut-openai merged 4 commits into
mainfrom
btraut/thread-list-descendants

Conversation

@btraut-openai

Copy link
Copy Markdown
Contributor

Why

thread/list can filter direct children with parentThreadId, but clients cannot request an entire spawned subtree. Discovering every descendant requires repeated client-side requests and gives up the database's existing filtering and pagination path.

What changed

Experimental clients can use ancestorThreadId to return strict descendants at any depth while parentThreadId retains its direct-child meaning. The filters are mutually exclusive, the ancestor is excluded, and every result preserves its immediate parentThreadId so callers can reconstruct the tree.

How it works

  • Explicit relationship: Internal list parameters distinguish direct children from transitive descendants without changing the meaning of parentThreadId.
  • Existing graph: Persisted parent-child spawn edges remain the source of truth, so descendant lookup needs no schema migration or ancestry cache.
  • Indexed traversal: A recursive SQLite query starts from the parent-edge index, walks each generation, and applies thread filters, sorting, and cursor pagination in the same database request.
  • Reconstructable results: The response stays flat and normally ordered while carrying each descendant's immediate parent.

Verification

Ran 550 tests across the protocol, state, rollout, and thread-store crates, then reran the four focused state, store, and app-server descendant-listing tests after the final diff reduction. Scoped Clippy and formatting checks passed. Stable and experimental schema generation was checked; the stable fixtures remain unchanged while the experimental schema includes the new field.

@btraut-openai

Copy link
Copy Markdown
Contributor Author

@codex review

@btraut-openai
btraut-openai marked this pull request as ready for review June 23, 2026 08:26
@btraut-openai
btraut-openai requested a review from a team as a code owner June 23, 2026 08:26

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5f3e121ad2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/app-server-protocol/src/protocol/v2/thread.rs
Comment thread codex-rs/state/src/runtime/threads.rs Outdated
btraut-openai added a commit that referenced this pull request Jun 23, 2026
btraut-openai added a commit that referenced this pull request Jun 23, 2026
@btraut-openai
btraut-openai force-pushed the btraut/thread-list-descendants branch from 81a0d9d to 6073bbb Compare June 23, 2026 10:46
btraut-openai added a commit that referenced this pull request Jun 23, 2026
btraut-openai added a commit that referenced this pull request Jun 23, 2026
btraut-openai added a commit that referenced this pull request Jun 23, 2026
btraut-openai added a commit that referenced this pull request Jun 23, 2026
@btraut-openai
btraut-openai force-pushed the btraut/thread-list-descendants branch from 6073bbb to a623e2f Compare June 23, 2026 16:50
btraut-openai added a commit that referenced this pull request Jun 23, 2026
btraut-openai added a commit that referenced this pull request Jun 23, 2026
@btraut-openai
btraut-openai force-pushed the btraut/thread-list-descendants branch from a623e2f to 6d3b942 Compare June 23, 2026 21:38

@jif-oai jif-oai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pre-approving but my comment stays valid

relation_filter: crate::ThreadRelationFilter,
filters: ThreadFilterOptions<'_>,
) -> anyhow::Result<crate::ThreadsPage> {
self.list_threads_matching(page_size, filters, Some(relation_filter))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we include thread_id in relation-list cursors/order for every sort key and add a tie-across-pages test or so?

@btraut-openai
btraut-openai force-pushed the btraut/thread-list-descendants branch from 80a96b9 to 9d0cf94 Compare June 24, 2026 19:51
@btraut-openai
btraut-openai merged commit 8057603 into main Jun 24, 2026
31 checks passed
@btraut-openai
btraut-openai deleted the btraut/thread-list-descendants branch June 24, 2026 20:08
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 24, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants