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

Function refresh_global_settings

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

Source from the content-addressed store, hash-verified

1989}
1990
1991async fn refresh_global_settings(app: &mut App) {
1992 let req = openshell_core::proto::GetGatewayConfigRequest {};
1993 let result =
1994 tokio::time::timeout(Duration::from_secs(5), app.client.get_gateway_config(req)).await;
1995 match result {
1996 Ok(Err(e)) => {
1997 tracing::warn!("failed to fetch global settings: {}", e.message());
1998 }
1999 Err(_) => {
2000 tracing::warn!("get gateway settings timed out");
2001 }
2002 Ok(Ok(resp)) => {
2003 let inner = resp.into_inner();
2004 app.apply_global_settings(inner.settings, inner.settings_revision);
2005 }
2006 }
2007
2008 // Check for active global policy.
2009 let policy_req = openshell_core::proto::ListSandboxPoliciesRequest {
2010 name: String::new(),
2011 limit: 1,
2012 offset: 0,
2013 global: true,
2014 };
2015 if let Ok(Ok(resp)) = tokio::time::timeout(
2016 Duration::from_secs(5),
2017 app.client.list_sandbox_policies(policy_req),
2018 )
2019 .await
2020 {
2021 let revisions = resp.into_inner().revisions;
2022 if let Some(latest) = revisions.first() {
2023 let status =
2024 openshell_core::proto::PolicyStatus::try_from(latest.status).unwrap_or_default();
2025 app.global_policy_active = status == openshell_core::proto::PolicyStatus::Loaded;
2026 app.global_policy_version = latest.version;
2027 } else {
2028 app.global_policy_active = false;
2029 app.global_policy_version = 0;
2030 }
2031 }
2032}
2033
2034fn spawn_set_global_setting(app: &App, tx: mpsc::UnboundedSender<Event>) {
2035 let Some(ref edit) = app.setting_edit else {

Callers 2

runFunction · 0.85
refresh_dataFunction · 0.85

Calls 3

apply_global_settingsMethod · 0.80
get_gateway_configMethod · 0.45
list_sandbox_policiesMethod · 0.45

Tested by

no test coverage detected