From 15e7c2b6e5d3dc56890317b4c04f46764fd471c4 Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Wed, 27 Aug 2025 18:01:40 -0300 Subject: [PATCH] feat: handle disabled hostname outputs in plugin and simplify status display Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) --- src/meta_plugin/hostname.rs | 64 +++++++++++++++++++++---------------- src/modes/status.rs | 46 +++----------------------- 2 files changed, 41 insertions(+), 69 deletions(-) diff --git a/src/meta_plugin/hostname.rs b/src/meta_plugin/hostname.rs index ca35bca..290a562 100644 --- a/src/meta_plugin/hostname.rs +++ b/src/meta_plugin/hostname.rs @@ -219,37 +219,47 @@ impl MetaPlugin for HostnameMetaPlugin { } }; - // Add hostname output if enabled - if hostname_enabled { - if let Some(meta_data) = crate::meta_plugin::process_metadata_outputs( - "hostname", - serde_yaml::Value::String(hostname_value), - &self.outputs - ) { - metadata.push(meta_data); - } + // Always process all outputs, setting disabled ones to Null + // Handle hostname output + let hostname_output_value = if hostname_enabled { + serde_yaml::Value::String(hostname_value) + } else { + serde_yaml::Value::Null + }; + if let Some(meta_data) = crate::meta_plugin::process_metadata_outputs( + "hostname", + hostname_output_value, + &self.outputs + ) { + metadata.push(meta_data); } - // Add hostname_full output if enabled - if hostname_full_enabled { - if let Some(meta_data) = crate::meta_plugin::process_metadata_outputs( - "hostname_full", - serde_yaml::Value::String(full_hostname.clone()), - &self.outputs - ) { - metadata.push(meta_data); - } + // Handle hostname_full output + let hostname_full_output_value = if hostname_full_enabled { + serde_yaml::Value::String(full_hostname.clone()) + } else { + serde_yaml::Value::Null + }; + if let Some(meta_data) = crate::meta_plugin::process_metadata_outputs( + "hostname_full", + hostname_full_output_value, + &self.outputs + ) { + metadata.push(meta_data); } - // Add hostname_short output if enabled - if hostname_short_enabled { - if let Some(meta_data) = crate::meta_plugin::process_metadata_outputs( - "hostname_short", - serde_yaml::Value::String(short_hostname), - &self.outputs - ) { - metadata.push(meta_data); - } + // Handle hostname_short output + let hostname_short_output_value = if hostname_short_enabled { + serde_yaml::Value::String(short_hostname) + } else { + serde_yaml::Value::Null + }; + if let Some(meta_data) = crate::meta_plugin::process_metadata_outputs( + "hostname_short", + hostname_short_output_value, + &self.outputs + ) { + metadata.push(meta_data); } // Mark as finalized since this plugin only needs to run once diff --git a/src/modes/status.rs b/src/modes/status.rs index 1f02a02..c21e201 100644 --- a/src/modes/status.rs +++ b/src/modes/status.rs @@ -206,50 +206,12 @@ fn build_meta_plugins_configured_table(settings: &config::Settings) -> Option { - // Check if hostname_short is disabled - if let Some(serde_yaml::Value::Bool(enabled)) = all_options.get("hostname_short") { - if !enabled { - continue; - } - } - } - "hostname_full" => { - // Check if hostname_full is disabled - if let Some(serde_yaml::Value::Bool(enabled)) = all_options.get("hostname_full") { - if !enabled { - continue; - } - } - } - "hostname" => { - // Check if hostname is disabled - if let Some(serde_yaml::Value::Bool(enabled)) = all_options.get("hostname") { - if !enabled { - continue; - } - } else if let Some(serde_yaml::Value::String(s)) = all_options.get("hostname") { - if s == "false" { - continue; - } - } - } - _ => {} - } - } - // For digest plugin, check if the output is None (disabled) - else if plugin_config.name == "digest" { - if value.is_null() { - continue; - } + // Skip null values (disabled outputs) + if value.is_null() { + continue; } // Convert serde_yaml::Value to a string representation