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

Method apply_global_settings

crates/openshell-tui/src/app.rs:963–995  ·  view source on GitHub ↗

Apply fetched global settings from the `GetGatewayConfig` response.

(
        &mut self,
        settings: HashMap<String, openshell_core::proto::SettingValue>,
        revision: u64,
    )

Source from the content-addressed store, hash-verified

961
962 /// Apply fetched global settings from the `GetGatewayConfig` response.
963 pub fn apply_global_settings(
964 &mut self,
965 settings: HashMap<String, openshell_core::proto::SettingValue>,
966 revision: u64,
967 ) {
968 self.global_settings_revision = revision;
969 self.providers_v2_enabled = settings
970 .get(settings::PROVIDERS_V2_ENABLED_KEY)
971 .and_then(|value| value.value.as_ref())
972 .and_then(|value| match value {
973 setting_value::Value::BoolValue(value) => Some(*value),
974 setting_value::Value::StringValue(value) => settings::parse_bool_like(value),
975 setting_value::Value::IntValue(value) => Some(*value != 0),
976 setting_value::Value::BytesValue(_) => None,
977 })
978 .unwrap_or(false);
979 self.global_settings = settings::REGISTERED_SETTINGS
980 .iter()
981 .map(|reg| {
982 let value = settings.get(reg.key).and_then(|sv| sv.value.clone());
983 GlobalSettingEntry {
984 key: reg.key.to_string(),
985 kind: reg.kind,
986 value,
987 }
988 })
989 .collect();
990 if self.global_settings_selected >= self.global_settings.len()
991 && !self.global_settings.is_empty()
992 {
993 self.global_settings_selected = self.global_settings.len() - 1;
994 }
995 }
996
997 /// Apply fetched sandbox settings from the `GetSandboxConfig` response.
998 pub fn apply_sandbox_settings(

Callers 2

runFunction · 0.80
refresh_global_settingsFunction · 0.80

Calls 4

parse_bool_likeFunction · 0.85
lenMethod · 0.80
getMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected