mirror of
https://github.com/openai/codex.git
synced 2026-11-17 22:10:37 +00:00
Allow agent search by thread ID and Git branch (#61926)
## What changed Extend agent search to match case-insensitive substrings of thread IDs and Git branch names, alongside the existing name, preview, and working-directory matches. ## Testing Extend live search coverage for branch names and partial thread IDs, and verify that history search finds a persisted thread by a case-insensitive partial ID. GitOrigin-RevId: 6872c5af589ab5f4ffb563facb07de692fde972f
This commit is contained in:
committed by
copyberry
parent
42248f5ef9
commit
885a1df5ee
@@ -795,15 +795,18 @@ toggle_pin = 'z p'
|
||||
#[tokio::test]
|
||||
async fn live_center_search_row_appears_only_while_editing() {
|
||||
let app = make_test_app().await;
|
||||
let mut view = app.agents_overview_view(
|
||||
vec![overview_thread(
|
||||
ThreadId::from_u128(/*value*/ 42),
|
||||
/*parent_thread_id*/ None,
|
||||
"Task to find",
|
||||
ThreadStatus::Idle,
|
||||
)],
|
||||
/*selected_thread_id*/ None,
|
||||
let mut thread = overview_thread(
|
||||
ThreadId::from_u128(/*value*/ 0xabcdef),
|
||||
/*parent_thread_id*/ None,
|
||||
"Task to find",
|
||||
ThreadStatus::Idle,
|
||||
);
|
||||
thread.git_info = Some(codex_app_server_protocol::GitInfo {
|
||||
sha: None,
|
||||
branch: Some("Fix/Resume".to_string()),
|
||||
origin_url: None,
|
||||
});
|
||||
let mut view = app.agents_overview_view(vec![thread], /*selected_thread_id*/ None);
|
||||
let area = Rect::new(
|
||||
/*x*/ 0, /*y*/ 0, /*width*/ 88, /*height*/ 16,
|
||||
);
|
||||
@@ -828,6 +831,13 @@ async fn live_center_search_row_appears_only_while_editing() {
|
||||
view.handle_key_event(KeyCode::Esc.into());
|
||||
assert_eq!(screen(&view, area.width, area.height), idle);
|
||||
}
|
||||
|
||||
for query in ["FIX/RES", "ABCDEF", "find Task"] {
|
||||
view.handle_key_event(KeyCode::Char('/').into());
|
||||
view.handle_paste(query.into());
|
||||
assert!(screen(&view, area.width, area.height).contains("Task to find"));
|
||||
view.handle_key_event(KeyCode::Esc.into());
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
|
||||
@@ -274,6 +274,12 @@ pub(super) fn matches_query(thread: &Thread, query: &str) -> bool {
|
||||
format!("{name} {} {cwd}", thread.preview)
|
||||
.to_lowercase()
|
||||
.contains(query)
|
||||
|| thread.id.to_lowercase().contains(query)
|
||||
|| thread
|
||||
.git_info
|
||||
.as_ref()
|
||||
.and_then(|git| git.branch.as_deref())
|
||||
.is_some_and(|branch| branch.to_lowercase().contains(query))
|
||||
}
|
||||
|
||||
impl App {
|
||||
|
||||
@@ -103,13 +103,14 @@ async fn check_discovery(mixed_sources: bool) -> Result<()> {
|
||||
)
|
||||
})
|
||||
.collect();
|
||||
let reopened_pin_id =
|
||||
ThreadId::from_u128(/*value*/ 0xda7aba5e_0000_4000_8000_000000000001);
|
||||
let reopened_pin = overview_thread(
|
||||
ThreadId::new(),
|
||||
reopened_pin_id,
|
||||
/*parent_thread_id*/ None,
|
||||
"Pinned after reopen",
|
||||
ThreadStatus::NotLoaded,
|
||||
);
|
||||
let reopened_pin_id = ThreadId::from_string(&reopened_pin.id).unwrap();
|
||||
let show_reopened_pin = Arc::new(AtomicBool::new(false));
|
||||
let expected_first_twenty: HashSet<_> = rows[1..21]
|
||||
.iter()
|
||||
@@ -393,12 +394,15 @@ async fn check_discovery(mixed_sources: bool) -> Result<()> {
|
||||
// Another CLI inserts a matching session ahead of the exhausted browse cursor.
|
||||
show_reopened_pin.store(true, Ordering::SeqCst);
|
||||
view.handle_key_event(KeyCode::Char('/').into());
|
||||
view.handle_paste("Pinned after reopen".into());
|
||||
view.handle_paste("DA7ABA5E-0000-4000".into());
|
||||
finish_history_search(&mut app, &mut tui, &mut session, &mut rx).await?;
|
||||
assert!(
|
||||
assert_eq!(
|
||||
app.agents_overview
|
||||
.search_matches
|
||||
.contains_key(&reopened_pin_id)
|
||||
.keys()
|
||||
.copied()
|
||||
.collect::<Vec<_>>(),
|
||||
[reopened_pin_id],
|
||||
);
|
||||
view.handle_key_event(KeyCode::Esc.into());
|
||||
app.agents_overview.threads.clear();
|
||||
|
||||
Reference in New Issue
Block a user