Repository navigation
fix(tui): bound agent picker lineage discovery - #675
GraciousGazelles wants to merge 24 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the subagent thread backfill mechanism in the TUI. Instead of fetching all loaded threads and filtering them individually, it now queries the app server's thread_list endpoint with an ancestor filter to fetch only the descendants of the primary thread, utilizing pagination. This change significantly reduces redundant metadata reads and improves performance. The review feedback suggests adding a safety limit on the maximum number of pages fetched during the backfill loop to prevent potential infinite loops or excessive resource consumption from circular cursors or unexpectedly large lineages.
|
Successor 91335f1 addresses the rejected candidate findings. Lineage pages are now validated and applied incrementally, transient list failures retain the failed cursor, cursor cycles remain explicitly incomplete until reset, and each picker open builds a rotating bounded row slice. The already-tracked pathless-child fallback now uses the existing liveness refresh path directly, preserving V1/V2 ownership semantics without scanning unrelated loaded threads. Hosted regressions were added for cross-page descendants, failed-cursor resume, terminal cursor cycles, multi-open page-budget progress, linear indexed traversal, bounded rotating rows, and reset cleanup. Fresh hosted validation is being dispatched for this exact head. |
|
Successor dc11277 consolidates the current review and hosted-test findings. It keeps ancestor-only empty-preview descendants visible to lineage discovery, requires an authoritative read before exposing unknown-capability pathless children, preserves transient read failures as retryable continuation state without relisting, and bounds cursor cycles independently per picker open so a later open can recover. The recurring V1/V2 capability regression remains substantive, with additional state, app-server, retry, and cycle-recovery coverage in the focused hosted lane. |
|
Successor 8ad15fb fixes the exact dc11277 hosted blockers. All four push_thread_filters call sites now pass the new preview policy explicitly; only ancestor DescendantsOf listing can include empty previews, while memories, exact-title, and id listing remain false. Cursor-cycle detection now resets pagination for the next open but drains the bounded authoritative-read queue before returning, so pathless V2 descendants are visible with server-confirmed ownership even under a persistent cycle. A focused fixture proves two bounded list calls and one authoritative read per open with fresh cursor restart, and the memories query test is now part of the targeted lane. |
8ad15fb to
6d3076a
Compare
|
Base-refresh receipt: the same five-commit semantic delta has been rebased without conflicts onto origin/main 3eda3f2. The rebased head is 6d3076a. Pre- and post-rebase full-index diff SHA-256 are identical at 437f3bdeaf00f45be6de2cffdd42b75dd25345270d750fdb4f0f19038e9d6a3e, with the same changed paths. Prior checks are superseded; fresh exact-head validation is being dispatched. |
6d3076a to
dc2a1ad
Compare
982cc54 to
27fb021
Compare
| 1, | ||
| ))?), | ||
| ]))); | ||
| let (mut app_server, requests, proxy) = start_recording_app_server_with_lineage_and_state( |
| let page_count = rows | ||
| .len() | ||
| .div_ceil(crate::app::session_lifecycle::SUBAGENT_BACKFILL_PAGE_SIZE as usize); | ||
| for (page_index, page) in rows |
| let thread_read_responses = Arc::new(Mutex::new(VecDeque::from([ | ||
| ScriptedThreadReadResponse::Thread(serde_json::to_value(child)?), | ||
| ]))); | ||
| let (mut app_server, requests, proxy) = start_recording_app_server_with_lineage_and_state( |
| /*next_cursor*/ None, | ||
| ), | ||
| )]))); | ||
| let (mut app_server, requests, proxy) = start_recording_app_server_with_lineage( |
| /*next_cursor*/ None, | ||
| )), | ||
| ]))); | ||
| let (mut app_server, requests, proxy) = start_recording_app_server_with_lineage( |
| scripted_unacknowledged_lineage_page(Vec::new(), /*next_cursor*/ None), | ||
| )); | ||
| let responses = Arc::new(Mutex::new(pages)); | ||
| let (mut app_server, requests, proxy) = start_recording_app_server_with_lineage( |
| crate::app::loaded_threads::SUBAGENT_BACKFILL_PAGES_PER_ATTEMPT + 1 | ||
| ); | ||
| let responses = Arc::new(Mutex::new(pages)); | ||
| let (mut app_server, requests, proxy) = start_recording_app_server_with_lineage( |
| ScriptedThreadReadResponse::Error("transient read failure".to_string()), | ||
| ScriptedThreadReadResponse::Thread(serde_json::to_value(authoritative_child)?), | ||
| ]))); | ||
| let (mut app_server, requests, proxy) = start_recording_app_server_with_lineage( |
| configure_backfill_primary(&mut app, primary_thread_id); | ||
| let mut pages = VecDeque::new(); | ||
| let descendant_thread_ids = (0..PAGE_COUNT).map(|_| ThreadId::new()).collect::<Vec<_>>(); | ||
| for (index, descendant_thread_id) in descendant_thread_ids.iter().copied().enumerate() { |
| ))); | ||
| } | ||
| let responses = Arc::new(Mutex::new(pages)); | ||
| let (mut app_server, requests, proxy) = start_recording_app_server_with_lineage( |
| let responses = Arc::new(Mutex::new(VecDeque::from([ScriptedLineageResponse::Page( | ||
| scripted_relation_limited_lineage_page(Vec::new(), /*next_cursor*/ None), | ||
| )]))); | ||
| let (mut app_server, requests, proxy) = start_recording_app_server_with_lineage( |
| ))); | ||
| } | ||
| let responses = Arc::new(Mutex::new(pages)); | ||
| let (mut app_server, requests, proxy) = start_recording_app_server_with_lineage( |
| let responses = Arc::new(Mutex::new(VecDeque::from([ScriptedLineageResponse::Page( | ||
| scripted_lineage_page(Vec::new(), Some("over-limit".to_string())), | ||
| )]))); | ||
| let (mut app_server, requests, proxy) = start_recording_app_server_with_lineage( |
|
Superseded by #736, merged as f40ba8f and contained in current main. The landed successor covers bounded ancestor-filtered discovery, persisted lineage, cursor and traversal limits, protected picker rows, notifications, and regression tests. Closing this older proposal; retaining its source branch for historical reference. |
Summary
Validation