Files
codex/codex-rs/core/src/web_search.rs
Charlie Marsh 221a341029 Remove unused Rust helpers (#34345)
## What changed

- Remove unused APIs and test helpers across the Rust workspace.
- Route Linux sandbox test setup through the shared exec request path.
- Drop dependencies that became unnecessary after the cleanup.

GitOrigin-RevId: 48fd9b2b1575bad7add0819786b4d8ec88d8486f
2026-07-20 13:45:29 +00:00

31 lines
1.1 KiB
Rust

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, 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}"),
(Some(pattern), None) => format!("'{pattern}'"),
(None, Some(url)) => url.clone(),
(None, None) => String::new(),
},
WebSearchAction::Other => String::new(),
}
}