fix: handle hostname_short disabled state properly

Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
Andrew Phillips
2025-08-27 17:55:27 -03:00
parent a708186b4f
commit 285d04aa9a

View File

@@ -206,41 +206,75 @@ fn build_meta_plugins_configured_table(settings: &config::Settings) -> Option<Ta
.to_string() .to_string()
}; };
// Show the merged outputs // Show the merged outputs, but filter based on plugin options
let outputs_str = if actual_plugin.outputs().is_empty() { // For hostname plugin, check if specific outputs are disabled
"{}".to_string() let mut enabled_output_pairs = Vec::new();
} else { for (key, value) in actual_plugin.outputs() {
let mut output_pairs = Vec::new(); // Check if this output should be enabled based on plugin-specific logic
for (key, value) in actual_plugin.outputs() { // For hostname plugin, check hostname_short, hostname_full options
// Convert serde_yaml::Value to a string representation if plugin_config.name == "hostname" {
let value_str = match value { match key.as_str() {
serde_yaml::Value::String(s) => s.clone(), "hostname_short" => {
serde_yaml::Value::Number(n) => n.to_string(), // Check if hostname_short is disabled
serde_yaml::Value::Bool(b) => b.to_string(), if let Some(serde_yaml::Value::Bool(enabled)) = all_options.get("hostname_short") {
serde_yaml::Value::Null => "null".to_string(), if !enabled {
serde_yaml::Value::Sequence(_) => { continue;
serde_yaml::to_string(value).unwrap_or_else(|_| "[]".to_string()) }
}
} }
serde_yaml::Value::Mapping(_) => { "hostname_full" => {
serde_yaml::to_string(value).unwrap_or_else(|_| "{}".to_string()) // Check if hostname_full is disabled
if let Some(serde_yaml::Value::Bool(enabled)) = all_options.get("hostname_full") {
if !enabled {
continue;
}
}
} }
serde_yaml::Value::Tagged(_) => { "hostname" => {
serde_yaml::to_string(value).unwrap_or_else(|_| "tagged".to_string()) // 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;
}
}
} }
}; _ => {}
// Trim any extra whitespace from the serialized values
let value_str = value_str.trim().to_string();
if key == &value_str {
output_pairs.push(key.clone());
} else {
output_pairs.push(format!("{}->{}", key, value_str));
} }
} }
if output_pairs.is_empty() {
"{}".to_string() // Convert serde_yaml::Value to a string representation
let value_str = match value {
serde_yaml::Value::String(s) => s.clone(),
serde_yaml::Value::Number(n) => n.to_string(),
serde_yaml::Value::Bool(b) => b.to_string(),
serde_yaml::Value::Null => "null".to_string(),
serde_yaml::Value::Sequence(_) => {
serde_yaml::to_string(value).unwrap_or_else(|_| "[]".to_string())
}
serde_yaml::Value::Mapping(_) => {
serde_yaml::to_string(value).unwrap_or_else(|_| "{}".to_string())
}
serde_yaml::Value::Tagged(_) => {
serde_yaml::to_string(value).unwrap_or_else(|_| "tagged".to_string())
}
};
// Trim any extra whitespace from the serialized values
let value_str = value_str.trim().to_string();
if key == &value_str {
enabled_output_pairs.push(key.clone());
} else { } else {
output_pairs.join(", ") enabled_output_pairs.push(format!("{}->{}", key, value_str));
} }
}
let outputs_str = if enabled_output_pairs.is_empty() {
"{}".to_string()
} else {
enabled_output_pairs.join(", ")
}; };
table.add_row(Row::new(vec![ table.add_row(Row::new(vec![