mirror of
https://github.com/openai/codex.git
synced 2026-06-01 19:02:59 +00:00
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:
@@ -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,
|
||||
},
|
||||
}
|
||||
),
|
||||
|
||||
@@ -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}"),
|
||||
|
||||
Reference in New Issue
Block a user