add missing fields to WebSearchAction and update app-server types (#10276)

- add `WebSearchAction` to app-server v2 types
- add `queries` to `WebSearchAction::Search` type

Updated tests.
This commit is contained in:
sayan-oai
2026-01-30 16:37:56 -08:00
committed by GitHub
parent 149f3aa27a
commit eb86663dcb
10 changed files with 95 additions and 10 deletions

View File

@@ -426,6 +426,7 @@ mod tests {
status: Some("completed".to_string()),
action: Some(WebSearchAction::Search {
query: Some("weather".to_string()),
queries: None,
}),
};
@@ -439,6 +440,7 @@ mod tests {
query: "weather".to_string(),
action: WebSearchAction::Search {
query: Some("weather".to_string()),
queries: None,
},
}
),

View File

@@ -1,8 +1,23 @@
use codex_protocol::models::WebSearchAction;
fn search_action_detail(query: &Option<String>, queries: &Option<Vec<String>>) -> String {
query.clone().filter(|q| !q.is_empty()).unwrap_or_else(|| {
let items = queries.as_ref();
let first = items
.and_then(|queries| queries.first())
.cloned()
.unwrap_or_default();
if items.is_some_and(|queries| queries.len() > 1) && !first.is_empty() {
format!("{first} ...")
} else {
first
}
})
}
pub fn web_search_action_detail(action: &WebSearchAction) -> String {
match action {
WebSearchAction::Search { query } => query.clone().unwrap_or_default(),
WebSearchAction::Search { query, queries } => search_action_detail(query, queries),
WebSearchAction::OpenPage { url } => url.clone().unwrap_or_default(),
WebSearchAction::FindInPage { url, pattern } => match (pattern, url) {
(Some(pattern), Some(url)) => format!("'{pattern}' in {url}"),