MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / refresh_sandboxes

Function refresh_sandboxes

crates/openshell-tui/src/lib.rs:2269–2355  ·  view source on GitHub ↗
(app: &mut App)

Source from the content-addressed store, hash-verified

2267}
2268
2269async fn refresh_sandboxes(app: &mut App) {
2270 let req = openshell_core::proto::ListSandboxesRequest {
2271 limit: 100,
2272 offset: 0,
2273 label_selector: String::new(),
2274 };
2275 let result = tokio::time::timeout(Duration::from_secs(5), app.client.list_sandboxes(req)).await;
2276 match result {
2277 Ok(Err(e)) => {
2278 tracing::warn!("failed to list sandboxes: {}", e.message());
2279 }
2280 Err(_) => {
2281 tracing::warn!("list sandboxes timed out");
2282 }
2283 Ok(Ok(resp)) => {
2284 let sandboxes = resp.into_inner().sandboxes;
2285 app.sandbox_count = sandboxes.len();
2286 app.sandbox_ids = sandboxes
2287 .iter()
2288 .map(|s| s.object_id().to_string())
2289 .collect();
2290 app.sandbox_names = sandboxes
2291 .iter()
2292 .map(|s| s.object_name().to_string())
2293 .collect();
2294 app.sandbox_phases = sandboxes.iter().map(|s| phase_label(s.phase())).collect();
2295 app.sandbox_images = sandboxes
2296 .iter()
2297 .map(|s| {
2298 s.spec
2299 .as_ref()
2300 .and_then(|spec| spec.template.as_ref())
2301 .map(|t| t.image.as_str())
2302 .filter(|img| !img.is_empty())
2303 .unwrap_or("-")
2304 .to_string()
2305 })
2306 .collect();
2307 app.sandbox_ages = sandboxes
2308 .iter()
2309 .map(|s| {
2310 s.metadata
2311 .as_ref()
2312 .map_or_else(|| "?".to_string(), |m| format_age(m.created_at_ms))
2313 })
2314 .collect();
2315 app.sandbox_created = sandboxes
2316 .iter()
2317 .map(|s| {
2318 s.metadata
2319 .as_ref()
2320 .map_or_else(|| "?".to_string(), |m| format_timestamp(m.created_at_ms))
2321 })
2322 .collect();
2323
2324 app.sandbox_policy_versions = sandboxes
2325 .iter()
2326 .map(openshell_core::proto::Sandbox::current_policy_version)

Callers 3

runFunction · 0.85
handle_sandbox_deleteFunction · 0.85
refresh_dataFunction · 0.85

Calls 13

phase_labelFunction · 0.85
format_ageFunction · 0.85
list_forwardsFunction · 0.85
build_sandbox_notesFunction · 0.85
lenMethod · 0.80
object_idMethod · 0.80
object_nameMethod · 0.80
object_labelsMethod · 0.80
format_timestampFunction · 0.70
list_sandboxesMethod · 0.45
phaseMethod · 0.45
as_strMethod · 0.45

Tested by

no test coverage detected